UNPKG

@pinuts/bsr-uikit-relaunch

Version:

BSR UI-KIT Relaunch

79 lines (78 loc) 3.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = luxonLocalizer; exports.formats = void 0; var _reactBigCalendar = require("react-big-calendar"); var dates = _interopRequireWildcard(require("react-big-calendar/lib/utils/dates")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } const dateRangeFormat = (_ref, culture, local) => { let { start, end } = _ref; return `${local.format(start, 'D', culture)}${local.format(end, 'D', culture)}`; }; const timeRangeFormat = (_ref2, culture, local) => { let { start, end } = _ref2; return `${local.format(start, 't', culture)}${local.format(end, 't', culture)}`; }; const timeRangeStartFormat = (_ref3, culture, local) => { let { start } = _ref3; return `${local.format(start, 't', culture)} — `; }; const timeRangeEndFormat = (_ref4, culture, local) => { let { end } = _ref4; return ` — ${local.format(end, 't', culture)}`; }; const weekRangeFormat = (_ref5, culture, local) => { let { start, end } = _ref5; return `${local.format(start, 'MMMM dd', culture)} - ${local.format(end, dates.eq(start, end, 'month') ? 'dd' : 'MMMM dd', culture)}`; }; const formats = exports.formats = { dateFormat: 'dd', dayFormat: 'dd EEE', weekdayFormat: 'cccc', selectRangeFormat: timeRangeFormat, eventTimeRangeFormat: timeRangeFormat, eventTimeRangeStartFormat: timeRangeStartFormat, eventTimeRangeEndFormat: timeRangeEndFormat, timeGutterFormat: 't', monthHeaderFormat: 'MMMM yyyy', dayHeaderFormat: 'dddd MMM dd', dayRangeHeaderFormat: weekRangeFormat, agendaHeaderFormat: dateRangeFormat, agendaDateFormat: 'EEE MMM dd', agendaTimeFormat: 't', agendaTimeRangeFormat: timeRangeFormat }; function luxonLocalizer(DateTime, _ref6) { let { firstDayOfWeek } = _ref6; const locale = (d, c) => c ? d.reconfigure(c) : d; return new _reactBigCalendar.DateLocalizer({ formats, firstOfWeek() { return firstDayOfWeek + 1; }, parse(value, format, culture) { return locale(DateTime.fromFormat(value, format), culture).toJSDate(); }, format(value, format, culture) { return locale(DateTime.fromJSDate(value), culture).toFormat(format); } }); }