well-petal 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/petal.js +2 -2
- package/package.json +1 -1
package/dist/petal.js
CHANGED
|
@@ -106,7 +106,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
106
106
|
\************************************/
|
|
107
107
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
108
108
|
|
|
109
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ initializeAllModals: () => (/* binding */ initializeAllModals)\n/* harmony export */ });\n/* harmony import */ var _lib_attributes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../lib/attributes */ \"./src/lib/attributes.ts\");\n/* harmony import */ var _lib_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../lib/helpers */ \"./src/lib/helpers.ts\");\n/* harmony import */ var _modal_config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modal-config */ \"./src/modules/modal/modal-config.ts\");\n/* harmony import */ var _lib_debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../lib/debug */ \"./src/lib/debug.ts\");\n/* harmony import */ var _lib_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../lib/memory */ \"./src/lib/memory.ts\");\n/* harmony import */ var _lib_scroll_lock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../lib/scroll-lock */ \"./src/lib/scroll-lock.ts\");\n\n\n\n\n\n\n/**\n * Modal Controller\n * Manages modal state and orchestrates opening/closing logic with animations.\n */\nclass ModalController {\n constructor(elements, config) {\n this.elements = elements;\n this.config = config;\n /**\n * Opens the modal using GSAP\n */\n this.open = () => {\n // Lock scroll if configured\n
|
|
109
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ initializeAllModals: () => (/* binding */ initializeAllModals)\n/* harmony export */ });\n/* harmony import */ var _lib_attributes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../lib/attributes */ \"./src/lib/attributes.ts\");\n/* harmony import */ var _lib_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../lib/helpers */ \"./src/lib/helpers.ts\");\n/* harmony import */ var _modal_config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./modal-config */ \"./src/modules/modal/modal-config.ts\");\n/* harmony import */ var _lib_debug__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../lib/debug */ \"./src/lib/debug.ts\");\n/* harmony import */ var _lib_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../lib/memory */ \"./src/lib/memory.ts\");\n/* harmony import */ var _lib_scroll_lock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../lib/scroll-lock */ \"./src/lib/scroll-lock.ts\");\n\n\n\n\n\n\n/**\n * Modal Controller\n * Manages modal state and orchestrates opening/closing logic with animations.\n */\nclass ModalController {\n constructor(elements, config) {\n this.elements = elements;\n this.config = config;\n /**\n * Opens the modal using GSAP\n */\n this.open = () => {\n try {\n // Lock scroll if configured\n if (this.config.lockScroll) {\n (0,_lib_scroll_lock__WEBPACK_IMPORTED_MODULE_5__.lockScroll)();\n if (this.config.debug)\n console.log(`[DEBUG] Modal \"${this.config.name}\" - Locked scroll`);\n }\n // Trigger the GSAP animation in Webflow\n const wfIx = Webflow.require(\"ix3\");\n wfIx.emit(this.config.animOpen);\n }\n catch (error) {\n // If animation fails, unlock scroll to prevent permanent lock\n if (this.config.lockScroll) {\n (0,_lib_scroll_lock__WEBPACK_IMPORTED_MODULE_5__.unlockScroll)();\n if (this.config.debug)\n console.log(`[DEBUG] Modal \"${this.config.name}\" - Unlocked scroll due to error`);\n }\n console.error(`[ERROR] Modal \"${this.config.name}\" - Failed to open:`, error);\n }\n };\n /**\n * Closes the modal using GSAP\n */\n this.close = () => {\n try {\n // Unlock scroll if configured\n if (this.config.lockScroll) {\n (0,_lib_scroll_lock__WEBPACK_IMPORTED_MODULE_5__.unlockScroll)();\n if (this.config.debug)\n console.log(`[DEBUG] Modal \"${this.config.name}\" - Unlocked scroll`);\n }\n // Pause any videos inside the modal\n (0,_lib_helpers__WEBPACK_IMPORTED_MODULE_1__.pauseVideo)(this.elements.modal);\n // Store modal closed state (session storage)\n (0,_lib_memory__WEBPACK_IMPORTED_MODULE_4__.storeClosedState)(\"modal\", this.config.name);\n // Store memory with expiration if memory is enabled\n if (this.config.memory.enabled && this.config.memory.expires) {\n (0,_lib_memory__WEBPACK_IMPORTED_MODULE_4__.storeMemoryWithExpiration)(\"modal\", this.config.name, this.config.memory.expires);\n if (this.config.debug) {\n console.log(`[DEBUG] Modal \"${this.config.name}\" - Stored in memory until ${this.config.memory.expires.toISOString()}`);\n }\n }\n // Trigger the GSAP animation in Webflow\n const wfIx = Webflow.require(\"ix3\");\n wfIx.emit(this.config.animClose);\n }\n catch (error) {\n console.error(`[ERROR] Modal \"${this.config.name}\" - Failed to close:`, error);\n }\n };\n }\n}\n/**\n * Initialize all modals on the page\n */\nfunction initializeAllModals() {\n const modals = (0,_lib_helpers__WEBPACK_IMPORTED_MODULE_1__.getAllPetalElementsOfType)(_lib_attributes__WEBPACK_IMPORTED_MODULE_0__.ATTR_PETAL_MODAL);\n modals.forEach((modal, index) => {\n // ===========================\n // Configuration\n // ===========================\n const name = modal.getAttribute(_lib_attributes__WEBPACK_IMPORTED_MODULE_0__.ATTR_PETAL_NAME) || null;\n const config = (0,_modal_config__WEBPACK_IMPORTED_MODULE_2__.parseModalConfig)(modal);\n (0,_lib_debug__WEBPACK_IMPORTED_MODULE_3__.debug)(config.debug, \"MODAL\", `Processing ${name} (${index + 1}/${modals.length})`);\n (0,_modal_config__WEBPACK_IMPORTED_MODULE_2__.logConfig)(config);\n // ===========================\n // Element References\n // ===========================\n const dialog = (0,_lib_helpers__WEBPACK_IMPORTED_MODULE_1__.findPetalElementByNameOrInParent)(modal, name, _lib_attributes__WEBPACK_IMPORTED_MODULE_0__.ATTR_PETAL_DIALOG);\n const openTriggers = (0,_lib_helpers__WEBPACK_IMPORTED_MODULE_1__.findTriggersByNameOrInParent)(modal, name, \"open\");\n const closeTriggers = (0,_lib_helpers__WEBPACK_IMPORTED_MODULE_1__.findTriggersByNameOrInParent)(modal, name, \"close\");\n (0,_lib_debug__WEBPACK_IMPORTED_MODULE_3__.debugElements)(config.debug, \"MODAL\", \"open trigger\", openTriggers);\n (0,_lib_debug__WEBPACK_IMPORTED_MODULE_3__.debugElements)(config.debug, \"MODAL\", \"close trigger\", closeTriggers);\n if (!dialog || !openTriggers || !closeTriggers) {\n console.error(`[ERROR] Modal \"${name}\" is missing required elements. Ensure dialog, open triggers, and close triggers are present.`);\n return;\n }\n const elements = {\n modal,\n dialog,\n openTriggers,\n closeTriggers,\n };\n // ===========================\n // Initialization\n // ===========================\n // Create a single controller instance for this modal\n const controller = new ModalController(elements, config);\n // Initialize Open Triggers\n openTriggers === null || openTriggers === void 0 ? void 0 : openTriggers.forEach((trigger, triggerIndex) => {\n trigger.addEventListener(\"click\", () => {\n controller.open();\n });\n });\n // Initialize Close Triggers\n closeTriggers === null || closeTriggers === void 0 ? void 0 : closeTriggers.forEach((trigger, triggerIndex) => {\n trigger.addEventListener(\"click\", () => {\n controller.close();\n });\n });\n // Find and attach close triggers without names (that are children of this modal)\n if (!name) {\n const allCloseTriggers = [...Array.from(document.querySelectorAll(`[${_lib_attributes__WEBPACK_IMPORTED_MODULE_0__.ATTR_PETAL_TRIGGER}=\"close\"]`))];\n allCloseTriggers.forEach((trigger) => {\n // Check if this close trigger doesn't have a name and is a child of this modal\n const triggerName = trigger.getAttribute(_lib_attributes__WEBPACK_IMPORTED_MODULE_0__.ATTR_PETAL_NAME);\n if (!triggerName) {\n const parentModal = (0,_lib_helpers__WEBPACK_IMPORTED_MODULE_1__.findClosestPetalParent)(trigger, _lib_attributes__WEBPACK_IMPORTED_MODULE_0__.ATTR_PETAL_MODAL);\n if (parentModal === modal) {\n trigger.addEventListener(\"click\", () => {\n controller.close();\n });\n }\n }\n });\n }\n // ===========================\n // Auto Open\n // ===========================\n if (config.autoOpen) {\n // Check if modal is in memory (user has closed it and it hasn't expired yet)\n const isInMemory = config.memory.enabled && (0,_lib_memory__WEBPACK_IMPORTED_MODULE_4__.checkMemory)(\"modal\", config.name);\n if (isInMemory) {\n (0,_lib_debug__WEBPACK_IMPORTED_MODULE_3__.debug)(config.debug, \"MODAL\", `Skipping auto-open for \"${name}\" - still in memory`);\n }\n else {\n const delay = config.autoOpenDelay ? config.autoOpenDelay.getTime() - Date.now() : 0;\n (0,_lib_debug__WEBPACK_IMPORTED_MODULE_3__.debug)(config.debug, \"MODAL\", `Auto-opening \"${name}\" after ${delay}ms`);\n setTimeout(() => {\n controller.open();\n }, delay);\n }\n }\n });\n}\n\n\n//# sourceURL=webpack://petal/./src/modules/modal/modal.ts?");
|
|
110
110
|
|
|
111
111
|
/***/ }),
|
|
112
112
|
|
|
@@ -116,7 +116,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
116
116
|
\**********************/
|
|
117
117
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
118
118
|
|
|
119
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _modules_modal_modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/modal/modal */ \"./src/modules/modal/modal.ts\");\n/* harmony import */ var _modules_banner_banner__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/banner/banner */ \"./src/modules/banner/banner.ts\");\n\n\nconsole.log(`🌸 Hello from Wellflow Petal v${\"0.1.
|
|
119
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _modules_modal_modal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modules/modal/modal */ \"./src/modules/modal/modal.ts\");\n/* harmony import */ var _modules_banner_banner__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./modules/banner/banner */ \"./src/modules/banner/banner.ts\");\n\n\nconsole.log(`🌸 Hello from Wellflow Petal v${\"0.1.4\"}`);\n(0,_modules_modal_modal__WEBPACK_IMPORTED_MODULE_0__.initializeAllModals)();\n(0,_modules_banner_banner__WEBPACK_IMPORTED_MODULE_1__.initializeBanner)();\n\n\n//# sourceURL=webpack://petal/./src/petal.ts?");
|
|
120
120
|
|
|
121
121
|
/***/ })
|
|
122
122
|
|