@fullcalendar/luxon3 7.0.0-beta.4 → 7.0.0-beta.6
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.md +1 -1
- package/README.md +7 -1
- package/{index.cjs → cjs/index.cjs} +45 -12
- package/{index.js → esm/index.js} +41 -8
- package/{index.global.js → global.js} +41 -8
- package/{index.global.min.js → global.min.js} +3 -3
- package/package.json +17 -14
- /package/{index.d.ts → esm/index.d.ts} +0 -0
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -25,12 +25,18 @@ Instantiate a Calendar with the necessary plugin:
|
|
|
25
25
|
import { Calendar } from '@fullcalendar/core'
|
|
26
26
|
import luxon3Plugin from '@fullcalendar/luxon3'
|
|
27
27
|
import dayGridPlugin from '@fullcalendar/daygrid'
|
|
28
|
+
import classicThemePlugin from '@fullcalendar/theme-classic'
|
|
29
|
+
|
|
30
|
+
import '@fullcalendar/core/skeleton.css'
|
|
31
|
+
import '@fullcalendar/theme-classic/theme.css'
|
|
32
|
+
import '@fullcalendar/theme-classic/palette.css'
|
|
28
33
|
|
|
29
34
|
const calendarEl = document.getElementById('calendar')
|
|
30
35
|
const calendar = new Calendar(calendarEl, {
|
|
31
36
|
plugins: [
|
|
32
37
|
luxon3Plugin,
|
|
33
|
-
dayGridPlugin
|
|
38
|
+
dayGridPlugin,
|
|
39
|
+
classicThemePlugin
|
|
34
40
|
],
|
|
35
41
|
initialView: 'dayGridMonth',
|
|
36
42
|
titleFormat: 'LLLL d, yyyy', // use Luxon format strings
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var core = require('@fullcalendar/core');
|
|
6
6
|
var luxon = require('luxon');
|
|
7
|
-
var
|
|
7
|
+
var internal = require('@fullcalendar/core/internal');
|
|
8
8
|
|
|
9
9
|
function toLuxonDateTime(date, calendar) {
|
|
10
|
-
if (!(calendar instanceof
|
|
10
|
+
if (!(calendar instanceof internal.CalendarImpl)) {
|
|
11
11
|
throw new Error('must supply a CalendarApi instance');
|
|
12
12
|
}
|
|
13
13
|
let { dateEnv } = calendar.getCurrentData();
|
|
@@ -17,7 +17,7 @@ function toLuxonDateTime(date, calendar) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
function toLuxonDuration(duration, calendar) {
|
|
20
|
-
if (!(calendar instanceof
|
|
20
|
+
if (!(calendar instanceof internal.CalendarImpl)) {
|
|
21
21
|
throw new Error('must supply a CalendarApi instance');
|
|
22
22
|
}
|
|
23
23
|
let { dateEnv } = calendar.getCurrentData();
|
|
@@ -52,7 +52,7 @@ function arrayToLuxon(arr, timeZone, locale) {
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
class LuxonNamedTimeZone extends
|
|
55
|
+
class LuxonNamedTimeZone extends internal.NamedTimeZoneImpl {
|
|
56
56
|
offsetForArray(a) {
|
|
57
57
|
return arrayToLuxon(a, this.timeZoneName).offset;
|
|
58
58
|
}
|
|
@@ -63,14 +63,17 @@ class LuxonNamedTimeZone extends internal_cjs.NamedTimeZoneImpl {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function formatWithCmdStr(cmdStr,
|
|
66
|
+
function formatWithCmdStr(cmdStr, data) {
|
|
67
67
|
let cmd = parseCmdStr(cmdStr);
|
|
68
|
-
if (
|
|
69
|
-
let start = arrayToLuxon(
|
|
70
|
-
let end = arrayToLuxon(
|
|
71
|
-
return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end),
|
|
68
|
+
if (data.end) {
|
|
69
|
+
let start = arrayToLuxon(data.start.array, data.timeZone, data.localeCodes[0]);
|
|
70
|
+
let end = arrayToLuxon(data.end.array, data.timeZone, data.localeCodes[0]);
|
|
71
|
+
return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end), data.defaultSeparator);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
const lux = arrayToLuxon(data.date.array, data.timeZone, data.localeCodes[0]);
|
|
74
|
+
const singleCmdStr = cmd.whole;
|
|
75
|
+
const singleOutStr = lux.toFormat(singleCmdStr);
|
|
76
|
+
return emulateParts(singleCmdStr, singleOutStr) || singleOutStr;
|
|
74
77
|
}
|
|
75
78
|
function parseCmdStr(cmdStr) {
|
|
76
79
|
let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters
|
|
@@ -111,8 +114,38 @@ function formatRange(cmd, formatStart, formatEnd, separator) {
|
|
|
111
114
|
}
|
|
112
115
|
return startWhole + separator + endWhole;
|
|
113
116
|
}
|
|
117
|
+
function emulateParts(cmdStr, outStr) {
|
|
118
|
+
const numParts = getSingleNumberParts(outStr);
|
|
119
|
+
if (numParts) {
|
|
120
|
+
const numType = getSingleNumberType(cmdStr);
|
|
121
|
+
if (numType) {
|
|
122
|
+
const [head, numStr, tail] = numParts;
|
|
123
|
+
const parts = [];
|
|
124
|
+
if (head) {
|
|
125
|
+
parts.push({ type: 'literal', value: head });
|
|
126
|
+
}
|
|
127
|
+
parts.push({ type: numType, value: numStr });
|
|
128
|
+
if (tail) {
|
|
129
|
+
parts.push({ type: 'literal', value: tail });
|
|
130
|
+
}
|
|
131
|
+
return parts;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function getSingleNumberParts(outStr) {
|
|
136
|
+
const parts = outStr.split(/(\d+)/); // capture group keeps match within parts
|
|
137
|
+
if (parts.length === 3) {
|
|
138
|
+
return parts;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function getSingleNumberType(cmdStr) {
|
|
142
|
+
const m = cmdStr.match(/d+/); // d/dd -- day-of-month
|
|
143
|
+
if (m) {
|
|
144
|
+
return 'day';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
114
147
|
|
|
115
|
-
var index =
|
|
148
|
+
var index = core.createPlugin({
|
|
116
149
|
name: '@fullcalendar/luxon3',
|
|
117
150
|
cmdFormatter: formatWithCmdStr,
|
|
118
151
|
namedTimeZonedImpl: LuxonNamedTimeZone,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createPlugin } from '@fullcalendar/core
|
|
1
|
+
import { createPlugin } from '@fullcalendar/core';
|
|
2
2
|
import { DateTime, Duration } from 'luxon';
|
|
3
|
-
import { CalendarImpl, NamedTimeZoneImpl } from '@fullcalendar/core/internal
|
|
3
|
+
import { CalendarImpl, NamedTimeZoneImpl } from '@fullcalendar/core/internal';
|
|
4
4
|
|
|
5
5
|
function toLuxonDateTime(date, calendar) {
|
|
6
6
|
if (!(calendar instanceof CalendarImpl)) {
|
|
@@ -59,14 +59,17 @@ class LuxonNamedTimeZone extends NamedTimeZoneImpl {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function formatWithCmdStr(cmdStr,
|
|
62
|
+
function formatWithCmdStr(cmdStr, data) {
|
|
63
63
|
let cmd = parseCmdStr(cmdStr);
|
|
64
|
-
if (
|
|
65
|
-
let start = arrayToLuxon(
|
|
66
|
-
let end = arrayToLuxon(
|
|
67
|
-
return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end),
|
|
64
|
+
if (data.end) {
|
|
65
|
+
let start = arrayToLuxon(data.start.array, data.timeZone, data.localeCodes[0]);
|
|
66
|
+
let end = arrayToLuxon(data.end.array, data.timeZone, data.localeCodes[0]);
|
|
67
|
+
return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end), data.defaultSeparator);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
const lux = arrayToLuxon(data.date.array, data.timeZone, data.localeCodes[0]);
|
|
70
|
+
const singleCmdStr = cmd.whole;
|
|
71
|
+
const singleOutStr = lux.toFormat(singleCmdStr);
|
|
72
|
+
return emulateParts(singleCmdStr, singleOutStr) || singleOutStr;
|
|
70
73
|
}
|
|
71
74
|
function parseCmdStr(cmdStr) {
|
|
72
75
|
let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters
|
|
@@ -107,6 +110,36 @@ function formatRange(cmd, formatStart, formatEnd, separator) {
|
|
|
107
110
|
}
|
|
108
111
|
return startWhole + separator + endWhole;
|
|
109
112
|
}
|
|
113
|
+
function emulateParts(cmdStr, outStr) {
|
|
114
|
+
const numParts = getSingleNumberParts(outStr);
|
|
115
|
+
if (numParts) {
|
|
116
|
+
const numType = getSingleNumberType(cmdStr);
|
|
117
|
+
if (numType) {
|
|
118
|
+
const [head, numStr, tail] = numParts;
|
|
119
|
+
const parts = [];
|
|
120
|
+
if (head) {
|
|
121
|
+
parts.push({ type: 'literal', value: head });
|
|
122
|
+
}
|
|
123
|
+
parts.push({ type: numType, value: numStr });
|
|
124
|
+
if (tail) {
|
|
125
|
+
parts.push({ type: 'literal', value: tail });
|
|
126
|
+
}
|
|
127
|
+
return parts;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function getSingleNumberParts(outStr) {
|
|
132
|
+
const parts = outStr.split(/(\d+)/); // capture group keeps match within parts
|
|
133
|
+
if (parts.length === 3) {
|
|
134
|
+
return parts;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function getSingleNumberType(cmdStr) {
|
|
138
|
+
const m = cmdStr.match(/d+/); // d/dd -- day-of-month
|
|
139
|
+
if (m) {
|
|
140
|
+
return 'day';
|
|
141
|
+
}
|
|
142
|
+
}
|
|
110
143
|
|
|
111
144
|
var index = createPlugin({
|
|
112
145
|
name: '@fullcalendar/luxon3',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar Luxon 3 Plugin v7.0.0-beta.
|
|
2
|
+
FullCalendar Luxon 3 Plugin v7.0.0-beta.6
|
|
3
3
|
Docs & License: https://fullcalendar.io/docs/luxon
|
|
4
|
-
(c)
|
|
4
|
+
(c) 2025 Adam Shaw
|
|
5
5
|
*/
|
|
6
6
|
FullCalendar.Luxon3 = (function (exports, core, luxon, internal) {
|
|
7
7
|
'use strict';
|
|
@@ -63,14 +63,17 @@ FullCalendar.Luxon3 = (function (exports, core, luxon, internal) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function formatWithCmdStr(cmdStr,
|
|
66
|
+
function formatWithCmdStr(cmdStr, data) {
|
|
67
67
|
let cmd = parseCmdStr(cmdStr);
|
|
68
|
-
if (
|
|
69
|
-
let start = arrayToLuxon(
|
|
70
|
-
let end = arrayToLuxon(
|
|
71
|
-
return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end),
|
|
68
|
+
if (data.end) {
|
|
69
|
+
let start = arrayToLuxon(data.start.array, data.timeZone, data.localeCodes[0]);
|
|
70
|
+
let end = arrayToLuxon(data.end.array, data.timeZone, data.localeCodes[0]);
|
|
71
|
+
return formatRange(cmd, start.toFormat.bind(start), end.toFormat.bind(end), data.defaultSeparator);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
const lux = arrayToLuxon(data.date.array, data.timeZone, data.localeCodes[0]);
|
|
74
|
+
const singleCmdStr = cmd.whole;
|
|
75
|
+
const singleOutStr = lux.toFormat(singleCmdStr);
|
|
76
|
+
return emulateParts(singleCmdStr, singleOutStr) || singleOutStr;
|
|
74
77
|
}
|
|
75
78
|
function parseCmdStr(cmdStr) {
|
|
76
79
|
let parts = cmdStr.match(/^(.*?)\{(.*)\}(.*)$/); // TODO: lookbehinds for escape characters
|
|
@@ -111,6 +114,36 @@ FullCalendar.Luxon3 = (function (exports, core, luxon, internal) {
|
|
|
111
114
|
}
|
|
112
115
|
return startWhole + separator + endWhole;
|
|
113
116
|
}
|
|
117
|
+
function emulateParts(cmdStr, outStr) {
|
|
118
|
+
const numParts = getSingleNumberParts(outStr);
|
|
119
|
+
if (numParts) {
|
|
120
|
+
const numType = getSingleNumberType(cmdStr);
|
|
121
|
+
if (numType) {
|
|
122
|
+
const [head, numStr, tail] = numParts;
|
|
123
|
+
const parts = [];
|
|
124
|
+
if (head) {
|
|
125
|
+
parts.push({ type: 'literal', value: head });
|
|
126
|
+
}
|
|
127
|
+
parts.push({ type: numType, value: numStr });
|
|
128
|
+
if (tail) {
|
|
129
|
+
parts.push({ type: 'literal', value: tail });
|
|
130
|
+
}
|
|
131
|
+
return parts;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function getSingleNumberParts(outStr) {
|
|
136
|
+
const parts = outStr.split(/(\d+)/); // capture group keeps match within parts
|
|
137
|
+
if (parts.length === 3) {
|
|
138
|
+
return parts;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function getSingleNumberType(cmdStr) {
|
|
142
|
+
const m = cmdStr.match(/d+/); // d/dd -- day-of-month
|
|
143
|
+
if (m) {
|
|
144
|
+
return 'day';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
114
147
|
|
|
115
148
|
var plugin = core.createPlugin({
|
|
116
149
|
name: '@fullcalendar/luxon3',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar Luxon 3 Plugin v7.0.0-beta.
|
|
2
|
+
FullCalendar Luxon 3 Plugin v7.0.0-beta.6
|
|
3
3
|
Docs & License: https://fullcalendar.io/docs/luxon
|
|
4
|
-
(c)
|
|
4
|
+
(c) 2025 Adam Shaw
|
|
5
5
|
*/
|
|
6
|
-
FullCalendar.Luxon3=function(e,t,n,a){"use strict";function l(e,t,a){return n.DateTime.fromObject({year:e[0],month:e[1]+1,day:e[2],hour:e[3],minute:e[4],second:e[5],millisecond:e[6]},{locale:a,zone:t})}class r extends a.NamedTimeZoneImpl{offsetForArray(e){return l(e,this.timeZoneName).offset}timestampToArray(e){return[(t=n.DateTime.fromMillis(e,{zone:this.timeZoneName})).year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond];var t}}var o=t.createPlugin({name:"@fullcalendar/luxon3",cmdFormatter:function(e,t){let n=function e(t){let n=t.match(/^(.*?)\{(.*)\}(.*)$/);if(n){let t=e(n[2]);return{head:n[1],middle:t,tail:n[3],whole:n[1]+t.whole+n[3]}}return{head:null,middle:null,tail:null,whole:t}}(e);if(t.end){let e=l(t.start.array,t.timeZone,t.localeCodes[0]),a=l(t.end.array,t.timeZone,t.localeCodes[0]);return function e(t,n,a,l){if(t.middle){let r=n(t.head),o=e(t.middle,n,a,l),i=n(t.tail),u=a(t.head),d=e(t.middle,n,a,l),m=a(t.tail);if(r===u&&i===m)return r+(o===d?o:o+l+d)+i}let r=n(t.whole),o=a(t.whole);if(r===o)return r;return r+l+o}(n,e.toFormat.bind(e),a.toFormat.bind(a),t.defaultSeparator)}
|
|
6
|
+
FullCalendar.Luxon3=function(e,t,n,a){"use strict";function l(e,t,a){return n.DateTime.fromObject({year:e[0],month:e[1]+1,day:e[2],hour:e[3],minute:e[4],second:e[5],millisecond:e[6]},{locale:a,zone:t})}class r extends a.NamedTimeZoneImpl{offsetForArray(e){return l(e,this.timeZoneName).offset}timestampToArray(e){return[(t=n.DateTime.fromMillis(e,{zone:this.timeZoneName})).year,t.month-1,t.day,t.hour,t.minute,t.second,t.millisecond];var t}}var o=t.createPlugin({name:"@fullcalendar/luxon3",cmdFormatter:function(e,t){let n=function e(t){let n=t.match(/^(.*?)\{(.*)\}(.*)$/);if(n){let t=e(n[2]);return{head:n[1],middle:t,tail:n[3],whole:n[1]+t.whole+n[3]}}return{head:null,middle:null,tail:null,whole:t}}(e);if(t.end){let e=l(t.start.array,t.timeZone,t.localeCodes[0]),a=l(t.end.array,t.timeZone,t.localeCodes[0]);return function e(t,n,a,l){if(t.middle){let r=n(t.head),o=e(t.middle,n,a,l),i=n(t.tail),u=a(t.head),d=e(t.middle,n,a,l),m=a(t.tail);if(r===u&&i===m)return r+(o===d?o:o+l+d)+i}let r=n(t.whole),o=a(t.whole);if(r===o)return r;return r+l+o}(n,e.toFormat.bind(e),a.toFormat.bind(a),t.defaultSeparator)}const a=l(t.date.array,t.timeZone,t.localeCodes[0]),r=n.whole,o=a.toFormat(r);return function(e,t){const n=function(e){const t=e.split(/(\d+)/);if(3===t.length)return t}(t);if(n){const t=function(e){if(e.match(/d+/))return"day"}(e);if(t){const[e,a,l]=n,r=[];return e&&r.push({type:"literal",value:e}),r.push({type:t,value:a}),l&&r.push({type:"literal",value:l}),r}}}(r,o)||o},namedTimeZonedImpl:r});return t.globalPlugins.push(o),e.default=o,e.toLuxonDateTime=function(e,t){if(!(t instanceof a.CalendarImpl))throw new Error("must supply a CalendarApi instance");let{dateEnv:l}=t.getCurrentData();return n.DateTime.fromJSDate(e,{zone:l.timeZone,locale:l.locale.codes[0]})},e.toLuxonDuration=function(e,t){if(!(t instanceof a.CalendarImpl))throw new Error("must supply a CalendarApi instance");let{dateEnv:l}=t.getCurrentData();return n.Duration.fromObject(e,{locale:l.locale.codes[0]})},Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar,luxon,FullCalendar.Internal);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullcalendar/luxon3",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.6",
|
|
4
4
|
"title": "FullCalendar Luxon 3 Plugin",
|
|
5
5
|
"description": "Enhanced date formatting, conversion, and named time zone functionality with Luxon 3",
|
|
6
6
|
"keywords": [
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"homepage": "https://fullcalendar.io/docs/luxon",
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@fullcalendar/core": "7.0.0-beta.
|
|
17
|
+
"@fullcalendar/core": "7.0.0-beta.6",
|
|
18
18
|
"luxon": "^3.0.0"
|
|
19
19
|
},
|
|
20
20
|
"type": "module",
|
|
@@ -30,21 +30,24 @@
|
|
|
30
30
|
"email": "arshaw@arshaw.com",
|
|
31
31
|
"url": "http://arshaw.com/"
|
|
32
32
|
},
|
|
33
|
-
"copyright": "
|
|
34
|
-
"types": "./index.d.ts",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"unpkg": "./
|
|
38
|
-
"jsdelivr": "./
|
|
33
|
+
"copyright": "2025 Adam Shaw",
|
|
34
|
+
"types": "./esm/index.d.ts",
|
|
35
|
+
"module": "./esm/index.js",
|
|
36
|
+
"main": "./cjs/index.cjs",
|
|
37
|
+
"unpkg": "./global.min.js",
|
|
38
|
+
"jsdelivr": "./global.min.js",
|
|
39
39
|
"exports": {
|
|
40
40
|
"./package.json": "./package.json",
|
|
41
|
-
"./index.cjs": "./index.cjs",
|
|
42
|
-
"./index.js": "./index.js",
|
|
43
41
|
".": {
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
"import": {
|
|
43
|
+
"types": "./esm/index.d.ts",
|
|
44
|
+
"default": "./esm/index.js"
|
|
45
|
+
},
|
|
46
|
+
"require": "./cjs/index.cjs"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
-
"sideEffects":
|
|
49
|
+
"sideEffects": [
|
|
50
|
+
"./global.js",
|
|
51
|
+
"./global.min.js"
|
|
52
|
+
]
|
|
50
53
|
}
|
|
File without changes
|