@event-calendar/core 2.6.0 → 2.6.1
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 -4
- package/index.js +42 -4
- package/package.json +1 -1
- package/src/lib/stores.js +42 -4
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ See [demo](https://vkurko.github.io/calendar/) and [changelog](CHANGELOG.md).
|
|
|
4
4
|
|
|
5
5
|
Full-sized drag & drop JavaScript event calendar with resource view:
|
|
6
6
|
|
|
7
|
-
* Lightweight (
|
|
7
|
+
* Lightweight (33kb [br](https://en.wikipedia.org/wiki/Brotli) compressed)
|
|
8
8
|
* Zero-dependency (pre-built bundle)
|
|
9
9
|
* Used on over 70,000 websites with [Bookly](https://wordpress.org/plugins/bookly-responsive-appointment-booking-tool/)
|
|
10
10
|
|
|
@@ -199,8 +199,8 @@ import '@event-calendar/core/index.css';
|
|
|
199
199
|
### Pre-built browser ready bundle
|
|
200
200
|
Include the following lines of code in the `<head>` section of your page:
|
|
201
201
|
```html
|
|
202
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.6.
|
|
203
|
-
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.6.
|
|
202
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.6.1/event-calendar.min.css">
|
|
203
|
+
<script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.6.1/event-calendar.min.js"></script>
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
<details>
|
|
@@ -1288,7 +1288,27 @@ This option is used instead of the `events` option.
|
|
|
1288
1288
|
</td>
|
|
1289
1289
|
<td>
|
|
1290
1290
|
|
|
1291
|
-
A URL that the calendar will fetch [Event](#event-object) objects from
|
|
1291
|
+
A URL that the calendar will fetch [Event](#event-object) objects from. HTTP requests with the following parameters will be sent to this URL whenever the calendar needs new event data
|
|
1292
|
+
<table>
|
|
1293
|
+
<tr>
|
|
1294
|
+
<td>
|
|
1295
|
+
|
|
1296
|
+
`start`
|
|
1297
|
+
</td>
|
|
1298
|
+
<td>
|
|
1299
|
+
Start date of the range the calendar needs events for
|
|
1300
|
+
</td>
|
|
1301
|
+
</tr>
|
|
1302
|
+
<tr>
|
|
1303
|
+
<td>
|
|
1304
|
+
|
|
1305
|
+
`end`
|
|
1306
|
+
</td>
|
|
1307
|
+
<td>
|
|
1308
|
+
End date of the range the calendar needs events for
|
|
1309
|
+
</td>
|
|
1310
|
+
</tr>
|
|
1311
|
+
</table>
|
|
1292
1312
|
</td>
|
|
1293
1313
|
</tr>
|
|
1294
1314
|
<tr>
|
package/index.js
CHANGED
|
@@ -619,15 +619,53 @@ function intl(locale, format) {
|
|
|
619
619
|
|
|
620
620
|
function intlRange(locale, format) {
|
|
621
621
|
return derived([locale, format], ([$locale, $format]) => {
|
|
622
|
-
let
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
let formatRange;
|
|
623
|
+
if (is_function($format)) {
|
|
624
|
+
formatRange = $format;
|
|
625
|
+
} else {
|
|
626
|
+
let intl = new Intl.DateTimeFormat($locale, $format);
|
|
627
|
+
formatRange = (start, end) => {
|
|
628
|
+
if (start <= end) {
|
|
629
|
+
return intl.formatRange(start, end);
|
|
630
|
+
} else {
|
|
631
|
+
// In iOS 16 and older, intl.formatRange() throws an exception if the start date is later than the end date.
|
|
632
|
+
// Therefore, we first swap the parameters, and then swap the resulting parts.
|
|
633
|
+
/** @see https://github.com/vkurko/calendar/issues/227 */
|
|
634
|
+
let parts = intl.formatRangeToParts(end, start);
|
|
635
|
+
let result = '';
|
|
636
|
+
let sources = ['startRange', 'endRange'];
|
|
637
|
+
let processed = [false, false];
|
|
638
|
+
for (let part of parts) {
|
|
639
|
+
let i = sources.indexOf(part.source);
|
|
640
|
+
if (i >= 0) {
|
|
641
|
+
if (!processed[i]) {
|
|
642
|
+
result += _getParts(sources[1 - i], parts);
|
|
643
|
+
processed[i] = true;
|
|
644
|
+
}
|
|
645
|
+
} else {
|
|
646
|
+
result += part.value;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return result;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
}
|
|
625
653
|
return {
|
|
626
|
-
formatRange: (start, end) =>
|
|
654
|
+
formatRange: (start, end) => formatRange(toLocalDate(start), toLocalDate(end))
|
|
627
655
|
};
|
|
628
656
|
});
|
|
629
657
|
}
|
|
630
658
|
|
|
659
|
+
function _getParts(source, parts) {
|
|
660
|
+
let result = '';
|
|
661
|
+
for (let part of parts) {
|
|
662
|
+
if (part.source == source) {
|
|
663
|
+
result += part.value;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
return result;
|
|
667
|
+
}
|
|
668
|
+
|
|
631
669
|
function createOptions(plugins) {
|
|
632
670
|
let options = {
|
|
633
671
|
allDayContent: undefined,
|
package/package.json
CHANGED
package/src/lib/stores.js
CHANGED
|
@@ -15,11 +15,49 @@ export function intl(locale, format) {
|
|
|
15
15
|
|
|
16
16
|
export function intlRange(locale, format) {
|
|
17
17
|
return derived([locale, format], ([$locale, $format]) => {
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let formatRange;
|
|
19
|
+
if (is_function($format)) {
|
|
20
|
+
formatRange = $format;
|
|
21
|
+
} else {
|
|
22
|
+
let intl = new Intl.DateTimeFormat($locale, $format);
|
|
23
|
+
formatRange = (start, end) => {
|
|
24
|
+
if (start <= end) {
|
|
25
|
+
return intl.formatRange(start, end);
|
|
26
|
+
} else {
|
|
27
|
+
// In iOS 16 and older, intl.formatRange() throws an exception if the start date is later than the end date.
|
|
28
|
+
// Therefore, we first swap the parameters, and then swap the resulting parts.
|
|
29
|
+
/** @see https://github.com/vkurko/calendar/issues/227 */
|
|
30
|
+
let parts = intl.formatRangeToParts(end, start);
|
|
31
|
+
let result = '';
|
|
32
|
+
let sources = ['startRange', 'endRange'];
|
|
33
|
+
let processed = [false, false];
|
|
34
|
+
for (let part of parts) {
|
|
35
|
+
let i = sources.indexOf(part.source);
|
|
36
|
+
if (i >= 0) {
|
|
37
|
+
if (!processed[i]) {
|
|
38
|
+
result += _getParts(sources[1 - i], parts);
|
|
39
|
+
processed[i] = true;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
result += part.value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
21
49
|
return {
|
|
22
|
-
formatRange: (start, end) =>
|
|
50
|
+
formatRange: (start, end) => formatRange(toLocalDate(start), toLocalDate(end))
|
|
23
51
|
};
|
|
24
52
|
});
|
|
25
53
|
}
|
|
54
|
+
|
|
55
|
+
function _getParts(source, parts) {
|
|
56
|
+
let result = '';
|
|
57
|
+
for (let part of parts) {
|
|
58
|
+
if (part.source == source) {
|
|
59
|
+
result += part.value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|