@event-calendar/core 2.0.0 → 2.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/README.md +24 -23
- package/index.css +20 -20
- package/index.js +124 -108
- package/package.json +1 -1
- package/src/Buttons.svelte +21 -4
- package/src/Calendar.svelte +2 -2
- package/src/index.scss +18 -18
- package/src/lib/a11y.js +0 -24
- package/src/lib/options.js +28 -0
- package/src/lib.js +1 -0
- package/src/storage/options.js +4 -7
- package/src/storage/state.js +17 -7
- package/src/storage/stores.js +10 -10
package/README.md
CHANGED
|
@@ -124,6 +124,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
|
|
|
124
124
|
- [unselect](#unselect-1)
|
|
125
125
|
</td></tr>
|
|
126
126
|
</table>
|
|
127
|
+
- [Content](#content)
|
|
127
128
|
- [Event object](#event-object)
|
|
128
129
|
- [Parsing event from a plain object](#parsing-event-from-a-plain-object)
|
|
129
130
|
- [Duration object](#duration-object)
|
|
@@ -194,8 +195,8 @@ import '@event-calendar/core/index.css';
|
|
|
194
195
|
### Pre-built browser ready bundle
|
|
195
196
|
Include the following lines of code in the `<head>` section of your page:
|
|
196
197
|
```html
|
|
197
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.
|
|
198
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.
|
|
198
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.1.0/event-calendar.min.css">
|
|
199
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.1.0/event-calendar.min.js"></script>
|
|
199
200
|
```
|
|
200
201
|
|
|
201
202
|
<details>
|
|
@@ -286,15 +287,15 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
|
|
|
286
287
|
- Type `object` or `function`
|
|
287
288
|
- Default `{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'day', resourceTimeGridWeek: 'week', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
|
|
288
289
|
> Views override the default value as follows:
|
|
289
|
-
> - dayGridMonth `
|
|
290
|
-
> - listDay `
|
|
291
|
-
> - listMonth `
|
|
292
|
-
> - listWeek `
|
|
293
|
-
> - listYear `
|
|
294
|
-
> - resourceTimeGridDay `
|
|
295
|
-
> - resourceTimeGridWeek `
|
|
296
|
-
> - timeGridDay `
|
|
297
|
-
> - timeGridWeek `
|
|
290
|
+
> - dayGridMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
|
|
291
|
+
> - listDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
292
|
+
> - listMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
|
|
293
|
+
> - listWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
|
|
294
|
+
> - listYear `text => ({...text, next: 'Next year', prev: 'Previous year'})`
|
|
295
|
+
> - resourceTimeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
296
|
+
> - resourceTimeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
|
|
297
|
+
> - timeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
|
|
298
|
+
> - timeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
|
|
298
299
|
|
|
299
300
|
|
|
300
301
|
Text that is displayed in buttons of the header toolbar.
|
|
@@ -1303,7 +1304,7 @@ Determines whether the events on the calendar can be dragged.
|
|
|
1303
1304
|
|
|
1304
1305
|
Defines the time-text that is displayed on each event.
|
|
1305
1306
|
|
|
1306
|
-
This value can be either an object with options for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object, or a callback function that returns a [Content](#content) with formatted string:
|
|
1307
|
+
This value can be either an object with options for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object, or a callback function that returns a [Content](#content) with the formatted string:
|
|
1307
1308
|
|
|
1308
1309
|
```js
|
|
1309
1310
|
function (start, end) {
|
|
@@ -1905,7 +1906,17 @@ This should be a value that can be parsed into a [Duration](#duration-object) ob
|
|
|
1905
1906
|
|
|
1906
1907
|
### theme
|
|
1907
1908
|
- Type `object` or `function`
|
|
1908
|
-
- Default `{active: 'ec-active', allDay: 'ec-all-day', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', compact: 'ec-compact', content: 'ec-content', day: 'ec-day', dayFoot: 'ec-day-foot', dayHead: 'ec-day-head', daySide: 'ec-day-side', days: 'ec-days', draggable: 'ec-draggable', dragging: 'ec-dragging', event: 'ec-event', eventBody: 'ec-event-body', eventTag: 'ec-event-tag', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', extra: 'ec-extra', ghost: 'ec-ghost', handle: 'ec-handle', header: 'ec-header', hiddenScroll: 'ec-hidden-scroll', highlight: 'ec-highlight', icon: 'ec-icon', line: 'ec-line', lines: 'ec-lines',
|
|
1909
|
+
- Default `{active: 'ec-active', allDay: 'ec-all-day', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', compact: 'ec-compact', content: 'ec-content', day: 'ec-day', dayFoot: 'ec-day-foot', dayHead: 'ec-day-head', daySide: 'ec-day-side', days: 'ec-days', draggable: 'ec-draggable', dragging: 'ec-dragging', event: 'ec-event', eventBody: 'ec-event-body', eventTag: 'ec-event-tag', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', extra: 'ec-extra', ghost: 'ec-ghost', handle: 'ec-handle', header: 'ec-header', hiddenScroll: 'ec-hidden-scroll', highlight: 'ec-highlight', icon: 'ec-icon', line: 'ec-line', lines: 'ec-lines', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', otherMonth: 'ec-other-month', pointer: 'ec-pointer', popup: 'ec-popup', preview: 'ec-preview', resizer: 'ec-resizer', resizingX: 'ec-resizing-x', resizingY: 'ec-resizing-y', resource: 'ec-resource', resourceTitle: 'ec-resource-title', selecting: 'ec-selecting', sidebar: 'ec-sidebar', sidebarTitle: 'ec-sidebar-title', time: 'ec-time', title: 'ec-title', today: 'ec-today', toolbar: 'ec-toolbar', uniform: 'ec-uniform', view: '', withScroll: 'ec-with-scroll'}`
|
|
1910
|
+
> Views override the default value as follows:
|
|
1911
|
+
> - dayGridMonth `theme => ({...theme, view: 'ec-day-grid ec-month-view'})`
|
|
1912
|
+
> - listDay `theme => ({...theme, view: 'ec-list ec-day-view'})`
|
|
1913
|
+
> - listMonth `theme => ({...theme, view: 'ec-list ec-month-view'})`
|
|
1914
|
+
> - listWeek `theme => ({...theme, view: 'ec-list ec-week-view'})`
|
|
1915
|
+
> - listYear `theme => ({...theme, view: 'ec-list ec-year-view'})`
|
|
1916
|
+
> - resourceTimeGridDay `theme => ({...theme, view: 'ec-time-grid ec-resource-day-view'})`
|
|
1917
|
+
> - resourceTimeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-resource-week-view'})`
|
|
1918
|
+
> - timeGridDay `theme => ({...theme, view: 'ec-time-grid ec-day-view'})`
|
|
1919
|
+
> - timeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-week-view'})`
|
|
1909
1920
|
|
|
1910
1921
|
Defines the CSS classes that the Event Calendar uses to generate HTML markup.
|
|
1911
1922
|
|
|
@@ -1959,16 +1970,6 @@ function (start, end) {
|
|
|
1959
1970
|
</tr>
|
|
1960
1971
|
</table>
|
|
1961
1972
|
|
|
1962
|
-
The callback function can return HTML markup. If you want to use HTML entities in the title, you must use the callback function:
|
|
1963
|
-
|
|
1964
|
-
```js
|
|
1965
|
-
function (date) {
|
|
1966
|
-
let month = date.toLocaleDateString('en-US', { month: 'long' })
|
|
1967
|
-
let year = date.toLocaleDateString('en-US', { year: 'numeric' })
|
|
1968
|
-
return `<span class="month">${month}</span> <span class="year">${year}</span>`
|
|
1969
|
-
}
|
|
1970
|
-
```
|
|
1971
|
-
|
|
1972
1973
|
### unselect
|
|
1973
1974
|
- Type `function`
|
|
1974
1975
|
- Default `undefined`
|
package/index.css
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
.ec:not(.ec-list) .ec-body {
|
|
162
162
|
border-top: none;
|
|
163
163
|
}
|
|
164
|
-
.ec-
|
|
164
|
+
.ec-day-grid .ec-body {
|
|
165
165
|
flex: 1 1 auto;
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -190,11 +190,11 @@
|
|
|
190
190
|
.ec-content {
|
|
191
191
|
display: flex;
|
|
192
192
|
}
|
|
193
|
-
.ec-
|
|
193
|
+
.ec-day-grid .ec-content {
|
|
194
194
|
flex-direction: column;
|
|
195
195
|
height: 100%;
|
|
196
196
|
}
|
|
197
|
-
.ec-
|
|
197
|
+
.ec-day-grid .ec-uniform .ec-content {
|
|
198
198
|
overflow: hidden;
|
|
199
199
|
}
|
|
200
200
|
.ec-list .ec-content {
|
|
@@ -212,10 +212,10 @@
|
|
|
212
212
|
.ec-days:last-child {
|
|
213
213
|
border-bottom: none;
|
|
214
214
|
}
|
|
215
|
-
.ec-
|
|
215
|
+
.ec-day-grid .ec-days, .ec-resource .ec-days {
|
|
216
216
|
flex: 1 0 auto;
|
|
217
217
|
}
|
|
218
|
-
.ec-
|
|
218
|
+
.ec-day-grid .ec-uniform .ec-days {
|
|
219
219
|
flex: 1 1 0%;
|
|
220
220
|
min-height: 0;
|
|
221
221
|
}
|
|
@@ -229,14 +229,14 @@
|
|
|
229
229
|
.ec-day.ec-highlight {
|
|
230
230
|
background-color: #e5f7fe;
|
|
231
231
|
}
|
|
232
|
-
.ec-
|
|
232
|
+
.ec-day-grid .ec-body .ec-day {
|
|
233
233
|
min-height: 5em;
|
|
234
234
|
position: relative;
|
|
235
235
|
}
|
|
236
|
-
.ec-
|
|
236
|
+
.ec-day-grid .ec-uniform .ec-day {
|
|
237
237
|
min-height: 0;
|
|
238
238
|
}
|
|
239
|
-
.ec-
|
|
239
|
+
.ec-day-grid .ec-day:first-child {
|
|
240
240
|
border-left: none;
|
|
241
241
|
}
|
|
242
242
|
.ec-day.ec-other-month .ec-day-head {
|
|
@@ -256,17 +256,17 @@
|
|
|
256
256
|
border-top: none;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
.ec-
|
|
259
|
+
.ec-day-grid .ec-day-head {
|
|
260
260
|
text-align: right;
|
|
261
261
|
padding: 4px 4px 3px;
|
|
262
262
|
}
|
|
263
|
-
.ec-
|
|
263
|
+
.ec-day-grid .ec-day-foot {
|
|
264
264
|
position: absolute;
|
|
265
265
|
bottom: 0;
|
|
266
266
|
padding: 2px;
|
|
267
267
|
font-size: 0.85em;
|
|
268
268
|
}
|
|
269
|
-
.ec-
|
|
269
|
+
.ec-day-grid .ec-day-foot a {
|
|
270
270
|
cursor: pointer;
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -281,7 +281,7 @@
|
|
|
281
281
|
.ec-events {
|
|
282
282
|
margin: 0 6px 0 0;
|
|
283
283
|
}
|
|
284
|
-
.ec-
|
|
284
|
+
.ec-time-grid .ec-events, .ec-events.ec-preview {
|
|
285
285
|
position: relative;
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -297,10 +297,10 @@
|
|
|
297
297
|
line-height: 1.5;
|
|
298
298
|
z-index: 1;
|
|
299
299
|
}
|
|
300
|
-
.ec-
|
|
300
|
+
.ec-day-grid .ec-event, .ec-all-day .ec-event {
|
|
301
301
|
position: relative;
|
|
302
302
|
}
|
|
303
|
-
.ec-
|
|
303
|
+
.ec-time-grid .ec-body .ec-event {
|
|
304
304
|
position: absolute;
|
|
305
305
|
}
|
|
306
306
|
.ec-list .ec-event {
|
|
@@ -335,7 +335,7 @@
|
|
|
335
335
|
flex-direction: column;
|
|
336
336
|
width: 100%;
|
|
337
337
|
}
|
|
338
|
-
.ec-
|
|
338
|
+
.ec-day-grid .ec-event-body, .ec-all-day .ec-event-body {
|
|
339
339
|
flex-direction: row;
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -351,7 +351,7 @@
|
|
|
351
351
|
margin: 0 0 1px 0;
|
|
352
352
|
flex-shrink: 0;
|
|
353
353
|
}
|
|
354
|
-
.ec-
|
|
354
|
+
.ec-day-grid .ec-event-time {
|
|
355
355
|
margin: 0 3px 0 0;
|
|
356
356
|
max-width: 100%;
|
|
357
357
|
text-overflow: ellipsis;
|
|
@@ -360,12 +360,12 @@
|
|
|
360
360
|
.ec-event-title {
|
|
361
361
|
overflow: hidden;
|
|
362
362
|
}
|
|
363
|
-
.ec-
|
|
363
|
+
.ec-day-grid .ec-event-title, .ec-all-day .ec-event-title {
|
|
364
364
|
min-height: 1.5em;
|
|
365
365
|
white-space: nowrap;
|
|
366
366
|
text-overflow: ellipsis;
|
|
367
367
|
}
|
|
368
|
-
.ec-
|
|
368
|
+
.ec-time-grid .ec-body .ec-event-title {
|
|
369
369
|
position: sticky;
|
|
370
370
|
top: 0;
|
|
371
371
|
}
|
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
position: absolute;
|
|
490
490
|
user-select: none;
|
|
491
491
|
}
|
|
492
|
-
.ec-
|
|
492
|
+
.ec-day-grid .ec-resizer, .ec-all-day .ec-resizer {
|
|
493
493
|
top: 0;
|
|
494
494
|
right: 0;
|
|
495
495
|
bottom: 0;
|
|
@@ -497,7 +497,7 @@
|
|
|
497
497
|
max-width: 8px;
|
|
498
498
|
cursor: ew-resize;
|
|
499
499
|
}
|
|
500
|
-
.ec-
|
|
500
|
+
.ec-time-grid .ec-body .ec-resizer {
|
|
501
501
|
left: 0;
|
|
502
502
|
right: 0;
|
|
503
503
|
bottom: 0;
|
package/index.js
CHANGED
|
@@ -8,30 +8,6 @@ function keyEnter(fn) {
|
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function btnTextDay(text) {
|
|
12
|
-
return btnText(text, 'day');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function btnTextWeek(text) {
|
|
16
|
-
return btnText(text, 'week');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function btnTextMonth(text) {
|
|
20
|
-
return btnText(text, 'month');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function btnTextYear(text) {
|
|
24
|
-
return btnText(text, 'year');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function btnText(text, period) {
|
|
28
|
-
return {
|
|
29
|
-
...text,
|
|
30
|
-
next: 'Next ' + period,
|
|
31
|
-
prev: 'Previous ' + period
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
11
|
function setContent(node, content) {
|
|
36
12
|
let actions = {
|
|
37
13
|
update(content) {
|
|
@@ -569,6 +545,34 @@ function pointerEvent(display) {
|
|
|
569
545
|
return display === 'pointer';
|
|
570
546
|
}
|
|
571
547
|
|
|
548
|
+
function btnTextDay(text) {
|
|
549
|
+
return btnText(text, 'day');
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function btnTextWeek(text) {
|
|
553
|
+
return btnText(text, 'week');
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function btnTextMonth(text) {
|
|
557
|
+
return btnText(text, 'month');
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function btnTextYear(text) {
|
|
561
|
+
return btnText(text, 'year');
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function btnText(text, period) {
|
|
565
|
+
return {
|
|
566
|
+
...text,
|
|
567
|
+
next: 'Next ' + period,
|
|
568
|
+
prev: 'Previous ' + period
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function themeView(view) {
|
|
573
|
+
return theme => ({...theme, view});
|
|
574
|
+
}
|
|
575
|
+
|
|
572
576
|
function writable2(value, parser, start) {
|
|
573
577
|
return {
|
|
574
578
|
...writable(value, start),
|
|
@@ -710,7 +714,7 @@ function createOptions(plugins) {
|
|
|
710
714
|
time: 'ec-time',
|
|
711
715
|
title: 'ec-title',
|
|
712
716
|
toolbar: 'ec-toolbar',
|
|
713
|
-
|
|
717
|
+
view: '',
|
|
714
718
|
withScroll: 'ec-with-scroll'
|
|
715
719
|
},
|
|
716
720
|
titleFormat: {
|
|
@@ -730,9 +734,8 @@ function createOptions(plugins) {
|
|
|
730
734
|
return options;
|
|
731
735
|
}
|
|
732
736
|
|
|
733
|
-
function createParsers(
|
|
737
|
+
function createParsers(plugins) {
|
|
734
738
|
let parsers = {
|
|
735
|
-
buttonText: input => is_function(input) ? input(options.buttonText) : input,
|
|
736
739
|
date: date => setMidnight(createDate(date)),
|
|
737
740
|
duration: createDuration,
|
|
738
741
|
events: createEvents,
|
|
@@ -742,12 +745,11 @@ function createParsers(options, plugins) {
|
|
|
742
745
|
scrollTime: createDuration,
|
|
743
746
|
slotDuration: createDuration,
|
|
744
747
|
slotMaxTime: createDuration,
|
|
745
|
-
slotMinTime: createDuration
|
|
746
|
-
theme: input => is_function(input) ? input(options.theme) : input
|
|
748
|
+
slotMinTime: createDuration
|
|
747
749
|
};
|
|
748
750
|
|
|
749
751
|
for (let plugin of plugins) {
|
|
750
|
-
plugin.createParsers?.(parsers
|
|
752
|
+
plugin.createParsers?.(parsers);
|
|
751
753
|
}
|
|
752
754
|
|
|
753
755
|
return parsers;
|
|
@@ -768,18 +770,18 @@ function diff(options) {
|
|
|
768
770
|
return diff;
|
|
769
771
|
}
|
|
770
772
|
|
|
771
|
-
function
|
|
773
|
+
function dayGrid(state) {
|
|
772
774
|
return derived(state.view, $view => $view?.startsWith('dayGrid'));
|
|
773
775
|
}
|
|
774
776
|
|
|
775
777
|
function activeRange(state) {
|
|
776
778
|
return derived(
|
|
777
|
-
[state._currentRange, state.firstDay, state.slotMaxTime, state.
|
|
778
|
-
([$_currentRange, $firstDay, $slotMaxTime, $
|
|
779
|
+
[state._currentRange, state.firstDay, state.slotMaxTime, state._dayGrid],
|
|
780
|
+
([$_currentRange, $firstDay, $slotMaxTime, $_dayGrid]) => {
|
|
779
781
|
let start = cloneDate($_currentRange.start);
|
|
780
782
|
let end = cloneDate($_currentRange.end);
|
|
781
783
|
|
|
782
|
-
if ($
|
|
784
|
+
if ($_dayGrid) {
|
|
783
785
|
// First day of week
|
|
784
786
|
prevClosestDay(start, $firstDay);
|
|
785
787
|
nextClosestDay(end, $firstDay);
|
|
@@ -798,10 +800,10 @@ function activeRange(state) {
|
|
|
798
800
|
|
|
799
801
|
function currentRange(state) {
|
|
800
802
|
return derived(
|
|
801
|
-
[state.date, state.duration, state.firstDay, state.
|
|
802
|
-
([$date, $duration, $firstDay, $
|
|
803
|
+
[state.date, state.duration, state.firstDay, state._dayGrid],
|
|
804
|
+
([$date, $duration, $firstDay, $_dayGrid]) => {
|
|
803
805
|
let start = cloneDate($date), end;
|
|
804
|
-
if ($
|
|
806
|
+
if ($_dayGrid) {
|
|
805
807
|
start.setUTCDate(1);
|
|
806
808
|
} else if ($duration.inWeeks) {
|
|
807
809
|
// First day of week
|
|
@@ -842,9 +844,9 @@ function viewDates(state) {
|
|
|
842
844
|
|
|
843
845
|
function viewTitle(state) {
|
|
844
846
|
return derived(
|
|
845
|
-
[state.date, state._activeRange, state._intlTitle, state.
|
|
846
|
-
([$date, $_activeRange, $_intlTitle, $
|
|
847
|
-
return $
|
|
847
|
+
[state.date, state._activeRange, state._intlTitle, state._dayGrid],
|
|
848
|
+
([$date, $_activeRange, $_intlTitle, $_dayGrid]) => {
|
|
849
|
+
return $_dayGrid
|
|
848
850
|
? $_intlTitle.formatRange($date, $date)
|
|
849
851
|
: $_intlTitle.formatRange($_activeRange.start, subtractDay(cloneDate($_activeRange.end)));
|
|
850
852
|
}
|
|
@@ -962,8 +964,8 @@ class State {
|
|
|
962
964
|
plugins = plugins || [];
|
|
963
965
|
|
|
964
966
|
// Create options
|
|
965
|
-
let options= createOptions(plugins);
|
|
966
|
-
let parsers = createParsers(
|
|
967
|
+
let options = createOptions(plugins);
|
|
968
|
+
let parsers = createParsers(plugins);
|
|
967
969
|
|
|
968
970
|
// Parse options
|
|
969
971
|
options = parseOpts(options, parsers);
|
|
@@ -977,7 +979,7 @@ class State {
|
|
|
977
979
|
// Private stores
|
|
978
980
|
this._queue = writable(new Map()); // debounce queue
|
|
979
981
|
this._auxiliary = writable([]); // auxiliary components
|
|
980
|
-
this.
|
|
982
|
+
this._dayGrid = dayGrid(this);
|
|
981
983
|
this._currentRange = currentRange(this);
|
|
982
984
|
this._activeRange = activeRange(this);
|
|
983
985
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
@@ -993,7 +995,6 @@ class State {
|
|
|
993
995
|
this._viewTitle = viewTitle(this);
|
|
994
996
|
this._viewDates = viewDates(this);
|
|
995
997
|
this._view = view(this);
|
|
996
|
-
this._viewClass = writable(undefined);
|
|
997
998
|
this._viewComponent = writable(undefined);
|
|
998
999
|
// Resources
|
|
999
1000
|
this._resBgColor = writable(noop);
|
|
@@ -1017,7 +1018,7 @@ class State {
|
|
|
1017
1018
|
// Set options for each view
|
|
1018
1019
|
let views = new Set([...keys(options.views), ...keys(input.views ?? {})]);
|
|
1019
1020
|
for (let view of views) {
|
|
1020
|
-
let opts =
|
|
1021
|
+
let opts = mergeOpts(options, options.views[view] ?? {}, input, input.views?.[view] ?? {});
|
|
1021
1022
|
// Change view component when view changes
|
|
1022
1023
|
this.view.subscribe(newView => {
|
|
1023
1024
|
if (newView === view) {
|
|
@@ -1069,6 +1070,17 @@ function parseOpts(opts, parsers) {
|
|
|
1069
1070
|
return result;
|
|
1070
1071
|
}
|
|
1071
1072
|
|
|
1073
|
+
function mergeOpts(...args) {
|
|
1074
|
+
let mergable = ['buttonText', 'theme'];
|
|
1075
|
+
let result = {};
|
|
1076
|
+
for (let opts of args) {
|
|
1077
|
+
for (let key of keys(opts)) {
|
|
1078
|
+
result[key] = mergable.includes(key) && is_function(opts[key]) ? opts[key](result[key]) : opts[key];
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
return result;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1072
1084
|
/* packages/core/src/Buttons.svelte generated by Svelte v4.1.1 */
|
|
1073
1085
|
|
|
1074
1086
|
function get_each_context$2(ctx, list, i) {
|
|
@@ -1077,7 +1089,7 @@ function get_each_context$2(ctx, list, i) {
|
|
|
1077
1089
|
return child_ctx;
|
|
1078
1090
|
}
|
|
1079
1091
|
|
|
1080
|
-
// (
|
|
1092
|
+
// (52:27)
|
|
1081
1093
|
function create_if_block_4(ctx) {
|
|
1082
1094
|
let button_1;
|
|
1083
1095
|
let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[23]] + "";
|
|
@@ -1129,7 +1141,7 @@ function create_if_block_4(ctx) {
|
|
|
1129
1141
|
};
|
|
1130
1142
|
}
|
|
1131
1143
|
|
|
1132
|
-
// (
|
|
1144
|
+
// (46:32)
|
|
1133
1145
|
function create_if_block_3(ctx) {
|
|
1134
1146
|
let button_1;
|
|
1135
1147
|
let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[23]] + "";
|
|
@@ -1176,13 +1188,14 @@ function create_if_block_3(ctx) {
|
|
|
1176
1188
|
};
|
|
1177
1189
|
}
|
|
1178
1190
|
|
|
1179
|
-
// (
|
|
1191
|
+
// (39:31)
|
|
1180
1192
|
function create_if_block_2(ctx) {
|
|
1181
1193
|
let button_1;
|
|
1182
1194
|
let i;
|
|
1183
1195
|
let i_class_value;
|
|
1184
1196
|
let button_1_class_value;
|
|
1185
1197
|
let button_1_aria_label_value;
|
|
1198
|
+
let button_1_title_value;
|
|
1186
1199
|
let mounted;
|
|
1187
1200
|
let dispose;
|
|
1188
1201
|
|
|
@@ -1193,6 +1206,7 @@ function create_if_block_2(ctx) {
|
|
|
1193
1206
|
attr(i, "class", i_class_value = "" + (/*$theme*/ ctx[3].icon + " ec-" + /*button*/ ctx[23]));
|
|
1194
1207
|
attr(button_1, "class", button_1_class_value = "" + (/*$theme*/ ctx[3].button + " ec-" + /*button*/ ctx[23]));
|
|
1195
1208
|
attr(button_1, "aria-label", button_1_aria_label_value = /*$buttonText*/ ctx[5].next);
|
|
1209
|
+
attr(button_1, "title", button_1_title_value = /*$buttonText*/ ctx[5].next);
|
|
1196
1210
|
},
|
|
1197
1211
|
m(target, anchor) {
|
|
1198
1212
|
insert(target, button_1, anchor);
|
|
@@ -1215,6 +1229,10 @@ function create_if_block_2(ctx) {
|
|
|
1215
1229
|
if (dirty & /*$buttonText*/ 32 && button_1_aria_label_value !== (button_1_aria_label_value = /*$buttonText*/ ctx[5].next)) {
|
|
1216
1230
|
attr(button_1, "aria-label", button_1_aria_label_value);
|
|
1217
1231
|
}
|
|
1232
|
+
|
|
1233
|
+
if (dirty & /*$buttonText*/ 32 && button_1_title_value !== (button_1_title_value = /*$buttonText*/ ctx[5].next)) {
|
|
1234
|
+
attr(button_1, "title", button_1_title_value);
|
|
1235
|
+
}
|
|
1218
1236
|
},
|
|
1219
1237
|
d(detaching) {
|
|
1220
1238
|
if (detaching) {
|
|
@@ -1234,6 +1252,7 @@ function create_if_block_1(ctx) {
|
|
|
1234
1252
|
let i_class_value;
|
|
1235
1253
|
let button_1_class_value;
|
|
1236
1254
|
let button_1_aria_label_value;
|
|
1255
|
+
let button_1_title_value;
|
|
1237
1256
|
let mounted;
|
|
1238
1257
|
let dispose;
|
|
1239
1258
|
|
|
@@ -1244,6 +1263,7 @@ function create_if_block_1(ctx) {
|
|
|
1244
1263
|
attr(i, "class", i_class_value = "" + (/*$theme*/ ctx[3].icon + " ec-" + /*button*/ ctx[23]));
|
|
1245
1264
|
attr(button_1, "class", button_1_class_value = "" + (/*$theme*/ ctx[3].button + " ec-" + /*button*/ ctx[23]));
|
|
1246
1265
|
attr(button_1, "aria-label", button_1_aria_label_value = /*$buttonText*/ ctx[5].prev);
|
|
1266
|
+
attr(button_1, "title", button_1_title_value = /*$buttonText*/ ctx[5].prev);
|
|
1247
1267
|
},
|
|
1248
1268
|
m(target, anchor) {
|
|
1249
1269
|
insert(target, button_1, anchor);
|
|
@@ -1266,6 +1286,10 @@ function create_if_block_1(ctx) {
|
|
|
1266
1286
|
if (dirty & /*$buttonText*/ 32 && button_1_aria_label_value !== (button_1_aria_label_value = /*$buttonText*/ ctx[5].prev)) {
|
|
1267
1287
|
attr(button_1, "aria-label", button_1_aria_label_value);
|
|
1268
1288
|
}
|
|
1289
|
+
|
|
1290
|
+
if (dirty & /*$buttonText*/ 32 && button_1_title_value !== (button_1_title_value = /*$buttonText*/ ctx[5].prev)) {
|
|
1291
|
+
attr(button_1, "title", button_1_title_value);
|
|
1292
|
+
}
|
|
1269
1293
|
},
|
|
1270
1294
|
d(detaching) {
|
|
1271
1295
|
if (detaching) {
|
|
@@ -2118,7 +2142,7 @@ function create_fragment(ctx) {
|
|
|
2118
2142
|
let mounted;
|
|
2119
2143
|
let dispose;
|
|
2120
2144
|
toolbar = new Toolbar({});
|
|
2121
|
-
var switch_value = /*$_viewComponent*/ ctx[
|
|
2145
|
+
var switch_value = /*$_viewComponent*/ ctx[4];
|
|
2122
2146
|
|
|
2123
2147
|
function switch_props(ctx, dirty) {
|
|
2124
2148
|
return {};
|
|
@@ -2139,15 +2163,13 @@ function create_fragment(ctx) {
|
|
|
2139
2163
|
t1 = space();
|
|
2140
2164
|
create_component(auxiliary.$$.fragment);
|
|
2141
2165
|
|
|
2142
|
-
attr(div, "class", div_class_value = "" + (/*$theme*/ ctx[1].calendar + (/*$
|
|
2143
|
-
? ' ' + /*$theme*/ ctx[1][/*$_viewClass*/ ctx[2]]
|
|
2144
|
-
: '') + (/*$_scrollable*/ ctx[0]
|
|
2166
|
+
attr(div, "class", div_class_value = "" + (/*$theme*/ ctx[1].calendar + " " + /*$theme*/ ctx[1].view + (/*$_scrollable*/ ctx[0]
|
|
2145
2167
|
? ' ' + /*$theme*/ ctx[1].withScroll
|
|
2146
|
-
: '') + (/*$_iClass*/ ctx[
|
|
2147
|
-
? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[
|
|
2168
|
+
: '') + (/*$_iClass*/ ctx[2]
|
|
2169
|
+
? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[2]]
|
|
2148
2170
|
: '')));
|
|
2149
2171
|
|
|
2150
|
-
set_style(div, "height", /*$height*/ ctx[
|
|
2172
|
+
set_style(div, "height", /*$height*/ ctx[3]);
|
|
2151
2173
|
},
|
|
2152
2174
|
m(target, anchor) {
|
|
2153
2175
|
insert(target, div, anchor);
|
|
@@ -2159,12 +2181,12 @@ function create_fragment(ctx) {
|
|
|
2159
2181
|
current = true;
|
|
2160
2182
|
|
|
2161
2183
|
if (!mounted) {
|
|
2162
|
-
dispose = listen(window, "resize", /*recheckScrollable*/ ctx[
|
|
2184
|
+
dispose = listen(window, "resize", /*recheckScrollable*/ ctx[16]);
|
|
2163
2185
|
mounted = true;
|
|
2164
2186
|
}
|
|
2165
2187
|
},
|
|
2166
2188
|
p(ctx, dirty) {
|
|
2167
|
-
if (dirty[0] & /*$_viewComponent*/
|
|
2189
|
+
if (dirty[0] & /*$_viewComponent*/ 16 && switch_value !== (switch_value = /*$_viewComponent*/ ctx[4])) {
|
|
2168
2190
|
if (switch_instance) {
|
|
2169
2191
|
group_outros();
|
|
2170
2192
|
const old_component = switch_instance;
|
|
@@ -2186,18 +2208,16 @@ function create_fragment(ctx) {
|
|
|
2186
2208
|
}
|
|
2187
2209
|
}
|
|
2188
2210
|
|
|
2189
|
-
if (!current || dirty[0] & /*$theme, $
|
|
2190
|
-
? ' ' + /*$theme*/ ctx[1][/*$_viewClass*/ ctx[2]]
|
|
2191
|
-
: '') + (/*$_scrollable*/ ctx[0]
|
|
2211
|
+
if (!current || dirty[0] & /*$theme, $_scrollable, $_iClass*/ 7 && div_class_value !== (div_class_value = "" + (/*$theme*/ ctx[1].calendar + " " + /*$theme*/ ctx[1].view + (/*$_scrollable*/ ctx[0]
|
|
2192
2212
|
? ' ' + /*$theme*/ ctx[1].withScroll
|
|
2193
|
-
: '') + (/*$_iClass*/ ctx[
|
|
2194
|
-
? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[
|
|
2213
|
+
: '') + (/*$_iClass*/ ctx[2]
|
|
2214
|
+
? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[2]]
|
|
2195
2215
|
: '')))) {
|
|
2196
2216
|
attr(div, "class", div_class_value);
|
|
2197
2217
|
}
|
|
2198
2218
|
|
|
2199
|
-
if (!current || dirty[0] & /*$height*/
|
|
2200
|
-
set_style(div, "height", /*$height*/ ctx[
|
|
2219
|
+
if (!current || dirty[0] & /*$height*/ 8) {
|
|
2220
|
+
set_style(div, "height", /*$height*/ ctx[3]);
|
|
2201
2221
|
}
|
|
2202
2222
|
},
|
|
2203
2223
|
i(local) {
|
|
@@ -2237,7 +2257,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2237
2257
|
let $eventSources;
|
|
2238
2258
|
let $_interaction;
|
|
2239
2259
|
let $theme;
|
|
2240
|
-
let $_viewClass;
|
|
2241
2260
|
let $_iClass;
|
|
2242
2261
|
let $height;
|
|
2243
2262
|
let $_viewComponent;
|
|
@@ -2246,18 +2265,17 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2246
2265
|
let component = get_current_component();
|
|
2247
2266
|
let state = new State(plugins, options);
|
|
2248
2267
|
setContext('state', state);
|
|
2249
|
-
let { _viewComponent,
|
|
2250
|
-
component_subscribe($$self, _viewComponent, value => $$invalidate(
|
|
2251
|
-
component_subscribe($$self,
|
|
2252
|
-
component_subscribe($$self,
|
|
2253
|
-
component_subscribe($$self,
|
|
2254
|
-
component_subscribe($$self,
|
|
2255
|
-
component_subscribe($$self,
|
|
2256
|
-
component_subscribe($$self, _queue, value => $$invalidate(34, $_queue = value));
|
|
2268
|
+
let { _viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _scrollable, events, eventSources, height, theme } = state;
|
|
2269
|
+
component_subscribe($$self, _viewComponent, value => $$invalidate(4, $_viewComponent = value));
|
|
2270
|
+
component_subscribe($$self, _bodyEl, value => $$invalidate(31, $_bodyEl = value));
|
|
2271
|
+
component_subscribe($$self, _interaction, value => $$invalidate(36, $_interaction = value));
|
|
2272
|
+
component_subscribe($$self, _iClass, value => $$invalidate(2, $_iClass = value));
|
|
2273
|
+
component_subscribe($$self, _events, value => $$invalidate(33, $_events = value));
|
|
2274
|
+
component_subscribe($$self, _queue, value => $$invalidate(32, $_queue = value));
|
|
2257
2275
|
component_subscribe($$self, _scrollable, value => $$invalidate(0, $_scrollable = value));
|
|
2258
|
-
component_subscribe($$self, events, value => $$invalidate(
|
|
2259
|
-
component_subscribe($$self, eventSources, value => $$invalidate(
|
|
2260
|
-
component_subscribe($$self, height, value => $$invalidate(
|
|
2276
|
+
component_subscribe($$self, events, value => $$invalidate(34, $events = value));
|
|
2277
|
+
component_subscribe($$self, eventSources, value => $$invalidate(35, $eventSources = value));
|
|
2278
|
+
component_subscribe($$self, height, value => $$invalidate(3, $height = value));
|
|
2261
2279
|
component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
|
|
2262
2280
|
|
|
2263
2281
|
function setOption(name, value) {
|
|
@@ -2365,12 +2383,12 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2365
2383
|
}
|
|
2366
2384
|
|
|
2367
2385
|
$$self.$$set = $$props => {
|
|
2368
|
-
if ('plugins' in $$props) $$invalidate(
|
|
2369
|
-
if ('options' in $$props) $$invalidate(
|
|
2386
|
+
if ('plugins' in $$props) $$invalidate(17, plugins = $$props.plugins);
|
|
2387
|
+
if ('options' in $$props) $$invalidate(18, options = $$props.options);
|
|
2370
2388
|
};
|
|
2371
2389
|
|
|
2372
2390
|
$$self.$$.update = () => {
|
|
2373
|
-
if ($$self.$$.dirty[0] & /*options*/
|
|
2391
|
+
if ($$self.$$.dirty[0] & /*options*/ 262144) {
|
|
2374
2392
|
// Reactively update options that did change
|
|
2375
2393
|
for (let [name, value] of diff(options)) {
|
|
2376
2394
|
setOption(name, value);
|
|
@@ -2381,12 +2399,10 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
2381
2399
|
return [
|
|
2382
2400
|
$_scrollable,
|
|
2383
2401
|
$theme,
|
|
2384
|
-
$_viewClass,
|
|
2385
2402
|
$_iClass,
|
|
2386
2403
|
$height,
|
|
2387
2404
|
$_viewComponent,
|
|
2388
2405
|
_viewComponent,
|
|
2389
|
-
_viewClass,
|
|
2390
2406
|
_bodyEl,
|
|
2391
2407
|
_interaction,
|
|
2392
2408
|
_iClass,
|
|
@@ -2426,20 +2442,20 @@ class Calendar extends SvelteComponent {
|
|
|
2426
2442
|
create_fragment,
|
|
2427
2443
|
safe_not_equal,
|
|
2428
2444
|
{
|
|
2429
|
-
plugins:
|
|
2430
|
-
options:
|
|
2431
|
-
setOption:
|
|
2432
|
-
getOption:
|
|
2433
|
-
refetchEvents:
|
|
2434
|
-
getEvents:
|
|
2435
|
-
getEventById:
|
|
2436
|
-
addEvent:
|
|
2437
|
-
updateEvent:
|
|
2438
|
-
removeEventById:
|
|
2439
|
-
getView:
|
|
2440
|
-
unselect:
|
|
2441
|
-
dateFromPoint:
|
|
2442
|
-
destroy:
|
|
2445
|
+
plugins: 17,
|
|
2446
|
+
options: 18,
|
|
2447
|
+
setOption: 19,
|
|
2448
|
+
getOption: 20,
|
|
2449
|
+
refetchEvents: 21,
|
|
2450
|
+
getEvents: 22,
|
|
2451
|
+
getEventById: 23,
|
|
2452
|
+
addEvent: 24,
|
|
2453
|
+
updateEvent: 25,
|
|
2454
|
+
removeEventById: 26,
|
|
2455
|
+
getView: 27,
|
|
2456
|
+
unselect: 28,
|
|
2457
|
+
dateFromPoint: 29,
|
|
2458
|
+
destroy: 30
|
|
2443
2459
|
},
|
|
2444
2460
|
null,
|
|
2445
2461
|
[-1, -1]
|
|
@@ -2447,52 +2463,52 @@ class Calendar extends SvelteComponent {
|
|
|
2447
2463
|
}
|
|
2448
2464
|
|
|
2449
2465
|
get setOption() {
|
|
2450
|
-
return this.$$.ctx[
|
|
2466
|
+
return this.$$.ctx[19];
|
|
2451
2467
|
}
|
|
2452
2468
|
|
|
2453
2469
|
get getOption() {
|
|
2454
|
-
return this.$$.ctx[
|
|
2470
|
+
return this.$$.ctx[20];
|
|
2455
2471
|
}
|
|
2456
2472
|
|
|
2457
2473
|
get refetchEvents() {
|
|
2458
|
-
return this.$$.ctx[
|
|
2474
|
+
return this.$$.ctx[21];
|
|
2459
2475
|
}
|
|
2460
2476
|
|
|
2461
2477
|
get getEvents() {
|
|
2462
|
-
return this.$$.ctx[
|
|
2478
|
+
return this.$$.ctx[22];
|
|
2463
2479
|
}
|
|
2464
2480
|
|
|
2465
2481
|
get getEventById() {
|
|
2466
|
-
return this.$$.ctx[
|
|
2482
|
+
return this.$$.ctx[23];
|
|
2467
2483
|
}
|
|
2468
2484
|
|
|
2469
2485
|
get addEvent() {
|
|
2470
|
-
return this.$$.ctx[
|
|
2486
|
+
return this.$$.ctx[24];
|
|
2471
2487
|
}
|
|
2472
2488
|
|
|
2473
2489
|
get updateEvent() {
|
|
2474
|
-
return this.$$.ctx[
|
|
2490
|
+
return this.$$.ctx[25];
|
|
2475
2491
|
}
|
|
2476
2492
|
|
|
2477
2493
|
get removeEventById() {
|
|
2478
|
-
return this.$$.ctx[
|
|
2494
|
+
return this.$$.ctx[26];
|
|
2479
2495
|
}
|
|
2480
2496
|
|
|
2481
2497
|
get getView() {
|
|
2482
|
-
return this.$$.ctx[
|
|
2498
|
+
return this.$$.ctx[27];
|
|
2483
2499
|
}
|
|
2484
2500
|
|
|
2485
2501
|
get unselect() {
|
|
2486
|
-
return this.$$.ctx[
|
|
2502
|
+
return this.$$.ctx[28];
|
|
2487
2503
|
}
|
|
2488
2504
|
|
|
2489
2505
|
get dateFromPoint() {
|
|
2490
|
-
return this.$$.ctx[
|
|
2506
|
+
return this.$$.ctx[29];
|
|
2491
2507
|
}
|
|
2492
2508
|
|
|
2493
2509
|
get destroy() {
|
|
2494
|
-
return this.$$.ctx[
|
|
2510
|
+
return this.$$.ctx[30];
|
|
2495
2511
|
}
|
|
2496
2512
|
}
|
|
2497
2513
|
|
|
2498
|
-
export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createView, datesEqual, debounce, Calendar as default, derived2, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, max, min, nextClosestDay, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates, writable2 };
|
|
2514
|
+
export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createView, datesEqual, debounce, Calendar as default, derived2, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, max, min, nextClosestDay, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, themeView, toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates, writable2 };
|
package/package.json
CHANGED
package/src/Buttons.svelte
CHANGED
|
@@ -30,12 +30,29 @@
|
|
|
30
30
|
<!-- svelte-ignore a11y-missing-content -->
|
|
31
31
|
<h2 class="{$theme.title}" use:setContent={$_viewTitle}></h2>
|
|
32
32
|
{:else if button == 'prev'}
|
|
33
|
-
<button
|
|
33
|
+
<button
|
|
34
|
+
class="{$theme.button} ec-{button}"
|
|
35
|
+
aria-label={$buttonText.prev}
|
|
36
|
+
title={$buttonText.prev}
|
|
37
|
+
on:click={prev}
|
|
38
|
+
><i class="{$theme.icon} ec-{button}"></i></button>
|
|
34
39
|
{:else if button == 'next'}
|
|
35
|
-
<button
|
|
40
|
+
<button
|
|
41
|
+
class="{$theme.button} ec-{button}"
|
|
42
|
+
aria-label={$buttonText.next}
|
|
43
|
+
title={$buttonText.next}
|
|
44
|
+
on:click={next}
|
|
45
|
+
><i class="{$theme.icon} ec-{button}"></i></button>
|
|
36
46
|
{:else if button == 'today'}
|
|
37
|
-
<button
|
|
47
|
+
<button
|
|
48
|
+
class="{$theme.button} ec-{button}"
|
|
49
|
+
on:click={() => $date = cloneDate(today)}
|
|
50
|
+
disabled={isToday}
|
|
51
|
+
>{$buttonText[button]}</button>
|
|
38
52
|
{:else if button != ''}
|
|
39
|
-
<button
|
|
53
|
+
<button
|
|
54
|
+
class="{$theme.button}{$view === button ? ' ' + $theme.active : ''} ec-{button}"
|
|
55
|
+
on:click={() => $view = button}
|
|
56
|
+
>{$buttonText[button]}</button>
|
|
40
57
|
{/if}
|
|
41
58
|
{/each}
|
package/src/Calendar.svelte
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
let state = new State(plugins, options);
|
|
27
27
|
setContext('state', state);
|
|
28
28
|
|
|
29
|
-
let {_viewComponent,
|
|
29
|
+
let {_viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _scrollable,
|
|
30
30
|
events, eventSources, height, theme} = state;
|
|
31
31
|
|
|
32
32
|
// Reactively update options that did change
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
</script>
|
|
131
131
|
|
|
132
132
|
<div
|
|
133
|
-
class="{$theme.calendar}{$
|
|
133
|
+
class="{$theme.calendar} {$theme.view}{$_scrollable ? ' ' + $theme.withScroll : ''}{$_iClass ? ' ' + $theme[$_iClass] : ''}"
|
|
134
134
|
style="height: {$height}"
|
|
135
135
|
>
|
|
136
136
|
<Toolbar/>
|
package/src/index.scss
CHANGED
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
border-top: none;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
.ec-
|
|
187
|
+
.ec-day-grid & {
|
|
188
188
|
flex: 1 1 auto;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -215,12 +215,12 @@
|
|
|
215
215
|
.ec-content {
|
|
216
216
|
display: flex;
|
|
217
217
|
|
|
218
|
-
.ec-
|
|
218
|
+
.ec-day-grid & {
|
|
219
219
|
flex-direction: column;
|
|
220
220
|
height: 100%;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
.ec-
|
|
223
|
+
.ec-day-grid .ec-uniform & {
|
|
224
224
|
overflow: hidden; // remove scrolling due to hidden events
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -241,12 +241,12 @@
|
|
|
241
241
|
border-bottom: none;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
.ec-
|
|
244
|
+
.ec-day-grid &,
|
|
245
245
|
.ec-resource & {
|
|
246
246
|
flex: 1 0 auto;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
.ec-
|
|
249
|
+
.ec-day-grid .ec-uniform & {
|
|
250
250
|
flex: 1 1 0%; // % is required to work properly for both auto and fixed calendar height
|
|
251
251
|
min-height: 0;
|
|
252
252
|
}
|
|
@@ -263,16 +263,16 @@
|
|
|
263
263
|
background-color: #e5f7fe;
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
.ec-
|
|
266
|
+
.ec-day-grid .ec-body & {
|
|
267
267
|
min-height: 5em;
|
|
268
268
|
position: relative;
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
.ec-
|
|
271
|
+
.ec-day-grid .ec-uniform & {
|
|
272
272
|
min-height: 0;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
.ec-
|
|
275
|
+
.ec-day-grid &:first-child {
|
|
276
276
|
border-left: none;
|
|
277
277
|
}
|
|
278
278
|
|
|
@@ -296,7 +296,7 @@
|
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
-
.ec-
|
|
299
|
+
.ec-day-grid {
|
|
300
300
|
.ec-day-head {
|
|
301
301
|
text-align: right;
|
|
302
302
|
padding: 4px 4px 3px;
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
.ec-events {
|
|
329
329
|
margin: 0 6px 0 0;
|
|
330
330
|
|
|
331
|
-
.ec-
|
|
331
|
+
.ec-time-grid &,
|
|
332
332
|
&.ec-preview {
|
|
333
333
|
position: relative;
|
|
334
334
|
}
|
|
@@ -346,12 +346,12 @@
|
|
|
346
346
|
line-height: 1.5;
|
|
347
347
|
z-index: 1; // put it above the pointer event (for multi-day events in month view)
|
|
348
348
|
|
|
349
|
-
.ec-
|
|
349
|
+
.ec-day-grid &,
|
|
350
350
|
.ec-all-day & {
|
|
351
351
|
position: relative;
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
.ec-
|
|
354
|
+
.ec-time-grid .ec-body & {
|
|
355
355
|
position: absolute;
|
|
356
356
|
}
|
|
357
357
|
|
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
flex-direction: column;
|
|
391
391
|
width: 100%;
|
|
392
392
|
|
|
393
|
-
.ec-
|
|
393
|
+
.ec-day-grid &,
|
|
394
394
|
.ec-all-day & {
|
|
395
395
|
flex-direction: row;
|
|
396
396
|
}
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
margin: 0 0 1px 0;
|
|
409
409
|
flex-shrink: 0;
|
|
410
410
|
|
|
411
|
-
.ec-
|
|
411
|
+
.ec-day-grid & {
|
|
412
412
|
margin: 0 3px 0 0;
|
|
413
413
|
max-width: 100%;
|
|
414
414
|
text-overflow: ellipsis;
|
|
@@ -418,14 +418,14 @@
|
|
|
418
418
|
.ec-event-title {
|
|
419
419
|
overflow: hidden;
|
|
420
420
|
|
|
421
|
-
.ec-
|
|
421
|
+
.ec-day-grid &,
|
|
422
422
|
.ec-all-day & {
|
|
423
423
|
min-height: 1.5em;
|
|
424
424
|
white-space: nowrap;
|
|
425
425
|
text-overflow: ellipsis;
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
.ec-
|
|
428
|
+
.ec-time-grid .ec-body & {
|
|
429
429
|
position: sticky;
|
|
430
430
|
top: 0;
|
|
431
431
|
}
|
|
@@ -557,7 +557,7 @@
|
|
|
557
557
|
position: absolute;
|
|
558
558
|
user-select: none;
|
|
559
559
|
|
|
560
|
-
.ec-
|
|
560
|
+
.ec-day-grid &,
|
|
561
561
|
.ec-all-day & {
|
|
562
562
|
top: 0;
|
|
563
563
|
right: 0;
|
|
@@ -567,7 +567,7 @@
|
|
|
567
567
|
cursor: ew-resize;
|
|
568
568
|
}
|
|
569
569
|
|
|
570
|
-
.ec-
|
|
570
|
+
.ec-time-grid .ec-body & {
|
|
571
571
|
left: 0;
|
|
572
572
|
right: 0;
|
|
573
573
|
bottom: 0;
|
package/src/lib/a11y.js
CHANGED
|
@@ -4,27 +4,3 @@ export function keyEnter(fn) {
|
|
|
4
4
|
return e.key === 'Enter' || e.key === ' ' ? fn.call(this, e) : undefined;
|
|
5
5
|
};
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
export function btnTextDay(text) {
|
|
9
|
-
return btnText(text, 'day');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function btnTextWeek(text) {
|
|
13
|
-
return btnText(text, 'week');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function btnTextMonth(text) {
|
|
17
|
-
return btnText(text, 'month');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function btnTextYear(text) {
|
|
21
|
-
return btnText(text, 'year');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function btnText(text, period) {
|
|
25
|
-
return {
|
|
26
|
-
...text,
|
|
27
|
-
next: 'Next ' + period,
|
|
28
|
-
prev: 'Previous ' + period
|
|
29
|
-
};
|
|
30
|
-
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
export function btnTextDay(text) {
|
|
3
|
+
return btnText(text, 'day');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function btnTextWeek(text) {
|
|
7
|
+
return btnText(text, 'week');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function btnTextMonth(text) {
|
|
11
|
+
return btnText(text, 'month');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function btnTextYear(text) {
|
|
15
|
+
return btnText(text, 'year');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function btnText(text, period) {
|
|
19
|
+
return {
|
|
20
|
+
...text,
|
|
21
|
+
next: 'Next ' + period,
|
|
22
|
+
prev: 'Previous ' + period
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function themeView(view) {
|
|
27
|
+
return theme => ({...theme, view});
|
|
28
|
+
}
|
package/src/lib.js
CHANGED
package/src/storage/options.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {assign, createDate, createDuration, setMidnight, createEvents, createEventSources} from '../lib.js';
|
|
2
|
-
import {is_function} from 'svelte/internal';
|
|
3
2
|
|
|
4
3
|
export function createOptions(plugins) {
|
|
5
4
|
let options = {
|
|
@@ -92,7 +91,7 @@ export function createOptions(plugins) {
|
|
|
92
91
|
time: 'ec-time',
|
|
93
92
|
title: 'ec-title',
|
|
94
93
|
toolbar: 'ec-toolbar',
|
|
95
|
-
|
|
94
|
+
view: '',
|
|
96
95
|
withScroll: 'ec-with-scroll'
|
|
97
96
|
},
|
|
98
97
|
titleFormat: {
|
|
@@ -112,9 +111,8 @@ export function createOptions(plugins) {
|
|
|
112
111
|
return options;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
export function createParsers(
|
|
114
|
+
export function createParsers(plugins) {
|
|
116
115
|
let parsers = {
|
|
117
|
-
buttonText: input => is_function(input) ? input(options.buttonText) : input,
|
|
118
116
|
date: date => setMidnight(createDate(date)),
|
|
119
117
|
duration: createDuration,
|
|
120
118
|
events: createEvents,
|
|
@@ -124,12 +122,11 @@ export function createParsers(options, plugins) {
|
|
|
124
122
|
scrollTime: createDuration,
|
|
125
123
|
slotDuration: createDuration,
|
|
126
124
|
slotMaxTime: createDuration,
|
|
127
|
-
slotMinTime: createDuration
|
|
128
|
-
theme: input => is_function(input) ? input(options.theme) : input
|
|
125
|
+
slotMinTime: createDuration
|
|
129
126
|
};
|
|
130
127
|
|
|
131
128
|
for (let plugin of plugins) {
|
|
132
|
-
plugin.createParsers?.(parsers
|
|
129
|
+
plugin.createParsers?.(parsers);
|
|
133
130
|
}
|
|
134
131
|
|
|
135
132
|
return parsers;
|
package/src/storage/state.js
CHANGED
|
@@ -4,23 +4,23 @@ import {createOptions, createParsers} from './options';
|
|
|
4
4
|
import {
|
|
5
5
|
activeRange,
|
|
6
6
|
currentRange,
|
|
7
|
+
dayGrid,
|
|
7
8
|
events,
|
|
8
|
-
monthMode,
|
|
9
9
|
now,
|
|
10
10
|
today,
|
|
11
11
|
viewDates,
|
|
12
12
|
viewTitle,
|
|
13
13
|
view as view2 // hack to avoid a runtime error in SvelteKit dev mode (ReferenceError: view is not defined)
|
|
14
14
|
} from './stores';
|
|
15
|
-
import {
|
|
15
|
+
import {keys, writable2, intl, intlRange} from '../lib.js';
|
|
16
16
|
|
|
17
17
|
export default class {
|
|
18
18
|
constructor(plugins, input) {
|
|
19
19
|
plugins = plugins || [];
|
|
20
20
|
|
|
21
21
|
// Create options
|
|
22
|
-
let options= createOptions(plugins);
|
|
23
|
-
let parsers = createParsers(
|
|
22
|
+
let options = createOptions(plugins);
|
|
23
|
+
let parsers = createParsers(plugins);
|
|
24
24
|
|
|
25
25
|
// Parse options
|
|
26
26
|
options = parseOpts(options, parsers);
|
|
@@ -34,7 +34,7 @@ export default class {
|
|
|
34
34
|
// Private stores
|
|
35
35
|
this._queue = writable(new Map()); // debounce queue
|
|
36
36
|
this._auxiliary = writable([]); // auxiliary components
|
|
37
|
-
this.
|
|
37
|
+
this._dayGrid = dayGrid(this);
|
|
38
38
|
this._currentRange = currentRange(this);
|
|
39
39
|
this._activeRange = activeRange(this);
|
|
40
40
|
this._fetchedRange = writable({start: undefined, end: undefined});
|
|
@@ -50,7 +50,6 @@ export default class {
|
|
|
50
50
|
this._viewTitle = viewTitle(this);
|
|
51
51
|
this._viewDates = viewDates(this);
|
|
52
52
|
this._view = view2(this);
|
|
53
|
-
this._viewClass = writable(undefined);
|
|
54
53
|
this._viewComponent = writable(undefined);
|
|
55
54
|
// Resources
|
|
56
55
|
this._resBgColor = writable(noop);
|
|
@@ -74,7 +73,7 @@ export default class {
|
|
|
74
73
|
// Set options for each view
|
|
75
74
|
let views = new Set([...keys(options.views), ...keys(input.views ?? {})]);
|
|
76
75
|
for (let view of views) {
|
|
77
|
-
let opts =
|
|
76
|
+
let opts = mergeOpts(options, options.views[view] ?? {}, input, input.views?.[view] ?? {});
|
|
78
77
|
// Change view component when view changes
|
|
79
78
|
this.view.subscribe(newView => {
|
|
80
79
|
if (newView === view) {
|
|
@@ -125,3 +124,14 @@ function parseOpts(opts, parsers) {
|
|
|
125
124
|
}
|
|
126
125
|
return result;
|
|
127
126
|
}
|
|
127
|
+
|
|
128
|
+
function mergeOpts(...args) {
|
|
129
|
+
let mergable = ['buttonText', 'theme'];
|
|
130
|
+
let result = {};
|
|
131
|
+
for (let opts of args) {
|
|
132
|
+
for (let key of keys(opts)) {
|
|
133
|
+
result[key] = mergable.includes(key) && is_function(opts[key]) ? opts[key](result[key]) : opts[key];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
package/src/storage/stores.js
CHANGED
|
@@ -19,18 +19,18 @@ import {
|
|
|
19
19
|
debounce
|
|
20
20
|
} from '../lib.js';
|
|
21
21
|
|
|
22
|
-
export function
|
|
22
|
+
export function dayGrid(state) {
|
|
23
23
|
return derived(state.view, $view => $view?.startsWith('dayGrid'));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function activeRange(state) {
|
|
27
27
|
return derived(
|
|
28
|
-
[state._currentRange, state.firstDay, state.slotMaxTime, state.
|
|
29
|
-
([$_currentRange, $firstDay, $slotMaxTime, $
|
|
28
|
+
[state._currentRange, state.firstDay, state.slotMaxTime, state._dayGrid],
|
|
29
|
+
([$_currentRange, $firstDay, $slotMaxTime, $_dayGrid]) => {
|
|
30
30
|
let start = cloneDate($_currentRange.start);
|
|
31
31
|
let end = cloneDate($_currentRange.end);
|
|
32
32
|
|
|
33
|
-
if ($
|
|
33
|
+
if ($_dayGrid) {
|
|
34
34
|
// First day of week
|
|
35
35
|
prevClosestDay(start, $firstDay);
|
|
36
36
|
nextClosestDay(end, $firstDay);
|
|
@@ -49,10 +49,10 @@ export function activeRange(state) {
|
|
|
49
49
|
|
|
50
50
|
export function currentRange(state) {
|
|
51
51
|
return derived(
|
|
52
|
-
[state.date, state.duration, state.firstDay, state.
|
|
53
|
-
([$date, $duration, $firstDay, $
|
|
52
|
+
[state.date, state.duration, state.firstDay, state._dayGrid],
|
|
53
|
+
([$date, $duration, $firstDay, $_dayGrid]) => {
|
|
54
54
|
let start = cloneDate($date), end;
|
|
55
|
-
if ($
|
|
55
|
+
if ($_dayGrid) {
|
|
56
56
|
start.setUTCDate(1);
|
|
57
57
|
} else if ($duration.inWeeks) {
|
|
58
58
|
// First day of week
|
|
@@ -93,9 +93,9 @@ export function viewDates(state) {
|
|
|
93
93
|
|
|
94
94
|
export function viewTitle(state) {
|
|
95
95
|
return derived(
|
|
96
|
-
[state.date, state._activeRange, state._intlTitle, state.
|
|
97
|
-
([$date, $_activeRange, $_intlTitle, $
|
|
98
|
-
return $
|
|
96
|
+
[state.date, state._activeRange, state._intlTitle, state._dayGrid],
|
|
97
|
+
([$date, $_activeRange, $_intlTitle, $_dayGrid]) => {
|
|
98
|
+
return $_dayGrid
|
|
99
99
|
? $_intlTitle.formatRange($date, $date)
|
|
100
100
|
: $_intlTitle.formatRange($_activeRange.start, subtractDay(cloneDate($_activeRange.end)));
|
|
101
101
|
}
|