svelte-range-calendar 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018–2026 Wojciech Maj
4
+ Copyright (c) 2026 Adhi Ravishankar
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # svelte-range-calendar
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A calendar for your Svelte 5 app, with century, decade, year and month views and range selection. Svelte port of [React-Calendar](https://github.com/wojtekmaj/react-calendar).
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install svelte-range-calendar
9
+ ```
10
+
11
+ Requires Svelte 5 or later.
12
+
13
+ ## Usage
14
+
15
+ ```svelte
16
+ <script lang="ts">
17
+ import Calendar from 'svelte-range-calendar';
18
+
19
+ let value = $state<Date | [Date | null, Date | null] | null>(new Date());
20
+ </script>
21
+
22
+ <Calendar onChange={(nextValue) => (value = nextValue)} selectRange {value} />
23
+ ```
24
+
25
+ Styles are imported automatically. Elements use BEM class names starting with `svelte-calendar`.
26
+
27
+ `value` is controlled: update it from `onChange`. With `selectRange`, `onChange` is called with `[from, to]` once both ends are selected (`to` is the end of the last day).
28
+
29
+ ## Props
30
+
31
+ | Prop name | Description | Default value |
32
+ | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
33
+ | value | A `Date`, a date string, or a `[from, to]` array of them. | n/a |
34
+ | onChange | `(value, event) => void`, called when the user selects a value. | n/a |
35
+ | selectRange | Whether the user selects a range. | `false` |
36
+ | allowPartialRange | Whether `onChange` is called with `[from, null]` after the first click of a range. | `false` |
37
+ | returnValue | `"start"`, `"end"` or `"range"`; which date `onChange` receives when `selectRange` is off. | `"start"` |
38
+ | minDate, maxDate | Dates the user can select. Partially overlapping periods stay selectable. | n/a |
39
+ | minDetail, maxDetail | Least and most detailed view: `"century"`, `"decade"`, `"year"`, `"month"`. | `"century"`, `"month"` |
40
+ | view (bindable), defaultView | Displayed view. | `maxDetail` |
41
+ | activeStartDate (bindable), defaultActiveStartDate | Beginning of the displayed period. | start of the value, or today |
42
+ | goToRangeStartOnSelect | Whether to go to the start of the value when it changes. | `true` |
43
+ | locale, calendarType | Locale, and `"gregory"`, `"hebrew"`, `"islamic"` or `"iso8601"`. The type defaults to one matching the locale. | browser locale |
44
+ | showNavigation, showNeighboringMonth, showWeekNumbers, showFixedNumberOfWeeks, showNeighboringDecade, showNeighboringCentury | Display options. | `true`, `true`, `false`, `false`, `true`, `true` |
45
+ | prevLabel, nextLabel, prev2Label, next2Label | Navigation button content. `null` hides the button. | `‹`, `›`, `«`, `»` |
46
+ | prevAriaLabel, nextAriaLabel, prev2AriaLabel, next2AriaLabel, navigationAriaLabel, navigationAriaLive | Accessibility labels. | n/a |
47
+ | navigationLabel | Snippet receiving `{ date, label, locale, view }`. | n/a |
48
+ | tileClassName, tileContent, tileDisabled | Class (or function), snippet and predicate receiving `{ activeStartDate, date, view }`. | n/a |
49
+ | formatDay, formatLongDate, formatMonth, formatMonthYear, formatShortWeekday, formatWeekday, formatYear | `(locale, date) => string` formatters. | `Intl.DateTimeFormat` |
50
+ | onActiveStartDateChange, onViewChange, onDrillDown, onDrillUp | Called with `{ action, activeStartDate, value, view }`. | n/a |
51
+ | onClickDay, onClickMonth, onClickYear, onClickDecade | `(date, event) => void`. | n/a |
52
+ | class | Class name(s) added along with `"svelte-calendar"`. | n/a |
53
+
54
+ ## Part of a monorepo
55
+
56
+ `svelte-range-calendar` is part of the [svelte-datetime-pickers monorepo](https://github.com/adhiravishankar/svelte-datetime-pickers). See the [live demo and Storybook](https://adhiravishankar.github.io/svelte-datetime-pickers/).
57
+
58
+ ## License
59
+
60
+ The MIT License.
@@ -0,0 +1,183 @@
1
+ .svelte-calendar {
2
+ width: 350px;
3
+ max-width: 100%;
4
+ background: white;
5
+ border: 1px solid #a0a096;
6
+ font-family: Arial, Helvetica, sans-serif;
7
+ line-height: 1.125em;
8
+ }
9
+
10
+ .svelte-calendar,
11
+ .svelte-calendar *,
12
+ .svelte-calendar *:before,
13
+ .svelte-calendar *:after {
14
+ -moz-box-sizing: border-box;
15
+ -webkit-box-sizing: border-box;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ .svelte-calendar button {
20
+ margin: 0;
21
+ border: 0;
22
+ outline: none;
23
+ }
24
+
25
+ .svelte-calendar button:enabled:hover {
26
+ cursor: pointer;
27
+ }
28
+
29
+ .svelte-calendar__navigation {
30
+ display: flex;
31
+ height: 44px;
32
+ margin-bottom: 1em;
33
+ }
34
+
35
+ .svelte-calendar__navigation button {
36
+ min-width: 44px;
37
+ background: none;
38
+ }
39
+
40
+ .svelte-calendar__navigation button:disabled {
41
+ background-color: #f0f0f0;
42
+ }
43
+
44
+ .svelte-calendar__navigation button:enabled:hover,
45
+ .svelte-calendar__navigation button:enabled:focus {
46
+ background-color: #e6e6e6;
47
+ }
48
+
49
+ .svelte-calendar__month-view {
50
+ display: flex;
51
+ align-items: flex-end;
52
+ }
53
+
54
+ .svelte-calendar__month-view__body {
55
+ flex-grow: 1;
56
+ min-width: 0;
57
+ }
58
+
59
+ .svelte-calendar__month-view__weekdays {
60
+ display: grid;
61
+ grid-template-columns: repeat(7, 1fr);
62
+ text-align: center;
63
+ text-transform: uppercase;
64
+ font: inherit;
65
+ font-size: 0.75em;
66
+ font-weight: bold;
67
+ }
68
+
69
+ .svelte-calendar__month-view__weekdays__weekday {
70
+ padding: 0.5em;
71
+ }
72
+
73
+ .svelte-calendar__month-view__weekdays__weekday abbr {
74
+ text-decoration: none;
75
+ }
76
+
77
+ .svelte-calendar__month-view__weekNumbers {
78
+ display: grid;
79
+ grid-auto-rows: auto;
80
+ width: 12.5%;
81
+ flex-shrink: 0;
82
+ }
83
+
84
+ .svelte-calendar__month-view__weekNumbers .svelte-calendar__tile {
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: center;
88
+ padding: 10px 0;
89
+ font: inherit;
90
+ font-size: 0.75em;
91
+ font-weight: bold;
92
+ }
93
+
94
+ .svelte-calendar__tiles {
95
+ display: grid;
96
+ }
97
+
98
+ .svelte-calendar__month-view__days {
99
+ grid-template-columns: repeat(7, 1fr);
100
+ }
101
+
102
+ .svelte-calendar__year-view__months,
103
+ .svelte-calendar__decade-view__years,
104
+ .svelte-calendar__century-view__decades {
105
+ grid-template-columns: repeat(3, 1fr);
106
+ }
107
+
108
+ .svelte-calendar__month-view__days__day--weekend {
109
+ color: #d10000;
110
+ }
111
+
112
+ .svelte-calendar__month-view__days__day--neighboringMonth,
113
+ .svelte-calendar__decade-view__years__year--neighboringDecade,
114
+ .svelte-calendar__century-view__decades__decade--neighboringCentury {
115
+ color: #757575;
116
+ }
117
+
118
+ .svelte-calendar__year-view .svelte-calendar__tile,
119
+ .svelte-calendar__decade-view .svelte-calendar__tile,
120
+ .svelte-calendar__century-view .svelte-calendar__tile {
121
+ padding: 2em 0.5em;
122
+ }
123
+
124
+ .svelte-calendar__tile {
125
+ max-width: 100%;
126
+ padding: 10px 6.6667px;
127
+ background: none;
128
+ text-align: center;
129
+ font: inherit;
130
+ font-size: 0.833em;
131
+ }
132
+
133
+ .svelte-calendar__tile abbr {
134
+ text-decoration: none;
135
+ }
136
+
137
+ .svelte-calendar__tile:disabled {
138
+ background-color: #f0f0f0;
139
+ color: #ababab;
140
+ }
141
+
142
+ .svelte-calendar__month-view__days__day--neighboringMonth:disabled,
143
+ .svelte-calendar__decade-view__years__year--neighboringDecade:disabled,
144
+ .svelte-calendar__century-view__decades__decade--neighboringCentury:disabled {
145
+ color: #cdcdcd;
146
+ }
147
+
148
+ .svelte-calendar__tile:enabled:hover,
149
+ .svelte-calendar__tile:enabled:focus {
150
+ background-color: #e6e6e6;
151
+ }
152
+
153
+ .svelte-calendar__tile--now {
154
+ background: #ffff76;
155
+ }
156
+
157
+ .svelte-calendar__tile--now:enabled:hover,
158
+ .svelte-calendar__tile--now:enabled:focus {
159
+ background: #ffffa9;
160
+ }
161
+
162
+ .svelte-calendar__tile--hasActive {
163
+ background: #76baff;
164
+ }
165
+
166
+ .svelte-calendar__tile--hasActive:enabled:hover,
167
+ .svelte-calendar__tile--hasActive:enabled:focus {
168
+ background: #a9d4ff;
169
+ }
170
+
171
+ .svelte-calendar__tile--active {
172
+ background: #006edc;
173
+ color: white;
174
+ }
175
+
176
+ .svelte-calendar__tile--active:enabled:hover,
177
+ .svelte-calendar__tile--active:enabled:focus {
178
+ background: #1087ff;
179
+ }
180
+
181
+ .svelte-calendar--selectRange .svelte-calendar__tile--hover {
182
+ background-color: #e6e6e6;
183
+ }