diff --git a/modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx b/modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx index 3bb43a72..010e45c4 100644 --- a/modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx +++ b/modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx @@ -15,7 +15,7 @@ export default function AsyncCalendar(props) { let statusValue = (props.requestFilter.post_status) ? props.requestFilter.post_status : ''; let typesValue = (props.requestFilter.post_type) ? props.requestFilter.post_type : ''; let weeksValue = (props.requestFilter.weeks) ? props.requestFilter.weeks : props.numberOfWeeksToDisplay; - + let categoryValue = ''; if (props.requestFilter.category && props.requestFilter.category.value) { categoryValue = props.requestFilter.category.value; @@ -25,12 +25,12 @@ export default function AsyncCalendar(props) { if (props.requestFilter.post_tag && props.requestFilter.post_tag.value) { postTagValue = props.requestFilter.post_tag.value; } - + let authorValue = ''; if (props.requestFilter.post_author && props.requestFilter.post_author.value) { authorValue = props.requestFilter.post_author.value; } - + const [firstDateToDisplay, setFirstDateToDisplay] = React.useState(getBeginDateOfWeekByDate(props.firstDateToDisplay, props.weekStartsOnSunday)); const [numberOfWeeksToDisplay, setNumberOfWeeksToDisplay] = React.useState(weeksValue); const [itemsByDate, setItemsByDate] = React.useState(props.items); @@ -454,7 +454,7 @@ export default function AsyncCalendar(props) { if (dayIndexInTheRow === 7) { dayIndexInTheRow = 0; tableRows.push( - {rowCells} + {rowCells} ); } diff --git a/modules/calendar/lib/async-calendar/js/Functions.jsx b/modules/calendar/lib/async-calendar/js/Functions.jsx index 27cdded8..21762664 100644 --- a/modules/calendar/lib/async-calendar/js/Functions.jsx +++ b/modules/calendar/lib/async-calendar/js/Functions.jsx @@ -136,9 +136,9 @@ export function getDateWithNoTimezoneOffset(dateString) { export function getPostLinksElement(linkData, handleOnClick) { if (linkData.url) { - return ({linkData.label}); + return ({linkData.label}); } else if (linkData.action) { - return ( handleOnClick(e, linkData)}>{linkData.label}); + return ( handleOnClick(e, linkData)}>{linkData.label}); } } diff --git a/modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx b/modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx index c0e58a02..0a7116f5 100644 --- a/modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx +++ b/modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx @@ -241,7 +241,7 @@ export default function ItemFormPopup(props) { } fieldRows.push( - + {field} @@ -389,11 +389,11 @@ export default function ItemFormPopup(props) { linkData = formLinks[linkName]; if (savingLink === linkData.id) { - links.push({linkData.labelLoading}); + links.push({linkData.labelLoading}); } else { links.push(getPostLinksElement(linkData, handleLinkOnClick)); } - links.push(|); + links.push(|); } links.pop(); diff --git a/modules/calendar/lib/async-calendar/js/ItemPopup.jsx b/modules/calendar/lib/async-calendar/js/ItemPopup.jsx index f6480e27..50aa1a8c 100644 --- a/modules/calendar/lib/async-calendar/js/ItemPopup.jsx +++ b/modules/calendar/lib/async-calendar/js/ItemPopup.jsx @@ -123,7 +123,7 @@ export default function ItemPopup(props) { } fieldRows.push( - + {dataProperty.label}: {field} @@ -155,15 +155,15 @@ export default function ItemPopup(props) { if (linkData.url) { links.push( - {linkData.label} + {linkData.label} ); } else if (linkData.action) { links.push( - handleOnClick(e, linkData)}>{linkData.label} + handleOnClick(e, linkData)}>{linkData.label} ); } - links.push(|); + links.push(|); } links.pop(); diff --git a/modules/calendar/lib/async-calendar/js/Select.jsx b/modules/calendar/lib/async-calendar/js/Select.jsx index 71e9f475..fff0870e 100644 --- a/modules/calendar/lib/async-calendar/js/Select.jsx +++ b/modules/calendar/lib/async-calendar/js/Select.jsx @@ -86,7 +86,7 @@ export default function Select(props) { if (props.options) { options = props.options.map(option => { - return + return }); } diff --git a/modules/calendar/lib/async-calendar/js/index.min.js b/modules/calendar/lib/async-calendar/js/index.min.js index 5b9a639d..a790a8ca 100644 --- a/modules/calendar/lib/async-calendar/js/index.min.js +++ b/modules/calendar/lib/async-calendar/js/index.min.js @@ -94,7 +94,7 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return AsyncCalendar; });\n/* harmony import */ var _NavigationBar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./NavigationBar */ \"./modules/calendar/lib/async-calendar/js/NavigationBar.jsx\");\n/* harmony import */ var _WeekDays__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./WeekDays */ \"./modules/calendar/lib/async-calendar/js/WeekDays.jsx\");\n/* harmony import */ var _MessageBar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./MessageBar */ \"./modules/calendar/lib/async-calendar/js/MessageBar.jsx\");\n/* harmony import */ var _DayCell__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DayCell */ \"./modules/calendar/lib/async-calendar/js/DayCell.jsx\");\n/* harmony import */ var _Functions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Functions */ \"./modules/calendar/lib/async-calendar/js/Functions.jsx\");\n/* harmony import */ var _FilterBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./FilterBar */ \"./modules/calendar/lib/async-calendar/js/FilterBar.jsx\");\n/* harmony import */ var _ItemFormPopup__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ItemFormPopup */ \"./modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx\");\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n\n\n\n\n\n\n\nvar $ = jQuery;\nfunction AsyncCalendar(props) {\n var theme = props.theme || 'light';\n var statusValue = props.requestFilter.post_status ? props.requestFilter.post_status : '';\n var typesValue = props.requestFilter.post_type ? props.requestFilter.post_type : '';\n var weeksValue = props.requestFilter.weeks ? props.requestFilter.weeks : props.numberOfWeeksToDisplay;\n var categoryValue = '';\n\n if (props.requestFilter.category && props.requestFilter.category.value) {\n categoryValue = props.requestFilter.category.value;\n }\n\n var postTagValue = '';\n\n if (props.requestFilter.post_tag && props.requestFilter.post_tag.value) {\n postTagValue = props.requestFilter.post_tag.value;\n }\n\n var authorValue = '';\n\n if (props.requestFilter.post_author && props.requestFilter.post_author.value) {\n authorValue = props.requestFilter.post_author.value;\n }\n\n var _React$useState = React.useState(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(props.firstDateToDisplay, props.weekStartsOnSunday)),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n firstDateToDisplay = _React$useState2[0],\n setFirstDateToDisplay = _React$useState2[1];\n\n var _React$useState3 = React.useState(weeksValue),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n numberOfWeeksToDisplay = _React$useState4[0],\n setNumberOfWeeksToDisplay = _React$useState4[1];\n\n var _React$useState5 = React.useState(props.items),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n itemsByDate = _React$useState6[0],\n setItemsByDate = _React$useState6[1];\n\n var _React$useState7 = React.useState(false),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n isLoading = _React$useState8[0],\n setIsLoading = _React$useState8[1];\n\n var _React$useState9 = React.useState(false),\n _React$useState10 = _slicedToArray(_React$useState9, 2),\n isDragging = _React$useState10[0],\n setIsDragging = _React$useState10[1];\n\n var _React$useState11 = React.useState(),\n _React$useState12 = _slicedToArray(_React$useState11, 2),\n message = _React$useState12[0],\n setMessage = _React$useState12[1];\n\n var _React$useState13 = React.useState(statusValue),\n _React$useState14 = _slicedToArray(_React$useState13, 2),\n filterStatus = _React$useState14[0],\n setFilterStatus = _React$useState14[1];\n\n var _React$useState15 = React.useState(categoryValue),\n _React$useState16 = _slicedToArray(_React$useState15, 2),\n filterCategory = _React$useState16[0],\n setFilterCategory = _React$useState16[1];\n\n var _React$useState17 = React.useState(postTagValue),\n _React$useState18 = _slicedToArray(_React$useState17, 2),\n filterTag = _React$useState18[0],\n setFilterTag = _React$useState18[1];\n\n var _React$useState19 = React.useState(authorValue),\n _React$useState20 = _slicedToArray(_React$useState19, 2),\n filterAuthor = _React$useState20[0],\n setFilterAuthor = _React$useState20[1];\n\n var _React$useState21 = React.useState(typesValue),\n _React$useState22 = _slicedToArray(_React$useState21, 2),\n filterPostType = _React$useState22[0],\n setFilterPostType = _React$useState22[1];\n\n var _React$useState23 = React.useState(weeksValue),\n _React$useState24 = _slicedToArray(_React$useState23, 2),\n filterWeeks = _React$useState24[0],\n setFilterWeeks = _React$useState24[1];\n\n var _React$useState25 = React.useState(),\n _React$useState26 = _slicedToArray(_React$useState25, 2),\n openedItemId = _React$useState26[0],\n setOpenedItemId = _React$useState26[1];\n\n var _React$useState27 = React.useState([]),\n _React$useState28 = _slicedToArray(_React$useState27, 2),\n openedItemData = _React$useState28[0],\n setOpenedItemData = _React$useState28[1];\n\n var _React$useState29 = React.useState(0),\n _React$useState30 = _slicedToArray(_React$useState29, 2),\n openedItemRefreshCount = _React$useState30[0],\n setOpenedItemRefreshCount = _React$useState30[1];\n\n var _React$useState31 = React.useState(0),\n _React$useState32 = _slicedToArray(_React$useState31, 2),\n refreshCount = _React$useState32[0],\n setRefreshCount = _React$useState32[1];\n\n var _React$useState33 = React.useState(),\n _React$useState34 = _slicedToArray(_React$useState33, 2),\n hoveredDate = _React$useState34[0],\n setHoveredDate = _React$useState34[1];\n\n var _React$useState35 = React.useState(),\n _React$useState36 = _slicedToArray(_React$useState35, 2),\n formDate = _React$useState36[0],\n setFormDate = _React$useState36[1];\n\n var DRAG_AND_DROP_HOVERING_CLASS = 'publishpress-calendar-day-hover';\n\n var getUrl = function getUrl(action, query) {\n if (!query) {\n query = '';\n }\n\n return props.ajaxUrl + '?action=' + action + '&nonce=' + props.nonce + query;\n };\n\n var addEventListeners = function addEventListeners() {\n document.addEventListener('keydown', onDocumentKeyDown);\n $(document).on('publishpress_calendar:close_popup', onCloseItemPopup);\n };\n\n var removeEventListeners = function removeEventListeners() {\n document.removeEventListener('keydown', onDocumentKeyDown);\n $('.publishpress-calendar tbody > tr > td').off('mouseenter');\n };\n\n var didMount = function didMount() {\n addEventListeners();\n\n if (props.userCanAddPosts) {\n initClickToCreateFeature();\n }\n\n return didUnmount;\n };\n\n var didUnmount = function didUnmount() {\n removeEventListeners();\n };\n\n var fetchCalendarData = function fetchCalendarData() {\n setIsLoading(true);\n setMessage(props.strings.loading);\n var dataUrl = getUrl(props.actionGetData, '&start_date=' + Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateAsStringInWpFormat\"])(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(firstDateToDisplay, props.weekStartsOnSunday)) + '&number_of_weeks=' + numberOfWeeksToDisplay);\n\n if (filterStatus) {\n dataUrl += '&post_status=' + filterStatus;\n }\n\n if (filterCategory) {\n dataUrl += '&category=' + filterCategory;\n }\n\n if (filterTag) {\n dataUrl += '&post_tag=' + filterTag;\n }\n\n if (filterAuthor) {\n dataUrl += '&post_author=' + filterAuthor;\n }\n\n if (filterPostType) {\n dataUrl += '&post_type=' + filterPostType;\n }\n\n if (filterWeeks) {\n dataUrl += '&weeks=' + filterWeeks;\n }\n\n fetch(dataUrl).then(function (response) {\n return response.json();\n }).then(function (fetchedData) {\n setItemsByDate(fetchedData);\n setIsLoading(false);\n setMessage(null);\n resetCSSClasses();\n });\n };\n\n var resetCSSClasses = function resetCSSClasses() {\n $('.' + DRAG_AND_DROP_HOVERING_CLASS).removeClass(DRAG_AND_DROP_HOVERING_CLASS);\n $('.publishpress-calendar-loading').removeClass('publishpress-calendar-loading');\n };\n\n var fetchCalendarItemData = function fetchCalendarItemData() {\n if (!openedItemId) {\n return;\n }\n\n setIsLoading(true);\n setMessage(props.strings.loadingItem);\n var dataUrl = props.ajaxUrl + '?action=' + 'publishpress_calendar_get_post_data' + '&nonce=' + props.nonce + '&id=' + openedItemId;\n fetch(dataUrl).then(function (response) {\n return response.json();\n }).then(function (data) {\n setIsLoading(false);\n setMessage(null);\n setOpenedItemData(data);\n });\n };\n\n var addOffsetInWeeksToFirstDateToDisplay = function addOffsetInWeeksToFirstDateToDisplay(offsetInWeeks) {\n setFirstDateToDisplay(new Date(firstDateToDisplay.getTime() + Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"calculateWeeksInMilliseconds\"])(offsetInWeeks)));\n };\n\n var handleRefreshOnClick = function handleRefreshOnClick(e) {\n e.preventDefault();\n setRefreshCount(refreshCount + 1);\n };\n\n var handleBackPageOnClick = function handleBackPageOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(numberOfWeeksToDisplay * -1);\n };\n\n var handleBackOnClick = function handleBackOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(-1);\n };\n\n var handleForwardOnClick = function handleForwardOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(1);\n };\n\n var handleForwardPageOnClick = function handleForwardPageOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(numberOfWeeksToDisplay);\n };\n\n var handleTodayOnClick = function handleTodayOnClick(e) {\n e.preventDefault();\n setFirstDateToDisplay(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(props.todayDate, props.weekStartsOnSunday));\n };\n\n var moveCalendarItemToANewDate = function moveCalendarItemToANewDate(itemDate, itemIndex, newYear, newMonth, newDay) {\n var item = itemsByDate[itemDate][itemIndex];\n setIsLoading(true);\n setMessage(props.strings.movingTheItem);\n var dataUrl = getUrl(props.actionMoveItem);\n var formData = new FormData();\n formData.append('id', item.id);\n formData.append('year', newYear);\n formData.append('month', newMonth);\n formData.append('day', newDay);\n fetch(dataUrl, {\n method: 'POST',\n body: formData\n }).then(function (response) {\n return response.json();\n }).then(function () {\n setRefreshCount(refreshCount + 1);\n });\n };\n\n var handleOnDropItemCallback = function handleOnDropItemCallback(event, ui) {\n var $dayCell = $(event.target);\n var $item = $(ui.draggable[0]);\n var dateTime = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateAsStringInWpFormat\"])(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateInstanceFromString\"])($item.data('datetime')));\n $(event.target).addClass('publishpress-calendar-loading');\n moveCalendarItemToANewDate(dateTime, $item.data('index'), $dayCell.data('year'), $dayCell.data('month'), $dayCell.data('day'));\n };\n\n var handleOnHoverCellCallback = function handleOnHoverCellCallback(event, ui) {\n resetCSSClasses();\n $(event.target).addClass(DRAG_AND_DROP_HOVERING_CLASS);\n };\n\n var itemPopupIsOpenedById = function itemPopupIsOpenedById(id) {\n return id === openedItemId;\n };\n\n var initDraggableAndDroppableBehaviors = function initDraggableAndDroppableBehaviors() {\n $('.publishpress-calendar-day-items li').draggable({\n zIndex: 99999,\n helper: 'clone',\n containment: '.publishpress-calendar table',\n start: function start(event, ui) {\n // Do not drag the item if the popup is opened.\n if (itemPopupIsOpenedById($(event.target).data('id'))) {\n return false;\n }\n\n if (!$(event.target).hasClass('publishpress-calendar-item-movable')) {\n return false;\n }\n\n $(event.target).addClass('ui-draggable-target');\n resetOpenedItemInPopup();\n setIsDragging(true);\n },\n stop: function stop(event, ui) {\n $('.ui-draggable-target').removeClass('ui-draggable-target');\n setIsDragging(false);\n }\n });\n $('.publishpress-calendar tbody > tr > td').droppable({\n drop: handleOnDropItemCallback,\n over: handleOnHoverCellCallback\n });\n };\n\n var getCellFromChild = function getCellFromChild(child) {\n var $child = $(child);\n\n if ($child.is('td.publishpress-calendar-business-day, td.publishpress-calendar-weekend-day')) {\n return $child;\n }\n\n if ($child.is('.publishpress-calendar-cell-header, .publishpress-calendar-date, .publishpress-calendar-cell-click-to-add, .publishpress-calendar-month-name')) {\n return $child.parents('td');\n }\n\n return null;\n };\n\n var getCellDate = function getCellDate(cell) {\n var date = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateInstanceFromString\"])(cell.data('year') + '-' + cell.data('month') + '-' + cell.data('day')); // Compensate the timezone for returning the correct date\n\n if (date.getHours() > 0) {\n date.setTime(date.getTime() + 60 * 1000 * date.getTimezoneOffset());\n }\n\n return date;\n };\n\n var isHoveringCellWhileDragging = function isHoveringCellWhileDragging(cell) {\n return $(cell).hasClass(DRAG_AND_DROP_HOVERING_CLASS);\n };\n\n var initClickToCreateFeature = function initClickToCreateFeature() {\n // We have to use this variable because when the click is done on the \"click to add\" label, we can't get its parent.\n // Probably because it was already removed from the DOM.\n var lastHoveredDate;\n $('.publishpress-calendar tbody > tr > td').on('mouseover', function (e) {\n e.preventDefault();\n e.stopPropagation();\n var cell = getCellFromChild(e.target);\n\n if (cell) {\n if (isHoveringCellWhileDragging(cell)) {\n return;\n }\n\n setHoveredDate(getCellDate(cell));\n lastHoveredDate = getCellDate(cell);\n }\n }).on('mouseout', function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n if (getCellFromChild(e.relatedTarget)) {\n return;\n }\n\n setHoveredDate(null);\n lastHoveredDate = null;\n }).on('click', function (e) {\n var cell = getCellFromChild(e.target);\n\n if (cell) {\n setOpenedItemId(null);\n setFormDate(lastHoveredDate);\n }\n });\n };\n\n var onFilterEventCallback = function onFilterEventCallback(filterName, value) {\n if ('status' === filterName) {\n setFilterStatus(value);\n }\n\n if ('category' === filterName) {\n setFilterCategory(value);\n }\n\n if ('tag' === filterName) {\n setFilterTag(value);\n }\n\n if ('author' === filterName) {\n setFilterAuthor(value);\n }\n\n if ('postType' === filterName) {\n setFilterPostType(value);\n }\n\n if ('weeks' === filterName) {\n value = parseInt(value);\n\n if (value === 0 || isNaN(value)) {\n value = props.numberOfWeeksToDisplay;\n }\n\n setFilterWeeks(value);\n setNumberOfWeeksToDisplay(value);\n }\n };\n\n var resetOpenedItemInPopup = function resetOpenedItemInPopup() {\n setOpenedItemId(null);\n setOpenedItemData(null);\n setFormDate(null);\n };\n\n var onClickItem = function onClickItem(id) {\n setOpenedItemData(null);\n setHoveredDate(null);\n setFormDate(null);\n setOpenedItemId(id);\n };\n\n var onPopupItemActionClick = function onPopupItemActionClick(action, id, result) {\n setOpenedItemRefreshCount(openedItemRefreshCount + 1);\n };\n\n var onDocumentKeyDown = function onDocumentKeyDown(e) {\n if (e.key === 'Escape') {\n resetOpenedItemInPopup();\n }\n };\n\n var getOpenedItemData = function getOpenedItemData() {\n return openedItemData;\n };\n\n var onCloseForm = function onCloseForm() {\n setRefreshCount(refreshCount + 1);\n setFormDate(null);\n };\n\n var onCloseItemPopup = function onCloseItemPopup() {\n setOpenedItemId(null);\n };\n\n var calendarTableBodyRowsWithCells = function calendarTableBodyRowsWithCells() {\n var numberOfDaysToDisplay = numberOfWeeksToDisplay * 7;\n var firstDate = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(firstDateToDisplay, props.weekStartsOnSunday);\n var tableRows = [];\n var rowCells = [];\n var dayIndexInTheRow = 0;\n var dayDate;\n var dateString;\n var lastMonthDisplayed = firstDate.getMonth();\n\n for (var dataIndex = 0; dataIndex < numberOfDaysToDisplay; dataIndex++) {\n if (dayIndexInTheRow === 0) {\n rowCells = [];\n }\n\n dayDate = new Date(firstDate);\n dayDate.setDate(dayDate.getDate() + dataIndex);\n dateString = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateAsStringInWpFormat\"])(dayDate);\n rowCells.push( /*#__PURE__*/React.createElement(_DayCell__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n key: 'day-' + dayDate.getTime(),\n date: dayDate,\n shouldDisplayMonthName: lastMonthDisplayed !== dayDate.getMonth() || dataIndex === 0,\n todayDate: props.todayDate,\n isLoading: false,\n isHovering: !isDragging && hoveredDate && hoveredDate.getTime() === dayDate.getTime() && !formDate,\n items: itemsByDate[dateString] || [],\n maxVisibleItems: parseInt(props.maxVisibleItems),\n timeFormat: props.timeFormat,\n openedItemId: openedItemId,\n getOpenedItemDataCallback: getOpenedItemData,\n ajaxUrl: props.ajaxUrl,\n onClickItemCallback: onClickItem,\n onItemActionClickCallback: onPopupItemActionClick,\n strings: props.strings\n }));\n dayIndexInTheRow++;\n\n if (dayIndexInTheRow === 7) {\n dayIndexInTheRow = 0;\n tableRows.push( /*#__PURE__*/React.createElement(\"tr\", null, rowCells));\n }\n\n lastMonthDisplayed = dayDate.getMonth();\n }\n\n return tableRows;\n };\n\n React.useEffect(didMount, []);\n React.useEffect(initDraggableAndDroppableBehaviors);\n\n if (props.userCanAddPosts) {\n React.useEffect(initClickToCreateFeature, [firstDateToDisplay, numberOfWeeksToDisplay, filterWeeks, filterAuthor, filterTag, filterCategory, filterStatus, filterPostType, refreshCount]);\n }\n\n React.useEffect(fetchCalendarData, [firstDateToDisplay, numberOfWeeksToDisplay, filterWeeks, filterAuthor, filterTag, filterCategory, filterStatus, filterPostType, refreshCount]);\n React.useEffect(fetchCalendarItemData, [openedItemId, openedItemRefreshCount]);\n var componentClassName = ['publishpress-calendar', 'publishpress-calendar-theme-' + theme];\n\n if (props.userCanAddPosts) {\n componentClassName.push('user-can-add-posts');\n }\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: componentClassName.join(' ')\n }, /*#__PURE__*/React.createElement(_FilterBar__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n statuses: props.statuses,\n postTypes: props.postTypes,\n numberOfWeeksToDisplay: numberOfWeeksToDisplay,\n ajaxUrl: props.ajaxUrl,\n nonce: props.nonce,\n onChange: onFilterEventCallback,\n requestFilter: props.requestFilter,\n strings: props.strings\n }), /*#__PURE__*/React.createElement(_NavigationBar__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n refreshOnClickCallback: handleRefreshOnClick,\n backPageOnClickCallback: handleBackPageOnClick,\n backOnClickCallback: handleBackOnClick,\n forwardOnClickCallback: handleForwardOnClick,\n forwardPageOnClickCallback: handleForwardPageOnClick,\n todayOnClickCallback: handleTodayOnClick,\n strings: props.strings\n }), /*#__PURE__*/React.createElement(\"table\", null, /*#__PURE__*/React.createElement(\"thead\", null, /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(_WeekDays__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n weekStartsOnSunday: props.weekStartsOnSunday,\n strings: props.strings\n }))), /*#__PURE__*/React.createElement(\"tbody\", null, calendarTableBodyRowsWithCells())), formDate && /*#__PURE__*/React.createElement(_ItemFormPopup__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n date: formDate,\n ajaxUrl: props.ajaxUrl,\n dateFormat: props.dateFormat,\n postTypes: props.postTypesCanCreate,\n statuses: props.statuses,\n actionGetPostTypeFields: props.actionGetPostTypeFields,\n nonce: props.nonce,\n onCloseCallback: onCloseForm,\n allowAddingMultipleAuthors: props.allowAddingMultipleAuthors,\n strings: props.strings\n }), /*#__PURE__*/React.createElement(_MessageBar__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n showSpinner: isLoading,\n message: message\n }));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return AsyncCalendar; });\n/* harmony import */ var _NavigationBar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./NavigationBar */ \"./modules/calendar/lib/async-calendar/js/NavigationBar.jsx\");\n/* harmony import */ var _WeekDays__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./WeekDays */ \"./modules/calendar/lib/async-calendar/js/WeekDays.jsx\");\n/* harmony import */ var _MessageBar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./MessageBar */ \"./modules/calendar/lib/async-calendar/js/MessageBar.jsx\");\n/* harmony import */ var _DayCell__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DayCell */ \"./modules/calendar/lib/async-calendar/js/DayCell.jsx\");\n/* harmony import */ var _Functions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Functions */ \"./modules/calendar/lib/async-calendar/js/Functions.jsx\");\n/* harmony import */ var _FilterBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./FilterBar */ \"./modules/calendar/lib/async-calendar/js/FilterBar.jsx\");\n/* harmony import */ var _ItemFormPopup__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ItemFormPopup */ \"./modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx\");\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n\n\n\n\n\n\n\nvar $ = jQuery;\nfunction AsyncCalendar(props) {\n var theme = props.theme || 'light';\n var statusValue = props.requestFilter.post_status ? props.requestFilter.post_status : '';\n var typesValue = props.requestFilter.post_type ? props.requestFilter.post_type : '';\n var weeksValue = props.requestFilter.weeks ? props.requestFilter.weeks : props.numberOfWeeksToDisplay;\n var categoryValue = '';\n\n if (props.requestFilter.category && props.requestFilter.category.value) {\n categoryValue = props.requestFilter.category.value;\n }\n\n var postTagValue = '';\n\n if (props.requestFilter.post_tag && props.requestFilter.post_tag.value) {\n postTagValue = props.requestFilter.post_tag.value;\n }\n\n var authorValue = '';\n\n if (props.requestFilter.post_author && props.requestFilter.post_author.value) {\n authorValue = props.requestFilter.post_author.value;\n }\n\n var _React$useState = React.useState(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(props.firstDateToDisplay, props.weekStartsOnSunday)),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n firstDateToDisplay = _React$useState2[0],\n setFirstDateToDisplay = _React$useState2[1];\n\n var _React$useState3 = React.useState(weeksValue),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n numberOfWeeksToDisplay = _React$useState4[0],\n setNumberOfWeeksToDisplay = _React$useState4[1];\n\n var _React$useState5 = React.useState(props.items),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n itemsByDate = _React$useState6[0],\n setItemsByDate = _React$useState6[1];\n\n var _React$useState7 = React.useState(false),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n isLoading = _React$useState8[0],\n setIsLoading = _React$useState8[1];\n\n var _React$useState9 = React.useState(false),\n _React$useState10 = _slicedToArray(_React$useState9, 2),\n isDragging = _React$useState10[0],\n setIsDragging = _React$useState10[1];\n\n var _React$useState11 = React.useState(),\n _React$useState12 = _slicedToArray(_React$useState11, 2),\n message = _React$useState12[0],\n setMessage = _React$useState12[1];\n\n var _React$useState13 = React.useState(statusValue),\n _React$useState14 = _slicedToArray(_React$useState13, 2),\n filterStatus = _React$useState14[0],\n setFilterStatus = _React$useState14[1];\n\n var _React$useState15 = React.useState(categoryValue),\n _React$useState16 = _slicedToArray(_React$useState15, 2),\n filterCategory = _React$useState16[0],\n setFilterCategory = _React$useState16[1];\n\n var _React$useState17 = React.useState(postTagValue),\n _React$useState18 = _slicedToArray(_React$useState17, 2),\n filterTag = _React$useState18[0],\n setFilterTag = _React$useState18[1];\n\n var _React$useState19 = React.useState(authorValue),\n _React$useState20 = _slicedToArray(_React$useState19, 2),\n filterAuthor = _React$useState20[0],\n setFilterAuthor = _React$useState20[1];\n\n var _React$useState21 = React.useState(typesValue),\n _React$useState22 = _slicedToArray(_React$useState21, 2),\n filterPostType = _React$useState22[0],\n setFilterPostType = _React$useState22[1];\n\n var _React$useState23 = React.useState(weeksValue),\n _React$useState24 = _slicedToArray(_React$useState23, 2),\n filterWeeks = _React$useState24[0],\n setFilterWeeks = _React$useState24[1];\n\n var _React$useState25 = React.useState(),\n _React$useState26 = _slicedToArray(_React$useState25, 2),\n openedItemId = _React$useState26[0],\n setOpenedItemId = _React$useState26[1];\n\n var _React$useState27 = React.useState([]),\n _React$useState28 = _slicedToArray(_React$useState27, 2),\n openedItemData = _React$useState28[0],\n setOpenedItemData = _React$useState28[1];\n\n var _React$useState29 = React.useState(0),\n _React$useState30 = _slicedToArray(_React$useState29, 2),\n openedItemRefreshCount = _React$useState30[0],\n setOpenedItemRefreshCount = _React$useState30[1];\n\n var _React$useState31 = React.useState(0),\n _React$useState32 = _slicedToArray(_React$useState31, 2),\n refreshCount = _React$useState32[0],\n setRefreshCount = _React$useState32[1];\n\n var _React$useState33 = React.useState(),\n _React$useState34 = _slicedToArray(_React$useState33, 2),\n hoveredDate = _React$useState34[0],\n setHoveredDate = _React$useState34[1];\n\n var _React$useState35 = React.useState(),\n _React$useState36 = _slicedToArray(_React$useState35, 2),\n formDate = _React$useState36[0],\n setFormDate = _React$useState36[1];\n\n var DRAG_AND_DROP_HOVERING_CLASS = 'publishpress-calendar-day-hover';\n\n var getUrl = function getUrl(action, query) {\n if (!query) {\n query = '';\n }\n\n return props.ajaxUrl + '?action=' + action + '&nonce=' + props.nonce + query;\n };\n\n var addEventListeners = function addEventListeners() {\n document.addEventListener('keydown', onDocumentKeyDown);\n $(document).on('publishpress_calendar:close_popup', onCloseItemPopup);\n };\n\n var removeEventListeners = function removeEventListeners() {\n document.removeEventListener('keydown', onDocumentKeyDown);\n $('.publishpress-calendar tbody > tr > td').off('mouseenter');\n };\n\n var didMount = function didMount() {\n addEventListeners();\n\n if (props.userCanAddPosts) {\n initClickToCreateFeature();\n }\n\n return didUnmount;\n };\n\n var didUnmount = function didUnmount() {\n removeEventListeners();\n };\n\n var fetchCalendarData = function fetchCalendarData() {\n setIsLoading(true);\n setMessage(props.strings.loading);\n var dataUrl = getUrl(props.actionGetData, '&start_date=' + Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateAsStringInWpFormat\"])(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(firstDateToDisplay, props.weekStartsOnSunday)) + '&number_of_weeks=' + numberOfWeeksToDisplay);\n\n if (filterStatus) {\n dataUrl += '&post_status=' + filterStatus;\n }\n\n if (filterCategory) {\n dataUrl += '&category=' + filterCategory;\n }\n\n if (filterTag) {\n dataUrl += '&post_tag=' + filterTag;\n }\n\n if (filterAuthor) {\n dataUrl += '&post_author=' + filterAuthor;\n }\n\n if (filterPostType) {\n dataUrl += '&post_type=' + filterPostType;\n }\n\n if (filterWeeks) {\n dataUrl += '&weeks=' + filterWeeks;\n }\n\n fetch(dataUrl).then(function (response) {\n return response.json();\n }).then(function (fetchedData) {\n setItemsByDate(fetchedData);\n setIsLoading(false);\n setMessage(null);\n resetCSSClasses();\n });\n };\n\n var resetCSSClasses = function resetCSSClasses() {\n $('.' + DRAG_AND_DROP_HOVERING_CLASS).removeClass(DRAG_AND_DROP_HOVERING_CLASS);\n $('.publishpress-calendar-loading').removeClass('publishpress-calendar-loading');\n };\n\n var fetchCalendarItemData = function fetchCalendarItemData() {\n if (!openedItemId) {\n return;\n }\n\n setIsLoading(true);\n setMessage(props.strings.loadingItem);\n var dataUrl = props.ajaxUrl + '?action=' + 'publishpress_calendar_get_post_data' + '&nonce=' + props.nonce + '&id=' + openedItemId;\n fetch(dataUrl).then(function (response) {\n return response.json();\n }).then(function (data) {\n setIsLoading(false);\n setMessage(null);\n setOpenedItemData(data);\n });\n };\n\n var addOffsetInWeeksToFirstDateToDisplay = function addOffsetInWeeksToFirstDateToDisplay(offsetInWeeks) {\n setFirstDateToDisplay(new Date(firstDateToDisplay.getTime() + Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"calculateWeeksInMilliseconds\"])(offsetInWeeks)));\n };\n\n var handleRefreshOnClick = function handleRefreshOnClick(e) {\n e.preventDefault();\n setRefreshCount(refreshCount + 1);\n };\n\n var handleBackPageOnClick = function handleBackPageOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(numberOfWeeksToDisplay * -1);\n };\n\n var handleBackOnClick = function handleBackOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(-1);\n };\n\n var handleForwardOnClick = function handleForwardOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(1);\n };\n\n var handleForwardPageOnClick = function handleForwardPageOnClick(e) {\n e.preventDefault();\n addOffsetInWeeksToFirstDateToDisplay(numberOfWeeksToDisplay);\n };\n\n var handleTodayOnClick = function handleTodayOnClick(e) {\n e.preventDefault();\n setFirstDateToDisplay(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(props.todayDate, props.weekStartsOnSunday));\n };\n\n var moveCalendarItemToANewDate = function moveCalendarItemToANewDate(itemDate, itemIndex, newYear, newMonth, newDay) {\n var item = itemsByDate[itemDate][itemIndex];\n setIsLoading(true);\n setMessage(props.strings.movingTheItem);\n var dataUrl = getUrl(props.actionMoveItem);\n var formData = new FormData();\n formData.append('id', item.id);\n formData.append('year', newYear);\n formData.append('month', newMonth);\n formData.append('day', newDay);\n fetch(dataUrl, {\n method: 'POST',\n body: formData\n }).then(function (response) {\n return response.json();\n }).then(function () {\n setRefreshCount(refreshCount + 1);\n });\n };\n\n var handleOnDropItemCallback = function handleOnDropItemCallback(event, ui) {\n var $dayCell = $(event.target);\n var $item = $(ui.draggable[0]);\n var dateTime = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateAsStringInWpFormat\"])(Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateInstanceFromString\"])($item.data('datetime')));\n $(event.target).addClass('publishpress-calendar-loading');\n moveCalendarItemToANewDate(dateTime, $item.data('index'), $dayCell.data('year'), $dayCell.data('month'), $dayCell.data('day'));\n };\n\n var handleOnHoverCellCallback = function handleOnHoverCellCallback(event, ui) {\n resetCSSClasses();\n $(event.target).addClass(DRAG_AND_DROP_HOVERING_CLASS);\n };\n\n var itemPopupIsOpenedById = function itemPopupIsOpenedById(id) {\n return id === openedItemId;\n };\n\n var initDraggableAndDroppableBehaviors = function initDraggableAndDroppableBehaviors() {\n $('.publishpress-calendar-day-items li').draggable({\n zIndex: 99999,\n helper: 'clone',\n containment: '.publishpress-calendar table',\n start: function start(event, ui) {\n // Do not drag the item if the popup is opened.\n if (itemPopupIsOpenedById($(event.target).data('id'))) {\n return false;\n }\n\n if (!$(event.target).hasClass('publishpress-calendar-item-movable')) {\n return false;\n }\n\n $(event.target).addClass('ui-draggable-target');\n resetOpenedItemInPopup();\n setIsDragging(true);\n },\n stop: function stop(event, ui) {\n $('.ui-draggable-target').removeClass('ui-draggable-target');\n setIsDragging(false);\n }\n });\n $('.publishpress-calendar tbody > tr > td').droppable({\n drop: handleOnDropItemCallback,\n over: handleOnHoverCellCallback\n });\n };\n\n var getCellFromChild = function getCellFromChild(child) {\n var $child = $(child);\n\n if ($child.is('td.publishpress-calendar-business-day, td.publishpress-calendar-weekend-day')) {\n return $child;\n }\n\n if ($child.is('.publishpress-calendar-cell-header, .publishpress-calendar-date, .publishpress-calendar-cell-click-to-add, .publishpress-calendar-month-name')) {\n return $child.parents('td');\n }\n\n return null;\n };\n\n var getCellDate = function getCellDate(cell) {\n var date = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateInstanceFromString\"])(cell.data('year') + '-' + cell.data('month') + '-' + cell.data('day')); // Compensate the timezone for returning the correct date\n\n if (date.getHours() > 0) {\n date.setTime(date.getTime() + 60 * 1000 * date.getTimezoneOffset());\n }\n\n return date;\n };\n\n var isHoveringCellWhileDragging = function isHoveringCellWhileDragging(cell) {\n return $(cell).hasClass(DRAG_AND_DROP_HOVERING_CLASS);\n };\n\n var initClickToCreateFeature = function initClickToCreateFeature() {\n // We have to use this variable because when the click is done on the \"click to add\" label, we can't get its parent.\n // Probably because it was already removed from the DOM.\n var lastHoveredDate;\n $('.publishpress-calendar tbody > tr > td').on('mouseover', function (e) {\n e.preventDefault();\n e.stopPropagation();\n var cell = getCellFromChild(e.target);\n\n if (cell) {\n if (isHoveringCellWhileDragging(cell)) {\n return;\n }\n\n setHoveredDate(getCellDate(cell));\n lastHoveredDate = getCellDate(cell);\n }\n }).on('mouseout', function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n if (getCellFromChild(e.relatedTarget)) {\n return;\n }\n\n setHoveredDate(null);\n lastHoveredDate = null;\n }).on('click', function (e) {\n var cell = getCellFromChild(e.target);\n\n if (cell) {\n setOpenedItemId(null);\n setFormDate(lastHoveredDate);\n }\n });\n };\n\n var onFilterEventCallback = function onFilterEventCallback(filterName, value) {\n if ('status' === filterName) {\n setFilterStatus(value);\n }\n\n if ('category' === filterName) {\n setFilterCategory(value);\n }\n\n if ('tag' === filterName) {\n setFilterTag(value);\n }\n\n if ('author' === filterName) {\n setFilterAuthor(value);\n }\n\n if ('postType' === filterName) {\n setFilterPostType(value);\n }\n\n if ('weeks' === filterName) {\n value = parseInt(value);\n\n if (value === 0 || isNaN(value)) {\n value = props.numberOfWeeksToDisplay;\n }\n\n setFilterWeeks(value);\n setNumberOfWeeksToDisplay(value);\n }\n };\n\n var resetOpenedItemInPopup = function resetOpenedItemInPopup() {\n setOpenedItemId(null);\n setOpenedItemData(null);\n setFormDate(null);\n };\n\n var onClickItem = function onClickItem(id) {\n setOpenedItemData(null);\n setHoveredDate(null);\n setFormDate(null);\n setOpenedItemId(id);\n };\n\n var onPopupItemActionClick = function onPopupItemActionClick(action, id, result) {\n setOpenedItemRefreshCount(openedItemRefreshCount + 1);\n };\n\n var onDocumentKeyDown = function onDocumentKeyDown(e) {\n if (e.key === 'Escape') {\n resetOpenedItemInPopup();\n }\n };\n\n var getOpenedItemData = function getOpenedItemData() {\n return openedItemData;\n };\n\n var onCloseForm = function onCloseForm() {\n setRefreshCount(refreshCount + 1);\n setFormDate(null);\n };\n\n var onCloseItemPopup = function onCloseItemPopup() {\n setOpenedItemId(null);\n };\n\n var calendarTableBodyRowsWithCells = function calendarTableBodyRowsWithCells() {\n var numberOfDaysToDisplay = numberOfWeeksToDisplay * 7;\n var firstDate = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getBeginDateOfWeekByDate\"])(firstDateToDisplay, props.weekStartsOnSunday);\n var tableRows = [];\n var rowCells = [];\n var dayIndexInTheRow = 0;\n var dayDate;\n var dateString;\n var lastMonthDisplayed = firstDate.getMonth();\n\n for (var dataIndex = 0; dataIndex < numberOfDaysToDisplay; dataIndex++) {\n if (dayIndexInTheRow === 0) {\n rowCells = [];\n }\n\n dayDate = new Date(firstDate);\n dayDate.setDate(dayDate.getDate() + dataIndex);\n dateString = Object(_Functions__WEBPACK_IMPORTED_MODULE_4__[\"getDateAsStringInWpFormat\"])(dayDate);\n rowCells.push( /*#__PURE__*/React.createElement(_DayCell__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n key: 'day-' + dayDate.getTime(),\n date: dayDate,\n shouldDisplayMonthName: lastMonthDisplayed !== dayDate.getMonth() || dataIndex === 0,\n todayDate: props.todayDate,\n isLoading: false,\n isHovering: !isDragging && hoveredDate && hoveredDate.getTime() === dayDate.getTime() && !formDate,\n items: itemsByDate[dateString] || [],\n maxVisibleItems: parseInt(props.maxVisibleItems),\n timeFormat: props.timeFormat,\n openedItemId: openedItemId,\n getOpenedItemDataCallback: getOpenedItemData,\n ajaxUrl: props.ajaxUrl,\n onClickItemCallback: onClickItem,\n onItemActionClickCallback: onPopupItemActionClick,\n strings: props.strings\n }));\n dayIndexInTheRow++;\n\n if (dayIndexInTheRow === 7) {\n dayIndexInTheRow = 0;\n tableRows.push( /*#__PURE__*/React.createElement(\"tr\", {\n key: \"calendar-row-\".concat(tableRows.length)\n }, rowCells));\n }\n\n lastMonthDisplayed = dayDate.getMonth();\n }\n\n return tableRows;\n };\n\n React.useEffect(didMount, []);\n React.useEffect(initDraggableAndDroppableBehaviors);\n\n if (props.userCanAddPosts) {\n React.useEffect(initClickToCreateFeature, [firstDateToDisplay, numberOfWeeksToDisplay, filterWeeks, filterAuthor, filterTag, filterCategory, filterStatus, filterPostType, refreshCount]);\n }\n\n React.useEffect(fetchCalendarData, [firstDateToDisplay, numberOfWeeksToDisplay, filterWeeks, filterAuthor, filterTag, filterCategory, filterStatus, filterPostType, refreshCount]);\n React.useEffect(fetchCalendarItemData, [openedItemId, openedItemRefreshCount]);\n var componentClassName = ['publishpress-calendar', 'publishpress-calendar-theme-' + theme];\n\n if (props.userCanAddPosts) {\n componentClassName.push('user-can-add-posts');\n }\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: componentClassName.join(' ')\n }, /*#__PURE__*/React.createElement(_FilterBar__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n statuses: props.statuses,\n postTypes: props.postTypes,\n numberOfWeeksToDisplay: numberOfWeeksToDisplay,\n ajaxUrl: props.ajaxUrl,\n nonce: props.nonce,\n onChange: onFilterEventCallback,\n requestFilter: props.requestFilter,\n strings: props.strings\n }), /*#__PURE__*/React.createElement(_NavigationBar__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n refreshOnClickCallback: handleRefreshOnClick,\n backPageOnClickCallback: handleBackPageOnClick,\n backOnClickCallback: handleBackOnClick,\n forwardOnClickCallback: handleForwardOnClick,\n forwardPageOnClickCallback: handleForwardPageOnClick,\n todayOnClickCallback: handleTodayOnClick,\n strings: props.strings\n }), /*#__PURE__*/React.createElement(\"table\", null, /*#__PURE__*/React.createElement(\"thead\", null, /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(_WeekDays__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n weekStartsOnSunday: props.weekStartsOnSunday,\n strings: props.strings\n }))), /*#__PURE__*/React.createElement(\"tbody\", null, calendarTableBodyRowsWithCells())), formDate && /*#__PURE__*/React.createElement(_ItemFormPopup__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n date: formDate,\n ajaxUrl: props.ajaxUrl,\n dateFormat: props.dateFormat,\n postTypes: props.postTypesCanCreate,\n statuses: props.statuses,\n actionGetPostTypeFields: props.actionGetPostTypeFields,\n nonce: props.nonce,\n onCloseCallback: onCloseForm,\n allowAddingMultipleAuthors: props.allowAddingMultipleAuthors,\n strings: props.strings\n }), /*#__PURE__*/React.createElement(_MessageBar__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n showSpinner: isLoading,\n message: message\n }));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/AsyncCalendar.jsx?"); /***/ }), @@ -142,7 +142,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getBeginDateOfWeekByWeekNumber\", function() { return getBeginDateOfWeekByWeekNumber; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getWeekNumberByDate\", function() { return getWeekNumberByDate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getBeginDateOfWeekByDate\", function() { return getBeginDateOfWeekByDate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getHourStringOnFormat\", function() { return getHourStringOnFormat; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDateAsStringInWpFormat\", function() { return getDateAsStringInWpFormat; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"calculateWeeksInMilliseconds\", function() { return calculateWeeksInMilliseconds; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getMonthNameByMonthIndex\", function() { return getMonthNameByMonthIndex; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDateWithNoTimezoneOffset\", function() { return getDateWithNoTimezoneOffset; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getPostLinksElement\", function() { return getPostLinksElement; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"callAjaxAction\", function() { return callAjaxAction; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"callAjaxPostAction\", function() { return callAjaxPostAction; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getTodayMidnight\", function() { return getTodayMidnight; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDateInstanceFromString\", function() { return getDateInstanceFromString; });\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\n/**\n * Base on :\n * https://stackoverflow.com/questions/16590500/javascript-calculate-date-from-week-number\n */\nfunction getBeginDateOfWeekByWeekNumber(weekNumber, year) {\n var weekStartsOnSunday = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n var simpleDate = new Date(year, 0, 1 + (weekNumber - 1) * 7);\n var dayOfWeek = simpleDate.getDay();\n var weekStartISO = simpleDate;\n\n if (dayOfWeek <= 4) {\n weekStartISO.setDate(simpleDate.getDate() - simpleDate.getDay() + 1);\n } else {\n weekStartISO.setDate(simpleDate.getDate() + 8 - simpleDate.getDay());\n }\n\n if (weekStartsOnSunday) {\n weekStartISO.setDate(weekStartISO.getDate() - 1);\n }\n\n return weekStartISO;\n}\n/* For a given date, get the ISO week number\n *\n * Based on information at:\n *\n * http://www.merlyn.demon.co.uk/weekcalc.htm#WNR\n *\n * Algorithm is to find nearest thursday, it's year\n * is the year of the week number. Then get weeks\n * between that date and the first day of that year.\n *\n * Note that dates in one year can be weeks of previous\n * or next year, overlap is up to 3 days.\n *\n * e.g. 2014/12/29 is Monday in week 1 of 2015\n * 2012/1/1 is Sunday in week 52 of 2011\n */\n\nfunction getWeekNumberByDate(theDate) {\n var weekStartsOnSunday = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n // Copy date so don't modify original\n var theDateCopy = new Date(theDate.getFullYear(), theDate.getMonth(), theDate.getDate(), theDate.getHours(), theDate.getMinutes(), theDate.getSeconds(), theDate.getMilliseconds());\n var dayOfWeek = theDateCopy.getDay(); // Set to nearest Thursday: current date + 4 - current day number\n // Make Sunday's day number 7\n\n theDateCopy.setDate(theDateCopy.getDate() + 4 - (theDateCopy.getDay() || 7)); // Get first day of year\n\n var yearStart = new Date(theDateCopy.getFullYear(), 0, 1); // Calculate full weeks to nearest Thursday\n\n var weekNo = Math.round(((theDateCopy - yearStart) / 86400000 + 1) / 7);\n\n if (weekStartsOnSunday && dayOfWeek === 0) {\n weekNo++;\n } // Return array of year and week number\n\n\n return [theDateCopy.getFullYear(), weekNo];\n}\nfunction getBeginDateOfWeekByDate(theDate) {\n var weekStartsOnSunday = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n var weekNumber = getWeekNumberByDate(theDate, weekStartsOnSunday);\n return getBeginDateOfWeekByWeekNumber(weekNumber[1], weekNumber[0], weekStartsOnSunday);\n}\nfunction getHourStringOnFormat(timestamp) {\n var timeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ga';\n var hours = timestamp.getHours();\n\n if (timeFormat === 'ga' || timeFormat === 'ha') {\n if (hours === 0) {\n hours = '12am';\n } else if (hours < 12) {\n if (timeFormat === 'ha') {\n hours = hours.toString().padStart(2, '0');\n }\n\n hours += 'am';\n } else {\n if (hours > 12) {\n hours -= 12;\n }\n\n if (timeFormat === 'ha') {\n hours = hours.toString().padStart(2, '0');\n }\n\n hours += 'pm';\n }\n } else {\n hours = hours.toString().padStart(2, '0');\n }\n\n return hours;\n}\nfunction getDateAsStringInWpFormat(theDate) {\n return theDate.getFullYear() + '-' + (theDate.getMonth() + 1).toString().padStart(2, '0') + '-' + theDate.getDate().toString().padStart(2, '0');\n}\nfunction calculateWeeksInMilliseconds(weeks) {\n return weeks * 7 * 24 * 60 * 60 * 1000;\n}\nfunction getMonthNameByMonthIndex(month) {\n var strings = publishpressCalendarParams.strings;\n var monthNames = [strings.monthJan, strings.monthFeb, strings.monthMar, strings.monthApr, strings.monthMay, strings.monthJun, strings.monthJul, strings.monthAug, strings.monthSep, strings.monthOct, strings.monthNov, strings.monthDec];\n return monthNames[month];\n}\nfunction getDateWithNoTimezoneOffset(dateString) {\n var date = new Date(dateString);\n var browserTimezoneOffset = date.getTimezoneOffset() * 60000;\n return new Date(date.getTime() + browserTimezoneOffset);\n}\nfunction getPostLinksElement(linkData, handleOnClick) {\n if (linkData.url) {\n return /*#__PURE__*/React.createElement(\"a\", {\n href: linkData.url\n }, linkData.label);\n } else if (linkData.action) {\n return /*#__PURE__*/React.createElement(\"a\", {\n href: \"javascript:void(0);\",\n onClick: function onClick(e) {\n return handleOnClick(e, linkData);\n }\n }, linkData.label);\n }\n}\nfunction callAjaxAction(_x, _x2, _x3) {\n return _callAjaxAction.apply(this, arguments);\n}\n\nfunction _callAjaxAction() {\n _callAjaxAction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(action, args, ajaxUrl) {\n var dataUrl, argumentName, response;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n dataUrl = ajaxUrl + '?action=' + action;\n _context.t0 = regeneratorRuntime.keys(args);\n\n case 2:\n if ((_context.t1 = _context.t0()).done) {\n _context.next = 9;\n break;\n }\n\n argumentName = _context.t1.value;\n\n if (args.hasOwnProperty(argumentName)) {\n _context.next = 6;\n break;\n }\n\n return _context.abrupt(\"continue\", 2);\n\n case 6:\n dataUrl += '&' + argumentName + '=' + args[argumentName];\n _context.next = 2;\n break;\n\n case 9:\n _context.next = 11;\n return fetch(dataUrl);\n\n case 11:\n response = _context.sent;\n _context.next = 14;\n return response.json();\n\n case 14:\n return _context.abrupt(\"return\", _context.sent);\n\n case 15:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee);\n }));\n return _callAjaxAction.apply(this, arguments);\n}\n\nfunction callAjaxPostAction(_x4, _x5, _x6, _x7) {\n return _callAjaxPostAction.apply(this, arguments);\n}\n\nfunction _callAjaxPostAction() {\n _callAjaxPostAction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(action, args, ajaxUrl, body) {\n var dataUrl, argumentName, response;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n dataUrl = ajaxUrl + '?action=' + action;\n _context2.t0 = regeneratorRuntime.keys(args);\n\n case 2:\n if ((_context2.t1 = _context2.t0()).done) {\n _context2.next = 9;\n break;\n }\n\n argumentName = _context2.t1.value;\n\n if (args.hasOwnProperty(argumentName)) {\n _context2.next = 6;\n break;\n }\n\n return _context2.abrupt(\"continue\", 2);\n\n case 6:\n dataUrl += '&' + argumentName + '=' + args[argumentName];\n _context2.next = 2;\n break;\n\n case 9:\n _context2.next = 11;\n return fetch(dataUrl, {\n method: 'post',\n body: body\n });\n\n case 11:\n response = _context2.sent;\n _context2.next = 14;\n return response.json();\n\n case 14:\n return _context2.abrupt(\"return\", _context2.sent);\n\n case 15:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2);\n }));\n return _callAjaxPostAction.apply(this, arguments);\n}\n\nfunction getTodayMidnight() {\n var today = new Date();\n today.setHours(0, 0, 0, 0);\n return today;\n}\nfunction getDateInstanceFromString(dateString) {\n // The \"-\" char is replaced to make it compatible to Safari browser. Issue #1001.\n return new Date(String(dateString).replace(/-/g, \"/\"));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/Functions.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getBeginDateOfWeekByWeekNumber\", function() { return getBeginDateOfWeekByWeekNumber; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getWeekNumberByDate\", function() { return getWeekNumberByDate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getBeginDateOfWeekByDate\", function() { return getBeginDateOfWeekByDate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getHourStringOnFormat\", function() { return getHourStringOnFormat; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDateAsStringInWpFormat\", function() { return getDateAsStringInWpFormat; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"calculateWeeksInMilliseconds\", function() { return calculateWeeksInMilliseconds; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getMonthNameByMonthIndex\", function() { return getMonthNameByMonthIndex; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDateWithNoTimezoneOffset\", function() { return getDateWithNoTimezoneOffset; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getPostLinksElement\", function() { return getPostLinksElement; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"callAjaxAction\", function() { return callAjaxAction; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"callAjaxPostAction\", function() { return callAjaxPostAction; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getTodayMidnight\", function() { return getTodayMidnight; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getDateInstanceFromString\", function() { return getDateInstanceFromString; });\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\n/**\n * Base on :\n * https://stackoverflow.com/questions/16590500/javascript-calculate-date-from-week-number\n */\nfunction getBeginDateOfWeekByWeekNumber(weekNumber, year) {\n var weekStartsOnSunday = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n var simpleDate = new Date(year, 0, 1 + (weekNumber - 1) * 7);\n var dayOfWeek = simpleDate.getDay();\n var weekStartISO = simpleDate;\n\n if (dayOfWeek <= 4) {\n weekStartISO.setDate(simpleDate.getDate() - simpleDate.getDay() + 1);\n } else {\n weekStartISO.setDate(simpleDate.getDate() + 8 - simpleDate.getDay());\n }\n\n if (weekStartsOnSunday) {\n weekStartISO.setDate(weekStartISO.getDate() - 1);\n }\n\n return weekStartISO;\n}\n/* For a given date, get the ISO week number\n *\n * Based on information at:\n *\n * http://www.merlyn.demon.co.uk/weekcalc.htm#WNR\n *\n * Algorithm is to find nearest thursday, it's year\n * is the year of the week number. Then get weeks\n * between that date and the first day of that year.\n *\n * Note that dates in one year can be weeks of previous\n * or next year, overlap is up to 3 days.\n *\n * e.g. 2014/12/29 is Monday in week 1 of 2015\n * 2012/1/1 is Sunday in week 52 of 2011\n */\n\nfunction getWeekNumberByDate(theDate) {\n var weekStartsOnSunday = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n // Copy date so don't modify original\n var theDateCopy = new Date(theDate.getFullYear(), theDate.getMonth(), theDate.getDate(), theDate.getHours(), theDate.getMinutes(), theDate.getSeconds(), theDate.getMilliseconds());\n var dayOfWeek = theDateCopy.getDay(); // Set to nearest Thursday: current date + 4 - current day number\n // Make Sunday's day number 7\n\n theDateCopy.setDate(theDateCopy.getDate() + 4 - (theDateCopy.getDay() || 7)); // Get first day of year\n\n var yearStart = new Date(theDateCopy.getFullYear(), 0, 1); // Calculate full weeks to nearest Thursday\n\n var weekNo = Math.round(((theDateCopy - yearStart) / 86400000 + 1) / 7);\n\n if (weekStartsOnSunday && dayOfWeek === 0) {\n weekNo++;\n } // Return array of year and week number\n\n\n return [theDateCopy.getFullYear(), weekNo];\n}\nfunction getBeginDateOfWeekByDate(theDate) {\n var weekStartsOnSunday = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n var weekNumber = getWeekNumberByDate(theDate, weekStartsOnSunday);\n return getBeginDateOfWeekByWeekNumber(weekNumber[1], weekNumber[0], weekStartsOnSunday);\n}\nfunction getHourStringOnFormat(timestamp) {\n var timeFormat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'ga';\n var hours = timestamp.getHours();\n\n if (timeFormat === 'ga' || timeFormat === 'ha') {\n if (hours === 0) {\n hours = '12am';\n } else if (hours < 12) {\n if (timeFormat === 'ha') {\n hours = hours.toString().padStart(2, '0');\n }\n\n hours += 'am';\n } else {\n if (hours > 12) {\n hours -= 12;\n }\n\n if (timeFormat === 'ha') {\n hours = hours.toString().padStart(2, '0');\n }\n\n hours += 'pm';\n }\n } else {\n hours = hours.toString().padStart(2, '0');\n }\n\n return hours;\n}\nfunction getDateAsStringInWpFormat(theDate) {\n return theDate.getFullYear() + '-' + (theDate.getMonth() + 1).toString().padStart(2, '0') + '-' + theDate.getDate().toString().padStart(2, '0');\n}\nfunction calculateWeeksInMilliseconds(weeks) {\n return weeks * 7 * 24 * 60 * 60 * 1000;\n}\nfunction getMonthNameByMonthIndex(month) {\n var strings = publishpressCalendarParams.strings;\n var monthNames = [strings.monthJan, strings.monthFeb, strings.monthMar, strings.monthApr, strings.monthMay, strings.monthJun, strings.monthJul, strings.monthAug, strings.monthSep, strings.monthOct, strings.monthNov, strings.monthDec];\n return monthNames[month];\n}\nfunction getDateWithNoTimezoneOffset(dateString) {\n var date = new Date(dateString);\n var browserTimezoneOffset = date.getTimezoneOffset() * 60000;\n return new Date(date.getTime() + browserTimezoneOffset);\n}\nfunction getPostLinksElement(linkData, handleOnClick) {\n if (linkData.url) {\n return /*#__PURE__*/React.createElement(\"a\", {\n key: \"link-\".concat(linkData.url, \"-\").concat(linkData.label),\n href: linkData.url\n }, linkData.label);\n } else if (linkData.action) {\n return /*#__PURE__*/React.createElement(\"a\", {\n key: \"link-\".concat(linkData.url, \"-\").concat(linkData.label),\n href: \"javascript:void(0);\",\n onClick: function onClick(e) {\n return handleOnClick(e, linkData);\n }\n }, linkData.label);\n }\n}\nfunction callAjaxAction(_x, _x2, _x3) {\n return _callAjaxAction.apply(this, arguments);\n}\n\nfunction _callAjaxAction() {\n _callAjaxAction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(action, args, ajaxUrl) {\n var dataUrl, argumentName, response;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n dataUrl = ajaxUrl + '?action=' + action;\n _context.t0 = regeneratorRuntime.keys(args);\n\n case 2:\n if ((_context.t1 = _context.t0()).done) {\n _context.next = 9;\n break;\n }\n\n argumentName = _context.t1.value;\n\n if (args.hasOwnProperty(argumentName)) {\n _context.next = 6;\n break;\n }\n\n return _context.abrupt(\"continue\", 2);\n\n case 6:\n dataUrl += '&' + argumentName + '=' + args[argumentName];\n _context.next = 2;\n break;\n\n case 9:\n _context.next = 11;\n return fetch(dataUrl);\n\n case 11:\n response = _context.sent;\n _context.next = 14;\n return response.json();\n\n case 14:\n return _context.abrupt(\"return\", _context.sent);\n\n case 15:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee);\n }));\n return _callAjaxAction.apply(this, arguments);\n}\n\nfunction callAjaxPostAction(_x4, _x5, _x6, _x7) {\n return _callAjaxPostAction.apply(this, arguments);\n}\n\nfunction _callAjaxPostAction() {\n _callAjaxPostAction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(action, args, ajaxUrl, body) {\n var dataUrl, argumentName, response;\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n dataUrl = ajaxUrl + '?action=' + action;\n _context2.t0 = regeneratorRuntime.keys(args);\n\n case 2:\n if ((_context2.t1 = _context2.t0()).done) {\n _context2.next = 9;\n break;\n }\n\n argumentName = _context2.t1.value;\n\n if (args.hasOwnProperty(argumentName)) {\n _context2.next = 6;\n break;\n }\n\n return _context2.abrupt(\"continue\", 2);\n\n case 6:\n dataUrl += '&' + argumentName + '=' + args[argumentName];\n _context2.next = 2;\n break;\n\n case 9:\n _context2.next = 11;\n return fetch(dataUrl, {\n method: 'post',\n body: body\n });\n\n case 11:\n response = _context2.sent;\n _context2.next = 14;\n return response.json();\n\n case 14:\n return _context2.abrupt(\"return\", _context2.sent);\n\n case 15:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2);\n }));\n return _callAjaxPostAction.apply(this, arguments);\n}\n\nfunction getTodayMidnight() {\n var today = new Date();\n today.setHours(0, 0, 0, 0);\n return today;\n}\nfunction getDateInstanceFromString(dateString) {\n // The \"-\" char is replaced to make it compatible to Safari browser. Issue #1001.\n return new Date(String(dateString).replace(/-/g, \"/\"));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/Functions.jsx?"); /***/ }), @@ -166,7 +166,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ItemFormPopup; });\n/* harmony import */ var _Functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Functions */ \"./modules/calendar/lib/async-calendar/js/Functions.jsx\");\n/* harmony import */ var _Select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Select */ \"./modules/calendar/lib/async-calendar/js/Select.jsx\");\n/* harmony import */ var _fields_DateTimeField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fields/DateTimeField */ \"./modules/calendar/lib/async-calendar/js/fields/DateTimeField.jsx\");\n/* harmony import */ var _fields_AuthorsField__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fields/AuthorsField */ \"./modules/calendar/lib/async-calendar/js/fields/AuthorsField.jsx\");\n/* harmony import */ var _fields_SelectField__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./fields/SelectField */ \"./modules/calendar/lib/async-calendar/js/fields/SelectField.jsx\");\n/* harmony import */ var _fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./fields/PostStatusField */ \"./modules/calendar/lib/async-calendar/js/fields/PostStatusField.jsx\");\n/* harmony import */ var _fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./fields/TaxonomyField */ \"./modules/calendar/lib/async-calendar/js/fields/TaxonomyField.jsx\");\n/* harmony import */ var _fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./fields/CheckboxField */ \"./modules/calendar/lib/async-calendar/js/fields/CheckboxField.jsx\");\n/* harmony import */ var _fields_LocationField__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./fields/LocationField */ \"./modules/calendar/lib/async-calendar/js/fields/LocationField.jsx\");\n/* harmony import */ var _fields_TextArea__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fields/TextArea */ \"./modules/calendar/lib/async-calendar/js/fields/TextArea.jsx\");\n/* harmony import */ var _fields_TextField__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./fields/TextField */ \"./modules/calendar/lib/async-calendar/js/fields/TextField.jsx\");\n/* harmony import */ var _fields_UserField__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./fields/UserField */ \"./modules/calendar/lib/async-calendar/js/fields/UserField.jsx\");\n/* harmony import */ var _fields_NumberField__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./fields/NumberField */ \"./modules/calendar/lib/async-calendar/js/fields/NumberField.jsx\");\n/* harmony import */ var _fields_TimeField__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./fields/TimeField */ \"./modules/calendar/lib/async-calendar/js/fields/TimeField.jsx\");\n/* harmony import */ var _fields_MetaField__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./fields/MetaField */ \"./modules/calendar/lib/async-calendar/js/fields/MetaField.jsx\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar $ = jQuery;\nfunction ItemFormPopup(props) {\n var _React$useState = React.useState(props.postTypes[0].value),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n postType = _React$useState2[0],\n setPostType = _React$useState2[1];\n\n var _React$useState3 = React.useState([]),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n fields = _React$useState4[0],\n setFields = _React$useState4[1];\n\n var _React$useState5 = React.useState(false),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n isLoading = _React$useState6[0],\n setIsLoading = _React$useState6[1];\n\n var _React$useState7 = React.useState(false),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n savingLink = _React$useState8[0],\n setSavingLink = _React$useState8[1];\n\n var _React$useState9 = React.useState(),\n _React$useState10 = _slicedToArray(_React$useState9, 2),\n errorMessage = _React$useState10[0],\n setErrorMessage = _React$useState10[1];\n\n var didMount = function didMount() {\n resetGlobalFormFieldData();\n setPostType(props.postTypes[0].value);\n setDefaultValueForFields();\n activateFixForScreenLockerSize();\n return didUnmount;\n };\n\n var didUnmount = function didUnmount() {\n deactivateFixForScreenLockerSize();\n resetGlobalFormFieldData();\n };\n\n var activateFixForScreenLockerSize = function activateFixForScreenLockerSize() {\n $('#wpwrap').css('overflow', 'hidden');\n };\n\n var deactivateFixForScreenLockerSize = function deactivateFixForScreenLockerSize() {\n $('#wpwrap').css('overflow', 'auto');\n };\n\n var setDefaultValueForFields = function setDefaultValueForFields() {\n updateGlobalFormFieldData('post_type', props.postTypes[0].value);\n updateGlobalFormFieldData('status', 'draft');\n };\n\n var getFormTableFieldRows = function getFormTableFieldRows() {\n var fieldRows = [];\n var dataProperty;\n var field;\n var fieldId;\n var placeholder;\n\n var _loop = function _loop(dataPropertyName) {\n if (!fields.hasOwnProperty(dataPropertyName)) {\n return \"continue\";\n }\n\n fieldId = 'publishpress-calendar-field-' + dataPropertyName;\n dataProperty = fields[dataPropertyName];\n placeholder = dataProperty.placeholder ? dataProperty.placeholder : null;\n\n switch (dataProperty.type) {\n case 'date':\n field = /*#__PURE__*/React.createElement(_fields_DateTimeField__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'authors':\n field = /*#__PURE__*/React.createElement(_fields_AuthorsField__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n name: dataPropertyName,\n id: fieldId,\n nonce: props.nonce,\n ajaxUrl: props.ajaxUrl,\n ajaxArgs: dataProperty.ajaxArgs,\n metadata: dataProperty.metadata ? true : false,\n post_types: dataProperty.post_types ? dataProperty.post_types : '',\n multiple: dataProperty.metadata ? dataProperty.multiple : props.allowAddingMultipleAuthors,\n onSelect: function onSelect(e, elem, data) {\n var values = [];\n\n for (var i = 0; i < data.length; i++) {\n values.push(data[i].id);\n }\n\n updateGlobalFormFieldData(dataPropertyName, values);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'select':\n field = /*#__PURE__*/React.createElement(_fields_SelectField__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n name: dataPropertyName,\n id: fieldId,\n nonce: props.nonce,\n ajaxUrl: props.ajaxUrl,\n ajaxAction: dataProperty.ajaxAction,\n ajaxArgs: dataProperty.ajaxArgs,\n multiple: dataProperty.multiple,\n onSelect: function onSelect(e, elem, data) {\n var values = [];\n\n for (var i = 0; i < data.length; i++) {\n values.push(data[i].id);\n }\n\n updateGlobalFormFieldData(dataPropertyName, values);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'status':\n field = /*#__PURE__*/React.createElement(_fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n options: dataProperty.options,\n onSelect: function onSelect(e, elem, data) {\n var value = null;\n\n if (data.length > 0) {\n value = data[0].id;\n }\n\n updateGlobalFormFieldData(dataPropertyName, value);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'taxonomy':\n field = /*#__PURE__*/React.createElement(_fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n taxonomy: dataProperty.taxonomy,\n nonce: props.nonce,\n ajaxUrl: props.ajaxUrl,\n multiple: true,\n onSelect: function onSelect(e, elem, data) {\n var values = [];\n\n for (var i = 0; i < data.length; i++) {\n values.push(data[i].id);\n }\n\n updateGlobalFormFieldData(dataPropertyName, values);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'checkbox':\n field = /*#__PURE__*/React.createElement(_fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n isEditing: true,\n id: fieldId,\n value: dataProperty.value\n });\n break;\n\n case 'location':\n field = /*#__PURE__*/React.createElement(_fields_LocationField__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'html':\n field = /*#__PURE__*/React.createElement(_fields_TextArea__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n value: dataProperty.value,\n name: dataPropertyName,\n metadata: dataProperty.metadata ? true : false,\n post_types: dataProperty.post_types ? dataProperty.post_types : '',\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'text':\n field = /*#__PURE__*/React.createElement(_fields_TextField__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n placeholder: placeholder,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'user':\n field = /*#__PURE__*/React.createElement(_fields_UserField__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId\n });\n break;\n\n case 'number':\n field = /*#__PURE__*/React.createElement(_fields_NumberField__WEBPACK_IMPORTED_MODULE_12__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'time':\n field = /*#__PURE__*/React.createElement(_fields_TimeField__WEBPACK_IMPORTED_MODULE_13__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n placeholder: placeholder,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'metafield':\n dataProperty.isEditing = true;\n field = Object(_fields_MetaField__WEBPACK_IMPORTED_MODULE_14__[\"default\"])(dataProperty);\n break;\n\n default:\n field = null;\n break;\n }\n\n fieldRows.push( /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(\"th\", null, /*#__PURE__*/React.createElement(\"label\", {\n htmlFor: fieldId\n }, dataProperty.label, \":\")), /*#__PURE__*/React.createElement(\"td\", null, field)));\n };\n\n for (var dataPropertyName in fields) {\n var _ret = _loop(dataPropertyName);\n\n if (_ret === \"continue\") continue;\n }\n\n return fieldRows;\n }; // We are using a global var because the states are async and we were having a hard time to make all\n // fields work together updating the same state.\n\n\n var getGlobalFormFieldData = function getGlobalFormFieldData(name) {\n if (typeof window.publishpressCalendarGlobalData === 'undefined') {\n window.publishpressCalendarGlobalData = {};\n }\n\n if (typeof window.publishpressCalendarGlobalData.formFieldsData === 'undefined') {\n window.publishpressCalendarGlobalData.formFieldsData = {};\n }\n\n if (window.publishpressCalendarGlobalData.formFieldsData.hasOwnProperty(name)) {\n return window.publishpressCalendarGlobalData.formFieldsData[name];\n }\n\n return null;\n };\n\n var setGlobalFormFieldData = function setGlobalFormFieldData(name, value) {\n getGlobalFormFieldData(name);\n window.publishpressCalendarGlobalData.formFieldsData[name] = value;\n };\n\n var resetGlobalFormFieldData = function resetGlobalFormFieldData() {\n if (typeof window.publishpressCalendarGlobalData !== 'undefined' && typeof window.publishpressCalendarGlobalData.formFieldsData !== 'undefined') {\n window.publishpressCalendarGlobalData.formFieldsData = [];\n }\n };\n\n var updateGlobalFormFieldData = function updateGlobalFormFieldData(fieldName, value) {\n setGlobalFormFieldData(fieldName, value);\n };\n\n var getFormDataForThePostRequest = function getFormDataForThePostRequest() {\n var formData = new FormData();\n formData.append('date', Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"getDateAsStringInWpFormat\"])(props.date));\n formData.append('nonce', props.nonce);\n\n for (var fieldName in window.publishpressCalendarGlobalData.formFieldsData) {\n if (window.publishpressCalendarGlobalData.formFieldsData.hasOwnProperty(fieldName)) {\n formData.append(fieldName, window.publishpressCalendarGlobalData.formFieldsData[fieldName]);\n }\n } //add metafield\n\n\n var field_name = '',\n field_value = '',\n field_type = '',\n skip_field = false;\n document.querySelectorAll('.pp-calendar-form-metafied-input').forEach(function (metafield) {\n field_name = metafield.getAttribute('name');\n field_type = metafield.getAttribute('type');\n field_value = metafield.value;\n skip_field = false;\n\n if (field_type === 'checkbox' && !metafield.checked) {\n skip_field = true;\n }\n\n if (metafield.classList.contains('pp_editorial_meta_multi_select2')) {\n skip_field = true;\n var selected_options = metafield.selectedOptions;\n var selected_key = '';\n\n for (selected_key in selected_options) {\n if (!selected_options.hasOwnProperty(selected_key)) {\n continue;\n }\n\n formData.append(field_name, selected_options[selected_key].value);\n }\n }\n\n if (!skip_field) {\n formData.append(field_name, field_value);\n }\n });\n return formData;\n };\n\n var handleLinkOnClick = function handleLinkOnClick(e, linkData) {\n e.preventDefault();\n setIsLoading(true);\n setSavingLink(linkData.id);\n setErrorMessage(null);\n Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"callAjaxPostAction\"])(linkData.action, linkData.args, props.ajaxUrl, getFormDataForThePostRequest()).then(function (result) {\n if (linkData.id === 'create') {\n setIsLoading(false);\n setSavingLink(null);\n\n if (result.status === 'success') {\n if (props.onCloseCallback) {\n props.onCloseCallback();\n }\n } else {\n setErrorMessage(result.message);\n }\n } else if (linkData.id === 'edit') {\n if (result.status === 'success') {\n window.location.href = result.data.link;\n } else {\n setIsLoading(false);\n setSavingLink(null);\n setErrorMessage(result.message);\n }\n }\n });\n };\n\n var getFooterLinks = function getFooterLinks() {\n var formLinks = [{\n 'id': 'create',\n 'label': props.strings.save,\n 'labelLoading': props.strings.saving,\n 'action': 'publishpress_calendar_create_item'\n }, {\n 'id': 'edit',\n 'label': props.strings.saveAndEdit,\n 'labelLoading': props.strings.saving,\n 'action': 'publishpress_calendar_create_item'\n }];\n var links = [];\n var linkData;\n\n for (var linkName in formLinks) {\n if (!formLinks.hasOwnProperty(linkName)) {\n continue;\n }\n\n linkData = formLinks[linkName];\n\n if (savingLink === linkData.id) {\n links.push( /*#__PURE__*/React.createElement(\"span\", null, linkData.labelLoading));\n } else {\n links.push(Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"getPostLinksElement\"])(linkData, handleLinkOnClick));\n }\n\n links.push( /*#__PURE__*/React.createElement(\"span\", null, \"|\"));\n }\n\n links.pop();\n return links;\n };\n\n var handleOnSelectPostTypeField = function handleOnSelectPostTypeField(e) {\n var $target = $(e.target);\n var postType = $target.pp_select2('data')[0].id;\n setPostType(postType);\n updateGlobalFormFieldData('post_type', postType);\n };\n\n var getFormPopupTitle = function getFormPopupTitle() {\n var title;\n\n if (props.postId) {\n title = '';\n } else {\n title = props.strings.addContentFor;\n title = title.replace('%s', date_i18n(props.dateFormat, props.date));\n }\n\n return title;\n };\n\n var getPostTypeNameBySlug = function getPostTypeNameBySlug(postTypeSlug) {\n var _iterator = _createForOfIteratorHelper(props.postTypes),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var postTypeObj = _step.value;\n\n if (postTypeObj.value === postTypeSlug) {\n return postTypeObj.text;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return props.strings.postTypeNotFound;\n };\n\n var fetchFieldsForSelectedPostType = function fetchFieldsForSelectedPostType() {\n setIsLoading(true);\n var args = {\n nonce: props.nonce,\n postType: getGlobalFormFieldData('post_type'),\n date: Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"getDateAsStringInWpFormat\"])(props.date)\n };\n setFields(null);\n Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"callAjaxAction\"])(props.actionGetPostTypeFields, args, props.ajaxUrl).then(function (result) {\n setFields(result.fields);\n }).then(function () {\n setFocusOnTitleField();\n setIsLoading(false);\n });\n };\n\n var setFocusOnTitleField = function setFocusOnTitleField() {\n setTimeout(function () {\n $('.publishpress-calendar-popup-form input').first().focus();\n }, 500);\n };\n\n React.useEffect(didMount, []);\n React.useEffect(fetchFieldsForSelectedPostType, [postType]);\n var fieldTableRows = getFormTableFieldRows();\n return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-screen-lock'\n }), /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup publishpress-calendar-popup-form'\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-title'\n }, getFormPopupTitle(), /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-no publishpress-calendar-popup-close',\n title: props.strings.close,\n onClick: props.onCloseCallback\n })), /*#__PURE__*/React.createElement(\"hr\", null), /*#__PURE__*/React.createElement(\"table\", null, /*#__PURE__*/React.createElement(\"tbody\", null, props.postTypes.length > 1 && /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(\"th\", null, /*#__PURE__*/React.createElement(\"label\", null, props.strings.postType)), /*#__PURE__*/React.createElement(\"td\", null, /*#__PURE__*/React.createElement(_Select__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n options: props.postTypes,\n allowClear: false,\n onSelect: handleOnSelectPostTypeField\n }))), props.postTypes.length === 1 && /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(\"th\", null, /*#__PURE__*/React.createElement(\"label\", null, props.strings.postType)), /*#__PURE__*/React.createElement(\"td\", null, getPostTypeNameBySlug(postType))), fieldTableRows.length > 0 && fieldTableRows)), fieldTableRows.length === 0 && /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-loading-fields'\n }, props.strings.pleaseWaitLoadingFormFields), errorMessage && /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-error-message'\n }, /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-warning'\n }), errorMessage), /*#__PURE__*/React.createElement(\"hr\", {\n className: 'publishpress-calendar-popup-links-hr'\n }), /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup-links\"\n }, getFooterLinks(), isLoading && /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-update-alt publishpress-spinner'\n }))));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ItemFormPopup; });\n/* harmony import */ var _Functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Functions */ \"./modules/calendar/lib/async-calendar/js/Functions.jsx\");\n/* harmony import */ var _Select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Select */ \"./modules/calendar/lib/async-calendar/js/Select.jsx\");\n/* harmony import */ var _fields_DateTimeField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fields/DateTimeField */ \"./modules/calendar/lib/async-calendar/js/fields/DateTimeField.jsx\");\n/* harmony import */ var _fields_AuthorsField__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fields/AuthorsField */ \"./modules/calendar/lib/async-calendar/js/fields/AuthorsField.jsx\");\n/* harmony import */ var _fields_SelectField__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./fields/SelectField */ \"./modules/calendar/lib/async-calendar/js/fields/SelectField.jsx\");\n/* harmony import */ var _fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./fields/PostStatusField */ \"./modules/calendar/lib/async-calendar/js/fields/PostStatusField.jsx\");\n/* harmony import */ var _fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./fields/TaxonomyField */ \"./modules/calendar/lib/async-calendar/js/fields/TaxonomyField.jsx\");\n/* harmony import */ var _fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./fields/CheckboxField */ \"./modules/calendar/lib/async-calendar/js/fields/CheckboxField.jsx\");\n/* harmony import */ var _fields_LocationField__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./fields/LocationField */ \"./modules/calendar/lib/async-calendar/js/fields/LocationField.jsx\");\n/* harmony import */ var _fields_TextArea__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fields/TextArea */ \"./modules/calendar/lib/async-calendar/js/fields/TextArea.jsx\");\n/* harmony import */ var _fields_TextField__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./fields/TextField */ \"./modules/calendar/lib/async-calendar/js/fields/TextField.jsx\");\n/* harmony import */ var _fields_UserField__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./fields/UserField */ \"./modules/calendar/lib/async-calendar/js/fields/UserField.jsx\");\n/* harmony import */ var _fields_NumberField__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./fields/NumberField */ \"./modules/calendar/lib/async-calendar/js/fields/NumberField.jsx\");\n/* harmony import */ var _fields_TimeField__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./fields/TimeField */ \"./modules/calendar/lib/async-calendar/js/fields/TimeField.jsx\");\n/* harmony import */ var _fields_MetaField__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./fields/MetaField */ \"./modules/calendar/lib/async-calendar/js/fields/MetaField.jsx\");\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== \"undefined\" && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar $ = jQuery;\nfunction ItemFormPopup(props) {\n var _React$useState = React.useState(props.postTypes[0].value),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n postType = _React$useState2[0],\n setPostType = _React$useState2[1];\n\n var _React$useState3 = React.useState([]),\n _React$useState4 = _slicedToArray(_React$useState3, 2),\n fields = _React$useState4[0],\n setFields = _React$useState4[1];\n\n var _React$useState5 = React.useState(false),\n _React$useState6 = _slicedToArray(_React$useState5, 2),\n isLoading = _React$useState6[0],\n setIsLoading = _React$useState6[1];\n\n var _React$useState7 = React.useState(false),\n _React$useState8 = _slicedToArray(_React$useState7, 2),\n savingLink = _React$useState8[0],\n setSavingLink = _React$useState8[1];\n\n var _React$useState9 = React.useState(),\n _React$useState10 = _slicedToArray(_React$useState9, 2),\n errorMessage = _React$useState10[0],\n setErrorMessage = _React$useState10[1];\n\n var didMount = function didMount() {\n resetGlobalFormFieldData();\n setPostType(props.postTypes[0].value);\n setDefaultValueForFields();\n activateFixForScreenLockerSize();\n return didUnmount;\n };\n\n var didUnmount = function didUnmount() {\n deactivateFixForScreenLockerSize();\n resetGlobalFormFieldData();\n };\n\n var activateFixForScreenLockerSize = function activateFixForScreenLockerSize() {\n $('#wpwrap').css('overflow', 'hidden');\n };\n\n var deactivateFixForScreenLockerSize = function deactivateFixForScreenLockerSize() {\n $('#wpwrap').css('overflow', 'auto');\n };\n\n var setDefaultValueForFields = function setDefaultValueForFields() {\n updateGlobalFormFieldData('post_type', props.postTypes[0].value);\n updateGlobalFormFieldData('status', 'draft');\n };\n\n var getFormTableFieldRows = function getFormTableFieldRows() {\n var fieldRows = [];\n var dataProperty;\n var field;\n var fieldId;\n var placeholder;\n\n var _loop = function _loop(dataPropertyName) {\n if (!fields.hasOwnProperty(dataPropertyName)) {\n return \"continue\";\n }\n\n fieldId = 'publishpress-calendar-field-' + dataPropertyName;\n dataProperty = fields[dataPropertyName];\n placeholder = dataProperty.placeholder ? dataProperty.placeholder : null;\n\n switch (dataProperty.type) {\n case 'date':\n field = /*#__PURE__*/React.createElement(_fields_DateTimeField__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'authors':\n field = /*#__PURE__*/React.createElement(_fields_AuthorsField__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n name: dataPropertyName,\n id: fieldId,\n nonce: props.nonce,\n ajaxUrl: props.ajaxUrl,\n ajaxArgs: dataProperty.ajaxArgs,\n metadata: dataProperty.metadata ? true : false,\n post_types: dataProperty.post_types ? dataProperty.post_types : '',\n multiple: dataProperty.metadata ? dataProperty.multiple : props.allowAddingMultipleAuthors,\n onSelect: function onSelect(e, elem, data) {\n var values = [];\n\n for (var i = 0; i < data.length; i++) {\n values.push(data[i].id);\n }\n\n updateGlobalFormFieldData(dataPropertyName, values);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'select':\n field = /*#__PURE__*/React.createElement(_fields_SelectField__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n name: dataPropertyName,\n id: fieldId,\n nonce: props.nonce,\n ajaxUrl: props.ajaxUrl,\n ajaxAction: dataProperty.ajaxAction,\n ajaxArgs: dataProperty.ajaxArgs,\n multiple: dataProperty.multiple,\n onSelect: function onSelect(e, elem, data) {\n var values = [];\n\n for (var i = 0; i < data.length; i++) {\n values.push(data[i].id);\n }\n\n updateGlobalFormFieldData(dataPropertyName, values);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'status':\n field = /*#__PURE__*/React.createElement(_fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n options: dataProperty.options,\n onSelect: function onSelect(e, elem, data) {\n var value = null;\n\n if (data.length > 0) {\n value = data[0].id;\n }\n\n updateGlobalFormFieldData(dataPropertyName, value);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'taxonomy':\n field = /*#__PURE__*/React.createElement(_fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n taxonomy: dataProperty.taxonomy,\n nonce: props.nonce,\n ajaxUrl: props.ajaxUrl,\n multiple: true,\n onSelect: function onSelect(e, elem, data) {\n var values = [];\n\n for (var i = 0; i < data.length; i++) {\n values.push(data[i].id);\n }\n\n updateGlobalFormFieldData(dataPropertyName, values);\n },\n onClear: function onClear(e, elem) {\n updateGlobalFormFieldData(dataPropertyName, null);\n }\n });\n break;\n\n case 'checkbox':\n field = /*#__PURE__*/React.createElement(_fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n isEditing: true,\n id: fieldId,\n value: dataProperty.value\n });\n break;\n\n case 'location':\n field = /*#__PURE__*/React.createElement(_fields_LocationField__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'html':\n field = /*#__PURE__*/React.createElement(_fields_TextArea__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n value: dataProperty.value,\n name: dataPropertyName,\n metadata: dataProperty.metadata ? true : false,\n post_types: dataProperty.post_types ? dataProperty.post_types : '',\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'text':\n field = /*#__PURE__*/React.createElement(_fields_TextField__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n placeholder: placeholder,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'user':\n field = /*#__PURE__*/React.createElement(_fields_UserField__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId\n });\n break;\n\n case 'number':\n field = /*#__PURE__*/React.createElement(_fields_NumberField__WEBPACK_IMPORTED_MODULE_12__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'time':\n field = /*#__PURE__*/React.createElement(_fields_TimeField__WEBPACK_IMPORTED_MODULE_13__[\"default\"], {\n value: dataProperty.value,\n isEditing: true,\n id: fieldId,\n placeholder: placeholder,\n onChange: function onChange(e, value) {\n updateGlobalFormFieldData(dataPropertyName, value);\n }\n });\n break;\n\n case 'metafield':\n dataProperty.isEditing = true;\n field = Object(_fields_MetaField__WEBPACK_IMPORTED_MODULE_14__[\"default\"])(dataProperty);\n break;\n\n default:\n field = null;\n break;\n }\n\n fieldRows.push( /*#__PURE__*/React.createElement(\"tr\", {\n key: \"field-rows-\".concat(fieldRows.length)\n }, /*#__PURE__*/React.createElement(\"th\", null, /*#__PURE__*/React.createElement(\"label\", {\n htmlFor: fieldId\n }, dataProperty.label, \":\")), /*#__PURE__*/React.createElement(\"td\", null, field)));\n };\n\n for (var dataPropertyName in fields) {\n var _ret = _loop(dataPropertyName);\n\n if (_ret === \"continue\") continue;\n }\n\n return fieldRows;\n }; // We are using a global var because the states are async and we were having a hard time to make all\n // fields work together updating the same state.\n\n\n var getGlobalFormFieldData = function getGlobalFormFieldData(name) {\n if (typeof window.publishpressCalendarGlobalData === 'undefined') {\n window.publishpressCalendarGlobalData = {};\n }\n\n if (typeof window.publishpressCalendarGlobalData.formFieldsData === 'undefined') {\n window.publishpressCalendarGlobalData.formFieldsData = {};\n }\n\n if (window.publishpressCalendarGlobalData.formFieldsData.hasOwnProperty(name)) {\n return window.publishpressCalendarGlobalData.formFieldsData[name];\n }\n\n return null;\n };\n\n var setGlobalFormFieldData = function setGlobalFormFieldData(name, value) {\n getGlobalFormFieldData(name);\n window.publishpressCalendarGlobalData.formFieldsData[name] = value;\n };\n\n var resetGlobalFormFieldData = function resetGlobalFormFieldData() {\n if (typeof window.publishpressCalendarGlobalData !== 'undefined' && typeof window.publishpressCalendarGlobalData.formFieldsData !== 'undefined') {\n window.publishpressCalendarGlobalData.formFieldsData = [];\n }\n };\n\n var updateGlobalFormFieldData = function updateGlobalFormFieldData(fieldName, value) {\n setGlobalFormFieldData(fieldName, value);\n };\n\n var getFormDataForThePostRequest = function getFormDataForThePostRequest() {\n var formData = new FormData();\n formData.append('date', Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"getDateAsStringInWpFormat\"])(props.date));\n formData.append('nonce', props.nonce);\n\n for (var fieldName in window.publishpressCalendarGlobalData.formFieldsData) {\n if (window.publishpressCalendarGlobalData.formFieldsData.hasOwnProperty(fieldName)) {\n formData.append(fieldName, window.publishpressCalendarGlobalData.formFieldsData[fieldName]);\n }\n } //add metafield\n\n\n var field_name = '',\n field_value = '',\n field_type = '',\n skip_field = false;\n document.querySelectorAll('.pp-calendar-form-metafied-input').forEach(function (metafield) {\n field_name = metafield.getAttribute('name');\n field_type = metafield.getAttribute('type');\n field_value = metafield.value;\n skip_field = false;\n\n if (field_type === 'checkbox' && !metafield.checked) {\n skip_field = true;\n }\n\n if (metafield.classList.contains('pp_editorial_meta_multi_select2')) {\n skip_field = true;\n var selected_options = metafield.selectedOptions;\n var selected_key = '';\n\n for (selected_key in selected_options) {\n if (!selected_options.hasOwnProperty(selected_key)) {\n continue;\n }\n\n formData.append(field_name, selected_options[selected_key].value);\n }\n }\n\n if (!skip_field) {\n formData.append(field_name, field_value);\n }\n });\n return formData;\n };\n\n var handleLinkOnClick = function handleLinkOnClick(e, linkData) {\n e.preventDefault();\n setIsLoading(true);\n setSavingLink(linkData.id);\n setErrorMessage(null);\n Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"callAjaxPostAction\"])(linkData.action, linkData.args, props.ajaxUrl, getFormDataForThePostRequest()).then(function (result) {\n if (linkData.id === 'create') {\n setIsLoading(false);\n setSavingLink(null);\n\n if (result.status === 'success') {\n if (props.onCloseCallback) {\n props.onCloseCallback();\n }\n } else {\n setErrorMessage(result.message);\n }\n } else if (linkData.id === 'edit') {\n if (result.status === 'success') {\n window.location.href = result.data.link;\n } else {\n setIsLoading(false);\n setSavingLink(null);\n setErrorMessage(result.message);\n }\n }\n });\n };\n\n var getFooterLinks = function getFooterLinks() {\n var formLinks = [{\n 'id': 'create',\n 'label': props.strings.save,\n 'labelLoading': props.strings.saving,\n 'action': 'publishpress_calendar_create_item'\n }, {\n 'id': 'edit',\n 'label': props.strings.saveAndEdit,\n 'labelLoading': props.strings.saving,\n 'action': 'publishpress_calendar_create_item'\n }];\n var links = [];\n var linkData;\n\n for (var linkName in formLinks) {\n if (!formLinks.hasOwnProperty(linkName)) {\n continue;\n }\n\n linkData = formLinks[linkName];\n\n if (savingLink === linkData.id) {\n links.push( /*#__PURE__*/React.createElement(\"span\", {\n key: linkData.id\n }, linkData.labelLoading));\n } else {\n links.push(Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"getPostLinksElement\"])(linkData, handleLinkOnClick));\n }\n\n links.push( /*#__PURE__*/React.createElement(\"span\", {\n key: \"link-separator-\".concat(links.length)\n }, \"|\"));\n }\n\n links.pop();\n return links;\n };\n\n var handleOnSelectPostTypeField = function handleOnSelectPostTypeField(e) {\n var $target = $(e.target);\n var postType = $target.pp_select2('data')[0].id;\n setPostType(postType);\n updateGlobalFormFieldData('post_type', postType);\n };\n\n var getFormPopupTitle = function getFormPopupTitle() {\n var title;\n\n if (props.postId) {\n title = '';\n } else {\n title = props.strings.addContentFor;\n title = title.replace('%s', date_i18n(props.dateFormat, props.date));\n }\n\n return title;\n };\n\n var getPostTypeNameBySlug = function getPostTypeNameBySlug(postTypeSlug) {\n var _iterator = _createForOfIteratorHelper(props.postTypes),\n _step;\n\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var postTypeObj = _step.value;\n\n if (postTypeObj.value === postTypeSlug) {\n return postTypeObj.text;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n\n return props.strings.postTypeNotFound;\n };\n\n var fetchFieldsForSelectedPostType = function fetchFieldsForSelectedPostType() {\n setIsLoading(true);\n var args = {\n nonce: props.nonce,\n postType: getGlobalFormFieldData('post_type'),\n date: Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"getDateAsStringInWpFormat\"])(props.date)\n };\n setFields(null);\n Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"callAjaxAction\"])(props.actionGetPostTypeFields, args, props.ajaxUrl).then(function (result) {\n setFields(result.fields);\n }).then(function () {\n setFocusOnTitleField();\n setIsLoading(false);\n });\n };\n\n var setFocusOnTitleField = function setFocusOnTitleField() {\n setTimeout(function () {\n $('.publishpress-calendar-popup-form input').first().focus();\n }, 500);\n };\n\n React.useEffect(didMount, []);\n React.useEffect(fetchFieldsForSelectedPostType, [postType]);\n var fieldTableRows = getFormTableFieldRows();\n return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-screen-lock'\n }), /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup publishpress-calendar-popup-form'\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-title'\n }, getFormPopupTitle(), /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-no publishpress-calendar-popup-close',\n title: props.strings.close,\n onClick: props.onCloseCallback\n })), /*#__PURE__*/React.createElement(\"hr\", null), /*#__PURE__*/React.createElement(\"table\", null, /*#__PURE__*/React.createElement(\"tbody\", null, props.postTypes.length > 1 && /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(\"th\", null, /*#__PURE__*/React.createElement(\"label\", null, props.strings.postType)), /*#__PURE__*/React.createElement(\"td\", null, /*#__PURE__*/React.createElement(_Select__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n options: props.postTypes,\n allowClear: false,\n onSelect: handleOnSelectPostTypeField\n }))), props.postTypes.length === 1 && /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(\"th\", null, /*#__PURE__*/React.createElement(\"label\", null, props.strings.postType)), /*#__PURE__*/React.createElement(\"td\", null, getPostTypeNameBySlug(postType))), fieldTableRows.length > 0 && fieldTableRows)), fieldTableRows.length === 0 && /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-loading-fields'\n }, props.strings.pleaseWaitLoadingFormFields), errorMessage && /*#__PURE__*/React.createElement(\"div\", {\n className: 'publishpress-calendar-popup-error-message'\n }, /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-warning'\n }), errorMessage), /*#__PURE__*/React.createElement(\"hr\", {\n className: 'publishpress-calendar-popup-links-hr'\n }), /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup-links\"\n }, getFooterLinks(), isLoading && /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-update-alt publishpress-spinner'\n }))));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/ItemFormPopup.jsx?"); /***/ }), @@ -178,7 +178,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ItemPopup; });\n/* harmony import */ var _Functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Functions */ \"./modules/calendar/lib/async-calendar/js/Functions.jsx\");\n/* harmony import */ var _fields_DateTimeField__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fields/DateTimeField */ \"./modules/calendar/lib/async-calendar/js/fields/DateTimeField.jsx\");\n/* harmony import */ var _fields_AuthorsField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fields/AuthorsField */ \"./modules/calendar/lib/async-calendar/js/fields/AuthorsField.jsx\");\n/* harmony import */ var _fields_PostTypeField__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fields/PostTypeField */ \"./modules/calendar/lib/async-calendar/js/fields/PostTypeField.jsx\");\n/* harmony import */ var _fields_SelectField__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./fields/SelectField */ \"./modules/calendar/lib/async-calendar/js/fields/SelectField.jsx\");\n/* harmony import */ var _fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./fields/PostStatusField */ \"./modules/calendar/lib/async-calendar/js/fields/PostStatusField.jsx\");\n/* harmony import */ var _fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./fields/TaxonomyField */ \"./modules/calendar/lib/async-calendar/js/fields/TaxonomyField.jsx\");\n/* harmony import */ var _fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./fields/CheckboxField */ \"./modules/calendar/lib/async-calendar/js/fields/CheckboxField.jsx\");\n/* harmony import */ var _fields_LocationField__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./fields/LocationField */ \"./modules/calendar/lib/async-calendar/js/fields/LocationField.jsx\");\n/* harmony import */ var _fields_TextArea__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fields/TextArea */ \"./modules/calendar/lib/async-calendar/js/fields/TextArea.jsx\");\n/* harmony import */ var _fields_TextField__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./fields/TextField */ \"./modules/calendar/lib/async-calendar/js/fields/TextField.jsx\");\n/* harmony import */ var _fields_UserField__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./fields/UserField */ \"./modules/calendar/lib/async-calendar/js/fields/UserField.jsx\");\n/* harmony import */ var _fields_NumberField__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./fields/NumberField */ \"./modules/calendar/lib/async-calendar/js/fields/NumberField.jsx\");\n/* harmony import */ var _fields_TimeField__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./fields/TimeField */ \"./modules/calendar/lib/async-calendar/js/fields/TimeField.jsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar $ = jQuery;\nfunction ItemPopup(props) {\n if (!props.data) {\n return /*#__PURE__*/React.createElement(React.Fragment, null);\n }\n\n if (!props.target.current) {\n return /*#__PURE__*/React.createElement(React.Fragment, null);\n }\n\n var offsetX = 10;\n var offsetWidth = 180;\n var targetPosition = $(props.target.current).position();\n var targetOffset = $(props.target.current).offset();\n var targetWidth = $(props.target.current).width();\n var popupWidth = 380;\n\n var isWiderThanParentWidth = function isWiderThanParentWidth() {\n return targetOffset.left + popupWidth + offsetX + offsetWidth >= $(document).width();\n };\n\n var getPositionOnRightSide = function getPositionOnRightSide() {\n return targetPosition.left + targetWidth + offsetX;\n };\n\n var getPositionOnLeftSide = function getPositionOnLeftSide() {\n return targetPosition.left - offsetX * 2.5 - popupWidth;\n };\n\n var closePopup = function closePopup() {\n $(document).trigger('publishpress_calendar:close_popup');\n };\n\n var positionTop = targetPosition.top;\n var positionLeft = isWiderThanParentWidth() ? getPositionOnLeftSide() : getPositionOnRightSide();\n\n var getFieldRows = function getFieldRows() {\n var fieldRows = [];\n var dataProperty;\n var field;\n\n for (var dataPropertyName in props.data.fields) {\n if (!props.data.fields.hasOwnProperty(dataPropertyName)) {\n continue;\n }\n\n dataProperty = props.data.fields[dataPropertyName];\n\n switch (dataProperty.type) {\n case 'date':\n field = /*#__PURE__*/React.createElement(_fields_DateTimeField__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n value: dataProperty.value,\n valueString: dataProperty.valueString || null,\n isEditing: false\n });\n break;\n\n case 'time':\n field = /*#__PURE__*/React.createElement(_fields_TimeField__WEBPACK_IMPORTED_MODULE_13__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'authors':\n field = /*#__PURE__*/React.createElement(_fields_AuthorsField__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'select':\n field = /*#__PURE__*/React.createElement(_fields_SelectField__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'type':\n field = /*#__PURE__*/React.createElement(_fields_PostTypeField__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'status':\n field = /*#__PURE__*/React.createElement(_fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'taxonomy':\n field = /*#__PURE__*/React.createElement(_fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'checkbox':\n field = /*#__PURE__*/React.createElement(_fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'location':\n field = /*#__PURE__*/React.createElement(_fields_LocationField__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'paragraph':\n field = /*#__PURE__*/React.createElement(_fields_TextArea__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'text':\n field = /*#__PURE__*/React.createElement(_fields_TextField__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'user':\n field = /*#__PURE__*/React.createElement(_fields_UserField__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'number':\n field = /*#__PURE__*/React.createElement(_fields_NumberField__WEBPACK_IMPORTED_MODULE_12__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n default:\n field = null;\n break;\n }\n\n fieldRows.push( /*#__PURE__*/React.createElement(\"tr\", null, /*#__PURE__*/React.createElement(\"th\", null, dataProperty.label, \":\"), /*#__PURE__*/React.createElement(\"td\", null, field)));\n }\n\n return fieldRows;\n };\n\n var handleOnClick = function handleOnClick(e, linkData) {\n e.preventDefault();\n Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"callAjaxAction\"])(linkData.action, linkData.args, props.ajaxUrl).then(function (result) {\n props.onItemActionClickCallback(linkData.action, props.id, result);\n });\n };\n\n var getPostLinks = function getPostLinks() {\n var links = [];\n var linkData;\n\n for (var linkName in props.data.links) {\n if (!props.data.links.hasOwnProperty(linkName)) {\n continue;\n }\n\n linkData = props.data.links[linkName];\n\n if (linkData.url) {\n links.push( /*#__PURE__*/React.createElement(\"a\", {\n href: linkData.url\n }, linkData.label));\n } else if (linkData.action) {\n links.push( /*#__PURE__*/React.createElement(\"a\", {\n href: \"javascript:void(0);\",\n onClick: function onClick(e) {\n return handleOnClick(e, linkData);\n }\n }, linkData.label));\n }\n\n links.push( /*#__PURE__*/React.createElement(\"span\", null, \"|\"));\n }\n\n links.pop();\n return links;\n };\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup\",\n style: {\n top: positionTop,\n left: positionLeft\n }\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup-title\",\n style: {\n backgroundColor: props.color\n }\n }, props.icon && /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons ' + props.icon + ' publishpress-calendar-icon'\n }), /*#__PURE__*/React.createElement(\"span\", {\n dangerouslySetInnerHTML: {\n __html: props.title\n }\n }), /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-no publishpress-calendar-popup-close',\n title: props.strings.close,\n onClick: closePopup\n })), /*#__PURE__*/React.createElement(\"table\", null, /*#__PURE__*/React.createElement(\"tbody\", null, getFieldRows())), /*#__PURE__*/React.createElement(\"hr\", null), /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup-links\"\n }, getPostLinks()));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/ItemPopup.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return ItemPopup; });\n/* harmony import */ var _Functions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Functions */ \"./modules/calendar/lib/async-calendar/js/Functions.jsx\");\n/* harmony import */ var _fields_DateTimeField__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fields/DateTimeField */ \"./modules/calendar/lib/async-calendar/js/fields/DateTimeField.jsx\");\n/* harmony import */ var _fields_AuthorsField__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fields/AuthorsField */ \"./modules/calendar/lib/async-calendar/js/fields/AuthorsField.jsx\");\n/* harmony import */ var _fields_PostTypeField__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fields/PostTypeField */ \"./modules/calendar/lib/async-calendar/js/fields/PostTypeField.jsx\");\n/* harmony import */ var _fields_SelectField__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./fields/SelectField */ \"./modules/calendar/lib/async-calendar/js/fields/SelectField.jsx\");\n/* harmony import */ var _fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./fields/PostStatusField */ \"./modules/calendar/lib/async-calendar/js/fields/PostStatusField.jsx\");\n/* harmony import */ var _fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./fields/TaxonomyField */ \"./modules/calendar/lib/async-calendar/js/fields/TaxonomyField.jsx\");\n/* harmony import */ var _fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./fields/CheckboxField */ \"./modules/calendar/lib/async-calendar/js/fields/CheckboxField.jsx\");\n/* harmony import */ var _fields_LocationField__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./fields/LocationField */ \"./modules/calendar/lib/async-calendar/js/fields/LocationField.jsx\");\n/* harmony import */ var _fields_TextArea__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./fields/TextArea */ \"./modules/calendar/lib/async-calendar/js/fields/TextArea.jsx\");\n/* harmony import */ var _fields_TextField__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./fields/TextField */ \"./modules/calendar/lib/async-calendar/js/fields/TextField.jsx\");\n/* harmony import */ var _fields_UserField__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./fields/UserField */ \"./modules/calendar/lib/async-calendar/js/fields/UserField.jsx\");\n/* harmony import */ var _fields_NumberField__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./fields/NumberField */ \"./modules/calendar/lib/async-calendar/js/fields/NumberField.jsx\");\n/* harmony import */ var _fields_TimeField__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./fields/TimeField */ \"./modules/calendar/lib/async-calendar/js/fields/TimeField.jsx\");\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvar $ = jQuery;\nfunction ItemPopup(props) {\n if (!props.data) {\n return /*#__PURE__*/React.createElement(React.Fragment, null);\n }\n\n if (!props.target.current) {\n return /*#__PURE__*/React.createElement(React.Fragment, null);\n }\n\n var offsetX = 10;\n var offsetWidth = 180;\n var targetPosition = $(props.target.current).position();\n var targetOffset = $(props.target.current).offset();\n var targetWidth = $(props.target.current).width();\n var popupWidth = 380;\n\n var isWiderThanParentWidth = function isWiderThanParentWidth() {\n return targetOffset.left + popupWidth + offsetX + offsetWidth >= $(document).width();\n };\n\n var getPositionOnRightSide = function getPositionOnRightSide() {\n return targetPosition.left + targetWidth + offsetX;\n };\n\n var getPositionOnLeftSide = function getPositionOnLeftSide() {\n return targetPosition.left - offsetX * 2.5 - popupWidth;\n };\n\n var closePopup = function closePopup() {\n $(document).trigger('publishpress_calendar:close_popup');\n };\n\n var positionTop = targetPosition.top;\n var positionLeft = isWiderThanParentWidth() ? getPositionOnLeftSide() : getPositionOnRightSide();\n\n var getFieldRows = function getFieldRows() {\n var fieldRows = [];\n var dataProperty;\n var field;\n\n for (var dataPropertyName in props.data.fields) {\n if (!props.data.fields.hasOwnProperty(dataPropertyName)) {\n continue;\n }\n\n dataProperty = props.data.fields[dataPropertyName];\n\n switch (dataProperty.type) {\n case 'date':\n field = /*#__PURE__*/React.createElement(_fields_DateTimeField__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n value: dataProperty.value,\n valueString: dataProperty.valueString || null,\n isEditing: false\n });\n break;\n\n case 'time':\n field = /*#__PURE__*/React.createElement(_fields_TimeField__WEBPACK_IMPORTED_MODULE_13__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'authors':\n field = /*#__PURE__*/React.createElement(_fields_AuthorsField__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'select':\n field = /*#__PURE__*/React.createElement(_fields_SelectField__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'type':\n field = /*#__PURE__*/React.createElement(_fields_PostTypeField__WEBPACK_IMPORTED_MODULE_3__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'status':\n field = /*#__PURE__*/React.createElement(_fields_PostStatusField__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'taxonomy':\n field = /*#__PURE__*/React.createElement(_fields_TaxonomyField__WEBPACK_IMPORTED_MODULE_6__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'checkbox':\n field = /*#__PURE__*/React.createElement(_fields_CheckboxField__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'location':\n field = /*#__PURE__*/React.createElement(_fields_LocationField__WEBPACK_IMPORTED_MODULE_8__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'paragraph':\n field = /*#__PURE__*/React.createElement(_fields_TextArea__WEBPACK_IMPORTED_MODULE_9__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'text':\n field = /*#__PURE__*/React.createElement(_fields_TextField__WEBPACK_IMPORTED_MODULE_10__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'user':\n field = /*#__PURE__*/React.createElement(_fields_UserField__WEBPACK_IMPORTED_MODULE_11__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n case 'number':\n field = /*#__PURE__*/React.createElement(_fields_NumberField__WEBPACK_IMPORTED_MODULE_12__[\"default\"], {\n value: dataProperty.value,\n isEditing: false\n });\n break;\n\n default:\n field = null;\n break;\n }\n\n fieldRows.push( /*#__PURE__*/React.createElement(\"tr\", {\n key: \"field-rows-popup-\".concat(fieldRows.length)\n }, /*#__PURE__*/React.createElement(\"th\", null, dataProperty.label, \":\"), /*#__PURE__*/React.createElement(\"td\", null, field)));\n }\n\n return fieldRows;\n };\n\n var handleOnClick = function handleOnClick(e, linkData) {\n e.preventDefault();\n Object(_Functions__WEBPACK_IMPORTED_MODULE_0__[\"callAjaxAction\"])(linkData.action, linkData.args, props.ajaxUrl).then(function (result) {\n props.onItemActionClickCallback(linkData.action, props.id, result);\n });\n };\n\n var getPostLinks = function getPostLinks() {\n var links = [];\n var linkData;\n\n for (var linkName in props.data.links) {\n if (!props.data.links.hasOwnProperty(linkName)) {\n continue;\n }\n\n linkData = props.data.links[linkName];\n\n if (linkData.url) {\n links.push( /*#__PURE__*/React.createElement(\"a\", {\n key: \"links-popup-\".concat(links.length),\n href: linkData.url\n }, linkData.label));\n } else if (linkData.action) {\n links.push( /*#__PURE__*/React.createElement(\"a\", {\n key: \"links-popup-\".concat(links.length),\n href: \"javascript:void(0);\",\n onClick: function onClick(e) {\n return handleOnClick(e, linkData);\n }\n }, linkData.label));\n }\n\n links.push( /*#__PURE__*/React.createElement(\"span\", {\n key: \"links-popup-\".concat(links.length)\n }, \"|\"));\n }\n\n links.pop();\n return links;\n };\n\n return /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup\",\n style: {\n top: positionTop,\n left: positionLeft\n }\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup-title\",\n style: {\n backgroundColor: props.color\n }\n }, props.icon && /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons ' + props.icon + ' publishpress-calendar-icon'\n }), /*#__PURE__*/React.createElement(\"span\", {\n dangerouslySetInnerHTML: {\n __html: props.title\n }\n }), /*#__PURE__*/React.createElement(\"span\", {\n className: 'dashicons dashicons-no publishpress-calendar-popup-close',\n title: props.strings.close,\n onClick: closePopup\n })), /*#__PURE__*/React.createElement(\"table\", null, /*#__PURE__*/React.createElement(\"tbody\", null, getFieldRows())), /*#__PURE__*/React.createElement(\"hr\", null), /*#__PURE__*/React.createElement(\"div\", {\n className: \"publishpress-calendar-popup-links\"\n }, getPostLinks()));\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/ItemPopup.jsx?"); /***/ }), @@ -214,7 +214,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) * /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Select; });\nvar $ = jQuery;\nfunction Select(props) {\n var selectRef = React.useRef(null);\n\n var getAllowClearProp = function getAllowClearProp() {\n if (typeof props.allowClear !== 'undefined' && props.allowClear !== null) {\n return props.allowClear;\n }\n\n return true;\n };\n\n var initSelect2 = function initSelect2() {\n var params = {\n placeholder: props.placeholder || false,\n tags: true,\n allowClear: getAllowClearProp()\n };\n\n if (props.ajaxUrl && props.ajaxAction) {\n params.ajax = {\n delay: 250,\n url: props.ajaxUrl,\n dataType: 'json',\n data: function data(params) {\n var args = {\n q: params.term,\n action: props.ajaxAction,\n nonce: props.nonce\n };\n\n if (props.ajaxArgs) {\n for (var arg in props.ajaxArgs) {\n if (props.ajaxArgs.hasOwnProperty(arg)) {\n args[arg] = props.ajaxArgs[arg];\n }\n }\n }\n\n return args;\n },\n processResults: function processResults(data) {\n return {\n results: data\n };\n }\n };\n }\n\n $(selectRef.current).pp_select2(params).on('select2:select', function (e) {\n if (typeof props.onSelect === 'function') {\n props.onSelect(e, selectRef.current, $(selectRef.current).pp_select2('data'));\n }\n }).on('select2:clear', function (e) {\n if (typeof props.onClear === 'function') {\n props.onClear(e, selectRef.current);\n }\n });\n return function () {\n $(selectRef.current).pp_select2('destroy');\n };\n };\n\n var blankOption = function blankOption() {\n if (props.placeholder) {\n return /*#__PURE__*/React.createElement(\"option\", {\n value: \"\"\n }, props.placeholder);\n }\n\n return /*#__PURE__*/React.createElement(React.Fragment, null);\n };\n\n React.useEffect(initSelect2, []);\n var options;\n\n if (props.options) {\n options = props.options.map(function (option) {\n return /*#__PURE__*/React.createElement(\"option\", {\n value: option.value,\n selected: option.value === props.value\n }, option.text);\n });\n }\n\n var className = 'pp_select2';\n\n if (props.className) {\n className += ' ' + props.className;\n }\n\n className += props.metadata ? 'pp-calendar-form-metafied ' + props.post_types : '';\n return /*#__PURE__*/React.createElement(\"select\", {\n className: className,\n type: \"select\",\n name: props.name,\n id: props.id,\n multiple: props.multiple,\n ref: selectRef\n }, blankOption(), options);\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/Select.jsx?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Select; });\nvar $ = jQuery;\nfunction Select(props) {\n var selectRef = React.useRef(null);\n\n var getAllowClearProp = function getAllowClearProp() {\n if (typeof props.allowClear !== 'undefined' && props.allowClear !== null) {\n return props.allowClear;\n }\n\n return true;\n };\n\n var initSelect2 = function initSelect2() {\n var params = {\n placeholder: props.placeholder || false,\n tags: true,\n allowClear: getAllowClearProp()\n };\n\n if (props.ajaxUrl && props.ajaxAction) {\n params.ajax = {\n delay: 250,\n url: props.ajaxUrl,\n dataType: 'json',\n data: function data(params) {\n var args = {\n q: params.term,\n action: props.ajaxAction,\n nonce: props.nonce\n };\n\n if (props.ajaxArgs) {\n for (var arg in props.ajaxArgs) {\n if (props.ajaxArgs.hasOwnProperty(arg)) {\n args[arg] = props.ajaxArgs[arg];\n }\n }\n }\n\n return args;\n },\n processResults: function processResults(data) {\n return {\n results: data\n };\n }\n };\n }\n\n $(selectRef.current).pp_select2(params).on('select2:select', function (e) {\n if (typeof props.onSelect === 'function') {\n props.onSelect(e, selectRef.current, $(selectRef.current).pp_select2('data'));\n }\n }).on('select2:clear', function (e) {\n if (typeof props.onClear === 'function') {\n props.onClear(e, selectRef.current);\n }\n });\n return function () {\n $(selectRef.current).pp_select2('destroy');\n };\n };\n\n var blankOption = function blankOption() {\n if (props.placeholder) {\n return /*#__PURE__*/React.createElement(\"option\", {\n value: \"\"\n }, props.placeholder);\n }\n\n return /*#__PURE__*/React.createElement(React.Fragment, null);\n };\n\n React.useEffect(initSelect2, []);\n var options;\n\n if (props.options) {\n options = props.options.map(function (option) {\n return /*#__PURE__*/React.createElement(\"option\", {\n key: \"select-option-\".concat(option.value),\n value: option.value,\n selected: option.value === props.value\n }, option.text);\n });\n }\n\n var className = 'pp_select2';\n\n if (props.className) {\n className += ' ' + props.className;\n }\n\n className += props.metadata ? 'pp-calendar-form-metafied ' + props.post_types : '';\n return /*#__PURE__*/React.createElement(\"select\", {\n className: className,\n type: \"select\",\n name: props.name,\n id: props.id,\n multiple: props.multiple,\n ref: selectRef\n }, blankOption(), options);\n}\n\n//# sourceURL=webpack:///./modules/calendar/lib/async-calendar/js/Select.jsx?"); /***/ }),