@fullcalendar/moment 6.0.2 → 6.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.
@@ -1,39 +1,31 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var index_cjs = require('@fullcalendar/core/index.cjs');
6
- var moment = require('moment');
7
- var internal_cjs = require('@fullcalendar/core/internal.cjs');
8
-
9
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
-
11
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
1
+ import { createPlugin } from '@fullcalendar/core';
2
+ import moment from 'moment';
3
+ import { CalendarImpl } from '@fullcalendar/core/internal';
12
4
 
13
5
  function toMoment(date, calendar) {
14
- if (!(calendar instanceof internal_cjs.CalendarImpl)) {
6
+ if (!(calendar instanceof CalendarImpl)) {
15
7
  throw new Error('must supply a CalendarApi instance');
16
8
  }
17
9
  let { dateEnv } = calendar.getCurrentData();
18
10
  return convertToMoment(date, dateEnv.timeZone, null, dateEnv.locale.codes[0]);
19
11
  }
20
12
  function toMomentDuration(fcDuration) {
21
- return moment__default["default"].duration(fcDuration); // moment accepts all the props that fc.Duration already has!
13
+ return moment.duration(fcDuration); // moment accepts all the props that fc.Duration already has!
22
14
  }
23
15
  // Internal Utils
24
16
  function convertToMoment(input, timeZone, timeZoneOffset, locale) {
25
17
  let mom;
26
18
  if (timeZone === 'local') {
27
- mom = moment__default["default"](input);
19
+ mom = moment(input);
28
20
  }
29
21
  else if (timeZone === 'UTC') {
30
- mom = moment__default["default"].utc(input);
22
+ mom = moment.utc(input);
31
23
  }
32
- else if (moment__default["default"].tz) {
33
- mom = moment__default["default"].tz(input, timeZone);
24
+ else if (moment.tz) {
25
+ mom = moment.tz(input, timeZone);
34
26
  }
35
27
  else {
36
- mom = moment__default["default"].utc(input);
28
+ mom = moment.utc(input);
37
29
  if (timeZoneOffset != null) {
38
30
  mom.utcOffset(timeZoneOffset);
39
31
  }
@@ -95,11 +87,9 @@ function formatRange(cmd, formatStart, formatEnd, separator) {
95
87
  return startWhole + separator + endWhole;
96
88
  }
97
89
 
98
- var index = index_cjs.createPlugin({
90
+ var index = createPlugin({
99
91
  name: '@fullcalendar/moment',
100
92
  cmdFormatter: formatWithCmdStr,
101
93
  });
102
94
 
103
- exports["default"] = index;
104
- exports.toMoment = toMoment;
105
- exports.toMomentDuration = toMomentDuration;
95
+ export { index as default, toMoment, toMomentDuration };
package/index.global.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- FullCalendar Moment Plugin v6.0.2
2
+ FullCalendar Moment Plugin v6.1.0
3
3
  Docs & License: https://fullcalendar.io/docs/moment-plugin
4
4
  (c) 2022 Adam Shaw
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- FullCalendar Moment Plugin v6.0.2
2
+ FullCalendar Moment Plugin v6.1.0
3
3
  Docs & License: https://fullcalendar.io/docs/moment-plugin
4
4
  (c) 2022 Adam Shaw
5
5
  */
package/index.js CHANGED
@@ -1,31 +1,39 @@
1
- import { createPlugin } from '@fullcalendar/core/index.js';
2
- import moment from 'moment';
3
- import { CalendarImpl } from '@fullcalendar/core/internal.js';
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@fullcalendar/core');
6
+ var moment = require('moment');
7
+ var internal = require('@fullcalendar/core/internal');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
4
12
 
5
13
  function toMoment(date, calendar) {
6
- if (!(calendar instanceof CalendarImpl)) {
14
+ if (!(calendar instanceof internal.CalendarImpl)) {
7
15
  throw new Error('must supply a CalendarApi instance');
8
16
  }
9
17
  let { dateEnv } = calendar.getCurrentData();
10
18
  return convertToMoment(date, dateEnv.timeZone, null, dateEnv.locale.codes[0]);
11
19
  }
12
20
  function toMomentDuration(fcDuration) {
13
- return moment.duration(fcDuration); // moment accepts all the props that fc.Duration already has!
21
+ return moment__default["default"].duration(fcDuration); // moment accepts all the props that fc.Duration already has!
14
22
  }
15
23
  // Internal Utils
16
24
  function convertToMoment(input, timeZone, timeZoneOffset, locale) {
17
25
  let mom;
18
26
  if (timeZone === 'local') {
19
- mom = moment(input);
27
+ mom = moment__default["default"](input);
20
28
  }
21
29
  else if (timeZone === 'UTC') {
22
- mom = moment.utc(input);
30
+ mom = moment__default["default"].utc(input);
23
31
  }
24
- else if (moment.tz) {
25
- mom = moment.tz(input, timeZone);
32
+ else if (moment__default["default"].tz) {
33
+ mom = moment__default["default"].tz(input, timeZone);
26
34
  }
27
35
  else {
28
- mom = moment.utc(input);
36
+ mom = moment__default["default"].utc(input);
29
37
  if (timeZoneOffset != null) {
30
38
  mom.utcOffset(timeZoneOffset);
31
39
  }
@@ -87,10 +95,11 @@ function formatRange(cmd, formatStart, formatEnd, separator) {
87
95
  return startWhole + separator + endWhole;
88
96
  }
89
97
 
90
- var index = createPlugin({
98
+ var index = core.createPlugin({
91
99
  name: '@fullcalendar/moment',
92
100
  cmdFormatter: formatWithCmdStr,
93
101
  });
94
102
 
95
- export { index as default, toMoment, toMomentDuration };
96
- //# sourceMappingURL=index.js.map
103
+ exports["default"] = index;
104
+ exports.toMoment = toMoment;
105
+ exports.toMomentDuration = toMomentDuration;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullcalendar/moment",
3
- "version": "6.0.2",
3
+ "version": "6.1.0",
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": "~6.0.2",
15
+ "@fullcalendar/core": "~6.1.0",
16
16
  "moment": "^2.29.1"
17
17
  },
18
18
  "type": "module",
@@ -29,19 +29,17 @@
29
29
  "url": "http://arshaw.com/"
30
30
  },
31
31
  "copyright": "2022 Adam Shaw",
32
- "main": "./index.cjs",
33
- "module": "./index.js",
34
32
  "types": "./index.d.ts",
33
+ "main": "./index.js",
34
+ "module": "./index.esm.js",
35
35
  "unpkg": "./index.global.min.js",
36
36
  "jsdelivr": "./index.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
40
  "types": "./index.d.ts",
43
- "require": "./index.cjs",
44
- "import": "./index.js"
41
+ "require": "./index.js",
42
+ "import": "./index.esm.js"
45
43
  }
46
44
  },
47
45
  "sideEffects": false
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/convert.ts","../src/format.ts","../src/index.ts"],"sourcesContent":["import moment from 'moment'\nimport { CalendarApi, Duration } from '@fullcalendar/core'\nimport { CalendarImpl } from '@fullcalendar/core/internal'\n\nexport function toMoment(date: Date, calendar: CalendarApi): moment.Moment {\n if (!(calendar instanceof CalendarImpl)) {\n throw new Error('must supply a CalendarApi instance')\n }\n\n let { dateEnv } = calendar.getCurrentData()\n\n return convertToMoment(\n date,\n dateEnv.timeZone,\n null,\n dateEnv.locale.codes[0],\n )\n}\n\nexport function toMomentDuration(fcDuration: Duration): moment.Duration {\n return moment.duration(fcDuration) // moment accepts all the props that fc.Duration already has!\n}\n\n// Internal Utils\n\nexport function convertToMoment(\n input: any,\n timeZone: string,\n timeZoneOffset: number | null,\n locale: string,\n): moment.Moment {\n let mom: moment.Moment\n\n if (timeZone === 'local') {\n mom = moment(input)\n } else if (timeZone === 'UTC') {\n mom = moment.utc(input)\n } else if ((moment as any).tz) {\n mom = (moment as any).tz(input, timeZone)\n } else {\n mom = moment.utc(input)\n\n if (timeZoneOffset != null) {\n mom.utcOffset(timeZoneOffset)\n }\n }\n\n mom.locale(locale)\n\n return mom\n}\n","import { VerboseFormattingArg } from '@fullcalendar/core/internal'\nimport { convertToMoment } from './convert.js'\n\nexport function formatWithCmdStr(cmdStr: string, arg: VerboseFormattingArg): string {\n let cmd = parseCmdStr(cmdStr)\n\n if (arg.end) {\n let startMom = convertToMoment(\n arg.start.array,\n arg.timeZone,\n arg.start.timeZoneOffset,\n arg.localeCodes[0],\n )\n let endMom = convertToMoment(\n arg.end.array,\n arg.timeZone,\n arg.end.timeZoneOffset,\n arg.localeCodes[0],\n )\n return formatRange(\n cmd,\n createMomentFormatFunc(startMom),\n createMomentFormatFunc(endMom),\n arg.defaultSeparator,\n )\n }\n\n return convertToMoment(\n arg.date.array,\n arg.timeZone,\n arg.date.timeZoneOffset,\n arg.localeCodes[0],\n ).format(cmd.whole) // TODO: test for this\n}\n\nfunction createMomentFormatFunc(mom: moment.Moment) {\n return (cmdStr) => (\n cmdStr ? mom.format(cmdStr) : '' // because calling with blank string results in ISO8601 :(\n )\n}\n\n/* Range Formatting (duplicate code as other date plugins)\n----------------------------------------------------------------------------------------------------*/\n\ninterface CmdParts {\n head: string | null\n middle: CmdParts | null\n tail: string | null\n whole: string\n}\n\nfunction parseCmdStr(cmdStr: string): CmdParts {\n let parts = cmdStr.match(/^(.*?)\\{(.*)\\}(.*)$/) // TODO: lookbehinds for escape characters\n\n if (parts) {\n let middle = parseCmdStr(parts[2])\n\n return {\n head: parts[1],\n middle,\n tail: parts[3],\n whole: parts[1] + middle.whole + parts[3],\n }\n }\n\n return {\n head: null,\n middle: null,\n tail: null,\n whole: cmdStr,\n }\n}\n\nfunction formatRange(\n cmd: CmdParts,\n formatStart: (cmdStr: string) => string,\n formatEnd: (cmdStr: string) => string,\n separator: string,\n): string {\n if (cmd.middle) {\n let startHead = formatStart(cmd.head)\n let startMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator)\n let startTail = formatStart(cmd.tail)\n\n let endHead = formatEnd(cmd.head)\n let endMiddle = formatRange(cmd.middle, formatStart, formatEnd, separator)\n let endTail = formatEnd(cmd.tail)\n\n if (startHead === endHead && startTail === endTail) {\n return startHead +\n (startMiddle === endMiddle ? startMiddle : startMiddle + separator + endMiddle) +\n startTail\n }\n }\n\n let startWhole = formatStart(cmd.whole)\n let endWhole = formatEnd(cmd.whole)\n\n if (startWhole === endWhole) {\n return startWhole\n }\n\n return startWhole + separator + endWhole\n}\n","import { createPlugin, PluginDef } from '@fullcalendar/core'\nimport { formatWithCmdStr } from './format.js'\n\nexport default createPlugin({\n name: '<%= pkgName %>',\n cmdFormatter: formatWithCmdStr,\n}) as PluginDef\n\nexport { toMoment, toMomentDuration } from './convert.js'\n"],"names":[],"mappings":";;;;AAIgB,SAAA,QAAQ,CAAC,IAAU,EAAE,QAAqB,EAAA;AACxD,IAAA,IAAI,EAAE,QAAQ,YAAY,YAAY,CAAC,EAAE;AACvC,QAAA,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;AACtD,KAAA;IAED,IAAI,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,cAAc,EAAE,CAAA;AAE3C,IAAA,OAAO,eAAe,CACpB,IAAI,EACJ,OAAO,CAAC,QAAQ,EAChB,IAAI,EACJ,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACxB,CAAA;AACH,CAAC;AAEK,SAAU,gBAAgB,CAAC,UAAoB,EAAA;IACnD,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AACpC,CAAC;AAED;AAEM,SAAU,eAAe,CAC7B,KAAU,EACV,QAAgB,EAChB,cAA6B,EAC7B,MAAc,EAAA;AAEd,IAAA,IAAI,GAAkB,CAAA;IAEtB,IAAI,QAAQ,KAAK,OAAO,EAAE;AACxB,QAAA,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;AACpB,KAAA;SAAM,IAAI,QAAQ,KAAK,KAAK,EAAE;AAC7B,QAAA,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACxB,KAAA;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