@fullcalendar/moment 7.0.0-beta.4 → 7.0.0-beta.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Adam Shaw
3
+ Copyright (c) 2025 Adam Shaw
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
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 momentPlugin from '@fullcalendar/moment'
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
  momentPlugin,
33
- dayGridPlugin
38
+ dayGridPlugin,
39
+ classicThemePlugin
34
40
  ],
35
41
  initialView: 'dayGridMonth',
36
42
  titleFormat: 'MMMM D, YYYY' // use Moment format strings
@@ -2,16 +2,16 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index_cjs = require('@fullcalendar/core/index.cjs');
5
+ var core = require('@fullcalendar/core');
6
6
  var moment = require('moment');
7
- var internal_cjs = require('@fullcalendar/core/internal.cjs');
7
+ var internal = require('@fullcalendar/core/internal');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
11
11
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
12
12
 
13
13
  function toMoment(date, calendar) {
14
- if (!(calendar instanceof internal_cjs.CalendarImpl)) {
14
+ if (!(calendar instanceof internal.CalendarImpl)) {
15
15
  throw new Error('must supply a CalendarApi instance');
16
16
  }
17
17
  let { dateEnv } = calendar.getCurrentData();
@@ -42,14 +42,17 @@ function convertToMoment(input, timeZone, timeZoneOffset, locale) {
42
42
  return mom;
43
43
  }
44
44
 
45
- function formatWithCmdStr(cmdStr, arg) {
45
+ function formatWithCmdStr(cmdStr, data) {
46
46
  let cmd = parseCmdStr(cmdStr);
47
- if (arg.end) {
48
- let startMom = convertToMoment(arg.start.array, arg.timeZone, arg.start.timeZoneOffset, arg.localeCodes[0]);
49
- let endMom = convertToMoment(arg.end.array, arg.timeZone, arg.end.timeZoneOffset, arg.localeCodes[0]);
50
- return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), arg.defaultSeparator);
47
+ if (data.end) {
48
+ let startMom = convertToMoment(data.start.array, data.timeZone, data.start.timeZoneOffset, data.localeCodes[0]);
49
+ let endMom = convertToMoment(data.end.array, data.timeZone, data.end.timeZoneOffset, data.localeCodes[0]);
50
+ return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), data.defaultSeparator);
51
51
  }
52
- return convertToMoment(arg.date.array, arg.timeZone, arg.date.timeZoneOffset, arg.localeCodes[0]).format(cmd.whole); // TODO: test for this
52
+ const mom = convertToMoment(data.date.array, data.timeZone, data.date.timeZoneOffset, data.localeCodes[0]);
53
+ const singleCmdStr = cmd.whole;
54
+ const singleOutStr = mom.format(singleCmdStr);
55
+ return emulateParts(singleCmdStr, singleOutStr) || singleOutStr;
53
56
  }
