File tree Expand file tree Collapse file tree 4 files changed +26
-5
lines changed
Expand file tree Collapse file tree 4 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,12 @@ Try it in the [Svelte REPL](https://svelte.dev/repl/cae0ce6e92634878b6e1a587146d
7878| theme | The theme name that should be assigned to the theme data-attribute. | ` string ` (default: ` '' ` )
7979| presetRanges | The array of present configs to replace the default set with. | ` array ` (default: [ ...] )
8080
81+ ### Events
82+ | Prop | Description | Default |
83+ | :----------------- | :------------------------------------------------------------------------------------ | :-------------------------- |
84+ | onDayClick | Callback function to handle day click events. | ` function `
85+ | onNavigationChange | Callback function to handle the navigation click event for months and years | ` function `
86+
8187## Theming
8288You can customize DatePicker theme using several methods:
8389- Assign a theme class name via the ` theme ` property that includes all of your CSS variables overrides
Original file line number Diff line number Diff line change 2727 endDate = ' ' ;
2828 };
2929
30+ const onNavigationChange = (e ) => {
31+ console .log (e, ' onNavigationChange' );
32+ };
33+
3034 const toggleDatePicker = () => (isOpen = ! isOpen);
3135 const formatDate = (dateString ) => dateString && format (new Date (dateString), dateFormat) || ' ' ;
3236
3943 bind:isOpen
4044 bind:startDate
4145 bind:endDate
46+ {onNavigationChange }
4247 isRange
4348 {isMultipane }
4449 {showPresets }
4550 {...$$restProps }
4651 >
47- <div class ="date-field" on:click ={toggleDatePicker } class:open ={isOpen }>
52+ <div class ="date-field" on:click ={toggleDatePicker } role = "button" tabindex = "0" class:open ={isOpen }>
4853 <i class =" icon-calendar" />
4954 <div class =" date" >
5055 {#if startDate }
5459 {/if }
5560 </div >
5661 {#if startDate }
57- <span on:click ={onClearDates }>
62+ <span role = "button" tabindex = "0" on:click ={onClearDates }>
5863 <i class =" os-icon-x" />
5964 </span >
6065 {/if }
Original file line number Diff line number Diff line change 2525 startDate = new Date (formattedStartDate);
2626 };
2727
28+ const onNavigationChange = (e ) => {
29+ console .log (e, ' onNavigationChange' );
30+ };
31+
2832 $: formattedStartDate = formatDate (startDate);
2933 </script >
3034
31- <DatePicker bind:isOpen bind:startDate {...$$props }>
35+ <DatePicker bind:isOpen bind:startDate {...$$props } { onNavigationChange } >
3236 <input type ="text" bind:value ={formattedStartDate } on:change ={onChange } on:click ={toggleDatePicker } />
3337</DatePicker >
3438
Original file line number Diff line number Diff line change 11<script >
22 // @ts-nocheck
3+ import { tick } from ' svelte' ;
34 import { clickOutside } from ' ./actions' ;
45
56 /**
102103 * Callback function to handle the navigation click event for months and years
103104 * @type {(event: Object) => void}
104105 */
105- export let onNavigationChange = () => {};
106+ export let onNavigationChange = () => {};
106107
107108 /**
108109 * Indicates whether the date picker should always be shown.
365366
366367 if (isMultipane) {
367368 month += 1 ;
369+
370+ if (month > 11 ) {
371+ month = 1 ;
372+ }
373+
368374 currentPeriod .end = ` ${ endDateYear} -${ month >= 10 ? month : ` 0${ month} ` } -${ lastDayOfMonth} ` ;
369375 current = new Date (endDateYear, endDateMonth);
370376 }
375381 currentPeriod,
376382 isPastPeriod: current < initial
377383 });
378- }
384+ };
379385
380386 /**
381387 * Handles the "to previous month" action in the date picker.
You can’t perform that action at this time.
0 commit comments