0.0.24 • Published 5 years ago

trb-calendar v0.0.24

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Calendar

Quick Start

<trb-calendar></trb-calendar>

Api

BindingNameTypeDescription
InputconfigICalendarViewConfigThe complete configuration for the calendar
InputdatesCellDataA Payloadable data for customizing porposes
OutputselectionChangeCalendarSelectionEvent fired when a cell selection is changed
OutputmonthSelectionChangeIMonthChangeEvent fired when a month selection is changed

ICalendarViewConfig

NameTypeDescription
headerICalendarHeaderConfigConfiguration for the header
monthIMonthViewConfigConfiguration for the month
selectionrange simple pickedDefine the selection strategy to use
stylePrefixstringoverwrite all the style prefix, assigning the new one. Default is trb

ICalendarHeaderConfig

NameTypeDescriptionDefault
linkedMonthsbooleanWhen two months are showing, the months must move togethertrue
pastMonthsbooleanHeader allow go to months of pasttrue

IMonthViewConfig

NameTypeDescriptionDefault
hideWeekendsbooleanhide the weekend columnsfalse
hideDaysOutsideMonthbooleanhide the overflow days, used to complete the 7 x 5 cellstrue
showTwoCalendarIfNeedbooleanshow two calendar if the selection is range or pickedtrue
firstDaynumberconfigure the first day used in the calendar, starting in 0 as Sunday0
monthLabelsstring[]month label to show in the headerenglish month labels
dayLabelsstring[]labels to show in the days rowenglish day labels
dayLengthnumbernumber of letters to show in the days row3
showChangeYearButtonbooleanshow the arrow button to change the year in the headertrue
showChangeMonthButtonbooleanshow the arrow button to change the month in the headertrue

CellData (Input)

As an optional input for the calendar, you can provide a list of CellData<T>, each for a specific date (using the date field) and with a disabled and payload optional fields.

The payload is really important if you want to customize the calendar with your business specific data.

NameTypeDescription
datestringthe current date in YYYY-MM-DD format
payloadanyyour specific payload
disabledbooleanthe passed in disabled option

Customize components

You can customize the inner components of the calendar. To do this you must to provide the template of each component you want to customize.

For each template you must to provide the current context.

<trb-calendar
    [dates]="dates"
    [config]="config"
    (selectionChange)="onSelectionChange($event)"
    (monthSelectionChange)="onMonthSelectionChange($event)">
      
      <trb-calendar-month *trbCalendarMonth="let context;" [context]="context">
        <trb-calendar-header 
          *trbCalendarHeader="let context;" 
          [context]="context">
        </trb-calendar-header>

        <trb-calendar-cell 
          *trbCalendarCell="let context;" 
          [context]="context">
          <!-- custom cell html here -->
          <span class="my-price" *ngIf="context.payload">${{ context.payload }}</span>
        </trb-calendar-cell>
      </trb-calendar-month>

  </trb-calendar>

Customize Cell

Continuing the above example, asume you pass in the dates input the following array.

dates:CellData<any> = [{
  date: '2019-05-05',
  payload: {
    currency : 'USD',
    value: 460
  }
} ... ]

The data will be propagated inside the calendar to reach the proper cell (2019-05-05).

Then you draw the data in the cell as in this line

<span class="my-price" *ngIf="context.payload">${{ context.payload }}</span>

CellContext

NameTypeDescription
datestringthe current date in YYYY-MM-DD format
payloadanyyour specific payload
disabledbooleanthe passed in disabled option
selectionICalendarSelectionthe current selection state in the calendar
monthSelectionMonthSelectionthe current month selection state in the calendar
hideDaysOutsideMonthbooleanthe configuration to hide the outside months days

Date Payload

Styling

This is the hierachy for the calendar classes:

trb-calendar
  trb-calendar-month
    trb-calendar-header
      trb-calendar-header-buttons
        label
    trb-calendar-row trb-calendar-day-labels
      day-label
    trb-calendar-row
      trb-calendar-cell
        overlay
        label

Note that you can provide a prefix to overwrite all the trb with your own prefix, using stylePrefix.

Style event classes

Each cell receives bunch of event classes depending of their state.

Css ClassEvent Description
selectedthe cell is selected
fromthe cell is selected, and is the first selection in the range
tothe cell is selected, and is the last selection in the range
in-rangethe cell is inside a range selection
pastthe cell is from past of the current day
outside-monththe cell is outside the current calendar month
todaythe cell is from today
has-payloadthe cell has any payload
selection-simplethe cell selection type is simple
selection-rangethe cell selection type is range
selection-pickthe cell selection type is picked
disabledthe cell is mark as disabled

Datepicker

0.0.24

5 years ago

0.0.23

5 years ago

0.0.22

5 years ago

0.0.21

5 years ago

0.0.20

5 years ago

0.0.19

5 years ago

0.0.18

5 years ago

0.0.17

5 years ago

0.0.16

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.1

5 years ago