54
57
  function createMomentFormatFunc(mom) {
55
58
  return (cmdStr) => (cmdStr ? mom.format(cmdStr) : '' // because calling with blank string results in ISO8601 :(
@@ -94,8 +97,41 @@ function formatRange(cmd, formatStart, formatEnd, separator) {
94
97
  }
95
98
  return startWhole + separator + endWhole;
96
99
  }
100
+ function emulateParts(cmdStr, outStr) {
101
+ const numParts = getSingleNumberParts(outStr);
102
+ if (numParts) {
103
+ const numType = getSingleNumberType(cmdStr);
104
+ if (numType) {
105
+ const [head, numStr, tail] = numParts;
106
+ const parts = [];
107
+ if (head) {
108
+ parts.push({ type: 'literal', value: head });
109
+ }
110
+ parts.push({ type: numType, value: numStr });
111
+ if (tail) {
112
+ parts.push({ type: 'literal', value: tail });
113
+ }
114
+ return parts;
115
+ }
116
+ }
117
+ }
118
+ function getSingleNumberParts(outStr) {
119
+ const parts = outStr.split(/(\d+)/); // capture group keeps match within parts
120
+ if (parts.length === 3) {
121
+ return parts;
122
+ }
123
+ }
124
+ function getSingleNumberType(cmdStr) {
125
+ const m = cmdStr.match(/D+/); // day-of-month/year
126
+ if (m) {
127
+ const [numberStr] = m;
128
+ if (numberStr.length < 3) { // D/DD -- day-of-month
129
+ return 'day';
130
+ } // otherwise DDD/DDDD -- day-of-year
131
+ }
132
+ }
97
133
 
98
- var index = index_cjs.createPlugin({
134
+ var index = core.createPlugin({
99
135
  name: '@fullcalendar/moment',
100
136
  cmdFormatter: formatWithCmdStr,
101
137
  });
@@ -1,6 +1,6 @@
1
- import { createPlugin } from '@fullcalendar/core/index.js';
1
+ import { createPlugin } from '@fullcalendar/core';
2
2
  import moment from 'moment';
3
- import { CalendarImpl } from '@fullcalendar/core/internal.js';
3
+ import { CalendarImpl } from '@fullcalendar/core/internal';
4
4
 
5
5
  function toMoment(date, calendar) {
6
6
  if (!(calendar instanceof CalendarImpl)) {
@@ -34,14 +34,17 @@ function convertToMoment(input, timeZone, timeZoneOffset, locale) {
34
34
  return mom;
35
35
  }
36
36
 
37
- function formatWithCmdStr(cmdStr, arg) {
37
+ function formatWithCmdStr(cmdStr, data) {
38
38
  let cmd = parseCmdStr(cmdStr);
39
- if (arg.end) {
40
- let startMom = convertToMoment(arg.start.array, arg.timeZone, arg.start.timeZoneOffset, arg.localeCodes[0]);
41
- let endMom = convertToMoment(arg.end.array, arg.timeZone, arg.end.timeZoneOffset, arg.localeCodes[0]);
42
- return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), arg.defaultSeparator);
39
+ if (data.end) {
40
+ let startMom = convertToMoment(data.start.array, data.timeZone, data.start.timeZoneOffset, data.localeCodes[0]);
41
+ let endMom = convertToMoment(data.end.array, data.timeZone, data.end.timeZoneOffset, data.localeCodes[0]);
42
+ return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), data.defaultSeparator);
43
43
  }
44
- return convertToMoment(arg.date.array, arg.timeZone, arg.date.timeZoneOffset, arg.localeCodes[0]).format(cmd.whole); // TODO: test for this
44
+ const mom = convertToMoment(data.date.array, data.timeZone, data.date.timeZoneOffset, data.localeCodes[0]);
45
+ const singleCmdStr = cmd.whole;
46
+ const singleOutStr = mom.format(singleCmdStr);
47
+ return emulateParts(singleCmdStr, singleOutStr) || singleOutStr;
45
48
  }
46
49
  function createMomentFormatFunc(mom) {
47
50
  return (cmdStr) => (cmdStr ? mom.format(cmdStr) : '' // because calling with blank string results in ISO8601 :(
@@ -86,6 +89,39 @@ function formatRange(cmd, formatStart, formatEnd, separator) {
86
89
  }
87
90
  return startWhole + separator + endWhole;
88
91
  }
92
+ function emulateParts(cmdStr, outStr) {
93
+ const numParts = getSingleNumberParts(outStr);
94
+ if (numParts) {
95
+ const numType = getSingleNumberType(cmdStr);
96
+ if (numType) {
97
+ const [head, numStr, tail] = numParts;
98
+ const parts = [];
99
+ if (head) {
100
+ parts.push({ type: 'literal', value: head });
101
+ }
102
+ parts.push({ type: numType, value: numStr });
103
+ if (tail) {
104
+ parts.push({ type: 'literal', value: tail });
105
+ }
106
+ return parts;
107
+ }
108
+ }
109
+ }
110
+ function getSingleNumberParts(outStr) {
111
+ const parts = outStr.split(/(\d+)/); // capture group keeps match within parts
112
+ if (parts.length === 3) {
113
+ return parts;
114
+ }
115
+ }
116
+ function getSingleNumberType(cmdStr) {
117
+ const m = cmdStr.match(/D+/); // day-of-month/year
118
+ if (m) {
119
+ const [numberStr] = m;
120
+ if (numberStr.length < 3) { // D/DD -- day-of-month
121
+ return 'day';
122
+ } // otherwise DDD/DDDD -- day-of-year
123
+ }
124
+ }
89
125
 
90
126
  var index = createPlugin({
91
127
  name: '@fullcalendar/moment',
@@ -1,7 +1,7 @@
1
1
  /*!
2
- FullCalendar Moment Plugin v7.0.0-beta.4
2
+ FullCalendar Moment Plugin v7.0.0-beta.5
3
3
  Docs & License: https://fullcalendar.io/docs/moment-plugin
4
- (c) 2024 Adam Shaw
4
+ (c) 2025 Adam Shaw
5
5
  */
6
6
  FullCalendar.Moment = (function (exports, core, moment, internal) {
7
7
  'use strict';
@@ -42,14 +42,17 @@ FullCalendar.Moment = (function (exports, core, moment, internal) {
42
42
  return mom;
43
43
  }
44
44
 
45
- function formatWithCmdStr(cmdStr, arg) {
45
+ function formatWithCmdStr(cmdStr, data) {
46
46
  let cmd = parseCmdStr(cmdStr);
47
- if (arg.end) {
48
- let startMom = convertToMoment(arg.start.array, arg.timeZone, arg.start.timeZoneOffset, arg.localeCodes[0]);
49
- let endMom = convertToMoment(arg.end.array, arg.timeZone, arg.end.timeZoneOffset, arg.localeCodes[0]);
50
- return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), arg.defaultSeparator);
47
+ if (data.end) {
48
+ let startMom = convertToMoment(data.start.array, data.timeZone, data.start.timeZoneOffset, data.localeCodes[0]);
49
+ let endMom = convertToMoment(data.end.array, data.timeZone, data.end.timeZoneOffset, data.localeCodes[0]);
50
+ return formatRange(cmd, createMomentFormatFunc(startMom), createMomentFormatFunc(endMom), data.defaultSeparator);
51
51
  }
52
- return convertToMoment(arg.date.array, arg.timeZone, arg.date.timeZoneOffset, arg.localeCodes[0]).format(cmd.whole); // TODO: test for this
52
+ const mom = convertToMoment(data.date.array, data.timeZone, data.date.timeZoneOffset, data.localeCodes[0]);
53
+ const singleCmdStr = cmd.whole;
54
+ const singleOutStr = mom.format(singleCmdStr);
55
+ return emulateParts(singleCmdStr, singleOutStr) || singleOutStr;
53
56
  }
54
57
  function createMomentFormatFunc(mom) {
55
58
  return (cmdStr) => (cmdStr ? mom.format(cmdStr) : '' // because calling with blank string results in ISO8601 :(
@@ -94,6 +97,39 @@ FullCalendar.Moment = (function (exports, core, moment, internal) {
94
97
  }
95
98
  return startWhole + separator + endWhole;
96
99
  }
100
+ function emulateParts(cmdStr, outStr) {
101
+ const numParts = getSingleNumberParts(outStr);
102
+ if (numParts) {
103
+ const numType = getSingleNumberType(cmdStr);
104
+ if (numType) {
105
+ const [head, numStr, tail] = numParts;
106
+ const parts = [];
107
+ if (head) {
108
+ parts.push({ type: 'literal', value: head });
109
+ }
110
+ parts.push({ type: numType, value: numStr });
111
+ if (tail) {
112
+ parts.push({ type: 'literal', value: tail });
113
+ }
114
+ return parts;
115
+ }
116
+ }
117
+ }
118
+ function getSingleNumberParts(outStr) {
119
+ const parts = outStr.split(/(\d+)/); // capture group keeps match within parts
120
+ if (parts.length === 3) {
121
+ return parts;
122
+ }
123
+ }
124
+ function getSingleNumberType(cmdStr) {
125
+ const m = cmdStr.match(/D+/); // day-of-month/year
126
+ if (m) {
127
+ const [numberStr] = m;
128
+ if (numberStr.length < 3) { // D/DD -- day-of-month
129
+ return 'day';
130
+ } // otherwise DDD/DDDD -- day-of-year
131
+ }
132
+ }
97
133
 
98
134
  var plugin = core.createPlugin({
99
135
  name: '@fullcalendar/moment',
package/global.min.js ADDED
@@ -0,0 +1,6 @@
1
+ /*!
2
+ FullCalendar Moment Plugin v7.0.0-beta.5
3
+ Docs & License: https://fullcalendar.io/docs/moment-plugin
4
+ (c) 2025 Adam Shaw
5
+ */
6
+ FullCalendar.Moment=function(e,t,n,l){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}var r=a(n);function u(e,t,n,l){let a;return"local"===t?a=r.default(e):"UTC"===t?a=r.default.utc(e):r.default.tz?a=r.default.tz(e,t):(a=r.default.utc(e),null!=n&&a.utcOffset(n)),a.locale(l),a}function o(e){return t=>t?e.format(t):""}var i=t.createPlugin({name:"@fullcalendar/moment",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=u(t.start.array,t.timeZone,t.start.timeZoneOffset,t.localeCodes[0]),l=u(t.end.array,t.timeZone,t.end.timeZoneOffset,t.localeCodes[0]);return function e(t,n,l,a){if(t.middle){let r=n(t.head),u=e(t.middle,n,l,a),o=n(t.tail),i=l(t.head),d=e(t.middle,n,l,a),f=l(t.tail);if(r===i&&o===f)return r+(u===d?u:u+a+d)+o}let r=n(t.whole),u=l(t.whole);if(r===u)return r;return r+a+u}(n,o(e),o(l),t.defaultSeparator)}const l=u(t.date.array,t.timeZone,t.date.timeZoneOffset,t.localeCodes[0]),a=n.whole,r=l.format(a);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){const t=e.match(/D+/);if(t){const[e]=t;if(e.length<3)return"day"}}(e);if(t){const[e,l,a]=n,r=[];return e&&r.push({type:"literal",value:e}),r.push({type:t,value:l}),a&&r.push({type:"literal",value:a}),r}}}(a,r)||r}});return t.globalPlugins.push(i),e.default=i,e.toMoment=function(e,t){if(!(t instanceof l.CalendarImpl))throw new Error("must supply a CalendarApi instance");let{dateEnv:n}=t.getCurrentData();return u(e,n.timeZone,null,n.locale.codes[0])},e.toMomentDuration=function(e){return r.default.duration(e)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar,moment,FullCalendar.Internal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullcalendar/moment",
3
- "version": "7.0.0-beta.4",
3
+ "version": "7.0.0-beta.5",
4
4
  "title": "FullCalendar Moment Plugin",
5
5
  "description": "Enhanced date formatting and conversion with Moment",
6
6
  "keywords": [
@@ -12,7 +12,7 @@
12
12
  ],
13
13
  "homepage": "https://fullcalendar.io/docs/moment-plugin",
14
14
  "peerDependencies": {
15
- "@fullcalendar/core": "7.0.0-beta.4",
15
+ "@fullcalendar/core": "7.0.0-beta.5",
16
16
  "moment": "^2.29.1"
17
17
  },
18
18
  "type": "module",
@@ -28,21 +28,24 @@
28
28
  "email": "arshaw@arshaw.com",
29
29
  "url": "http://arshaw.com/"
30
30
  },
31
- "copyright": "2024 Adam Shaw",
32
- "types": "./index.d.ts",
33
- "main": "./index.cjs",
34
- "module": "./index.js",
35
- "unpkg": "./index.global.min.js",
36
- "jsdelivr": "./index.global.min.js",
31
+ "copyright": "2025 Adam Shaw",
32
+ "types": "./esm/index.d.ts",
33
+ "module": "./esm/index.js",
34
+ "main": "./cjs/index.cjs",
35
+ "unpkg": "./global.min.js",
36
+ "jsdelivr": "./global.min.js",
37
37
  "exports": {
38
38
  "./package.json": "./package.json",
39
- "./index.cjs": "./index.cjs",
40
- "./index.js": "./index.js",
41
39
  ".": {
42
- "types": "./index.d.ts",
43
- "require": "./index.cjs",
44
- "import": "./index.js"
40
+ "import": {
41
+ "types": "./esm/index.d.ts",
42
+ "default": "./esm/index.js"
43
+ },
44
+ "require": "./cjs/index.cjs"
45
45
  }
46
46
  },
47
- "sideEffects": false
47
+ "sideEffects": [
48
+ "./global.js",
49
+ "./global.min.js"
50
+ ]
48
51
  }
@@ -1,6 +0,0 @@
1
- /*!
2
- FullCalendar Moment Plugin v7.0.0-beta.4
3
- Docs & License: https://fullcalendar.io/docs/moment-plugin
4
- (c) 2024 Adam Shaw
5
- */
6
- FullCalendar.Moment=function(e,t,l,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}var r=a(l);function u(e,t,l,n){let a;return"local"===t?a=r.default(e):"UTC"===t?a=r.default.utc(e):r.default.tz?a=r.default.tz(e,t):(a=r.default.utc(e),null!=l&&a.utcOffset(l)),a.locale(n),a}function o(e){return t=>t?e.format(t):""}var d=t.createPlugin({name:"@fullcalendar/moment",cmdFormatter:function(e,t){let l=function e(t){let l=t.match(/^(.*?)\{(.*)\}(.*)$/);if(l){let t=e(l[2]);return{head:l[1],middle:t,tail:l[3],whole:l[1]+t.whole+l[3]}}return{head:null,middle:null,tail:null,whole:t}}(e);if(t.end){let e=u(t.start.array,t.timeZone,t.start.timeZoneOffset,t.localeCodes[0]),n=u(t.end.array,t.timeZone,t.end.timeZoneOffset,t.localeCodes[0]);return function e(t,l,n,a){if(t.middle){let r=l(t.head),u=e(t.middle,l,n,a),o=l(t.tail),d=n(t.head),i=e(t.middle,l,n,a),f=n(t.tail);if(r===d&&o===f)return r+(u===i?u:u+a+i)+o}let r=l(t.whole),u=n(t.whole);if(r===u)return r;return r+a+u}(l,o(e),o(n),t.defaultSeparator)}return u(t.date.array,t.timeZone,t.date.timeZoneOffset,t.localeCodes[0]).format(l.whole)}});return t.globalPlugins.push(d),e.default=d,e.toMoment=function(e,t){if(!(t instanceof n.CalendarImpl))throw new Error("must supply a CalendarApi instance");let{dateEnv:l}=t.getCurrentData();return u(e,l.timeZone,null,l.locale.codes[0])},e.toMomentDuration=function(e){return r.default.duration(e)},Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar,moment,FullCalendar.Internal);
File without changes