0.0.10 • Published 4 months ago

rc-calendar-picker v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

A lightweight but complete calendar picker react component.

API

NameTypeDefaultDescription
valueDayjsundefinedRepresents the selected date by the component, in order to use it as a controlled component. This prop is parsed by dayjs, so it is possible to use a date string or a dayjs object.
initialValueDayjsundefinedRepresents the selected date for the component to use it as a uncontrolled component. This prop is parsed by Dayjs, so it is possible to use a date string or a dayjs object. If you need to set the selected date programmatically after the picker is initialized, please use the value prop instead.
initialViewModestringdayThe default view to display when the picker is shown for the first time ('year', 'month', 'day', 'time'). If you want to set the view mode after the component has been initialize see the imperative API.
showInputbooleantrueWhether to show an input field to edit the date manually.
openbooleanundefinedWhether to open or close the picker. If not set react-calendar will open the datepicker on input focus and close it on click outside.
onChangefunctionempty functionCallback trigger when the date changes. The callback receives the selected dayjs object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback receives the value of the input (a string).
onOpenfunctionempty functionCallback trigger for when the user opens the calendar.
onClosefunctionempty functionCallback trigger for when the calendar get closed. The callback receives the selected dayjs object as only parameter, if the date in the input is valid. If the date in the input is not valid, the callback returns the value in the input.
closeOnSelectbooleanfalseWhen true, once the day has been selected, the datepicker will be automatically closed.
onNavigatefunctionempty functionCallback trigger when the view mode changes. The callback receives the selected view mode string (year, month, day or time) as only parameter.
onBeforeNavigatefunction( nextView, currentView, viewDate ) => nextViewAllows to intercept a change of the calendar view. The accepted function receives the view that it's supposed to navigate to, the view that is showing currently and the date currently shown in the view. Return a viewMode ( default ones are year, month, day or time) to navigate to it. If the function returns a "falsy" value, the navigation is stopped and we will remain in the current view.
onNavigateBackfunctionempty functionCallback trigger when the user navigates to the previous month, year or decade. The callback receives the amount and type ('month', 'year') as parameters.
onNavigateForwardfunctionempty functionCallback trigger when the user navigates to the next month, year or decade. The callback receives the amount and type ('month', 'year') as parameters.
classNamestring or string[]''Extra class name for the outermost markup element.
inputPropsobjectundefinedDefines additional attributes for the input element of the component. For example: onClick, placeholder, disabled, required, name and className (className sets the class attribute for the input element). See Customize the Input Appearance.
isValidDatefunction() => booleanDefine the dates that can be selected. The function receives (currentDate, selectedDate) and shall return a true or false whether the currentDate is valid or not. See selectable dates.
dateFormatboolean or stringtrueDefines the format for the date. It accepts any dayjs time format. If true the date will be displayed using the defaults for the current locale. If false the datepicker is disabled and the component can be used as timepicker.
timeFormatboolean or stringtrueDefines the format for the time. It accepts any dayjs time format. If true the time will be displayed using the defaults for the current locale. If false the timepicker is disabled and the component can be used as datepicker.
closeOnClickOutsidebooleantrueWhen the calendar is open and closeOnClickOutside is true (its default value), clickin outside of the calendar or input closes the calendar. If false the calendar stays open.

How to use

Develop

pnpm i

npm run dev

Test

npm run test

npm run coverage

LICENSE

This repository is published under MIT license

0.0.11-beta.0

4 months ago

0.0.11-beta.1

4 months ago

0.0.10

10 months ago

0.0.9

10 months ago

0.0.8

10 months ago

0.0.7

10 months ago

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

11 months ago

0.0.1

11 months ago