diff --git a/build/admin.asset.php b/build/admin.asset.php index 8ca20bd5d..ac8955958 100644 --- a/build/admin.asset.php +++ b/build/admin.asset.php @@ -1 +1 @@ - array('wp-blocks', 'wp-data', 'wp-dom-ready'), 'version' => 'bccff6cd671b0e947c21'); + array('wp-blocks', 'wp-data', 'wp-dom-ready'), 'version' => '3611bca17011dd4cf5be'); diff --git a/build/admin.js b/build/admin.js index 462aead8f..7e0fe851e 100644 --- a/build/admin.js +++ b/build/admin.js @@ -1,262 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/helpers/globals.js": -/*!********************************!*\ - !*** ./src/helpers/globals.js ***! - \********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ enableSave: () => (/* binding */ enableSave), -/* harmony export */ getFromGlobal: () => (/* binding */ getFromGlobal), -/* harmony export */ isSinglePostInEditor: () => (/* binding */ isSinglePostInEditor), -/* harmony export */ setToGlobal: () => (/* binding */ setToGlobal) -/* harmony export */ }); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); - - -/** - * Enable the Save buttons after making an update. - * - * This function uses a hacky approach to trigger a change in the post's meta, which prompts - * Gutenberg to recognize that changes have been made and enables the Save buttons. - * It dispatches an editPost action with a non-existing meta key. - * - * @since 1.0.0 - * - * @todo This is a hacky approach and relies on the behavior described in - * https://github.com/WordPress/gutenberg/issues/13774. - * Monitor the issue for any updates or changes in the Gutenberg behavior. - */ -function enableSave() { - (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.dispatch)('core/editor')?.editPost({ - meta: { - _non_existing_meta: true - } - }); -} - -/** - * Checks if the current editor session is editing a post type entity. - * - * This function determines if the current context within the WordPress editor - * is focused on editing an entity that is classified as a post type. This includes - * single posts, pages, and custom post types. It is particularly useful for distinguishing - * editor sessions that are editing post type entities from those editing other types of content, - * such as widget areas or templates in the full site editor, ensuring that specific actions or features - * are correctly applied only when editing post type entities. - * - * @return {boolean} True if the current editor session is for editing a post type entity, false otherwise. - */ -function isSinglePostInEditor() { - return 'string' === typeof (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.select)('core/editor')?.getCurrentPostType(); -} - -/** - * Get a value from the global GatherPress object based on the provided dot-separated path. - * - * This function is designed to retrieve values from the global GatherPress object. - * It takes a dot-separated path as an argument and traverses the object to return the specified value. - * If the object or any level along the path is undefined, it returns undefined. - * - * @since 1.0.0 - * - * @param {string} args - Dot-separated path to the desired property in the GatherPress global object. - * @return {*} The value at the specified path in the GatherPress global object or undefined if not found. - */ -function getFromGlobal(args) { - // eslint-disable-next-line no-undef - if ('object' !== typeof GatherPress) { - return undefined; - } - return args.split('.').reduce( - // eslint-disable-next-line no-undef - (GatherPress, level) => GatherPress && GatherPress[level], - // eslint-disable-next-line no-undef - GatherPress); -} - -/** - * Set a value to a global object based on the provided path. - * - * This function allows setting values within a nested global object using a dot-separated path. - * If the global object (GatherPress) does not exist, it will be initialized. - * - * @since 1.0.0 - * - * @param {string} args - Dot-separated path to the property. - * @param {*} value - The value to set. - * - * @return {void} - */ -function setToGlobal(args, value) { - // eslint-disable-next-line no-undef - if ('object' !== typeof GatherPress) { - return; - } - const properties = args.split('.'); - const last = properties.pop(); - - // eslint-disable-next-line no-undef - properties.reduce((all, item) => { - var _all$item; - return (_all$item = all[item]) !== null && _all$item !== void 0 ? _all$item : all[item] = {}; - }, GatherPress)[last] = value; -} - -/***/ }), - -/***/ "@wordpress/blocks": -/*!********************************!*\ - !*** external ["wp","blocks"] ***! - \********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blocks"]; - -/***/ }), - -/***/ "@wordpress/data": -/*!******************************!*\ - !*** external ["wp","data"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["data"]; - -/***/ }), - -/***/ "@wordpress/dom-ready": -/*!**********************************!*\ - !*** external ["wp","domReady"] ***! - \**********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["domReady"]; - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -/*!**********************!*\ - !*** ./src/admin.js ***! - \**********************/ -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/dom-ready */ "@wordpress/dom-ready"); -/* harmony import */ var _wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _helpers_globals__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./helpers/globals */ "./src/helpers/globals.js"); -/** - * WordPress dependencies. - */ - - - -/** - * Internal dependencies. - */ - - -/** - * Remove Unwanted Blocks - * - * This script removes unwanted blocks from the localized array. - * It utilizes the `domReady` function to ensure the DOM is ready before execution. - * It iterates through the keys of the 'unregister_blocks' array obtained from the global scope, - * retrieves the block name, and unregisters the block using the `unregisterBlockType` function. - * - * @since 1.0.0 - */ - -// Execute the following code when the DOM is ready. -_wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0___default()(() => { - // Iterate through keys of the 'unregister_blocks' array in the global scope. - Object.keys((0,_helpers_globals__WEBPACK_IMPORTED_MODULE_2__.getFromGlobal)('misc.unregisterBlocks')).forEach(key => { - // Retrieve the block name using the key. - const blockName = (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_2__.getFromGlobal)('misc.unregisterBlocks')[key]; - - // Check if the block name is defined and unregister the block. - if (blockName && 'undefined' !== typeof (0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.getBlockType)(blockName)) { - (0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_1__.unregisterBlockType)(blockName); - } - }); -}); -})(); - -/******/ })() -; -//# sourceMappingURL=admin.js.map \ No newline at end of file +(()=>{"use strict";var e={n:r=>{var t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)};const r=window.wp.domReady;var t=e.n(r);const o=window.wp.blocks;function s(e){if("object"==typeof GatherPress)return e.split(".").reduce(((e,r)=>e&&e[r]),GatherPress)}window.wp.data,t()((()=>{Object.keys(s("misc.unregisterBlocks")).forEach((e=>{const r=s("misc.unregisterBlocks")[e];r&&void 0!==(0,o.getBlockType)(r)&&(0,o.unregisterBlockType)(r)}))}))})(); \ No newline at end of file diff --git a/build/admin_style.asset.php b/build/admin_style.asset.php index 10231999a..16bcf03a2 100644 --- a/build/admin_style.asset.php +++ b/build/admin_style.asset.php @@ -1 +1 @@ - array(), 'version' => '54ce19837a9ab5960801'); + array(), 'version' => 'ceb7c66a2b1e518e5f59'); diff --git a/build/admin_style.css b/build/admin_style.css index a98b91de7..b09bce20a 100644 --- a/build/admin_style.css +++ b/build/admin_style.css @@ -1,14 +1 @@ -/*!***************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/admin.scss ***! - \***************************************************************************************************************************************************************************************************************************************/ -.gp-admin__membership-check { - align-items: center; - display: flex; - gap: 1rem; - padding: 0.5rem; -} -.gp-admin__membership-check > div:last-child { - margin-left: auto; -} - -/*# sourceMappingURL=admin_style.css.map*/ \ No newline at end of file +.gp-admin__membership-check{align-items:center;display:flex;gap:1rem;padding:.5rem}.gp-admin__membership-check>div:last-child{margin-left:auto} diff --git a/build/admin_style.js b/build/admin_style.js index 0cbe9c75a..e69de29bb 100644 --- a/build/admin_style.js +++ b/build/admin_style.js @@ -1,28 +0,0 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ // The require scope -/******/ var __webpack_require__ = {}; -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -/*!************************!*\ - !*** ./src/admin.scss ***! - \************************/ -__webpack_require__.r(__webpack_exports__); -// extracted by mini-css-extract-plugin - -/******/ })() -; -//# sourceMappingURL=admin_style.js.map \ No newline at end of file diff --git a/build/blocks/add-to-calendar/add-to-calendar.asset.php b/build/blocks/add-to-calendar/add-to-calendar.asset.php index 90bd4a096..a99e87807 100644 --- a/build/blocks/add-to-calendar/add-to-calendar.asset.php +++ b/build/blocks/add-to-calendar/add-to-calendar.asset.php @@ -1 +1 @@ - array('wp-dom-ready'), 'version' => 'c5e07b505ee22c88a97a'); + array('wp-dom-ready'), 'version' => '3ebd875b9e03f34024e6'); diff --git a/build/blocks/add-to-calendar/add-to-calendar.js b/build/blocks/add-to-calendar/add-to-calendar.js index 9eecda5b2..875654888 100644 --- a/build/blocks/add-to-calendar/add-to-calendar.js +++ b/build/blocks/add-to-calendar/add-to-calendar.js @@ -1,163 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "@wordpress/dom-ready": -/*!**********************************!*\ - !*** external ["wp","domReady"] ***! - \**********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["domReady"]; - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/************************************************************************/ -var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. -(() => { -/*!*******************************************************!*\ - !*** ./src/blocks/add-to-calendar/add-to-calendar.js ***! - \*******************************************************/ -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/dom-ready */ "@wordpress/dom-ready"); -/* harmony import */ var _wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0__); -/** - * WordPress dependencies. - */ - - -/** - * Toggle to Show/Hide Calendar options. - * - * @param {TouchEvent} e Event. - */ -const addToCalendarToggle = e => { - e.preventDefault(); - const currentListDisplay = e.target.nextElementSibling.style.display; - const lists = document.querySelectorAll('.gp-add-to-calendar__list'); - for (let i = 0; i < lists.length; i++) { - lists[i].style.display = 'none'; - } - e.target.nextElementSibling.style.display = 'none' === currentListDisplay ? 'flex' : 'none'; -}; - -/** - * Initialize all Add To Calendar blocks. - * - * This function initializes the behavior of Add To Calendar blocks on the page. - * It sets up event listeners for click and keydown events to toggle the display - * of the calendar options list. The function targets elements with the class - * 'gp-add-to-calendar' and adds event listeners to handle user interactions. - * - * @since 1.0.0 - * - * @return {void} - */ -const addToCalendarInit = () => { - const containers = document.querySelectorAll('.gp-add-to-calendar'); - for (let i = 0; i < containers.length; i++) { - containers[i].querySelector('.gp-add-to-calendar__init').addEventListener('click', addToCalendarToggle, false); - document.addEventListener('click', ({ - target - }) => { - if (!target.closest('.gp-add-to-calendar')) { - containers[i].querySelector('.gp-add-to-calendar__list').style.display = 'none'; - } - }); - document.addEventListener('keydown', ({ - key - }) => { - if ('Escape' === key) { - containers[i].querySelector('.gp-add-to-calendar__list').style.display = 'none'; - } - }); - } -}; - -/** - * Callback for when the DOM is ready. - * - * This callback function is executed when the DOM is fully loaded and ready for manipulation. - * It calls the `addToCalendarInit` function to initialize the behavior of Add To Calendar blocks - * on the page, setting up event listeners for user interactions. - * - * @since 1.0.0 - * - * @return {void} - */ -_wordpress_dom_ready__WEBPACK_IMPORTED_MODULE_0___default()(() => { - addToCalendarInit(); -}); -})(); - -/******/ })() -; -//# sourceMappingURL=add-to-calendar.js.map \ No newline at end of file +(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var l in n)e.o(n,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:n[l]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.domReady,n=e=>{e.preventDefault();const t=e.target.nextElementSibling.style.display,n=document.querySelectorAll(".gp-add-to-calendar__list");for(let e=0;e{(()=>{const e=document.querySelectorAll(".gp-add-to-calendar");for(let t=0;t{n.closest(".gp-add-to-calendar")||(e[t].querySelector(".gp-add-to-calendar__list").style.display="none")})),document.addEventListener("keydown",(({key:n})=>{"Escape"===n&&(e[t].querySelector(".gp-add-to-calendar__list").style.display="none")}))})()}))})(); \ No newline at end of file diff --git a/build/blocks/add-to-calendar/index.asset.php b/build/blocks/add-to-calendar/index.asset.php index 8ff45f2a0..8e9ffe493 100644 --- a/build/blocks/add-to-calendar/index.asset.php +++ b/build/blocks/add-to-calendar/index.asset.php @@ -1 +1 @@ - array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'd99d220bb310f2294e02'); + array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '526d6768d91e90ae011a'); diff --git a/build/blocks/add-to-calendar/index.js b/build/blocks/add-to-calendar/index.js index 90532e7fa..597082f51 100644 --- a/build/blocks/add-to-calendar/index.js +++ b/build/blocks/add-to-calendar/index.js @@ -1,402 +1 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/blocks/add-to-calendar/edit.js": -/*!********************************************!*\ - !*** ./src/blocks/add-to-calendar/edit.js ***! - \********************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _components_EditCover__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../components/EditCover */ "./src/components/EditCover.js"); - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - -/** - * Edit component for the GatherPress Add to Calendar block. - * - * This component renders the edit view of the GatherPress Add to Calendar block. - * It provides an interface for users to add the event to their calendar. - * The component includes an icon and a link for adding the event to the calendar. - * - * @since 1.0.0 - * - * @return {JSX.Element} The rendered React component. - */ -const Edit = () => { - const blockProps = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_2__.useBlockProps)(); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - ...blockProps - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_EditCover__WEBPACK_IMPORTED_MODULE_4__["default"], null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Flex, { - justify: "normal", - align: "center", - gap: "4" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.FlexItem, { - display: "flex", - className: "gp-event-date__icon" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.Icon, { - icon: "calendar" - })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_3__.FlexItem, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: "#" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Add to calendar', 'gatherpress')))))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Edit); - -/***/ }), - -/***/ "./src/blocks/add-to-calendar/index.js": -/*!*********************************************!*\ - !*** ./src/blocks/add-to-calendar/index.js ***! - \*********************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./edit */ "./src/blocks/add-to-calendar/edit.js"); -/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./block.json */ "./src/blocks/add-to-calendar/block.json"); -/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style.scss */ "./src/blocks/add-to-calendar/style.scss"); -/** - * WordPress dependencies. - */ - - -/** - * Internal dependencies. - */ - - - - -/** - * Register the GatherPress Add to Calendar block. - * - * This code registers the GatherPress Add to Calendar block in the WordPress block editor. - * It utilizes the block metadata from the 'block.json' file and associates it with the - * edit component for rendering in the editor. The 'save' function is set to null as - * the block doesn't have a front-end representation and is only used in the editor. - * - * @since 1.0.0 - * - * @return {void} - */ - -(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_2__, { - edit: _edit__WEBPACK_IMPORTED_MODULE_1__["default"], - save: () => null -}); - -/***/ }), - -/***/ "./src/components/EditCover.js": -/*!*************************************!*\ - !*** ./src/components/EditCover.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); - -/** - * EditCover component for GatherPress. - * - * This component is used to create an overlay cover for the block editor. - * It is typically used to visually distinguish the selected and unselected states - * of a block in the editor. - * - * @since 1.0.0 - * - * @param {Object} props - Component properties. - * @param {boolean} props.isSelected - Indicates whether the block is selected. - * - * @return {JSX.Element} The rendered React component. - */ -const EditCover = props => { - const { - isSelected - } = props; - const display = isSelected ? 'none' : 'block'; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - style: { - position: 'relative' - } - }, props.children, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - style: { - position: 'absolute', - top: '0', - right: '0', - bottom: '0', - left: '0', - display - } - })); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EditCover); - -/***/ }), - -/***/ "./src/blocks/add-to-calendar/style.scss": -/*!***********************************************!*\ - !*** ./src/blocks/add-to-calendar/style.scss ***! - \***********************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -// extracted by mini-css-extract-plugin - - -/***/ }), - -/***/ "react": -/*!************************!*\ - !*** external "React" ***! - \************************/ -/***/ ((module) => { - -module.exports = window["React"]; - -/***/ }), - -/***/ "@wordpress/block-editor": -/*!*************************************!*\ - !*** external ["wp","blockEditor"] ***! - \*************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blockEditor"]; - -/***/ }), - -/***/ "@wordpress/blocks": -/*!********************************!*\ - !*** external ["wp","blocks"] ***! - \********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blocks"]; - -/***/ }), - -/***/ "@wordpress/components": -/*!************************************!*\ - !*** external ["wp","components"] ***! - \************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["components"]; - -/***/ }), - -/***/ "@wordpress/i18n": -/*!******************************!*\ - !*** external ["wp","i18n"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["i18n"]; - -/***/ }), - -/***/ "./src/blocks/add-to-calendar/block.json": -/*!***********************************************!*\ - !*** ./src/blocks/add-to-calendar/block.json ***! - \***********************************************/ -/***/ ((module) => { - -module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"gatherpress/add-to-calendar","version":"1.0.0","title":"Add to Calendar","category":"gatherpress","icon":"calendar","example":{},"description":"Allows a member to add an event to their preferred calendar.","attributes":{"blockId":{"type":"string"}},"supports":{"html":false},"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css","viewScript":"file:./add-to-calendar.js","render":"file:./render.php"}'); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = __webpack_modules__; -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/chunk loaded */ -/******/ (() => { -/******/ var deferred = []; -/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { -/******/ if(chunkIds) { -/******/ priority = priority || 0; -/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; -/******/ deferred[i] = [chunkIds, fn, priority]; -/******/ return; -/******/ } -/******/ var notFulfilled = Infinity; -/******/ for (var i = 0; i < deferred.length; i++) { -/******/ var [chunkIds, fn, priority] = deferred[i]; -/******/ var fulfilled = true; -/******/ for (var j = 0; j < chunkIds.length; j++) { -/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { -/******/ chunkIds.splice(j--, 1); -/******/ } else { -/******/ fulfilled = false; -/******/ if(priority < notFulfilled) notFulfilled = priority; -/******/ } -/******/ } -/******/ if(fulfilled) { -/******/ deferred.splice(i--, 1) -/******/ var r = fn(); -/******/ if (r !== undefined) result = r; -/******/ } -/******/ } -/******/ return result; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/jsonp chunk loading */ -/******/ (() => { -/******/ // no baseURI -/******/ -/******/ // object to store loaded and loading chunks -/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched -/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded -/******/ var installedChunks = { -/******/ "blocks/add-to-calendar/index": 0, -/******/ "blocks/add-to-calendar/style-index": 0 -/******/ }; -/******/ -/******/ // no chunk on demand loading -/******/ -/******/ // no prefetching -/******/ -/******/ // no preloaded -/******/ -/******/ // no HMR -/******/ -/******/ // no HMR manifest -/******/ -/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); -/******/ -/******/ // install a JSONP callback for chunk loading -/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { -/******/ var [chunkIds, moreModules, runtime] = data; -/******/ // add "moreModules" to the modules object, -/******/ // then flag all "chunkIds" as loaded and fire callback -/******/ var moduleId, chunkId, i = 0; -/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { -/******/ for(moduleId in moreModules) { -/******/ if(__webpack_require__.o(moreModules, moduleId)) { -/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; -/******/ } -/******/ } -/******/ if(runtime) var result = runtime(__webpack_require__); -/******/ } -/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); -/******/ for(;i < chunkIds.length; i++) { -/******/ chunkId = chunkIds[i]; -/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { -/******/ installedChunks[chunkId][0](); -/******/ } -/******/ installedChunks[chunkId] = 0; -/******/ } -/******/ return __webpack_require__.O(result); -/******/ } -/******/ -/******/ var chunkLoadingGlobal = globalThis["webpackChunkgatherpress"] = globalThis["webpackChunkgatherpress"] || []; -/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); -/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); -/******/ })(); -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module depends on other loaded chunks and execution need to be delayed -/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["blocks/add-to-calendar/style-index"], () => (__webpack_require__("./src/blocks/add-to-calendar/index.js"))) -/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); -/******/ -/******/ })() -; -//# sourceMappingURL=index.js.map \ No newline at end of file +(()=>{"use strict";var e,t={5358:()=>{const e=window.wp.blocks,t=window.React,r=window.wp.i18n,n=window.wp.blockEditor,a=window.wp.components,l=e=>{const{isSelected:r}=e,n=r?"none":"block";return(0,t.createElement)("div",{style:{position:"relative"}},e.children,(0,t.createElement)("div",{style:{position:"absolute",top:"0",right:"0",bottom:"0",left:"0",display:n}}))},o=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"gatherpress/add-to-calendar","version":"1.0.0","title":"Add to Calendar","category":"gatherpress","icon":"calendar","example":{},"description":"Allows a member to add an event to their preferred calendar.","attributes":{"blockId":{"type":"string"}},"supports":{"html":false},"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css","viewScript":"file:./add-to-calendar.js","render":"file:./render.php"}');(0,e.registerBlockType)(o,{edit:()=>{const e=(0,n.useBlockProps)();return(0,t.createElement)("div",{...e},(0,t.createElement)(l,null,(0,t.createElement)(a.Flex,{justify:"normal",align:"center",gap:"4"},(0,t.createElement)(a.FlexItem,{display:"flex",className:"gp-event-date__icon"},(0,t.createElement)(a.Icon,{icon:"calendar"})),(0,t.createElement)(a.FlexItem,null,(0,t.createElement)("a",{href:"#"},(0,r.__)("Add to calendar","gatherpress"))))))},save:()=>null})}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var l=r[e]={exports:{}};return t[e](l,l.exports,n),l.exports}n.m=t,e=[],n.O=(t,r,a,l)=>{if(!r){var o=1/0;for(d=0;d=l)&&Object.keys(n.O).every((e=>n.O[e](r[i])))?r.splice(i--,1):(s=!1,l0&&e[d-1][2]>l;d--)e[d]=e[d-1];e[d]=[r,a,l]},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={181:0,129:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var a,l,[o,s,i]=r,c=0;if(o.some((t=>0!==e[t]))){for(a in s)n.o(s,a)&&(n.m[a]=s[a]);if(i)var d=i(n)}for(t&&t(r);cn(5358)));a=n.O(a)})(); \ No newline at end of file diff --git a/build/blocks/add-to-calendar/style-index.css b/build/blocks/add-to-calendar/style-index.css index 0971a26eb..3a025cf07 100644 --- a/build/blocks/add-to-calendar/style-index.css +++ b/build/blocks/add-to-calendar/style-index.css @@ -1,42 +1 @@ -/*!**************************************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/blocks/add-to-calendar/style.scss ***! - \**************************************************************************************************************************************************************************************************************************************************************/ -.gp-add-to-calendar { - position: relative; -} -.gp-add-to-calendar__icon { - align-items: flex-start; - display: flex; -} -.gp-add-to-calendar__item { - align-items: center; - display: flex; - gap: 0.75rem; -} -.gp-add-to-calendar__list { - border: 1px solid #CCCCCC; - border-radius: 0.4rem; - flex-direction: column; - overflow: hidden; - position: absolute; - width: 15rem; - z-index: 50; -} -.gp-add-to-calendar__list-item { - border-top: 1px solid #CCCCCC; - margin-top: -1px; -} -.gp-add-to-calendar__list-item a { - background-color: #FFFFFF; - color: #000000; - display: block; - padding: 0.5rem; -} -.gp-add-to-calendar__list-item a:hover { - background-color: #EEEEEE; -} -.gp-add-to-calendar__row { - display: flex; -} - -/*# sourceMappingURL=style-index.css.map*/ \ No newline at end of file +.gp-add-to-calendar{position:relative}.gp-add-to-calendar__icon{align-items:flex-start;display:flex}.gp-add-to-calendar__item{align-items:center;display:flex;gap:.75rem}.gp-add-to-calendar__list{border:1px solid #ccc;border-radius:.4rem;flex-direction:column;overflow:hidden;position:absolute;width:15rem;z-index:50}.gp-add-to-calendar__list-item{border-top:1px solid #ccc;margin-top:-1px}.gp-add-to-calendar__list-item a{background-color:#fff;color:#000;display:block;padding:.5rem}.gp-add-to-calendar__list-item a:hover{background-color:#eee}.gp-add-to-calendar__row{display:flex} diff --git a/build/blocks/event-date/index.asset.php b/build/blocks/event-date/index.asset.php index ffc25df1e..3e54888ab 100644 --- a/build/blocks/event-date/index.asset.php +++ b/build/blocks/event-date/index.asset.php @@ -1 +1 @@ - array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '552daab996148013e59f'); + array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '7296d91ca66be3911344'); diff --git a/build/blocks/event-date/index.js b/build/blocks/event-date/index.js index 04c7c9a0c..151d1a33a 100644 --- a/build/blocks/event-date/index.js +++ b/build/blocks/event-date/index.js @@ -1,1822 +1,2 @@ -/******/ (() => { // webpackBootstrap -/******/ "use strict"; -/******/ var __webpack_modules__ = ({ - -/***/ "./src/blocks/event-date/edit.js": -/*!***************************************!*\ - !*** ./src/blocks/event-date/edit.js ***! - \***************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "moment"); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); -/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _helpers_broadcasting__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../helpers/broadcasting */ "./src/helpers/broadcasting.js"); -/* harmony import */ var _helpers_datetime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../helpers/datetime */ "./src/helpers/datetime.js"); -/* harmony import */ var _components_EditCover__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../components/EditCover */ "./src/components/EditCover.js"); -/* harmony import */ var _components_DateTimeRange__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../components/DateTimeRange */ "./src/components/DateTimeRange.js"); -/* harmony import */ var _helpers_globals__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../helpers/globals */ "./src/helpers/globals.js"); - -/** - * External dependencies. - */ - - -/** - * WordPress dependencies. - */ - - - - - -/** - * Internal dependencies. - */ - - - - - - -/** - * Similar to get_display_datetime method in class-event.php. - * - * @param {string} start - * @param {string} end - * @param {string} tz - * @return {string} Displayed date. - */ -const displayDateTime = (start, end, tz) => { - const dateFormat = (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.convertPHPToMomentFormat)((0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('settings.dateFormat')); - const timeFormat = (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.convertPHPToMomentFormat)((0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('settings.timeFormat')); - const timeZoneFormat = (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('settings.showTimezone') ? 'z' : ''; - const startFormat = dateFormat + ' ' + timeFormat; - const timeZone = (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.getTimeZone)(tz); - let endFormat = dateFormat + ' ' + timeFormat + ' ' + timeZoneFormat; - if (moment__WEBPACK_IMPORTED_MODULE_1___default().tz(start, timeZone).format(dateFormat) === moment__WEBPACK_IMPORTED_MODULE_1___default().tz(end, timeZone).format(dateFormat)) { - endFormat = timeFormat + ' ' + timeZoneFormat; - } - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.sprintf)( /* translators: %1$s: datetime start, %2$s: datetime end, %3$s timezone. */ - (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('%1$s to %2$s %3$s'), moment__WEBPACK_IMPORTED_MODULE_1___default().tz(start, timeZone).format(startFormat), moment__WEBPACK_IMPORTED_MODULE_1___default().tz(end, timeZone).format(endFormat), (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.getUtcOffset)(timeZone)); -}; - -/** - * Edit component for the GatherPress Event Date block. - * - * This component represents the editable view of the GatherPress Event Date block - * in the WordPress block editor. It manages the state of date, time, and timezone - * for the block and renders the user interface accordingly. The component includes - * an icon, displays the formatted date and time, and provides controls to edit the - * date and time range via the DateTimeRange component in the InspectorControls. - * - * @since 1.0.0 - * - * @return {JSX.Element} The rendered Edit component for the GatherPress Event Date block. - * - * @see {@link DateTimeRange} - Component for editing date and time range. - * @see {@link EditCover} - Component for displaying a cover over the block. - * @see {@link useBlockProps} - Custom hook for block props. - * @see {@link displayDateTime} - Function for formatting and displaying date and time. - * @see {@link Listener} - Function for adding event listeners. - */ -const Edit = () => { - const blockProps = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.useBlockProps)(); - const [dateTimeStart, setDateTimeStart] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.useState)(_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.defaultDateTimeStart); - const [dateTimeEnd, setDateTimeEnd] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.useState)(_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.defaultDateTimeEnd); - const [timezone, setTimezone] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.useState)((0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_7__.getTimeZone)()); - (0,_helpers_broadcasting__WEBPACK_IMPORTED_MODULE_6__.Listener)({ - setDateTimeEnd, - setDateTimeStart, - setTimezone - }); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - ...blockProps - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_EditCover__WEBPACK_IMPORTED_MODULE_8__["default"], null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.Flex, { - justify: "normal", - align: "center", - gap: "4" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.FlexItem, { - display: "flex", - className: "gp-event-date__icon" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.Icon, { - icon: "clock" - })), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.FlexItem, null, displayDateTime(dateTimeStart, dateTimeEnd, timezone)), (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.isSinglePostInEditor)() && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InspectorControls, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.PanelBody, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_DateTimeRange__WEBPACK_IMPORTED_MODULE_9__["default"], null)))))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Edit); - -/***/ }), - -/***/ "./src/blocks/event-date/index.js": -/*!****************************************!*\ - !*** ./src/blocks/event-date/index.js ***! - \****************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); -/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./edit */ "./src/blocks/event-date/edit.js"); -/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./block.json */ "./src/blocks/event-date/block.json"); -/* harmony import */ var _style_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style.scss */ "./src/blocks/event-date/style.scss"); -/** - * WordPress dependencies. - */ - - -/** - * Internal dependencies. - */ - - - - -/** - * Register the GatherPress Event Date block. - * - * This code registers the GatherPress Event Date block in the WordPress block editor. - * It includes metadata from the 'block.json' file, defines the block styles with 'style.scss', - * and specifies the 'edit' and 'save' components for the block. The 'edit' component is responsible - * for the block's appearance and behavior in the editor, while the 'save' component defines how - * the block should be rendered on the front end. - * - * @since 1.0.0 - * - * @return {void} - */ -(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_2__, { - edit: _edit__WEBPACK_IMPORTED_MODULE_1__["default"], - save: () => null -}); - -/***/ }), - -/***/ "./src/components/DateTime.js": -/*!************************************!*\ - !*** ./src/components/DateTime.js ***! - \************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ DateTimeEndLabel: () => (/* binding */ DateTimeEndLabel), -/* harmony export */ DateTimeEndPicker: () => (/* binding */ DateTimeEndPicker), -/* harmony export */ DateTimeStartLabel: () => (/* binding */ DateTimeStartLabel), -/* harmony export */ DateTimeStartPicker: () => (/* binding */ DateTimeStartPicker) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/date */ "@wordpress/date"); -/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_date__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! moment */ "moment"); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _helpers_datetime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers/datetime */ "./src/helpers/datetime.js"); - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - -/** - * Formats the provided start date and time according to the specified label format - * and returns the formatted result in the time zone configured for the plugin. - * - * @since 1.0.0 - * - * @param {Object} props - The properties object containing the start date and time. - * @param {string} props.dateTimeStart - The start date and time to be formatted. - * - * @return {string} Formatted date and time label based on the configured format and time zone. - */ -const DateTimeStartLabel = props => { - const { - dateTimeStart - } = props; - return moment__WEBPACK_IMPORTED_MODULE_3___default().tz(dateTimeStart, (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.getTimeZone)()).format((0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.dateTimeLabelFormat)()); -}; - -/** - * Formats the provided end date and time according to the specified label format - * and returns the formatted result in the time zone configured for the plugin. - * - * @since 1.0.0 - * - * @param {Object} props - The properties object containing the end date and time. - * @param {string} props.dateTimeStart - The end date and time to be formatted. - * - * @return {string} Formatted date and time label based on the configured format and time zone. - */ -const DateTimeEndLabel = props => { - const { - dateTimeEnd - } = props; - return moment__WEBPACK_IMPORTED_MODULE_3___default().tz(dateTimeEnd, (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.getTimeZone)()).format((0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.dateTimeLabelFormat)()); -}; - -/** - * DateTimeStartPicker component for GatherPress. - * - * This component renders a DateTimePicker for selecting the start date and time of an event. - * It takes the current date and time, as well as a callback function to update the state. - * The component is configured based on the site's time settings (12-hour or 24-hour format). - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {Date} props.dateTimeStart - The current date and time for the picker. - * @param {Function} props.setDateTimeStart - Callback function to update the start date and time. - * - * @return {JSX.Element} The rendered React component. - */ -const DateTimeStartPicker = props => { - const { - dateTimeStart, - setDateTimeStart - } = props; - const settings = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_1__.getSettings)(); - const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase().replace(/\\\\/g, '').split('').reverse().join('')); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.DateTimePicker, { - currentDate: dateTimeStart, - onChange: date => (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.updateDateTimeStart)(date, setDateTimeStart), - is12Hour: is12HourTime - }); -}; - -/** - * DateTimeEndPicker component for GatherPress. - * - * This component renders a DateTimePicker for selecting the end date and time of an event. - * It takes the current date and time, as well as a callback function to update the state. - * The component is configured based on the site's time settings (12-hour or 24-hour format). - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {Date} props.dateTimeEnd - The current date and time for the picker. - * @param {Function} props.setDateTimeEnd - Callback function to update the end date and time. - * - * @return {JSX.Element} The rendered React component. - */ -const DateTimeEndPicker = props => { - const { - dateTimeEnd, - setDateTimeEnd - } = props; - const settings = (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_1__.getSettings)(); - const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase().replace(/\\\\/g, '').split('').reverse().join('')); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.DateTimePicker, { - currentDate: dateTimeEnd, - onChange: date => (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.updateDateTimeEnd)(date, setDateTimeEnd), - is12Hour: is12HourTime - }); -}; - -/***/ }), - -/***/ "./src/components/DateTimeEnd.js": -/*!***************************************!*\ - !*** ./src/components/DateTimeEnd.js ***! - \***************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "moment"); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _DateTime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DateTime */ "./src/components/DateTime.js"); -/* harmony import */ var _helpers_event__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../helpers/event */ "./src/helpers/event.js"); -/* harmony import */ var _helpers_broadcasting__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../helpers/broadcasting */ "./src/helpers/broadcasting.js"); -/* harmony import */ var _helpers_datetime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../helpers/datetime */ "./src/helpers/datetime.js"); - -/** - * External dependencies. - */ - - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - - - - -/** - * DateTimeEnd component for GatherPress. - * - * This component renders the end date and time selection in the editor. - * It includes a DateTimeEndPicker for selecting the end date and time. - * The component also updates the state using the setDateTimeEnd callback. - * Additionally, it broadcasts the end date and time using the Broadcaster utility. - * If the event has passed, it displays a notice using hasEventPastNotice function. - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {Date} props.dateTimeEnd - The current date and time for the picker. - * @param {Function} props.setDateTimeEnd - Callback function to update the end date and time. - * - * @return {JSX.Element} The rendered React component. - */ -const DateTimeEnd = props => { - const { - dateTimeEnd, - setDateTimeEnd - } = props; - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => { - setDateTimeEnd(moment__WEBPACK_IMPORTED_MODULE_1___default().tz((0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_8__.getDateTimeEnd)(), (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_8__.getTimeZone)()).format(_helpers_datetime__WEBPACK_IMPORTED_MODULE_8__.dateTimeMomentFormat)); - (0,_helpers_broadcasting__WEBPACK_IMPORTED_MODULE_7__.Broadcaster)({ - setDateTimeEnd: dateTimeEnd - }); - (0,_helpers_event__WEBPACK_IMPORTED_MODULE_6__.hasEventPastNotice)(); - }); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelRow, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Flex, { - direction: "column", - gap: "0" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.FlexItem, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { - htmlFor: "gp-datetime-end" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('End', 'gatherpress'))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.FlexItem, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Dropdown, { - popoverProps: { - placement: 'bottom-end' - }, - renderToggle: ({ - isOpen, - onToggle - }) => (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Button, { - id: "gp-datetime-end", - onClick: onToggle, - "aria-expanded": isOpen, - isLink: true - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_DateTime__WEBPACK_IMPORTED_MODULE_5__.DateTimeEndLabel, { - dateTimeEnd: dateTimeEnd - })), - renderContent: () => (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_DateTime__WEBPACK_IMPORTED_MODULE_5__.DateTimeEndPicker, { - dateTimeEnd: dateTimeEnd, - setDateTimeEnd: setDateTimeEnd - }) - })))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DateTimeEnd); - -/***/ }), - -/***/ "./src/components/DateTimePreview.js": -/*!*******************************************!*\ - !*** ./src/components/DateTimePreview.js ***! - \*******************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/date */ "@wordpress/date"); -/* harmony import */ var _wordpress_date__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_date__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); - -/** - * WordPress dependencies. - */ - - - -/** - * DateTimePreview component for GatherPress. - * - * This component renders a preview of the formatted date and time based on the specified format. - * It listens for the 'input' event on the input field with the specified name and updates - * the state with the new date and time format. The formatted preview is displayed accordingly. - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {Object} props.attrs - Component attributes. - * @param {string} props.attrs.name - The name of the input field. - * @param {string} props.attrs.value - The initial value of the input field (date and time format). - * - * @return {JSX.Element} The rendered React component. - */ -const DateTimePreview = props => { - const { - name, - value - } = props.attrs; - const [dateTimeFormat, setDateTimeFormat] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useState)(value); - const input = document.querySelector(`[name="${name}"]`); - input.addEventListener('input', e => { - setDateTimeFormat(e.target.value); - }, { - once: true - }); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, dateTimeFormat && (0,_wordpress_date__WEBPACK_IMPORTED_MODULE_1__.format)(dateTimeFormat)); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DateTimePreview); - -/***/ }), - -/***/ "./src/components/DateTimeRange.js": -/*!*****************************************!*\ - !*** ./src/components/DateTimeRange.js ***! - \*****************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _helpers_datetime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers/datetime */ "./src/helpers/datetime.js"); -/* harmony import */ var _components_DateTimeStart__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../components/DateTimeStart */ "./src/components/DateTimeStart.js"); -/* harmony import */ var _components_DateTimeEnd__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../components/DateTimeEnd */ "./src/components/DateTimeEnd.js"); -/* harmony import */ var _components_TimeZone__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../components/TimeZone */ "./src/components/TimeZone.js"); - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - - - - -/** - * DateTimeRange component for GatherPress. - * - * This component manages the date and time range selection. It includes - * DateTimeStart, DateTimeEnd, and TimeZone components. The selected values - * for start date and time, end date and time, and timezone are managed in the - * component's state. The component subscribes to the saveDateTime function, - * which is triggered to save the selected date and time values. - * - * @since 1.0.0 - * - * @return {JSX.Element} The rendered React component. - */ -const DateTimeRange = () => { - const [dateTimeStart, setDateTimeStart] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useState)(); - const [dateTimeEnd, setDateTimeEnd] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useState)(); - const [timezone, setTimezone] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useState)(); - (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.subscribe)(_helpers_datetime__WEBPACK_IMPORTED_MODULE_4__.saveDateTime); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("h3", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Date & time', 'gatherpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_DateTimeStart__WEBPACK_IMPORTED_MODULE_5__["default"], { - dateTimeStart: dateTimeStart, - setDateTimeStart: setDateTimeStart - }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_DateTimeEnd__WEBPACK_IMPORTED_MODULE_6__["default"], { - dateTimeEnd: dateTimeEnd, - setDateTimeEnd: setDateTimeEnd - }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_TimeZone__WEBPACK_IMPORTED_MODULE_7__["default"], { - timezone: timezone, - setTimezone: setTimezone - })); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DateTimeRange); - -/***/ }), - -/***/ "./src/components/DateTimeStart.js": -/*!*****************************************!*\ - !*** ./src/components/DateTimeStart.js ***! - \*****************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "moment"); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _DateTime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./DateTime */ "./src/components/DateTime.js"); -/* harmony import */ var _helpers_event__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../helpers/event */ "./src/helpers/event.js"); -/* harmony import */ var _helpers_broadcasting__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../helpers/broadcasting */ "./src/helpers/broadcasting.js"); -/* harmony import */ var _helpers_datetime__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../helpers/datetime */ "./src/helpers/datetime.js"); - -/** - * External dependencies. - */ - - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - - - - -/** - * DateTimeStart component for GatherPress. - * - * This component manages the selection of the start date and time. It uses - * DateTimeStartPicker for the user to pick the date and time. The selected - * values are formatted and broadcasted using Broadcaster. The component - * subscribes to the saveDateTime function and triggers the hasEventPastNotice - * function to handle any event past notices. - * - * @since 1.0.0 - * - * @param {Object} props - Component properties. - * @param {string} props.dateTimeStart - The current start date and time. - * @param {Function} props.setDateTimeStart - Function to set the start date and time. - * - * @return {JSX.Element} The rendered React component. - */ -const DateTimeStart = props => { - const { - dateTimeStart, - setDateTimeStart - } = props; - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => { - setDateTimeStart(moment__WEBPACK_IMPORTED_MODULE_1___default().tz((0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_8__.getDateTimeStart)(), (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_8__.getTimeZone)()).format(_helpers_datetime__WEBPACK_IMPORTED_MODULE_8__.dateTimeMomentFormat)); - (0,_helpers_broadcasting__WEBPACK_IMPORTED_MODULE_7__.Broadcaster)({ - setDateTimeStart: dateTimeStart - }); - (0,_helpers_event__WEBPACK_IMPORTED_MODULE_6__.hasEventPastNotice)(); - }); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelRow, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Flex, { - direction: "column", - gap: "0" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.FlexItem, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { - htmlFor: "gp-datetime-start" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Start', 'gatherpress'))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.FlexItem, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Dropdown, { - popoverProps: { - placement: 'bottom-end' - }, - renderToggle: ({ - isOpen, - onToggle - }) => (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Button, { - id: "gp-datetime-start", - onClick: onToggle, - "aria-expanded": isOpen, - isLink: true - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_DateTime__WEBPACK_IMPORTED_MODULE_5__.DateTimeStartLabel, { - dateTimeStart: dateTimeStart - })), - renderContent: () => (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_DateTime__WEBPACK_IMPORTED_MODULE_5__.DateTimeStartPicker, { - dateTimeStart: dateTimeStart, - setDateTimeStart: setDateTimeStart - }) - })))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DateTimeStart); - -/***/ }), - -/***/ "./src/components/EditCover.js": -/*!*************************************!*\ - !*** ./src/components/EditCover.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); - -/** - * EditCover component for GatherPress. - * - * This component is used to create an overlay cover for the block editor. - * It is typically used to visually distinguish the selected and unselected states - * of a block in the editor. - * - * @since 1.0.0 - * - * @param {Object} props - Component properties. - * @param {boolean} props.isSelected - Indicates whether the block is selected. - * - * @return {JSX.Element} The rendered React component. - */ -const EditCover = props => { - const { - isSelected - } = props; - const display = isSelected ? 'none' : 'block'; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - style: { - position: 'relative' - } - }, props.children, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - style: { - position: 'absolute', - top: '0', - right: '0', - bottom: '0', - left: '0', - display - } - })); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EditCover); - -/***/ }), - -/***/ "./src/components/TimeZone.js": -/*!************************************!*\ - !*** ./src/components/TimeZone.js ***! - \************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _helpers_broadcasting__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../helpers/broadcasting */ "./src/helpers/broadcasting.js"); -/* harmony import */ var _helpers_globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../helpers/globals */ "./src/helpers/globals.js"); -/* harmony import */ var _helpers_datetime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../helpers/datetime */ "./src/helpers/datetime.js"); - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - - - -/** - * TimeZone component for GatherPress. - * - * This component allows users to select their preferred time zone from a list of choices. - * It includes a SelectControl with options grouped by regions. The selected time zone is - * stored in the state and broadcasted using the Broadcaster utility. - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {string} props.timezone - The current selected time zone. - * @param {Function} props.setTimezone - Callback function to set the selected time zone. - * - * @return {JSX.Element} The rendered React component. - */ -const TimeZone = props => { - const { - timezone, - setTimezone - } = props; - const choices = (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.getFromGlobal)('misc.timezoneChoices'); - - // Run only once. - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { - setTimezone((0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.getFromGlobal)('eventDetails.dateTime.timezone')); - }, [setTimezone]); - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => { - (0,_helpers_broadcasting__WEBPACK_IMPORTED_MODULE_4__.Broadcaster)({ - setTimezone: (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.getFromGlobal)('eventDetails.dateTime.timezone') - }); - }); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.PanelRow, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_1__.SelectControl, { - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('Time Zone', 'gatherpress'), - value: (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_6__.maybeConvertUtcOffsetForSelect)(timezone), - onChange: value => { - value = (0,_helpers_datetime__WEBPACK_IMPORTED_MODULE_6__.maybeConvertUtcOffsetForDatabase)(value); - setTimezone(value); - (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.setToGlobal)('eventDetails.dateTime.timezone', value); - (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.enableSave)(); - } - }, Object.keys(choices).map(group => { - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("optgroup", { - key: group, - label: group - }, Object.keys(choices[group]).map(item => { - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("option", { - key: item, - value: item - }, choices[group][item]); - })); - }))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (TimeZone); - -/***/ }), - -/***/ "./src/helpers/broadcasting.js": -/*!*************************************!*\ - !*** ./src/helpers/broadcasting.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ Broadcaster: () => (/* binding */ Broadcaster), -/* harmony export */ Listener: () => (/* binding */ Listener) -/* harmony export */ }); -/** - * Broadcasts custom events based on the provided payload, optionally appending an identifier to each event type. - * - * @since 1.0.0 - * - * @param {Object} payload - An object containing data to be dispatched with custom events. - * @param {string} identifier - An optional identifier to append to each event type. - * - * @return {void} - */ -const Broadcaster = (payload, identifier = '') => { - for (const [key, value] of Object.entries(payload)) { - let type = key; - if (identifier) { - type += '_' + String(identifier); - } - const dispatcher = new CustomEvent(type, { - detail: value - }); - dispatchEvent(dispatcher); - } -}; - -/** - * Sets up event listeners for custom events based on the provided payload, optionally appending an identifier to each event type. - * When an event is triggered, the corresponding listener callback is executed with the event detail. - * - * @since 1.0.0 - * - * @param {Object} payload - An object specifying event types and their corresponding listener callbacks. - * @param {string} identifier - An optional identifier to append to each event type. - * - * @return {void} - */ -const Listener = (payload, identifier = '') => { - for (const [key, value] of Object.entries(payload)) { - let type = key; - if (identifier) { - type += '_' + String(identifier); - } - addEventListener(type, e => { - value(e.detail); - }, false); - } -}; - -/***/ }), - -/***/ "./src/helpers/datetime.js": -/*!*********************************!*\ - !*** ./src/helpers/datetime.js ***! - \*********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ convertPHPToMomentFormat: () => (/* binding */ convertPHPToMomentFormat), -/* harmony export */ dateTimeDatabaseFormat: () => (/* binding */ dateTimeDatabaseFormat), -/* harmony export */ dateTimeLabelFormat: () => (/* binding */ dateTimeLabelFormat), -/* harmony export */ dateTimeMomentFormat: () => (/* binding */ dateTimeMomentFormat), -/* harmony export */ dateTimePreview: () => (/* binding */ dateTimePreview), -/* harmony export */ defaultDateTimeEnd: () => (/* binding */ defaultDateTimeEnd), -/* harmony export */ defaultDateTimeStart: () => (/* binding */ defaultDateTimeStart), -/* harmony export */ getDateTimeEnd: () => (/* binding */ getDateTimeEnd), -/* harmony export */ getDateTimeStart: () => (/* binding */ getDateTimeStart), -/* harmony export */ getTimeZone: () => (/* binding */ getTimeZone), -/* harmony export */ getUtcOffset: () => (/* binding */ getUtcOffset), -/* harmony export */ maybeConvertUtcOffsetForDatabase: () => (/* binding */ maybeConvertUtcOffsetForDatabase), -/* harmony export */ maybeConvertUtcOffsetForDisplay: () => (/* binding */ maybeConvertUtcOffsetForDisplay), -/* harmony export */ maybeConvertUtcOffsetForSelect: () => (/* binding */ maybeConvertUtcOffsetForSelect), -/* harmony export */ saveDateTime: () => (/* binding */ saveDateTime), -/* harmony export */ updateDateTimeEnd: () => (/* binding */ updateDateTimeEnd), -/* harmony export */ updateDateTimeStart: () => (/* binding */ updateDateTimeStart), -/* harmony export */ validateDateTimeEnd: () => (/* binding */ validateDateTimeEnd), -/* harmony export */ validateDateTimeStart: () => (/* binding */ validateDateTimeStart) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! moment */ "moment"); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./globals */ "./src/helpers/globals.js"); -/* harmony import */ var _event__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./event */ "./src/helpers/event.js"); -/* harmony import */ var _components_DateTimePreview__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../components/DateTimePreview */ "./src/components/DateTimePreview.js"); - -/** - * External dependencies. - */ - - -/** - * WordPress dependencies. - */ - - - - - -/** - * Internal dependencies. - */ - - - - -/** - * Date and time format string for use with Moment.js. - * - * This format is designed to represent date and time in the format - * "YYYY-MM-DDTHH:mm:ss" for compatibility with Moment.js library. - * - * @since 1.0.0 - * - * @type {string} - */ -const dateTimeMomentFormat = 'YYYY-MM-DDTHH:mm:ss'; - -/** - * Database-compatible date and time format string for storage. - * - * This format is designed to represent date and time in the format - * "YYYY-MM-DD HH:mm:ss" for compatibility with database storage. - * - * @since 1.0.0 - * - * @type {string} - */ -const dateTimeDatabaseFormat = 'YYYY-MM-DD HH:mm:ss'; - -/** - * The default start date and time for an event. - * It is set to the current date and time plus one day at 18:00:00 in the application's timezone. - * - * @since 1.0.0 - * - * @type {string} Formatted default start date and time in the application's timezone. - */ -const defaultDateTimeStart = moment__WEBPACK_IMPORTED_MODULE_1___default().tz(getTimeZone()).add(1, 'day').set('hour', 18).set('minute', 0).set('second', 0).format(dateTimeMomentFormat); - -/** - * The default end date and time for an event. - * It is calculated based on the default start date and time plus two hours in the application's timezone. - * - * @since 1.0.0 - * - * @type {string} Formatted default end date and time in the application's timezone. - */ -const defaultDateTimeEnd = moment__WEBPACK_IMPORTED_MODULE_1___default().tz(defaultDateTimeStart, getTimeZone()).add(2, 'hours').format(dateTimeMomentFormat); - -/** - * Get the combined date and time format for event labels. - * - * This function retrieves the date and time formats from global settings - * and combines them to create a formatted label for event start and end times. - * - * @since 1.0.0 - * - * @return {string} The combined date and time format for event labels. - */ -function dateTimeLabelFormat() { - const dateFormat = convertPHPToMomentFormat((0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('settings.dateFormat')); - const timeFormat = convertPHPToMomentFormat((0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('settings.timeFormat')); - return dateFormat + ' ' + timeFormat; -} - -/** - * Retrieves the timezone for the application based on the provided timezone or the global setting. - * If the provided timezone is invalid, the default timezone is set to 'GMT'. - * - * @since 1.0.0 - * - * @param {string} timezone - The timezone to be used, defaults to the global setting 'event_datetime.timezone'. - * - * @return {string} The retrieved timezone, or 'GMT' if the provided timezone is invalid. - */ -function getTimeZone(timezone = (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.timezone')) { - if (!!moment__WEBPACK_IMPORTED_MODULE_1___default().tz.zone(timezone)) { - return timezone; - } - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('GMT', 'gatherpress'); -} - -/** - * Retrieves the UTC offset for a given timezone. - * If the timezone is not set to 'GMT', an empty string is returned. - * - * @since 1.0.0 - * - * @param {string} timezone - The timezone for which to retrieve the UTC offset. - * - * @return {string} UTC offset without the colon if the timezone is set to 'GMT', otherwise an empty string. - */ -function getUtcOffset(timezone) { - timezone = getTimeZone(timezone); - if ((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_4__.__)('GMT', 'gatherpress') !== timezone) { - return ''; - } - const offset = (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.timezone'); - return maybeConvertUtcOffsetForDisplay(offset); -} - -/** - * Converts a UTC offset string to a format suitable for display, - * removing the colon (:) between hours and minutes. - * - * @since 1.0.0 - * - * @param {string} offset - The UTC offset string to be converted. - * - * @return {string} Converted UTC offset without the colon, suitable for display. - */ -function maybeConvertUtcOffsetForDisplay(offset = '') { - return offset.replace(':', ''); -} - -/** - * Converts a UTC offset string to a standardized format suitable for database storage. - * The function accepts offsets in the form of 'UTC+HH:mm', 'UTC-HH:mm', 'UTC+HH', or 'UTC-HH'. - * The resulting format is '+HH:mm' or '-HH:mm'. - * - * @since 1.0.0 - * - * @param {string} offset - The UTC offset string to be converted. - * - * @return {string} Converted UTC offset in the format '+HH:mm' or '-HH:mm'. - */ -function maybeConvertUtcOffsetForDatabase(offset = '') { - // Regex: https://regex101.com/r/9bMgJd/2. - const pattern = /^UTC([+-])(\d+)(.\d+)?$/; - const sign = offset.replace(pattern, '$1'); - if (sign !== offset) { - const hour = offset.replace(pattern, '$2').padStart(2, '0'); - let minute = offset.replace(pattern, '$3'); - if ('' === minute) { - minute = ':00'; - } - minute = minute.replace('.25', ':15').replace('.5', ':30').replace('.75', ':45'); - return sign + hour + minute; - } - return offset; -} - -/** - * Converts a UTC offset string to a format suitable for dropdown selection, - * specifically in the format '+HH:mm' or '-HH:mm'. - * - * @since 1.0.0 - * - * @param {string} offset - The UTC offset string to be converted. - * - * @return {string} Converted UTC offset in the format '+HH:mm' or '-HH:mm'. - */ -function maybeConvertUtcOffsetForSelect(offset = '') { - // Regex: https://regex101.com/r/nOXCPo/2. - const pattern = /^([+-])(\d{2}):(00|15|30|45)$/; - const sign = offset.replace(pattern, '$1'); - if (sign !== offset) { - const hour = parseInt(offset.replace(pattern, '$2')).toString(); - const minute = offset.replace(pattern, '$3').replace('00', '').replace('15', '.25').replace('30', '.5').replace('45', '.75'); - return 'UTC' + sign + hour + minute; - } - return offset; -} - -/** - * Retrieves the start date and time for an event, formatted based on the plugin's timezone. - * If the start date and time is not set, it defaults to a predefined value. - * The formatted datetime is then stored in the global settings for future access. - * - * @since 1.0.0 - * - * @return {string} The formatted start date and time for the event. - */ -function getDateTimeStart() { - let dateTime = (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.datetime_start'); - dateTime = '' !== dateTime ? moment__WEBPACK_IMPORTED_MODULE_1___default().tz(dateTime, getTimeZone()).format(dateTimeMomentFormat) : defaultDateTimeStart; - (0,_globals__WEBPACK_IMPORTED_MODULE_6__.setToGlobal)('eventDetails.dateTime.datetime_start', dateTime); - return dateTime; -} - -/** - * Retrieves the end date and time for an event, formatted based on the plugin's timezone. - * If the end date and time is not set, it defaults to a predefined value. - * The formatted datetime is then stored in the global settings for future access. - * - * @since 1.0.0 - * - * @return {string} The formatted end date and time for the event. - */ -function getDateTimeEnd() { - let dateTime = (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.datetime_end'); - dateTime = '' !== dateTime ? moment__WEBPACK_IMPORTED_MODULE_1___default().tz(dateTime, getTimeZone()).format(dateTimeMomentFormat) : defaultDateTimeEnd; - (0,_globals__WEBPACK_IMPORTED_MODULE_6__.setToGlobal)('eventDetails.dateTime.datetime_end', dateTime); - return dateTime; -} - -/** - * Updates the start date and time for an event, performs validation, and triggers the save functionality. - * - * @since 1.0.0 - * - * @param {string} date - The new start date and time to be set. - * @param {Function} setDateTimeStart - Optional callback function to update the state or perform additional actions. - * - * @return {void} - */ -function updateDateTimeStart(date, setDateTimeStart = null) { - validateDateTimeStart(date); - (0,_globals__WEBPACK_IMPORTED_MODULE_6__.setToGlobal)('eventDetails.dateTime.datetime_start', date); - if ('function' === typeof setDateTimeStart) { - setDateTimeStart(date); - } - (0,_globals__WEBPACK_IMPORTED_MODULE_6__.enableSave)(); -} - -/** - * Update the end date and time of the event and trigger necessary actions. - * - * This function sets the end date and time of the event to the specified value, - * validates the input, and triggers additional actions such as updating the UI. - * - * @since 1.0.0 - * - * @param {string} date - The new end date and time in a valid format. - * @param {Function|null} setDateTimeEnd - Optional callback to update the UI with the new end date and time. - * - * @return {void} - */ -function updateDateTimeEnd(date, setDateTimeEnd = null) { - validateDateTimeEnd(date); - (0,_globals__WEBPACK_IMPORTED_MODULE_6__.setToGlobal)('eventDetails.dateTime.datetime_end', date); - if (null !== setDateTimeEnd) { - setDateTimeEnd(date); - } - (0,_globals__WEBPACK_IMPORTED_MODULE_6__.enableSave)(); -} - -/** - * Validate the start date and time of the event and perform necessary adjustments if needed. - * - * This function compares the provided start date and time with the current end date - * and time of the event. If the start date is greater than or equal to the end date, - * it adjusts the end date to ensure a minimum two-hour duration. - * - * @since 1.0.0 - * - * @param {string} dateTimeStart - The start date and time in a valid format. - * - * @return {void} - */ -function validateDateTimeStart(dateTimeStart) { - const dateTimeEndNumeric = moment__WEBPACK_IMPORTED_MODULE_1___default().tz((0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.datetime_end'), getTimeZone()).valueOf(); - const dateTimeStartNumeric = moment__WEBPACK_IMPORTED_MODULE_1___default().tz(dateTimeStart, getTimeZone()).valueOf(); - if (dateTimeStartNumeric >= dateTimeEndNumeric) { - const dateTimeEnd = moment__WEBPACK_IMPORTED_MODULE_1___default().tz(dateTimeStartNumeric, getTimeZone()).add(2, 'hours').format(dateTimeMomentFormat); - updateDateTimeEnd(dateTimeEnd); - } -} - -/** - * Validate the end date and time of the event and perform necessary adjustments if needed. - * - * This function compares the provided end date and time with the current start date - * and time of the event. If the end date is less than or equal to the start date, - * it adjusts the start date to ensure a minimum two-hour duration. - * - * @since 1.0.0 - * - * @param {string} dateTimeEnd - The end date and time in a valid format. - * - * @return {void} - */ -function validateDateTimeEnd(dateTimeEnd) { - const dateTimeStartNumeric = moment__WEBPACK_IMPORTED_MODULE_1___default().tz((0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.datetime_start'), getTimeZone()).valueOf(); - const dateTimeEndNumeric = moment__WEBPACK_IMPORTED_MODULE_1___default().tz(dateTimeEnd, getTimeZone()).valueOf(); - if (dateTimeEndNumeric <= dateTimeStartNumeric) { - const dateTimeStart = moment__WEBPACK_IMPORTED_MODULE_1___default().tz(dateTimeEndNumeric, getTimeZone()).subtract(2, 'hours').format(dateTimeMomentFormat); - updateDateTimeStart(dateTimeStart); - } -} - -/** - * Save the event date, time, and timezone to the server. - * - * This function sends a POST request to the server with the updated event date, - * time, and timezone information for storage. It is triggered during the process - * of saving an event post in the WordPress editor. - * - * @since 1.0.0 - * - * @return {void} - */ -function saveDateTime() { - const isSavingPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('core/editor').isSavingPost(), - isAutosavingPost = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_2__.select)('core/editor').isAutosavingPost(); - if ((0,_event__WEBPACK_IMPORTED_MODULE_7__.isEventPostType)() && isSavingPost && !isAutosavingPost) { - _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_3___default()({ - path: (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('urls.eventRestApi') + '/datetime', - method: 'POST', - data: { - post_id: (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.postId'), - datetime_start: moment__WEBPACK_IMPORTED_MODULE_1___default().tz((0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.datetime_start'), getTimeZone()).format(dateTimeDatabaseFormat), - datetime_end: moment__WEBPACK_IMPORTED_MODULE_1___default().tz((0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.datetime_end'), getTimeZone()).format(dateTimeDatabaseFormat), - timezone: (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('eventDetails.dateTime.timezone'), - _wpnonce: (0,_globals__WEBPACK_IMPORTED_MODULE_6__.getFromGlobal)('misc.nonce') - } - }).then(() => { - (0,_event__WEBPACK_IMPORTED_MODULE_7__.triggerEventCommuncation)(); - }); - } -} - -/** - * Convert PHP date format to Moment.js date format. - * - * This function converts a PHP date format string to its equivalent Moment.js date format. - * It uses a mapping of PHP format characters to Moment.js format characters. - * - * @see https://gist.github.com/neilrackett/7881b5bef4cb4ae63af5c3a6a244cffa - * - * @since 1.0.0 - * - * @param {string} format - The PHP date format to be converted. - * @return {string} The equivalent Moment.js date format. - */ -function convertPHPToMomentFormat(format) { - const replacements = { - d: 'DD', - D: 'ddd', - j: 'D', - l: 'dddd', - N: 'E', - S: 'o', - w: 'e', - z: 'DDD', - W: 'W', - F: 'MMMM', - m: 'MM', - M: 'MMM', - n: 'M', - t: '', - // no equivalent - L: '', - // no equivalent - o: 'YYYY', - Y: 'YYYY', - y: 'YY', - a: 'a', - A: 'A', - B: '', - // no equivalent - g: 'h', - G: 'H', - h: 'hh', - H: 'HH', - i: 'mm', - s: 'ss', - u: 'SSS', - e: 'zz', - // deprecated since Moment.js 1.6.0 - I: '', - // no equivalent - O: '', - // no equivalent - P: '', - // no equivalent - T: '', - // no equivalent - Z: '', - // no equivalent - c: '', - // no equivalent - r: '', - // no equivalent - U: 'X' - }; - return String(format).split('').map(chr => chr in replacements ? replacements[chr] : chr).join(''); -} - -/** - * DateTime Preview Initialization - * - * This script initializes the DateTime Preview functionality for all elements - * with the attribute 'data-gp_component_name' set to 'datetime-preview'. - * It iterates through all matching elements and initializes a DateTimePreview component - * with the attributes provided in the 'data-gp_component_attrs' attribute. - * - * @since 1.0.0 - */ -function dateTimePreview() { - // Select all elements with the attribute 'data-gp_component_name' set to 'datetime-preview'. - const dateTimePreviewContainers = document.querySelectorAll(`[data-gp_component_name="datetime-preview"]`); - - // Iterate through each matched element and initialize DateTimePreview component. - for (let i = 0; i < dateTimePreviewContainers.length; i++) { - // Parse attributes from the 'data-gp_component_attrs' attribute. - const attrs = JSON.parse(dateTimePreviewContainers[i].dataset.gp_component_attrs); - - // Create a root element and render the DateTimePreview component with the parsed attributes. - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_5__.createRoot)(dateTimePreviewContainers[i]).render((0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_components_DateTimePreview__WEBPACK_IMPORTED_MODULE_8__["default"], { - attrs: attrs - })); - } -} - -/***/ }), - -/***/ "./src/helpers/event.js": -/*!******************************!*\ - !*** ./src/helpers/event.js ***! - \******************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ hasEventPast: () => (/* binding */ hasEventPast), -/* harmony export */ hasEventPastNotice: () => (/* binding */ hasEventPastNotice), -/* harmony export */ isEventPostType: () => (/* binding */ isEventPostType), -/* harmony export */ triggerEventCommuncation: () => (/* binding */ triggerEventCommuncation) -/* harmony export */ }); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! moment */ "moment"); -/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _datetime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./datetime */ "./src/helpers/datetime.js"); -/* harmony import */ var _globals__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./globals */ "./src/helpers/globals.js"); -/* harmony import */ var _broadcasting__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./broadcasting */ "./src/helpers/broadcasting.js"); -/** - * External dependencies. - */ - - -/** - * WordPress dependencies. - */ - - - -/** - * Internal dependencies. - */ - - - - -/** - * Checks if the current post type is an event in the GatherPress application. - * - * This function queries the current post type using the `select` function from the `core/editor` package. - * It returns `true` if the current post type is 'gp_event', indicating that the post is an event, - * and `false` otherwise. - * - * @since 1.0.0 - * - * @return {boolean} True if the current post type is 'gp_event', false otherwise. - */ -function isEventPostType() { - return 'gp_event' === (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('core/editor').getCurrentPostType(); -} - -/** - * Check if the event has already passed. - * - * This function compares the current time with the end time of the event - * to determine if the event has already taken place. - * - * @return {boolean} True if the event has passed; false otherwise. - */ -function hasEventPast() { - const dateTimeEnd = moment__WEBPACK_IMPORTED_MODULE_0___default().tz((0,_globals__WEBPACK_IMPORTED_MODULE_4__.getFromGlobal)('eventDetails.dateTime.datetime_end'), (0,_datetime__WEBPACK_IMPORTED_MODULE_3__.getTimeZone)()); - return 'gp_event' === (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('core/editor')?.getCurrentPostType() && moment__WEBPACK_IMPORTED_MODULE_0___default().tz((0,_datetime__WEBPACK_IMPORTED_MODULE_3__.getTimeZone)()).valueOf() > dateTimeEnd.valueOf(); -} - -/** - * Display a notice if the event has already passed. - * - * This function checks if the event has passed and displays a warning notice - * if so. The notice is non-dismissible to ensure the user is informed about - * the event status. - * - * @since 1.0.0 - * - * @return {void} - */ -function hasEventPastNotice() { - const id = 'gp_event_past'; - const notices = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('core/notices'); - notices.removeNotice(id); - if (hasEventPast()) { - notices.createNotice('warning', (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('This event has already past.', 'gatherpress'), { - id, - isDismissible: false - }); - } -} - -/** - * Trigger communication notice for event updates. - * - * This function checks if the event is published and not yet passed, - * then displays a success notice prompting the user to send an event update - * to members via email. The notice includes an action to compose the message. - * - * @since 1.0.0 - * - * @return {void} - */ -function triggerEventCommuncation() { - const id = 'gp_event_communcation'; - const notices = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.dispatch)('core/notices'); - notices.removeNotice(id); - if ('publish' === (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('core/editor').getEditedPostAttribute('status') && !hasEventPast()) { - notices.createNotice('success', (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Send an event update to members via email?', 'gatherpress'), { - id, - isDismissible: true, - actions: [{ - onClick: () => { - (0,_broadcasting__WEBPACK_IMPORTED_MODULE_5__.Broadcaster)({ - setOpen: true - }); - }, - label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Compose Message', 'gatherpress') - }] - }); - } -} - -/***/ }), - -/***/ "./src/helpers/globals.js": -/*!********************************!*\ - !*** ./src/helpers/globals.js ***! - \********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ enableSave: () => (/* binding */ enableSave), -/* harmony export */ getFromGlobal: () => (/* binding */ getFromGlobal), -/* harmony export */ isSinglePostInEditor: () => (/* binding */ isSinglePostInEditor), -/* harmony export */ setToGlobal: () => (/* binding */ setToGlobal) -/* harmony export */ }); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); - - -/** - * Enable the Save buttons after making an update. - * - * This function uses a hacky approach to trigger a change in the post's meta, which prompts - * Gutenberg to recognize that changes have been made and enables the Save buttons. - * It dispatches an editPost action with a non-existing meta key. - * - * @since 1.0.0 - * - * @todo This is a hacky approach and relies on the behavior described in - * https://github.com/WordPress/gutenberg/issues/13774. - * Monitor the issue for any updates or changes in the Gutenberg behavior. - */ -function enableSave() { - (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.dispatch)('core/editor')?.editPost({ - meta: { - _non_existing_meta: true - } - }); -} - -/** - * Checks if the current editor session is editing a post type entity. - * - * This function determines if the current context within the WordPress editor - * is focused on editing an entity that is classified as a post type. This includes - * single posts, pages, and custom post types. It is particularly useful for distinguishing - * editor sessions that are editing post type entities from those editing other types of content, - * such as widget areas or templates in the full site editor, ensuring that specific actions or features - * are correctly applied only when editing post type entities. - * - * @return {boolean} True if the current editor session is for editing a post type entity, false otherwise. - */ -function isSinglePostInEditor() { - return 'string' === typeof (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.select)('core/editor')?.getCurrentPostType(); -} - -/** - * Get a value from the global GatherPress object based on the provided dot-separated path. - * - * This function is designed to retrieve values from the global GatherPress object. - * It takes a dot-separated path as an argument and traverses the object to return the specified value. - * If the object or any level along the path is undefined, it returns undefined. - * - * @since 1.0.0 - * - * @param {string} args - Dot-separated path to the desired property in the GatherPress global object. - * @return {*} The value at the specified path in the GatherPress global object or undefined if not found. - */ -function getFromGlobal(args) { - // eslint-disable-next-line no-undef - if ('object' !== typeof GatherPress) { - return undefined; - } - return args.split('.').reduce( - // eslint-disable-next-line no-undef - (GatherPress, level) => GatherPress && GatherPress[level], - // eslint-disable-next-line no-undef - GatherPress); -} - -/** - * Set a value to a global object based on the provided path. - * - * This function allows setting values within a nested global object using a dot-separated path. - * If the global object (GatherPress) does not exist, it will be initialized. - * - * @since 1.0.0 - * - * @param {string} args - Dot-separated path to the property. - * @param {*} value - The value to set. - * - * @return {void} - */ -function setToGlobal(args, value) { - // eslint-disable-next-line no-undef - if ('object' !== typeof GatherPress) { - return; - } - const properties = args.split('.'); - const last = properties.pop(); - - // eslint-disable-next-line no-undef - properties.reduce((all, item) => { - var _all$item; - return (_all$item = all[item]) !== null && _all$item !== void 0 ? _all$item : all[item] = {}; - }, GatherPress)[last] = value; -} - -/***/ }), - -/***/ "./src/blocks/event-date/style.scss": -/*!******************************************!*\ - !*** ./src/blocks/event-date/style.scss ***! - \******************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -__webpack_require__.r(__webpack_exports__); -// extracted by mini-css-extract-plugin - - -/***/ }), - -/***/ "react": -/*!************************!*\ - !*** external "React" ***! - \************************/ -/***/ ((module) => { - -module.exports = window["React"]; - -/***/ }), - -/***/ "moment": -/*!*************************!*\ - !*** external "moment" ***! - \*************************/ -/***/ ((module) => { - -module.exports = window["moment"]; - -/***/ }), - -/***/ "@wordpress/api-fetch": -/*!**********************************!*\ - !*** external ["wp","apiFetch"] ***! - \**********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["apiFetch"]; - -/***/ }), - -/***/ "@wordpress/block-editor": -/*!*************************************!*\ - !*** external ["wp","blockEditor"] ***! - \*************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blockEditor"]; - -/***/ }), - -/***/ "@wordpress/blocks": -/*!********************************!*\ - !*** external ["wp","blocks"] ***! - \********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["blocks"]; - -/***/ }), - -/***/ "@wordpress/components": -/*!************************************!*\ - !*** external ["wp","components"] ***! - \************************************/ -/***/ ((module) => { - -module.exports = window["wp"]["components"]; - -/***/ }), - -/***/ "@wordpress/data": -/*!******************************!*\ - !*** external ["wp","data"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["data"]; - -/***/ }), - -/***/ "@wordpress/date": -/*!******************************!*\ - !*** external ["wp","date"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["date"]; - -/***/ }), - -/***/ "@wordpress/element": -/*!*********************************!*\ - !*** external ["wp","element"] ***! - \*********************************/ -/***/ ((module) => { - -module.exports = window["wp"]["element"]; - -/***/ }), - -/***/ "@wordpress/i18n": -/*!******************************!*\ - !*** external ["wp","i18n"] ***! - \******************************/ -/***/ ((module) => { - -module.exports = window["wp"]["i18n"]; - -/***/ }), - -/***/ "./src/blocks/event-date/block.json": -/*!******************************************!*\ - !*** ./src/blocks/event-date/block.json ***! - \******************************************/ -/***/ ((module) => { - -module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"gatherpress/event-date","version":"1.0.0","title":"Event Date","category":"gatherpress","icon":"clock","example":{},"description":"Displays the date and time for an event.","attributes":{"eventEnd":{"type":"string"},"eventStart":{"type":"string"}},"supports":{"html":false},"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css","render":"file:./render.php"}'); - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = __webpack_modules__; -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/chunk loaded */ -/******/ (() => { -/******/ var deferred = []; -/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { -/******/ if(chunkIds) { -/******/ priority = priority || 0; -/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; -/******/ deferred[i] = [chunkIds, fn, priority]; -/******/ return; -/******/ } -/******/ var notFulfilled = Infinity; -/******/ for (var i = 0; i < deferred.length; i++) { -/******/ var [chunkIds, fn, priority] = deferred[i]; -/******/ var fulfilled = true; -/******/ for (var j = 0; j < chunkIds.length; j++) { -/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { -/******/ chunkIds.splice(j--, 1); -/******/ } else { -/******/ fulfilled = false; -/******/ if(priority < notFulfilled) notFulfilled = priority; -/******/ } -/******/ } -/******/ if(fulfilled) { -/******/ deferred.splice(i--, 1) -/******/ var r = fn(); -/******/ if (r !== undefined) result = r; -/******/ } -/******/ } -/******/ return result; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/define property getters */ -/******/ (() => { -/******/ // define getter functions for harmony exports -/******/ __webpack_require__.d = (exports, definition) => { -/******/ for(var key in definition) { -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); -/******/ } -/******/ } -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/hasOwnProperty shorthand */ -/******/ (() => { -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) -/******/ })(); -/******/ -/******/ /* webpack/runtime/make namespace object */ -/******/ (() => { -/******/ // define __esModule on exports -/******/ __webpack_require__.r = (exports) => { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ })(); -/******/ -/******/ /* webpack/runtime/jsonp chunk loading */ -/******/ (() => { -/******/ // no baseURI -/******/ -/******/ // object to store loaded and loading chunks -/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched -/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded -/******/ var installedChunks = { -/******/ "blocks/event-date/index": 0, -/******/ "blocks/event-date/style-index": 0 -/******/ }; -/******/ -/******/ // no chunk on demand loading -/******/ -/******/ // no prefetching -/******/ -/******/ // no preloaded -/******/ -/******/ // no HMR -/******/ -/******/ // no HMR manifest -/******/ -/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); -/******/ -/******/ // install a JSONP callback for chunk loading -/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { -/******/ var [chunkIds, moreModules, runtime] = data; -/******/ // add "moreModules" to the modules object, -/******/ // then flag all "chunkIds" as loaded and fire callback -/******/ var moduleId, chunkId, i = 0; -/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { -/******/ for(moduleId in moreModules) { -/******/ if(__webpack_require__.o(moreModules, moduleId)) { -/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; -/******/ } -/******/ } -/******/ if(runtime) var result = runtime(__webpack_require__); -/******/ } -/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); -/******/ for(;i < chunkIds.length; i++) { -/******/ chunkId = chunkIds[i]; -/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { -/******/ installedChunks[chunkId][0](); -/******/ } -/******/ installedChunks[chunkId] = 0; -/******/ } -/******/ return __webpack_require__.O(result); -/******/ } -/******/ -/******/ var chunkLoadingGlobal = globalThis["webpackChunkgatherpress"] = globalThis["webpackChunkgatherpress"] || []; -/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); -/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); -/******/ })(); -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module depends on other loaded chunks and execution need to be delayed -/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["blocks/event-date/style-index"], () => (__webpack_require__("./src/blocks/event-date/index.js"))) -/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); -/******/ -/******/ })() -; -//# sourceMappingURL=index.js.map \ No newline at end of file +(()=>{"use strict";var e,t={9554:(e,t,n)=>{const r=window.wp.blocks,a=window.React,i=window.moment;var s=n.n(i);const o=window.wp.i18n,l=window.wp.blockEditor,c=window.wp.components,m=window.wp.element,d=(e,t="")=>{for(const[n,r]of Object.entries(e)){let e=n;t&&(e+="_"+String(t));const a=new CustomEvent(e,{detail:r});dispatchEvent(a)}},p=window.wp.data,u=window.wp.apiFetch;var f=n.n(u);function g(){(0,p.dispatch)("core/editor")?.editPost({meta:{_non_existing_meta:!0}})}function v(e){if("object"==typeof GatherPress)return e.split(".").reduce(((e,t)=>e&&e[t]),GatherPress)}function T(e,t){if("object"!=typeof GatherPress)return;const n=e.split("."),r=n.pop();n.reduce(((e,t)=>{var n;return null!==(n=e[t])&&void 0!==n?n:e[t]={}}),GatherPress)[r]=t}function h(){const e=s().tz(v("eventDetails.dateTime.datetime_end"),y());return"gp_event"===(0,p.select)("core/editor")?.getCurrentPostType()&&s().tz(y()).valueOf()>e.valueOf()}function E(){const e="gp_event_past",t=(0,p.dispatch)("core/notices");t.removeNotice(e),h()&&t.createNotice("warning",(0,o.__)("This event has already past.","gatherpress"),{id:e,isDismissible:!1})}const D=window.wp.date,_="YYYY-MM-DDTHH:mm:ss",w="YYYY-MM-DD HH:mm:ss",z=s().tz(y()).add(1,"day").set("hour",18).set("minute",0).set("second",0).format(_),b=s().tz(z,y()).add(2,"hours").format(_);function S(){return x(v("settings.dateFormat"))+" "+x(v("settings.timeFormat"))}function y(e=v("eventDetails.dateTime.timezone")){return s().tz.zone(e)?e:(0,o.__)("GMT","gatherpress")}function O(e=""){const t=/^([+-])(\d{2}):(00|15|30|45)$/,n=e.replace(t,"$1");return n!==e?"UTC"+n+parseInt(e.replace(t,"$2")).toString()+e.replace(t,"$3").replace("00","").replace("15",".25").replace("30",".5").replace("45",".75"):e}function k(e,t=null){!function(e){const t=s().tz(v("eventDetails.dateTime.datetime_end"),y()).valueOf(),n=s().tz(e,y()).valueOf();n>=t&&P(s().tz(n,y()).add(2,"hours").format(_))}(e),T("eventDetails.dateTime.datetime_start",e),"function"==typeof t&&t(e),g()}function P(e,t=null){!function(e){const t=s().tz(v("eventDetails.dateTime.datetime_start"),y()).valueOf(),n=s().tz(e,y()).valueOf();n<=t&&k(s().tz(n,y()).subtract(2,"hours").format(_))}(e),T("eventDetails.dateTime.datetime_end",e),null!==t&&t(e),g()}function C(){const e=(0,p.select)("core/editor").isSavingPost(),t=(0,p.select)("core/editor").isAutosavingPost();"gp_event"===(0,p.select)("core/editor").getCurrentPostType()&&e&&!t&&f()({path:v("urls.eventRestApi")+"/datetime",method:"POST",data:{post_id:v("eventDetails.postId"),datetime_start:s().tz(v("eventDetails.dateTime.datetime_start"),y()).format(w),datetime_end:s().tz(v("eventDetails.dateTime.datetime_end"),y()).format(w),timezone:v("eventDetails.dateTime.timezone"),_wpnonce:v("misc.nonce")}}).then((()=>{!function(){const e="gp_event_communcation",t=(0,p.dispatch)("core/notices");t.removeNotice(e),"publish"!==(0,p.select)("core/editor").getEditedPostAttribute("status")||h()||t.createNotice("success",(0,o.__)("Send an event update to members via email?","gatherpress"),{id:e,isDismissible:!0,actions:[{onClick:()=>{d({setOpen:!0})},label:(0,o.__)("Compose Message","gatherpress")}]})}()}))}function x(e){const t={d:"DD",D:"ddd",j:"D",l:"dddd",N:"E",S:"o",w:"e",z:"DDD",W:"W",F:"MMMM",m:"MM",M:"MMM",n:"M",t:"",L:"",o:"YYYY",Y:"YYYY",y:"YY",a:"a",A:"A",B:"",g:"h",G:"H",h:"hh",H:"HH",i:"mm",s:"ss",u:"SSS",e:"zz",I:"",O:"",P:"",T:"",Z:"",c:"",r:"",U:"X"};return String(e).split("").map((e=>e in t?t[e]:e)).join("")}const M=e=>{const{isSelected:t}=e,n=t?"none":"block";return(0,a.createElement)("div",{style:{position:"relative"}},e.children,(0,a.createElement)("div",{style:{position:"absolute",top:"0",right:"0",bottom:"0",left:"0",display:n}}))},Y=e=>{const{dateTimeStart:t}=e;return s().tz(t,y()).format(S())},F=e=>{const{dateTimeEnd:t}=e;return s().tz(t,y()).format(S())},j=e=>{const{dateTimeStart:t,setDateTimeStart:n}=e,r=(0,D.getSettings)(),i=/a(?!\\)/i.test(r.formats.time.toLowerCase().replace(/\\\\/g,"").split("").reverse().join(""));return(0,a.createElement)(c.DateTimePicker,{currentDate:t,onChange:e=>k(e,n),is12Hour:i})},$=e=>{const{dateTimeEnd:t,setDateTimeEnd:n}=e,r=(0,D.getSettings)(),i=/a(?!\\)/i.test(r.formats.time.toLowerCase().replace(/\\\\/g,"").split("").reverse().join(""));return(0,a.createElement)(c.DateTimePicker,{currentDate:t,onChange:e=>P(e,n),is12Hour:i})},I=e=>{const{dateTimeStart:t,setDateTimeStart:n}=e;return(0,m.useEffect)((()=>{n(s().tz(function(){let e=v("eventDetails.dateTime.datetime_start");return e=""!==e?s().tz(e,y()).format(_):z,T("eventDetails.dateTime.datetime_start",e),e}(),y()).format(_)),d({setDateTimeStart:t}),E()})),(0,a.createElement)(c.PanelRow,null,(0,a.createElement)(c.Flex,{direction:"column",gap:"0"},(0,a.createElement)(c.FlexItem,null,(0,a.createElement)("label",{htmlFor:"gp-datetime-start"},(0,o.__)("Start","gatherpress"))),(0,a.createElement)(c.FlexItem,null,(0,a.createElement)(c.Dropdown,{popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:n})=>(0,a.createElement)(c.Button,{id:"gp-datetime-start",onClick:n,"aria-expanded":e,isLink:!0},(0,a.createElement)(Y,{dateTimeStart:t})),renderContent:()=>(0,a.createElement)(j,{dateTimeStart:t,setDateTimeStart:n})}))))},H=e=>{const{dateTimeEnd:t,setDateTimeEnd:n}=e;return(0,m.useEffect)((()=>{n(s().tz(function(){let e=v("eventDetails.dateTime.datetime_end");return e=""!==e?s().tz(e,y()).format(_):b,T("eventDetails.dateTime.datetime_end",e),e}(),y()).format(_)),d({setDateTimeEnd:t}),E()})),(0,a.createElement)(c.PanelRow,null,(0,a.createElement)(c.Flex,{direction:"column",gap:"0"},(0,a.createElement)(c.FlexItem,null,(0,a.createElement)("label",{htmlFor:"gp-datetime-end"},(0,o.__)("End","gatherpress"))),(0,a.createElement)(c.FlexItem,null,(0,a.createElement)(c.Dropdown,{popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:n})=>(0,a.createElement)(c.Button,{id:"gp-datetime-end",onClick:n,"aria-expanded":e,isLink:!0},(0,a.createElement)(F,{dateTimeEnd:t})),renderContent:()=>(0,a.createElement)($,{dateTimeEnd:t,setDateTimeEnd:n})}))))},G=e=>{const{timezone:t,setTimezone:n}=e,r=v("misc.timezoneChoices");return(0,m.useEffect)((()=>{n(v("eventDetails.dateTime.timezone"))}),[n]),(0,m.useEffect)((()=>{d({setTimezone:v("eventDetails.dateTime.timezone")})})),(0,a.createElement)(c.PanelRow,null,(0,a.createElement)(c.SelectControl,{label:(0,o.__)("Time Zone","gatherpress"),value:O(t),onChange:e=>{e=function(e=""){const t=/^UTC([+-])(\d+)(.\d+)?$/,n=e.replace(t,"$1");if(n!==e){const r=e.replace(t,"$2").padStart(2,"0");let a=e.replace(t,"$3");return""===a&&(a=":00"),a=a.replace(".25",":15").replace(".5",":30").replace(".75",":45"),n+r+a}return e}(e),n(e),T("eventDetails.dateTime.timezone",e),g()}},Object.keys(r).map((e=>(0,a.createElement)("optgroup",{key:e,label:e},Object.keys(r[e]).map((t=>(0,a.createElement)("option",{key:t,value:t},r[e][t]))))))))},N=()=>{const[e,t]=(0,m.useState)(),[n,r]=(0,m.useState)(),[i,s]=(0,m.useState)();return(0,p.subscribe)(C),(0,a.createElement)(a.Fragment,null,(0,a.createElement)("h3",null,(0,o.__)("Date & time","gatherpress")),(0,a.createElement)(I,{dateTimeStart:e,setDateTimeStart:t}),(0,a.createElement)(H,{dateTimeEnd:n,setDateTimeEnd:r}),(0,a.createElement)(G,{timezone:i,setTimezone:s}))},B=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"gatherpress/event-date","version":"1.0.0","title":"Event Date","category":"gatherpress","icon":"clock","example":{},"description":"Displays the date and time for an event.","attributes":{"eventEnd":{"type":"string"},"eventStart":{"type":"string"}},"supports":{"html":false},"textdomain":"gatherpress","editorScript":"file:./index.js","style":"file:./style-index.css","render":"file:./render.php"}');(0,r.registerBlockType)(B,{edit:()=>{const e=(0,l.useBlockProps)(),[t,n]=(0,m.useState)(z),[r,i]=(0,m.useState)(b),[d,u]=(0,m.useState)(y());return((e,t="")=>{for(const[n,r]of Object.entries(e)){let e=n;t&&(e+="_"+String(t)),addEventListener(e,(e=>{r(e.detail)}),!1)}})({setDateTimeEnd:i,setDateTimeStart:n,setTimezone:u}),(0,a.createElement)("div",{...e},(0,a.createElement)(M,null,(0,a.createElement)(c.Flex,{justify:"normal",align:"center",gap:"4"},(0,a.createElement)(c.FlexItem,{display:"flex",className:"gp-event-date__icon"},(0,a.createElement)(c.Icon,{icon:"clock"})),(0,a.createElement)(c.FlexItem,null,((e,t,n)=>{const r=x(v("settings.dateFormat")),a=x(v("settings.timeFormat")),i=v("settings.showTimezone")?"z":"",l=r+" "+a,c=y(n);let m=r+" "+a+" "+i;return s().tz(e,c).format(r)===s().tz(t,c).format(r)&&(m=a+" "+i),(0,o.sprintf)(/* translators: %1$s: datetime start, %2$s: datetime end, %3$s timezone. */ /* translators: %1$s: datetime start, %2$s: datetime end, %3$s timezone. */ +(0,o.__)("%1$s to %2$s %3$s","gatherpress"),s().tz(e,c).format(l),s().tz(t,c).format(m),(d=y(d=c),(0,o.__)("GMT","gatherpress")!==d?"":function(e=""){return e.replace(":","")}(v("eventDetails.dateTime.timezone"))));var d})(t,r,d)),"string"==typeof(0,p.select)("core/editor")?.getCurrentPostType()&&(0,a.createElement)(l.InspectorControls,null,(0,a.createElement)(c.PanelBody,null,(0,a.createElement)(N,null))))))},save:()=>null})}},n={};function r(e){var a=n[e];if(void 0!==a)return a.exports;var i=n[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.m=t,e=[],r.O=(t,n,a,i)=>{if(!n){var s=1/0;for(m=0;m=i)&&Object.keys(r.O).every((e=>r.O[e](n[l])))?n.splice(l--,1):(o=!1,i0&&e[m-1][2]>i;m--)e[m]=e[m-1];e[m]=[n,a,i]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={532:0,4:0};r.O.j=t=>0===e[t];var t=(t,n)=>{var a,i,[s,o,l]=n,c=0;if(s.some((t=>0!==e[t]))){for(a in o)r.o(o,a)&&(r.m[a]=o[a]);if(l)var m=l(r)}for(t&&t(n);cr(9554)));a=r.O(a)})(); \ No newline at end of file diff --git a/build/blocks/event-date/style-index.css b/build/blocks/event-date/style-index.css index 06d09e474..64a4cd1e2 100644 --- a/build/blocks/event-date/style-index.css +++ b/build/blocks/event-date/style-index.css @@ -1,17 +1 @@ -/*!*********************************************************************************************************************************************************************************************************************************************************!*\ - !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/blocks/event-date/style.scss ***! - \*********************************************************************************************************************************************************************************************************************************************************/ -.gp-event-date__icon { - align-items: flex-start; - display: flex; -} -.gp-event-date__item { - align-items: center; - display: flex; - gap: 0.75rem; -} -.gp-event-date__row { - display: flex; -} - -/*# sourceMappingURL=style-index.css.map*/ \ No newline at end of file +.gp-event-date__icon{align-items:flex-start;display:flex}.gp-event-date__item{align-items:center;display:flex;gap:.75rem}.gp-event-date__row{display:flex} diff --git a/build/blocks/events-list/events-list.asset.php b/build/blocks/events-list/events-list.asset.php index f56ea2b2b..18b7600bc 100644 --- a/build/blocks/events-list/events-list.asset.php +++ b/build/blocks/events-list/events-list.asset.php @@ -1 +1 @@ - array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '0738d21f316ca93bde1a'); + array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'a0cd383815fe382f153d'); diff --git a/build/blocks/events-list/events-list.js b/build/blocks/events-list/events-list.js index fb58fa66f..ec0218450 100644 --- a/build/blocks/events-list/events-list.js +++ b/build/blocks/events-list/events-list.js @@ -1,9304 +1,5 @@ -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ "./src/components/EventItem.js": -/*!*************************************!*\ - !*** ./src/components/EventItem.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var html_react_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! html-react-parser */ "./node_modules/html-react-parser/esm/index.mjs"); -/* harmony import */ var _Rsvp__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Rsvp */ "./src/components/Rsvp.js"); -/* harmony import */ var _RsvpResponseAvatarOnly__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./RsvpResponseAvatarOnly */ "./src/components/RsvpResponseAvatarOnly.js"); -/* harmony import */ var _RsvpStatusResponse__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RsvpStatusResponse */ "./src/components/RsvpStatusResponse.js"); - -/** - * External dependencies. - */ - - -/** - * Internal dependencies. - */ - - - - -/** - * EventItem component for GatherPress. - * - * This component represents an individual event item in the events list. - * It displays various details of the event, including the featured image, - * date and time, title, venue, and description. It also handles RSVP and - * RSVP response components based on the event type. - * - * @since 1.0.0 - * - * @param {Object} props - Component properties. - * @param {string} props.type - The type of the event (upcoming or past). - * @param {Object} props.event - The event data. - * @param {Object} props.eventOptions - Options for displaying the event. - * - * @return {JSX.Element} The rendered React component. - */ -const EventItem = props => { - const { - type, - event, - eventOptions - } = props; - const limitExcerpt = excerpt => { - return excerpt.split(' ').splice(0, parseInt(eventOptions.descriptionLimit)).join(' ') + '[…]'; - }; - const size = eventOptions.imageSize === 'default' ? 'featured_image' : 'featured_image_' + eventOptions.imageSize; - const featuredImage = (0,html_react_parser__WEBPACK_IMPORTED_MODULE_1__["default"])(event[size]); - const eventClass = `gp-events-list`; - let icon = 'location'; - const isOnlineEvent = event.venue?.is_online_event; - if (isOnlineEvent) { - icon = 'video-alt2'; - } - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__header` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__info` - }, eventOptions.showFeaturedImage && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("figure", { - className: `${eventClass}__image` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: event.permalink - }, featuredImage)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__datetime` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("strong", null, event.datetime_start)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__title` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: event.permalink - }, (0,html_react_parser__WEBPACK_IMPORTED_MODULE_1__["default"])(event.title))), event.venue && eventOptions.showVenue && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__venue` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { - className: `dashicons dashicons-${icon}` - }), !isOnlineEvent && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: event.venue.permalink - }, (0,html_react_parser__WEBPACK_IMPORTED_MODULE_1__["default"])(event.venue.name)), isOnlineEvent && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,html_react_parser__WEBPACK_IMPORTED_MODULE_1__["default"])(event.venue.name))), eventOptions.showDescription && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__content` - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__excerpt` - }, (0,html_react_parser__WEBPACK_IMPORTED_MODULE_1__["default"])(limitExcerpt(event.excerpt)))))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `${eventClass}__footer` - }, eventOptions.showRsvpResponse && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-rsvp-response__items" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_RsvpResponseAvatarOnly__WEBPACK_IMPORTED_MODULE_3__["default"], { - postId: event.ID, - value: "attending", - responses: event.responses, - limit: "3" - })), 'upcoming' === type && eventOptions.showRsvp && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_Rsvp__WEBPACK_IMPORTED_MODULE_2__["default"], { - postId: event.ID, - currentUser: event.current_user, - type: type, - enableAnonymousRsvp: event.enable_anonymous_rsvp, - enableInitialDecline: event.enable_initial_decline - }), 'past' === type && eventOptions.showRsvp && '' !== event.current_user && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_RsvpStatusResponse__WEBPACK_IMPORTED_MODULE_4__["default"], { - type: type, - status: event.current_user?.status - }))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EventItem); - -/***/ }), - -/***/ "./src/components/EventsList.js": -/*!**************************************!*\ - !*** ./src/components/EventsList.js ***! - \**************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _EventItem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./EventItem */ "./src/components/EventItem.js"); -/* harmony import */ var _helpers_globals__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../helpers/globals */ "./src/helpers/globals.js"); -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_6__); - -/** - * WordPress dependencies. - */ - - - - -/** - * Internal dependencies. - */ - - - - -/** - * EventsList component for GatherPress. - * - * This component displays a list of events based on the provided parameters. - * It retrieves the events from the server using the WordPress REST API or - * GatherPress custom API, depending on whether the user is logged in or not. - * - * @since 1.0.0 - * - * @param {Object} props - Component properties. - * @param {Object} props.eventOptions - Options for displaying each event in the list. - * @param {number} props.maxNumberOfEvents - The maximum number of events to display. - * @param {string} props.type - The type of events to retrieve ('upcoming' or 'past'). - * @param {Array} props.topics - An array of topic objects to filter events by. - * @param {Array} props.venues - An array of venue objects to filter events by. - * - * @return {JSX.Element} The rendered React component. - */ -const EventsList = props => { - const { - eventOptions, - maxNumberOfEvents, - datetimeFormat, - type, - topics, - venues - } = props; - const [events, setEvents] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)([]); - const [loaded, setLoaded] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(false); - const renderEvents = events.map(event => { - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_EventItem__WEBPACK_IMPORTED_MODULE_4__["default"], { - key: event.ID, - eventOptions: eventOptions, - type: type, - event: event - }); - }); - const renderNoEventsMessage = () => { - const message = 'upcoming' === type ? (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('There are no upcoming events.', 'gatherpress') : (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_3__.__)('There are no past events.', 'gatherpress'); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `gp-${type}-events__no_events_message` - }, message); - }; - (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useEffect)(() => { - let topicsString = ''; - let venuesString = ''; - if ('object' === typeof topics) { - topicsString = topics.map(topic => { - return topic.slug; - })?.join(','); - } - if ('object' === typeof venues) { - venuesString = venues.map(venue => { - return venue.slug; - })?.join(','); - } - const endpoint = (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.getFromGlobal)('urls.eventRestApi') + `/events-list?event_list_type=${type}&max_number=${maxNumberOfEvents}&datetime_format=${datetimeFormat}&topics=${topicsString}&venues=${venuesString}`; - - /** - * Check if user is logged in, so we have current_user for the event present, which - * allows them to interact with the block. - */ - if ((0,_helpers_globals__WEBPACK_IMPORTED_MODULE_5__.getFromGlobal)('misc.isUserLoggedIn')) { - _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_6___default()({ - path: endpoint - }).then(data => { - setLoaded(true); - setEvents(data); - }); - } else { - /** - * Not using apiFetch helper here as it will use X-Wp-Nonce and cache it when page caching is on causing a 403. - * - * @see https://github.com/GatherPress/gatherpress/issues/300 - */ - fetch(endpoint).then(response => { - return response.json(); - }).then(data => { - setLoaded(true); - setEvents(data); - }); - } - }, [setEvents, maxNumberOfEvents, datetimeFormat, type, topics, venues]); - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: `gp-${type}-events-list` - }, !loaded && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Spinner, null), loaded && 0 === events.length && renderNoEventsMessage(), loaded && renderEvents); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (EventsList); - -/***/ }), - -/***/ "./src/components/Rsvp.js": -/*!********************************!*\ - !*** ./src/components/Rsvp.js ***! - \********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var react_modal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-modal */ "./node_modules/react-modal/lib/index.js"); -/* harmony import */ var react_modal__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_modal__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var html_react_parser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! html-react-parser */ "./node_modules/html-react-parser/esm/index.mjs"); -/* harmony import */ var react_tooltip__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-tooltip */ "./node_modules/react-tooltip/dist/react-tooltip.min.mjs"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_6__); -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); -/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_7__); -/* harmony import */ var _helpers_broadcasting__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../helpers/broadcasting */ "./src/helpers/broadcasting.js"); -/* harmony import */ var _RsvpStatusResponse__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./RsvpStatusResponse */ "./src/components/RsvpStatusResponse.js"); -/* harmony import */ var _helpers_globals__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../helpers/globals */ "./src/helpers/globals.js"); - -/** - * External dependencies - */ - - - - -/** - * WordPress dependencies. - */ - - - - - -/** - * Internal Dependencies. - */ - - - - -/** - * Rsvp component for GatherPress. - * - * This component provides functionality for users to RSVP to events. It includes a button - * to open a modal for RSVP actions, handles different RSVP statuses, and updates the RSVP - * status and guest count accordingly. If the enableAnonymousRsvp prop is true, it shows - * a checkbox to permit anonymous RSVPs. The component communicates with the server through - * REST API calls and broadcasts changes to other components. - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {number} props.postId - The ID of the event. - * @param {Object} [props.currentUser=''] - Current user's RSVP information. - * @param {boolean} props.enableAnonymousRsvp - If true, shows a checkbox to allow anonymous RSVPs. - * @param {boolean} props.enableInitialDecline - If true, shows an option to decline attendance initially. - * @param {number} props.maxGuestLimit - The maximum number of guests allowed per RSVP. - * @param {string} props.type - Type of event ('upcoming' or 'past'). - * - * @return {JSX.Element} The rendered React component. - */ -const Rsvp = ({ - postId, - currentUser = '', - type, - enableAnonymousRsvp, - enableInitialDecline, - maxGuestLimit -}) => { - const [rsvpStatus, setRsvpStatus] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(currentUser.status); - const [rsvpAnonymous, setRsvpAnonymous] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(Number(currentUser.anonymous)); - const [rsvpGuests, setRsvpGuests] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(currentUser.guests); - const [selectorHidden, setSelectorHidden] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)('hidden'); - const [selectorExpanded, setSelectorExpanded] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)('false'); - const [modalIsOpen, setIsOpen] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(false); - const customStyles = { - overlay: { - zIndex: 999999999 - }, - content: { - top: '50%', - left: '50%', - right: 'auto', - bottom: 'auto', - marginRight: '-50%', - transform: 'translate(-50%, -50%)' - } - }; - const openModal = e => { - e.preventDefault(); - setIsOpen(true); - }; - - // No need to show block if event is in the past. - if ('past' === type) { - return ''; - } - - // Might be better way to do this, but should only run on frontend, not admin. - if ('undefined' === typeof adminpage) { - react_modal__WEBPACK_IMPORTED_MODULE_1___default().setAppElement('.gp-enabled'); - } - const closeModal = e => { - e.preventDefault(); - setIsOpen(false); - }; - const onAnchorClick = async (e, status, anonymous, guests = 0, close = true) => { - e.preventDefault(); - if ('attending' !== status) { - guests = 0; - } - _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_7___default()({ - path: (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('urls.eventRestApi') + '/rsvp', - method: 'POST', - data: { - post_id: postId, - status, - guests, - anonymous, - _wpnonce: (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('misc.nonce') - } - }).then(res => { - if (res.success) { - setRsvpStatus(res.status); - setRsvpGuests(res.guests); - const count = { - all: 0, - attending: 0, - not_attending: 0, - // eslint-disable-line camelcase - waiting_list: 0 // eslint-disable-line camelcase - }; - - for (const [key, value] of Object.entries(res.responses)) { - count[key] = value.count; - } - const payload = { - setRsvpStatus: res.status, - setRsvpResponse: res.responses, - setRsvpCount: count, - setRsvpSeeAllLink: count[res.status] > 8, - // @todo make defaultLimit a setting, not hardcoded. - setOnlineEventLink: res.online_link - }; - (0,_helpers_broadcasting__WEBPACK_IMPORTED_MODULE_8__.Broadcaster)(payload, res.event_id); - if (close) { - closeModal(e); - } - } - }); - }; - const getButtonText = status => { - switch (status) { - case 'attending': - case 'waiting_list': - case 'not_attending': - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Edit RSVP', 'gatherpress'); - } - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('RSVP', 'gatherpress'); - }; - const getModalLabel = status => { - switch (status) { - case 'attending': - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)("You're attending", 'gatherpress'); - case 'waiting_list': - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)("You're wait listed", 'gatherpress'); - case 'not_attending': - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)("You're not attending", 'gatherpress'); - } - return (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('RSVP to this event', 'gatherpress'); - }; - const onSpanKeyDown = e => { - if (13 === e.keyCode) { - setSelectorHidden('hidden' === selectorHidden ? 'show' : 'hidden'); - setSelectorExpanded('false' === selectorExpanded ? 'true' : 'false'); - } - }; - const LoggedOutModal = () => { - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal gp-modal__rsvp" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__header" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Login Required', 'gatherpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__content" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__text" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('You must ', 'gatherpress'), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('urls.loginUrl') - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Login', 'gatherpress')), (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)(' to RSVP to events.', 'gatherpress')), '' !== (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('urls.registrationUrl') && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__text" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: (0,_helpers_globals__WEBPACK_IMPORTED_MODULE_10__.getFromGlobal)('urls.registrationUrl') - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Register', 'gatherpress')), (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)(' if you do not have an account.', 'gatherpress'))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_6__.ButtonGroup, { - className: "gp-buttons wp-block-buttons" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-buttons__container wp-block-button" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: "#", - onClick: closeModal, - className: "gp-buttons__button wp-block-button__link" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Close', 'gatherpress'))))); - }; - const LoggedInModal = ({ - status - }) => { - let buttonStatus = ''; - let buttonLabel = ''; - if ('not_attending' === status || 'no_status' === status) { - buttonStatus = 'attending'; - buttonLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Attend', 'gatherpress'); - } else { - buttonStatus = 'not_attending'; - buttonLabel = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__._x)('Not Attending', 'action of not attending', 'gatherpress'); - } - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal gp-modal__rsvp" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__header" - }, getModalLabel(rsvpStatus) ? getModalLabel(rsvpStatus) : (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_6__.Spinner, null)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__content" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__text" - }, (0,html_react_parser__WEBPACK_IMPORTED_MODULE_2__["default"])((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.sprintf)( /* translators: %s: button label. */ - (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('To set or change your attending status, simply click the %s button below.', 'gatherpress'), '' + buttonLabel + ''))), 0 < maxGuestLimit && !rsvpAnonymous && 'attending' === rsvpStatus && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__guests" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { - htmlFor: "gp-guests" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Number of guests?', 'gatherpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("input", { - id: "gp-guests", - type: "number", - min: "0", - max: maxGuestLimit, - onChange: e => { - const value = Number(e.target.value); - setRsvpGuests(value); - onAnchorClick(e, rsvpStatus, rsvpAnonymous, value, false); - }, - defaultValue: rsvpGuests - })), enableAnonymousRsvp && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-modal__anonymous" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("input", { - id: "gp-anonymous", - type: "checkbox", - onChange: e => { - const value = Number(e.target.checked); - setRsvpAnonymous(value); - onAnchorClick(e, rsvpStatus, value, 0, false); - }, - checked: rsvpAnonymous - }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { - htmlFor: "gp-anonymous", - tabIndex: "0", - className: "gp-tooltip", - "data-tooltip-id": "gp-anonymous-tooltip", - "data-tooltip-content": (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Only admins will see your identity.', 'gatherpress') - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('List me as anonymous.', 'gatherpress')), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react_tooltip__WEBPACK_IMPORTED_MODULE_3__.Tooltip, { - id: "gp-anonymous-tooltip" - }))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_6__.ButtonGroup, { - className: "gp-buttons wp-block-buttons" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-buttons__container wp-block-button is-style-outline" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: "#", - onClick: e => onAnchorClick(e, buttonStatus, rsvpAnonymous, 'not_attending' !== buttonStatus ? rsvpGuests : 0, 'not_attending' === buttonStatus), - className: "gp-buttons__button wp-block-button__link" - }, buttonLabel)), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-buttons__container wp-block-button" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: "#", - onClick: closeModal, - className: "gp-buttons__button wp-block-button__link" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Close', 'gatherpress')))), enableInitialDecline && 'no_status' === rsvpStatus && 1 !== rsvpAnonymous ? (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_6__.ButtonGroup, { - className: "gp-buttons wp-block-buttons" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-buttons__container wp-block-button" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: "#", - onClick: e => onAnchorClick(e, 'not_attending', null), - className: "gp-buttons__text-link" - }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)("I can't attend", 'gatherpress')))) : (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null)); - }; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-rsvp" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_6__.ButtonGroup, { - className: "gp-buttons wp-block-buttons" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-buttons__container wp-block-button" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { - href: "#", - className: "gp-buttons__button wp-block-button__link", - "aria-expanded": selectorExpanded, - tabIndex: "0", - onKeyDown: onSpanKeyDown, - onClick: e => openModal(e) - }, getButtonText(rsvpStatus))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)((react_modal__WEBPACK_IMPORTED_MODULE_1___default()), { - isOpen: modalIsOpen, - onRequestClose: closeModal, - style: customStyles, - contentLabel: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.__)('Edit RSVP', 'gatherpress') - }, 0 === currentUser.length && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(LoggedOutModal, null), 0 !== currentUser.length && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(LoggedInModal, { - status: rsvpStatus - }))), 'no_status' !== rsvpStatus && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-status" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_RsvpStatusResponse__WEBPACK_IMPORTED_MODULE_9__["default"], { - type: type, - status: rsvpStatus - }), 0 < rsvpGuests && (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-status__guests" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, "+", ' ', (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__.sprintf)( /* translators: %d: Number of guests. */ - (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_5__._n)('%d guest', '%d guests', Number(rsvpGuests), 'gatherpress'), Number(rsvpGuests)))))); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Rsvp); - -/***/ }), - -/***/ "./src/components/RsvpResponseAvatarOnly.js": -/*!**************************************************!*\ - !*** ./src/components/RsvpResponseAvatarOnly.js ***! - \**************************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _helpers_broadcasting__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../helpers/broadcasting */ "./src/helpers/broadcasting.js"); - -/** - * WordPress dependencies. - */ - - -/** - * Internal dependencies. - */ - - -/** - * RsvpResponseCard component for GatherPress. - * - * This component displays avatars of attendees who have responded to an event's RSVP. - * It receives information about the RSVP responses, including the attendee's name and photo, - * and renders their avatars accordingly. The component listens for updates to the RSVP responses - * and dynamically reflects changes. - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {number} props.postId - The ID of the event. - * @param {string} props.value - The RSVP status value ('attending', 'not_attending', etc.). - * @param {number} props.limit - The maximum number of responses to display. - * @param {Array} [props.responses=[]] - An array of RSVP responses for the specified status. - * - * @return {JSX.Element} The rendered React component. - */ -const RsvpResponseCard = ({ - postId, - value, - limit, - responses = [] -}) => { - const [rsvpResponse, setRsvpResponse] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_1__.useState)(responses); - (0,_helpers_broadcasting__WEBPACK_IMPORTED_MODULE_2__.Listener)({ - setRsvpResponse - }, postId); - let renderedItems = ''; - if ('object' === typeof rsvpResponse && 'undefined' !== typeof rsvpResponse[value]) { - responses = [...rsvpResponse[value].responses]; - if (limit) { - responses = responses.splice(0, limit); - } - renderedItems = responses.map((response, index) => { - const { - name, - photo - } = response; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("figure", { - key: index, - className: "gp-rsvp-response__member-avatar" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", { - alt: name, - title: name, - src: photo - })); - }); - } - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, renderedItems); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RsvpResponseCard); - -/***/ }), - -/***/ "./src/components/RsvpStatusResponse.js": -/*!**********************************************!*\ - !*** ./src/components/RsvpStatusResponse.js ***! - \**********************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) -/* harmony export */ }); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); - -/** - * WordPress dependencies. - */ - - -/** - * RsvpStatusResponse component for GatherPress. - * - * This component displays the RSVP status response based on the event type (upcoming or past) - * and the provided status. It includes an icon and text representing the corresponding RSVP status. - * The component is typically used within the `Rsvp` component to show the user's RSVP status. - * - * @since 1.0.0 - * - * @param {Object} props - Component props. - * @param {string} [props.type='upcoming'] - The type of the event, either 'upcoming' or 'past'. - * @param {string} [props.status='no_status'] - The RSVP status, such as 'attending', 'waiting_list', 'not_attending', 'no_status'. - * - * @return {JSX.Element} The rendered React component. - */ -const RsvpStatusResponse = ({ - type = 'upcoming', - status = 'no_status' -}) => { - const responses = { - upcoming: { - attending: { - icon: 'dashicons dashicons-yes-alt', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)('Attending', 'Responded Status', 'gatherpress') - }, - waiting_list: { - icon: 'dashicons dashicons-editor-help', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)('Waiting List', 'Responded Status', 'gatherpress') - }, - not_attending: { - icon: 'dashicons dashicons-dismiss', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)('Not Attending', 'Responded Status', 'gatherpress') - }, - no_status: { - icon: '', - text: '' - } - }, - past: { - attending: { - icon: 'dashicons dashicons-yes-alt', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)('Went', 'Responded Status', 'gatherpress') - }, - waiting_list: { - icon: 'dashicons dashicons-dismiss', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)("Didn't Go", 'Responded Status', 'gatherpress') - }, - not_attending: { - icon: 'dashicons dashicons-dismiss', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)("Didn't Go", 'Responded Status', 'gatherpress') - }, - no_status: { - icon: 'dashicons dashicons-dismiss', - text: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__._x)("Didn't Go", 'Responded Status', 'gatherpress') - } - } - }; - return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { - className: "gp-status__response" - }, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", { - className: responses[type][status].icon - }), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("strong", null, responses[type][status].text)); -}; -/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RsvpStatusResponse); - -/***/ }), - -/***/ "./src/helpers/broadcasting.js": -/*!*************************************!*\ - !*** ./src/helpers/broadcasting.js ***! - \*************************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ Broadcaster: () => (/* binding */ Broadcaster), -/* harmony export */ Listener: () => (/* binding */ Listener) -/* harmony export */ }); -/** - * Broadcasts custom events based on the provided payload, optionally appending an identifier to each event type. - * - * @since 1.0.0 - * - * @param {Object} payload - An object containing data to be dispatched with custom events. - * @param {string} identifier - An optional identifier to append to each event type. - * - * @return {void} - */ -const Broadcaster = (payload, identifier = '') => { - for (const [key, value] of Object.entries(payload)) { - let type = key; - if (identifier) { - type += '_' + String(identifier); - } - const dispatcher = new CustomEvent(type, { - detail: value - }); - dispatchEvent(dispatcher); - } -}; - -/** - * Sets up event listeners for custom events based on the provided payload, optionally appending an identifier to each event type. - * When an event is triggered, the corresponding listener callback is executed with the event detail. - * - * @since 1.0.0 - * - * @param {Object} payload - An object specifying event types and their corresponding listener callbacks. - * @param {string} identifier - An optional identifier to append to each event type. - * - * @return {void} - */ -const Listener = (payload, identifier = '') => { - for (const [key, value] of Object.entries(payload)) { - let type = key; - if (identifier) { - type += '_' + String(identifier); - } - addEventListener(type, e => { - value(e.detail); - }, false); - } -}; - -/***/ }), - -/***/ "./src/helpers/globals.js": -/*!********************************!*\ - !*** ./src/helpers/globals.js ***! - \********************************/ -/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export */ __webpack_require__.d(__webpack_exports__, { -/* harmony export */ enableSave: () => (/* binding */ enableSave), -/* harmony export */ getFromGlobal: () => (/* binding */ getFromGlobal), -/* harmony export */ isSinglePostInEditor: () => (/* binding */ isSinglePostInEditor), -/* harmony export */ setToGlobal: () => (/* binding */ setToGlobal) -/* harmony export */ }); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__); - - -/** - * Enable the Save buttons after making an update. - * - * This function uses a hacky approach to trigger a change in the post's meta, which prompts - * Gutenberg to recognize that changes have been made and enables the Save buttons. - * It dispatches an editPost action with a non-existing meta key. - * - * @since 1.0.0 - * - * @todo This is a hacky approach and relies on the behavior described in - * https://github.com/WordPress/gutenberg/issues/13774. - * Monitor the issue for any updates or changes in the Gutenberg behavior. - */ -function enableSave() { - (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.dispatch)('core/editor')?.editPost({ - meta: { - _non_existing_meta: true - } - }); -} - -/** - * Checks if the current editor session is editing a post type entity. - * - * This function determines if the current context within the WordPress editor - * is focused on editing an entity that is classified as a post type. This includes - * single posts, pages, and custom post types. It is particularly useful for distinguishing - * editor sessions that are editing post type entities from those editing other types of content, - * such as widget areas or templates in the full site editor, ensuring that specific actions or features - * are correctly applied only when editing post type entities. - * - * @return {boolean} True if the current editor session is for editing a post type entity, false otherwise. - */ -function isSinglePostInEditor() { - return 'string' === typeof (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.select)('core/editor')?.getCurrentPostType(); -} - -/** - * Get a value from the global GatherPress object based on the provided dot-separated path. - * - * This function is designed to retrieve values from the global GatherPress object. - * It takes a dot-separated path as an argument and traverses the object to return the specified value. - * If the object or any level along the path is undefined, it returns undefined. - * - * @since 1.0.0 - * - * @param {string} args - Dot-separated path to the desired property in the GatherPress global object. - * @return {*} The value at the specified path in the GatherPress global object or undefined if not found. - */ -function getFromGlobal(args) { - // eslint-disable-next-line no-undef - if ('object' !== typeof GatherPress) { - return undefined; - } - return args.split('.').reduce( - // eslint-disable-next-line no-undef - (GatherPress, level) => GatherPress && GatherPress[level], - // eslint-disable-next-line no-undef - GatherPress); -} - -/** - * Set a value to a global object based on the provided path. - * - * This function allows setting values within a nested global object using a dot-separated path. - * If the global object (GatherPress) does not exist, it will be initialized. - * - * @since 1.0.0 - * - * @param {string} args - Dot-separated path to the property. - * @param {*} value - The value to set. - * - * @return {void} - */ -function setToGlobal(args, value) { - // eslint-disable-next-line no-undef - if ('object' !== typeof GatherPress) { - return; - } - const properties = args.split('.'); - const last = properties.pop(); - - // eslint-disable-next-line no-undef - properties.reduce((all, item) => { - var _all$item; - return (_all$item = all[item]) !== null && _all$item !== void 0 ? _all$item : all[item] = {}; - }, GatherPress)[last] = value; -} - -/***/ }), - -/***/ "./node_modules/domelementtype/lib/index.js": -/*!**************************************************!*\ - !*** ./node_modules/domelementtype/lib/index.js ***! - \**************************************************/ -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.Doctype = exports.CDATA = exports.Tag = exports.Style = exports.Script = exports.Comment = exports.Directive = exports.Text = exports.Root = exports.isTag = exports.ElementType = void 0; -/** Types of elements found in htmlparser2's DOM */ -var ElementType; -(function (ElementType) { - /** Type for the root element of a document */ - ElementType["Root"] = "root"; - /** Type for Text */ - ElementType["Text"] = "text"; - /** Type for */ - ElementType["Directive"] = "directive"; - /** Type for */ - ElementType["Comment"] = "comment"; - /** Type for