← All changes
|
assets/js/packages/locations/locations.js
+2
-347
4.2.0-dev2
→
3.22.0-beta1
View file →
| @@ -1,347 +1,2 @@ | ||
| 1 | -/******/ (function() { // webpackBootstrap | |
| 2 | -/******/ "use strict"; | |
| 3 | -/******/ var __webpack_modules__ = ({ | |
| 4 | - | |
| 5 | -/***/ "./packages/packages/libs/locations/src/components/error-boundary.tsx": | |
| 6 | -/*!****************************************************************************!*\ | |
| 7 | - !*** ./packages/packages/libs/locations/src/components/error-boundary.tsx ***! | |
| 8 | - \****************************************************************************/ | |
| 9 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 10 | - | |
| 11 | -__webpack_require__.r(__webpack_exports__); | |
| 12 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 13 | -/* harmony export */ "default": function() { return /* binding */ ErrorBoundary; } | |
| 14 | -/* harmony export */ }); | |
| 15 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 16 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 17 | - | |
| 18 | -class ErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component { | |
| 19 | - state = { | |
| 20 | - hasError: false | |
| 21 | - }; | |
| 22 | - static getDerivedStateFromError() { | |
| 23 | - // Update state so the next render will show the fallback UI. | |
| 24 | - return { | |
| 25 | - hasError: true | |
| 26 | - }; | |
| 27 | - } | |
| 28 | - render() { | |
| 29 | - if (this.state.hasError) { | |
| 30 | - return this.props.fallback; | |
| 31 | - } | |
| 32 | - return this.props.children; | |
| 33 | - } | |
| 34 | -} | |
| 35 | - | |
| 36 | -/***/ }), | |
| 37 | - | |
| 38 | -/***/ "./packages/packages/libs/locations/src/components/injected-component-wrapper.tsx": | |
| 39 | -/*!****************************************************************************************!*\ | |
| 40 | - !*** ./packages/packages/libs/locations/src/components/injected-component-wrapper.tsx ***! | |
| 41 | - \****************************************************************************************/ | |
| 42 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 43 | - | |
| 44 | -__webpack_require__.r(__webpack_exports__); | |
| 45 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 46 | -/* harmony export */ "default": function() { return /* binding */ InjectedComponentWrapper; } | |
| 47 | -/* harmony export */ }); | |
| 48 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 49 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 50 | -/* harmony import */ var _error_boundary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./error-boundary */ "./packages/packages/libs/locations/src/components/error-boundary.tsx"); | |
| 51 | - | |
| 52 | - | |
| 53 | - | |
| 54 | -function InjectedComponentWrapper({ | |
| 55 | - children | |
| 56 | -}) { | |
| 57 | - return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_error_boundary__WEBPACK_IMPORTED_MODULE_1__["default"], { | |
| 58 | - fallback: null | |
| 59 | - }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Suspense, { | |
| 60 | - fallback: null | |
| 61 | - }, children)); | |
| 62 | -} | |
| 63 | - | |
| 64 | -/***/ }), | |
| 65 | - | |
| 66 | -/***/ "./packages/packages/libs/locations/src/create-location.tsx": | |
| 67 | -/*!******************************************************************!*\ | |
| 68 | - !*** ./packages/packages/libs/locations/src/create-location.tsx ***! | |
| 69 | - \******************************************************************/ | |
| 70 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 71 | - | |
| 72 | -__webpack_require__.r(__webpack_exports__); | |
| 73 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 74 | -/* harmony export */ createLocation: function() { return /* binding */ createLocation; } | |
| 75 | -/* harmony export */ }); | |
| 76 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 77 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 78 | -/* harmony import */ var _injections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./injections */ "./packages/packages/libs/locations/src/injections.tsx"); | |
| 79 | -function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } | |
| 80 | - | |
| 81 | - | |
| 82 | -function createLocation() { | |
| 83 | - const injections = new Map(); | |
| 84 | - const getInjections = (0,_injections__WEBPACK_IMPORTED_MODULE_1__.createGetInjections)(injections); | |
| 85 | - const useInjections = (0,_injections__WEBPACK_IMPORTED_MODULE_1__.createUseInjections)(getInjections); | |
| 86 | - const Slot = createSlot(useInjections); | |
| 87 | - const inject = createInject(injections); | |
| 88 | - | |
| 89 | - // Push the clear function to the flushInjectionsFns array, so we can flush all injections at once. | |
| 90 | - _injections__WEBPACK_IMPORTED_MODULE_1__.flushInjectionsFns.push(() => injections.clear()); | |
| 91 | - return { | |
| 92 | - inject, | |
| 93 | - getInjections, | |
| 94 | - useInjections, | |
| 95 | - Slot | |
| 96 | - }; | |
| 97 | -} | |
| 98 | -function createSlot(useInjections) { | |
| 99 | - return props => { | |
| 100 | - const injections = useInjections(); | |
| 101 | - return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, injections.map(({ | |
| 102 | - id, | |
| 103 | - component: Component | |
| 104 | - }) => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Component, _extends({}, props, { | |
| 105 | - key: id | |
| 106 | - })))); | |
| 107 | - }; | |
| 108 | -} | |
| 109 | -function createInject(injections) { | |
| 110 | - return ({ | |
| 111 | - component, | |
| 112 | - id, | |
| 113 | - options = {} | |
| 114 | - }) => { | |
| 115 | - if (injections.has(id) && !options?.overwrite) { | |
| 116 | - // eslint-disable-next-line no-console | |
| 117 | - console.warn(`An injection with the id "${id}" already exists. Did you mean to use "options.overwrite"?`); | |
| 118 | - return; | |
| 119 | - } | |
| 120 | - injections.set(id, { | |
| 121 | - id, | |
| 122 | - component: (0,_injections__WEBPACK_IMPORTED_MODULE_1__.wrapInjectedComponent)(component), | |
| 123 | - priority: options.priority ?? _injections__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_PRIORITY | |
| 124 | - }); | |
| 125 | - }; | |
| 126 | -} | |
| 127 | - | |
| 128 | -/***/ }), | |
| 129 | - | |
| 130 | -/***/ "./packages/packages/libs/locations/src/create-replaceable-location.tsx": | |
| 131 | -/*!******************************************************************************!*\ | |
| 132 | - !*** ./packages/packages/libs/locations/src/create-replaceable-location.tsx ***! | |
| 133 | - \******************************************************************************/ | |
| 134 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 135 | - | |
| 136 | -__webpack_require__.r(__webpack_exports__); | |
| 137 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 138 | -/* harmony export */ createReplaceableLocation: function() { return /* binding */ createReplaceableLocation; } | |
| 139 | -/* harmony export */ }); | |
| 140 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 141 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 142 | -/* harmony import */ var _injections__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./injections */ "./packages/packages/libs/locations/src/injections.tsx"); | |
| 143 | - | |
| 144 | - | |
| 145 | -function createReplaceableLocation() { | |
| 146 | - const injections = new Map(); | |
| 147 | - const getInjections = (0,_injections__WEBPACK_IMPORTED_MODULE_1__.createGetInjections)(injections); | |
| 148 | - const useInjections = (0,_injections__WEBPACK_IMPORTED_MODULE_1__.createUseInjections)(getInjections); | |
| 149 | - const Slot = createReplaceable(useInjections); | |
| 150 | - const inject = createRegister(injections); | |
| 151 | - | |
| 152 | - // Push the clear function to the flushInjectionsFns array, so we can flush all injections at once. | |
| 153 | - _injections__WEBPACK_IMPORTED_MODULE_1__.flushInjectionsFns.push(() => injections.clear()); | |
| 154 | - return { | |
| 155 | - getInjections, | |
| 156 | - useInjections, | |
| 157 | - inject, | |
| 158 | - Slot | |
| 159 | - }; | |
| 160 | -} | |
| 161 | -function createReplaceable(useInjections) { | |
| 162 | - return props => { | |
| 163 | - const injections = useInjections(); | |
| 164 | - const { | |
| 165 | - component: Component | |
| 166 | - } = injections.find(({ | |
| 167 | - condition | |
| 168 | - }) => condition?.(props)) ?? {}; | |
| 169 | - if (!Component) { | |
| 170 | - return props.children; | |
| 171 | - } | |
| 172 | - return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Component, props); | |
| 173 | - }; | |
| 174 | -} | |
| 175 | -function createRegister(injections) { | |
| 176 | - return ({ | |
| 177 | - component, | |
| 178 | - id, | |
| 179 | - condition = () => true, | |
| 180 | - options = {} | |
| 181 | - }) => { | |
| 182 | - injections.set(id, { | |
| 183 | - id, | |
| 184 | - component: (0,_injections__WEBPACK_IMPORTED_MODULE_1__.wrapInjectedComponent)(component), | |
| 185 | - condition, | |
| 186 | - priority: options.priority ?? _injections__WEBPACK_IMPORTED_MODULE_1__.DEFAULT_PRIORITY | |
| 187 | - }); | |
| 188 | - }; | |
| 189 | -} | |
| 190 | - | |
| 191 | -/***/ }), | |
| 192 | - | |
| 193 | -/***/ "./packages/packages/libs/locations/src/injections.tsx": | |
| 194 | -/*!*************************************************************!*\ | |
| 195 | - !*** ./packages/packages/libs/locations/src/injections.tsx ***! | |
| 196 | - \*************************************************************/ | |
| 197 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 198 | - | |
| 199 | -__webpack_require__.r(__webpack_exports__); | |
| 200 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 201 | -/* harmony export */ DEFAULT_PRIORITY: function() { return /* binding */ DEFAULT_PRIORITY; }, | |
| 202 | -/* harmony export */ createGetInjections: function() { return /* binding */ createGetInjections; }, | |
| 203 | -/* harmony export */ createUseInjections: function() { return /* binding */ createUseInjections; }, | |
| 204 | -/* harmony export */ flushAllInjections: function() { return /* binding */ flushAllInjections; }, | |
| 205 | -/* harmony export */ flushInjectionsFns: function() { return /* binding */ flushInjectionsFns; }, | |
| 206 | -/* harmony export */ wrapInjectedComponent: function() { return /* binding */ wrapInjectedComponent; } | |
| 207 | -/* harmony export */ }); | |
| 208 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); | |
| 209 | -/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | |
| 210 | -/* harmony import */ var _components_injected_component_wrapper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/injected-component-wrapper */ "./packages/packages/libs/locations/src/components/injected-component-wrapper.tsx"); | |
| 211 | - | |
| 212 | - | |
| 213 | - | |
| 214 | -const DEFAULT_PRIORITY = 10; | |
| 215 | - | |
| 216 | -// Allow flushing all injections at once, for testing purposes. | |
| 217 | -const flushInjectionsFns = []; | |
| 218 | -function flushAllInjections() { | |
| 219 | - flushInjectionsFns.forEach(flush => flush()); | |
| 220 | -} | |
| 221 | -function createGetInjections(injections) { | |
| 222 | - return () => [...injections.values()].sort((a, b) => a.priority - b.priority); | |
| 223 | -} | |
| 224 | -function createUseInjections(getInjections) { | |
| 225 | - return () => (0,react__WEBPACK_IMPORTED_MODULE_0__.useMemo)(() => getInjections(), []); | |
| 226 | -} | |
| 227 | -function wrapInjectedComponent(Component) { | |
| 228 | - return props => /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(_components_injected_component_wrapper__WEBPACK_IMPORTED_MODULE_1__["default"], null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(Component, props)); | |
| 229 | -} | |
| 230 | - | |
| 231 | -/***/ }), | |
| 232 | - | |
| 233 | -/***/ "./packages/packages/libs/locations/src/types.ts": | |
| 234 | -/*!*******************************************************!*\ | |
| 235 | - !*** ./packages/packages/libs/locations/src/types.ts ***! | |
| 236 | - \*******************************************************/ | |
| 237 | -/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { | |
| 238 | - | |
| 239 | -__webpack_require__.r(__webpack_exports__); | |
| 240 | - | |
| 241 | - | |
| 242 | -/***/ }), | |
| 243 | - | |
| 244 | -/***/ "react": | |
| 245 | -/*!**************************!*\ | |
| 246 | - !*** external ["React"] ***! | |
| 247 | - \**************************/ | |
| 248 | -/***/ (function(module) { | |
| 249 | - | |
| 250 | -module.exports = window["React"]; | |
| 251 | - | |
| 252 | -/***/ }) | |
| 253 | - | |
| 254 | -/******/ }); | |
| 255 | -/************************************************************************/ | |
| 256 | -/******/ // The module cache | |
| 257 | -/******/ var __webpack_module_cache__ = {}; | |
| 258 | -/******/ | |
| 259 | -/******/ // The require function | |
| 260 | -/******/ function __webpack_require__(moduleId) { | |
| 261 | -/******/ // Check if module is in cache | |
| 262 | -/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 263 | -/******/ if (cachedModule !== undefined) { | |
| 264 | -/******/ return cachedModule.exports; | |
| 265 | -/******/ } | |
| 266 | -/******/ // Create a new module (and put it into the cache) | |
| 267 | -/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 268 | -/******/ // no module.id needed | |
| 269 | -/******/ // no module.loaded needed | |
| 270 | -/******/ exports: {} | |
| 271 | -/******/ }; | |
| 272 | -/******/ | |
| 273 | -/******/ // Execute the module function | |
| 274 | -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | |
| 275 | -/******/ | |
| 276 | -/******/ // Return the exports of the module | |
| 277 | -/******/ return module.exports; | |
| 278 | -/******/ } | |
| 279 | -/******/ | |
| 280 | -/************************************************************************/ | |
| 281 | -/******/ /* webpack/runtime/compat get default export */ | |
| 282 | -/******/ !function() { | |
| 283 | -/******/ // getDefaultExport function for compatibility with non-harmony modules | |
| 284 | -/******/ __webpack_require__.n = function(module) { | |
| 285 | -/******/ var getter = module && module.__esModule ? | |
| 286 | -/******/ function() { return module['default']; } : | |
| 287 | -/******/ function() { return module; }; | |
| 288 | -/******/ __webpack_require__.d(getter, { a: getter }); | |
| 289 | -/******/ return getter; | |
| 290 | -/******/ }; | |
| 291 | -/******/ }(); | |
| 292 | -/******/ | |
| 293 | -/******/ /* webpack/runtime/define property getters */ | |
| 294 | -/******/ !function() { | |
| 295 | -/******/ // define getter functions for harmony exports | |
| 296 | -/******/ __webpack_require__.d = function(exports, definition) { | |
| 297 | -/******/ for(var key in definition) { | |
| 298 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 299 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 300 | -/******/ } | |
| 301 | -/******/ } | |
| 302 | -/******/ }; | |
| 303 | -/******/ }(); | |
| 304 | -/******/ | |
| 305 | -/******/ /* webpack/runtime/hasOwnProperty shorthand */ | |
| 306 | -/******/ !function() { | |
| 307 | -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } | |
| 308 | -/******/ }(); | |
| 309 | -/******/ | |
| 310 | -/******/ /* webpack/runtime/make namespace object */ | |
| 311 | -/******/ !function() { | |
| 312 | -/******/ // define __esModule on exports | |
| 313 | -/******/ __webpack_require__.r = function(exports) { | |
| 314 | -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { | |
| 315 | -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); | |
| 316 | -/******/ } | |
| 317 | -/******/ Object.defineProperty(exports, '__esModule', { value: true }); | |
| 318 | -/******/ }; | |
| 319 | -/******/ }(); | |
| 320 | -/******/ | |
| 321 | -/************************************************************************/ | |
| 322 | -var __webpack_exports__ = {}; | |
| 323 | -// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. | |
| 324 | -!function() { | |
| 325 | -/*!*******************************************************!*\ | |
| 326 | - !*** ./packages/packages/libs/locations/src/index.ts ***! | |
| 327 | - \*******************************************************/ | |
| 328 | -__webpack_require__.r(__webpack_exports__); | |
| 329 | -/* harmony export */ __webpack_require__.d(__webpack_exports__, { | |
| 330 | -/* harmony export */ __flushAllInjections: function() { return /* reexport safe */ _injections__WEBPACK_IMPORTED_MODULE_3__.flushAllInjections; }, | |
| 331 | -/* harmony export */ createLocation: function() { return /* reexport safe */ _create_location__WEBPACK_IMPORTED_MODULE_1__.createLocation; }, | |
| 332 | -/* harmony export */ createReplaceableLocation: function() { return /* reexport safe */ _create_replaceable_location__WEBPACK_IMPORTED_MODULE_2__.createReplaceableLocation; } | |
| 333 | -/* harmony export */ }); | |
| 334 | -/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types */ "./packages/packages/libs/locations/src/types.ts"); | |
| 335 | -/* harmony import */ var _create_location__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./create-location */ "./packages/packages/libs/locations/src/create-location.tsx"); | |
| 336 | -/* harmony import */ var _create_replaceable_location__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./create-replaceable-location */ "./packages/packages/libs/locations/src/create-replaceable-location.tsx"); | |
| 337 | -/* harmony import */ var _injections__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./injections */ "./packages/packages/libs/locations/src/injections.tsx"); | |
| 338 | - | |
| 339 | - | |
| 340 | - | |
| 341 | - | |
| 342 | -}(); | |
| 343 | -(window.elementorV2 = window.elementorV2 || {}).locations = __webpack_exports__; | |
| 344 | -/******/ })() | |
| 345 | -; | |
| 346 | -window.elementorV2.locations?.init?.(); | |
| 347 | -//# sourceMappingURL=locations.js.map | |
| 1 | +/*! For license information please see locations.js.LICENSE.txt */ | |
| 2 | +!function(){"use strict";var e={react:function(e){e.exports=window.React}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}r.d=function(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=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){r.r(n),r.d(n,{__flushAllInjections:function(){return u},createLocation:function(){return a}});var e=r("react"),t=class extends e.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}};function o({children:r}){return e.createElement(t,{fallback:null},e.createElement(e.Suspense,{fallback:null},r))}var i=10,c=[];function a(){const t=new Map,r=function(e){return()=>[...e.values()].sort(((e,t)=>e.priority-t.priority))}(t),n=function(t){return()=>(0,e.useMemo)((()=>t()),[])}(r),a=function(t){return r=>{const n=t();return e.createElement(e.Fragment,null,n.map((({id:t,component:n})=>e.createElement(n,{...r,key:t}))))}}(n),u=function(t){return({component:r,id:n,options:c={}})=>{var a;!t.has(n)||c?.overwrite?t.set(n,{id:n,component:(a=r,t=>e.createElement(o,null,e.createElement(a,{...t}))),priority:c.priority??i}):console.warn(`An injection with the id "${n}" already exists. Did you mean to use "options.overwrite"?`)}}(t);return c.push((()=>t.clear())),{inject:u,getInjections:r,useInjections:n,Slot:a}}function u(){c.forEach((e=>e()))}}(),(window.elementorV2=window.elementorV2||{}).locations=n}(); | |