zvelte-datepicker
v2.0.2
Published
A datepicker fork from the version 2.0.4 of https://github.com/6eDesign/svelte-calendar with time selection fonctionality
Downloads
15
Maintainers
Readme
zvelte-datepicker
A datepicker fork from the version 2.0.4 of https://github.com/6eDesign/svelte-calendar with time selection fonctionality
Installation
npm i -D zvelte-datepicker
Basic usage
<script>
import Datepicker from 'zvelte-datepicker';
</script>
<Datepicker start={minDate} end={maxDate} />
Props
prop name | type | default
---------------------|------------------------|-------------------------
start
| date
| one year in past
end
| date
| one year in future
selected
| date
| today
formattedSelected
| string
| today
dateChosen
| boolean
| false
withTime
| boolean
| false
selectableCallback
| function
| null
format
| string
| function
| '#{m}/#{d}/#{Y}'
locale
| string
| En-US Locale (see below)
style
| string
| ""
start
and end
These properties set the minimum and maximum dates that will be rendered by this calendar. It is recommended that you do not leave these as their defaults and supply values which suit your application's needs.
selected
and formattedSelected
Bind to these properties to observe the selected date as either a date or a string. Use selected
to set the day which is selected by default.
dateChosen
Bind to this property to observe whether a user has selected a day.
withTime
Boolean to enable time selection
selectableCallback
Provide a function which accepts a date and returns a boolean determining whether a day between start
and end
is selectable. For example, use this to prevent weekend days from being selected.
format
Date formatting uses [timeUtils
] formatting (MM/DD/YYYY by default). If you would like to use a different formatting library, supply a function which accepts a date and returns a string.
locale
This prop is used to internationalize the calendar.
<Datepicker bind:formattedSelected={selectedDateFormatted} bind:selected={selectedDate} bind:dateChosen={userHasChosenDate} start={threeDaysInPast} end={inThirtyDays} selectableCallback={filterWeekends} withTime={true} locale='fr' format={date => dayjs(date).format('DD/MM/YYYY')} />
## Developing/Modifying Svelte-Calendar Guide
*Note that you will need to have [Node.js] installed.*
Install the dependencies...
```bash
cd zvelte-datepicker
npm install
...then start [Rollup]:
npm run dev
Navigate to [localhost:3000]. You should see your app running. Edit a component file in src
, save it, and your browser will reload the page so you can see your changes automatically.