| @@ -1,40 +1,7 @@ | ||
| 1 | 1 | /******/ (() => { // webpackBootstrap |
| 2 | 2 | /******/ var __webpack_modules__ = ({ |
| 3 | 3 | |
| 4 | -/***/ 20 | |
| 5 | -(__unused_webpack_module, exports, __webpack_require__) { | |
| 6 | - | |
| 7 | -"use strict"; | |
| 8 | -/** | |
| 9 | - * @license React | |
| 10 | - * react-jsx-runtime.production.min.js | |
| 11 | - * | |
| 12 | - * Copyright (c) Facebook, Inc. and its affiliates. | |
| 13 | - * | |
| 14 | - * This source code is licensed under the MIT license found in the | |
| 15 | - * LICENSE file in the root directory of this source tree. | |
| 16 | - */ | |
| 17 | -var f=__webpack_require__(677),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0}; | |
| 18 | -function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q; | |
| 19 | - | |
| 20 | - | |
| 21 | -/***/ }, | |
| 22 | - | |
| 23 | -/***/ 848 | |
| 24 | -(module, __unused_webpack_exports, __webpack_require__) { | |
| 25 | - | |
| 26 | -"use strict"; | |
| 27 | - | |
| 28 | - | |
| 29 | -if (true) { | |
| 30 | - module.exports = __webpack_require__(20); | |
| 31 | -} else // removed by dead control flow | |
| 32 | -{} | |
| 33 | - | |
| 34 | - | |
| 35 | -/***/ }, | |
| 36 | - | |
| 37 | 4 | /***/ 677 |
| 38 | 5 | (module) { |
| 39 | 6 | |
| 40 | 7 | module.exports = (function() { return this["React"]; }()); |
| @@ -120,19 +87,19 @@ | ||
| 120 | 87 | |
| 121 | 88 | /******/ }); |
| 122 | 89 | /************************************************************************/ |
| 123 | 90 | /******/ // The module cache |
| 124 | -/******/ var __webpack_module_cache__ = {}; | |
| 91 | +/******/ const __webpack_module_cache__ = {}; | |
| 125 | 92 | /******/ |
| 126 | 93 | /******/ // The require function |
| 127 | 94 | /******/ function __webpack_require__(moduleId) { |
| 128 | 95 | /******/ // Check if module is in cache |
| 129 | -/******/ var cachedModule = __webpack_module_cache__[moduleId]; | |
| 96 | +/******/ const cachedModule = __webpack_module_cache__[moduleId]; | |
| 130 | 97 | /******/ if (cachedModule !== undefined) { |
| 131 | 98 | /******/ return cachedModule.exports; |
| 132 | 99 | /******/ } |
| 133 | 100 | /******/ // Create a new module (and put it into the cache) |
| 134 | -/******/ var module = __webpack_module_cache__[moduleId] = { | |
| 101 | +/******/ const module = __webpack_module_cache__[moduleId] = { | |
| 135 | 102 | /******/ // no module.id needed |
| 136 | 103 | /******/ // no module.loaded needed |
| 137 | 104 | /******/ exports: {} |
| 138 | 105 | /******/ }; |
| @@ -145,48 +112,92 @@ | ||
| 145 | 112 | /******/ } |
| 146 | 113 | /******/ |
| 147 | 114 | /************************************************************************/ |
| 148 | 115 | /******/ /* webpack/runtime/compat get default export */ |
| 149 | -/******/ (() => { | |
| 150 | -/******/ // getDefaultExport function for compatibility with non-harmony modules | |
| 151 | -/******/ __webpack_require__.n = (module) => { | |
| 152 | -/******/ var getter = module && module.__esModule ? | |
| 153 | -/******/ () => (module['default']) : | |
| 154 | -/******/ () => (module); | |
| 155 | -/******/ __webpack_require__.d(getter, { a: getter }); | |
| 156 | -/******/ return getter; | |
| 116 | +/******/ // getDefaultExport function for compatibility with non-harmony modules | |
| 117 | +/******/ __webpack_require__.n = (module) => { | |
| 118 | +/******/ const getter = module && module.__esModule ? | |
| 119 | +/******/ () => (module['default']) : | |
| 120 | +/******/ () => (module); | |
| 121 | +/******/ __webpack_require__.d(getter, { a: getter }); | |
| 122 | +/******/ return getter; | |
| 123 | +/******/ }; | |
| 124 | +/******/ | |
| 125 | +/******/ /* webpack/runtime/concatenation wrap */ | |
| 126 | +/******/ // wrap a concatenated module body as a lazy, memoized accessor; mod is | |
| 127 | +/******/ // set before the body runs so re-entrant calls (require cycles) observe | |
| 128 | +/******/ // the partial exports like Node.js | |
| 129 | +/******/ __webpack_require__.cw = (body) => { | |
| 130 | +/******/ var mod; | |
| 131 | +/******/ return () => { | |
| 132 | +/******/ if (body) { | |
| 133 | +/******/ var fn = body; | |
| 134 | +/******/ body = 0; | |
| 135 | +/******/ mod = { exports: {} }; | |
| 136 | +/******/ fn.call(mod.exports, mod, mod.exports); | |
| 137 | +/******/ } | |
| 138 | +/******/ return mod.exports; | |
| 157 | 139 | /******/ }; |
| 158 | -/******/ })(); | |
| 140 | +/******/ }; | |
| 159 | 141 | /******/ |
| 160 | 142 | /******/ /* webpack/runtime/define property getters */ |
| 161 | -/******/ (() => { | |
| 162 | -/******/ // define getter functions for harmony exports | |
| 163 | -/******/ __webpack_require__.d = (exports, definition) => { | |
| 164 | -/******/ for(var key in definition) { | |
| 165 | -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 166 | -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 167 | -/******/ } | |
| 143 | +/******/ // define getter/value functions for harmony exports | |
| 144 | +/******/ __webpack_require__.d = (exports, definition) => { | |
| 145 | +/******/ for(var key in definition) { | |
| 146 | +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { | |
| 147 | +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); | |
| 168 | 148 | /******/ } |
| 169 | -/******/ }; | |
| 170 | -/******/ })(); | |
| 149 | +/******/ } | |
| 150 | +/******/ }; | |
| 171 | 151 | /******/ |
| 172 | 152 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 173 | -/******/ (() => { | |
| 174 | -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) | |
| 175 | -/******/ })(); | |
| 153 | +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)); | |
| 176 | 154 | /******/ |
| 177 | 155 | /************************************************************************/ |
| 178 | -var __webpack_exports__ = {}; | |
| 156 | +let __webpack_exports__ = {}; | |
| 179 | 157 | // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. |
| 180 | 158 | (() => { |
| 181 | 159 | "use strict"; |
| 182 | 160 | |
| 161 | +// MODULE: ./node_modules/react/cjs/react-jsx-runtime.production.min.js | |
| 162 | +var react_jsx_runtime_production_min_namespaceFn = /*#__PURE__*/__webpack_require__.cw(function(module, exports) { | |
| 163 | +/** | |
| 164 | + * @license React | |
| 165 | + * react-jsx-runtime.production.min.js | |
| 166 | + * | |
| 167 | + * Copyright (c) Facebook, Inc. and its affiliates. | |
| 168 | + * | |
| 169 | + * This source code is licensed under the MIT license found in the | |
| 170 | + * LICENSE file in the root directory of this source tree. | |
| 171 | + */ | |
| 172 | +var f=(external_React_namespaceFn()),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0}; | |
| 173 | +function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}exports.Fragment=l;exports.jsx=q;exports.jsxs=q; | |
| 174 | + | |
| 175 | +}); | |
| 176 | + | |
| 177 | +// MODULE: ./node_modules/react/jsx-runtime.js | |
| 178 | +var jsx_runtime_namespaceFn = /*#__PURE__*/__webpack_require__.cw(function(module, exports) { | |
| 179 | + | |
| 180 | + | |
| 181 | +if (true) { | |
| 182 | + module.exports = (react_jsx_runtime_production_min_namespaceFn()); | |
| 183 | +} else // removed by dead control flow | |
| 184 | +{} | |
| 185 | + | |
| 186 | +}); | |
| 187 | + | |
| 188 | +// EXTERNAL MODULE: external "React" | |
| 189 | +var external_React_namespaceFn = () => { | |
| 190 | + return __webpack_require__(677); | |
| 191 | +}; | |
| 192 | + | |
| 183 | 193 | // EXTERNAL MODULE: external {"this":["wp","blocks"]} |
| 184 | 194 | var external_this_wp_blocks_ = __webpack_require__(545); |
| 185 | 195 | // EXTERNAL MODULE: external {"this":["wp","primitives"]} |
| 186 | 196 | var external_this_wp_primitives_ = __webpack_require__(933); |
| 187 | -// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js | |
| 188 | -var jsx_runtime = __webpack_require__(848); | |
| 197 | +;// ./node_modules/react/jsx-runtime.js | |
| 198 | +jsx_runtime_namespaceFn(); | |
| 199 | + | |
| 189 | 200 | ;// ./node_modules/@wpsyntex/polylang-react-library/build/icons/translation.js |
| 190 | 201 | /** |
| 191 | 202 | * Translation icon - translation Dashicon. |
| 192 | 203 | */ |
| @@ -196,14 +207,14 @@ | ||
| 196 | 207 | */ |
| 197 | 208 | |
| 198 | 209 | |
| 199 | 210 | const isPrimitivesComponents = 'undefined' !== typeof wp.primitives; |
| 200 | -const translation = isPrimitivesComponents ? /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_primitives_.SVG, { | |
| 211 | +const translation = isPrimitivesComponents ? /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_primitives_.SVG, { | |
| 201 | 212 | width: "20", |
| 202 | 213 | height: "20", |
| 203 | 214 | xmlns: "http://www.w3.org/2000/svg", |
| 204 | 215 | viewBox: "0 0 20 20", |
| 205 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_primitives_.Path, { | |
| 216 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_primitives_.Path, { | |
| 206 | 217 | d: "M11 7H9.49c-.63 0-1.25.3-1.59.7L7 5H4.13l-2.39 7h1.69l.74-2H7v4H2c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2h7c1.1 0 2 .9 2 2v2zM6.51 9H4.49l1-2.93zM10 8h7c1.1 0 2 .9 2 2v7c0 1.1-.9 2-2 2h-7c-1.1 0-2-.9-2-2v-7c0-1.1.9-2 2-2zm7.25 5v-1.08h-3.17V9.75h-1.16v2.17H9.75V13h1.28c.11.85.56 1.85 1.28 2.62-.87.36-1.89.62-2.31.62-.01.02.22.97.2 1.46.84 0 2.21-.5 3.28-1.15 1.09.65 2.48 1.15 3.34 1.15-.02-.49.2-1.44.2-1.46-.43 0-1.49-.27-2.38-.63.7-.77 1.14-1.77 1.25-2.61h1.36zm-3.81 1.93c-.5-.46-.85-1.13-1.01-1.93h2.09c-.17.8-.51 1.47-1 1.93l-.04.03s-.03-.02-.04-.03z" |
| 207 | 218 | }) |
| 208 | 219 | }) : 'translation'; |
| 209 | 220 | /* harmony default export */ const icons_translation = (translation); |
| @@ -279,9 +290,9 @@ | ||
| 279 | 290 | hide_current, |
| 280 | 291 | hide_if_no_translation |
| 281 | 292 | } = props.attributes; |
| 282 | 293 | function ToggleControlDropdown() { |
| 283 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, { | |
| 294 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, { | |
| 284 | 295 | label: i18nAttributeStrings.dropdown, |
| 285 | 296 | checked: dropdown, |
| 286 | 297 | onChange: toggleDropdown |
| 287 | 298 | }); |
| @@ -286,9 +297,9 @@ | ||
| 286 | 297 | onChange: toggleDropdown |
| 287 | 298 | }); |
| 288 | 299 | } |
| 289 | 300 | function ToggleControlShowNames() { |
| 290 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, { | |
| 301 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, { | |
| 291 | 302 | label: i18nAttributeStrings.show_names, |
| 292 | 303 | checked: show_names // eslint-disable-line camelcase |
| 293 | 304 | , |
| 294 | 305 | onChange: toggleShowNames |
| @@ -294,9 +305,9 @@ | ||
| 294 | 305 | onChange: toggleShowNames |
| 295 | 306 | }); |
| 296 | 307 | } |
| 297 | 308 | function ToggleControlShowFlags() { |
| 298 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, { | |
| 309 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, { | |
| 299 | 310 | label: i18nAttributeStrings.show_flags, |
| 300 | 311 | checked: show_flags // eslint-disable-line camelcase |
| 301 | 312 | , |
| 302 | 313 | onChange: toggleShowFlags |
| @@ -302,9 +313,9 @@ | ||
| 302 | 313 | onChange: toggleShowFlags |
| 303 | 314 | }); |
| 304 | 315 | } |
| 305 | 316 | function ToggleControlForceHome() { |
| 306 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, { | |
| 317 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, { | |
| 307 | 318 | label: i18nAttributeStrings.force_home, |
| 308 | 319 | checked: force_home // eslint-disable-line camelcase |
| 309 | 320 | , |
| 310 | 321 | onChange: toggleForceHome |
| @@ -310,9 +321,9 @@ | ||
| 310 | 321 | onChange: toggleForceHome |
| 311 | 322 | }); |
| 312 | 323 | } |
| 313 | 324 | function ToggleControlHideCurrent() { |
| 314 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, { | |
| 325 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, { | |
| 315 | 326 | label: i18nAttributeStrings.hide_current, |
| 316 | 327 | checked: hide_current // eslint-disable-line camelcase |
| 317 | 328 | , |
| 318 | 329 | onChange: toggleHideCurrent |
| @@ -318,9 +329,9 @@ | ||
| 318 | 329 | onChange: toggleHideCurrent |
| 319 | 330 | }); |
| 320 | 331 | } |
| 321 | 332 | function ToggleControlHideIfNoTranslations() { |
| 322 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, { | |
| 333 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, { | |
| 323 | 334 | label: i18nAttributeStrings.hide_if_no_translation, |
| 324 | 335 | checked: hide_if_no_translation // eslint-disable-line camelcase |
| 325 | 336 | , |
| 326 | 337 | onChange: toggleHideIfNoTranslation |
| @@ -336,8 +347,62 @@ | ||
| 336 | 347 | }; |
| 337 | 348 | } |
| 338 | 349 | // EXTERNAL MODULE: external {"this":["wp","element"]} |
| 339 | 350 | var external_this_wp_element_ = __webpack_require__(601); |
| 351 | +// EXTERNAL MODULE: external {"this":["wp","data"]} | |
| 352 | +var external_this_wp_data_ = __webpack_require__(987); | |
| 353 | +;// ./js/src/blocks/hooks/use-current-language-with-editor-context.js | |
| 354 | +/** | |
| 355 | + * WordPress dependencies | |
| 356 | + */ | |
| 357 | + | |
| 358 | + | |
| 359 | +/** | |
| 360 | + * Finds a language by slug. | |
| 361 | + * | |
| 362 | + * @param {Array} languages The languages list. | |
| 363 | + * @param {string} slug The language slug. | |
| 364 | + * @return {Object|null} The language, `null` if not found. | |
| 365 | + */ | |
| 366 | +const findLanguageBySlug = (languages, slug) => { | |
| 367 | + if (!languages || !slug) { | |
| 368 | + return null; | |
| 369 | + } | |
| 370 | + const currentLanguage = languages.find(language => { | |
| 371 | + return language.slug === slug; | |
| 372 | + }); | |
| 373 | + return currentLanguage ? currentLanguage : null; | |
| 374 | +}; | |
| 375 | + | |
| 376 | +/** | |
| 377 | + * Resolves the current language in block editor contexts. | |
| 378 | + * | |
| 379 | + * The widgets editor does not load `@wordpress/editor`, so the `core/editor` | |
| 380 | + * store may be unavailable. In that context, fall back to the current language | |
| 381 | + * slug injected by PHP (default language when none is set). | |
| 382 | + * | |
| 383 | + * @param {Array} languages The languages list. | |
| 384 | + * @return {Object|null} The current language, `null` if not found. | |
| 385 | + */ | |
| 386 | +const useCurrentLanguageWithEditorContext = languages => { | |
| 387 | + return (0,external_this_wp_data_.useSelect)(select => { | |
| 388 | + if (!languages) { | |
| 389 | + return null; | |
| 390 | + } | |
| 391 | + const editorStore = select('core/editor'); | |
| 392 | + if (!editorStore) { | |
| 393 | + return findLanguageBySlug(languages, pllEditorCurrentLanguageSlug // eslint-disable-line no-undef | |
| 394 | + ); | |
| 395 | + } | |
| 396 | + const currentPost = editorStore.getCurrentPost(); | |
| 397 | + if (!currentPost) { | |
| 398 | + return null; | |
| 399 | + } | |
| 400 | + const currentLanguageSlug = currentPost.lang ?? pllEditorCurrentLanguageSlug; // eslint-disable-line no-undef | |
| 401 | + | |
| 402 | + return findLanguageBySlug(languages, currentLanguageSlug); | |
| 403 | + }, [languages]); | |
| 404 | +}; | |
| 340 | 405 | ;// ./js/src/blocks/languages-context.js |
| 341 | 406 | /** |
| 342 | 407 | * WordPress dependencies. |
| 343 | 408 | */ |
| @@ -413,10 +478,10 @@ | ||
| 413 | 478 | const { |
| 414 | 479 | text, |
| 415 | 480 | flag |
| 416 | 481 | } = useMemoizedSwitcherLabel(language, showFlags, showNames); |
| 417 | - return /*#__PURE__*/(0,jsx_runtime.jsxs)("li", { | |
| 418 | - children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", { | |
| 482 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("li", { | |
| 483 | + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", { | |
| 419 | 484 | dangerouslySetInnerHTML: { |
| 420 | 485 | __html: flag |
| 421 | 486 | } |
| 422 | 487 | }), " ", text, " "] |
| @@ -445,11 +510,11 @@ | ||
| 445 | 510 | showNames, |
| 446 | 511 | isDropdown |
| 447 | 512 | }) => { |
| 448 | 513 | if (isDropdown) { |
| 449 | - return /*#__PURE__*/(0,jsx_runtime.jsx)("select", { | |
| 514 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("select", { | |
| 450 | 515 | children: languages.map(language => { |
| 451 | - return /*#__PURE__*/(0,jsx_runtime.jsx)("option", { | |
| 516 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("option", { | |
| 452 | 517 | value: language.slug, |
| 453 | 518 | children: language.name |
| 454 | 519 | }, language.slug); |
| 455 | 520 | }) |
| @@ -454,11 +519,11 @@ | ||
| 454 | 519 | }, language.slug); |
| 455 | 520 | }) |
| 456 | 521 | }); |
| 457 | 522 | } |
| 458 | - return /*#__PURE__*/(0,jsx_runtime.jsx)("ul", { | |
| 523 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("ul", { | |
| 459 | 524 | children: languages.map(language => { |
| 460 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherListElement, { | |
| 525 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherListElement, { | |
| 461 | 526 | language: language, |
| 462 | 527 | showFlags: showFlags, |
| 463 | 528 | showNames: showNames |
| 464 | 529 | }, language.slug); |
| @@ -464,39 +529,8 @@ | ||
| 464 | 529 | }, language.slug); |
| 465 | 530 | }) |
| 466 | 531 | }); |
| 467 | 532 | }; |
| 468 | -// EXTERNAL MODULE: external {"this":["wp","data"]} | |
| 469 | -var external_this_wp_data_ = __webpack_require__(987); | |
| 470 | -// EXTERNAL MODULE: external {"this":["wp","editor"]} | |
| 471 | -var external_this_wp_editor_ = __webpack_require__(2); | |
| 472 | -;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-current-language.js | |
| 473 | -/** | |
| 474 | - * WordPress dependencies | |
| 475 | - */ | |
| 476 | - | |
| 477 | -// This package is not found in `@wordpress/scripts` like others (peer dependency). | |
| 478 | -// eslint-disable-next-line import/no-unresolved | |
| 479 | - | |
| 480 | - | |
| 481 | -/** | |
| 482 | - * Custom hook to get the current language from the editor. | |
| 483 | - * | |
| 484 | - * @param {Array} languages The languages list. | |
| 485 | - * @return {Object|null} The current language, `null` if not found. | |
| 486 | - */ | |
| 487 | -const useCurrentLanguage = languages => { | |
| 488 | - const currentPost = (0,external_this_wp_data_.useSelect)(select => select(external_this_wp_editor_.store).getCurrentPost()); | |
| 489 | - if (!languages || !currentPost) { | |
| 490 | - return null; | |
| 491 | - } | |
| 492 | - const currentLanguageSlug = currentPost.lang ?? pllEditorCurrentLanguageSlug; // eslint-disable-line no-undef | |
| 493 | - | |
| 494 | - const currentLanguage = languages.find(language => { | |
| 495 | - return language.slug === currentLanguageSlug; | |
| 496 | - }); | |
| 497 | - return currentLanguage ? currentLanguage : null; | |
| 498 | -}; | |
| 499 | 533 | ;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-curated-languages.js |
| 500 | 534 | /** |
| 501 | 535 | * WordPress dependencies |
| 502 | 536 | */ |
| @@ -537,8 +571,9 @@ | ||
| 537 | 571 | |
| 538 | 572 | |
| 539 | 573 | |
| 540 | 574 | |
| 575 | + | |
| 541 | 576 | /** |
| 542 | 577 | * Switcher container component. |
| 543 | 578 | * |
| 544 | 579 | * @param {Object} props The component props. |
| @@ -556,11 +591,11 @@ | ||
| 556 | 591 | } = attributes; |
| 557 | 592 | const { |
| 558 | 593 | languages |
| 559 | 594 | } = (0,external_this_wp_element_.useContext)(LanguagesContext); |
| 560 | - const currentLanguage = useCurrentLanguage(languages); | |
| 595 | + const currentLanguage = useCurrentLanguageWithEditorContext(languages); | |
| 561 | 596 | const curatedLanguages = useCuratedLanguages(languages, currentLanguage, dropdown); |
| 562 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherUI, { | |
| 597 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherUI, { | |
| 563 | 598 | languages: curatedLanguages, |
| 564 | 599 | showFlags: show_flags, |
| 565 | 600 | showNames: show_names, |
| 566 | 601 | isDropdown: dropdown |
| @@ -630,21 +665,21 @@ | ||
| 630 | 665 | ToggleControlForceHome, |
| 631 | 666 | ToggleControlHideCurrent, |
| 632 | 667 | ToggleControlHideIfNoTranslations |
| 633 | 668 | } = createLanguageSwitcherEdit(props); |
| 634 | - return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { | |
| 669 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div", { | |
| 635 | 670 | ...(0,external_this_wp_blockEditor_.useBlockProps)(), |
| 636 | - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_blockEditor_.InspectorControls, { | |
| 637 | - children: /*#__PURE__*/(0,jsx_runtime.jsxs)(external_this_wp_components_.PanelBody, { | |
| 671 | + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_blockEditor_.InspectorControls, { | |
| 672 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_components_.PanelBody, { | |
| 638 | 673 | title: (0,external_this_wp_i18n_.__)('Language switcher settings', 'polylang'), |
| 639 | - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlDropdown, {}), !dropdown && /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlShowNames, {}), !dropdown && /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlShowFlags, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlForceHome, {}), !dropdown && /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlHideCurrent, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlHideIfNoTranslations, {})] | |
| 674 | + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlDropdown, {}), !dropdown && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlShowNames, {}), !dropdown && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlShowFlags, {}), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlForceHome, {}), !dropdown && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlHideCurrent, {}), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlHideIfNoTranslations, {})] | |
| 640 | 675 | }) |
| 641 | - }), /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.Disabled, { | |
| 642 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(LanguagesContext.Provider, { | |
| 676 | + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.Disabled, { | |
| 677 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(LanguagesContext.Provider, { | |
| 643 | 678 | value: { |
| 644 | 679 | languages |
| 645 | 680 | }, |
| 646 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherContainer, { | |
| 681 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherContainer, { | |
| 647 | 682 | attributes: props.attributes |
| 648 | 683 | }) |
| 649 | 684 | }) |
| 650 | 685 | })] |
| @@ -704,11 +739,11 @@ | ||
| 704 | 739 | const prefix = isTopLevel ? '' : ' '; |
| 705 | 740 | return ( |
| 706 | 741 | /*#__PURE__*/ |
| 707 | 742 | // eslint-disable-next-line jsx-a11y/anchor-is-valid |
| 708 | - (0,jsx_runtime.jsxs)("a", { | |
| 743 | + (0,react_jsx_runtime_production_min_namespaceFn().jsxs)("a", { | |
| 709 | 744 | href: '#', |
| 710 | - children: [prefix, /*#__PURE__*/(0,jsx_runtime.jsx)("span", { | |
| 745 | + children: [prefix, /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", { | |
| 711 | 746 | dangerouslySetInnerHTML: { |
| 712 | 747 | __html: flag |
| 713 | 748 | } |
| 714 | 749 | }), " ", text, " "] |
| @@ -725,15 +760,15 @@ | ||
| 725 | 760 | */ |
| 726 | 761 | |
| 727 | 762 | |
| 728 | 763 | const submenu_isPrimitivesComponents = 'undefined' !== typeof wp.primitives; |
| 729 | -const SubmenuIcon = () => submenu_isPrimitivesComponents ? /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_primitives_.SVG, { | |
| 764 | +const SubmenuIcon = () => submenu_isPrimitivesComponents ? /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_primitives_.SVG, { | |
| 730 | 765 | xmlns: "http://www.w3.org/2000/svg", |
| 731 | 766 | width: "12", |
| 732 | 767 | height: "12", |
| 733 | 768 | viewBox: "0 0 12 12", |
| 734 | 769 | fill: "none", |
| 735 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_primitives_.Path, { | |
| 770 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_primitives_.Path, { | |
| 736 | 771 | d: "M1.50002 4L6.00002 8L10.5 4", |
| 737 | 772 | strokeWidth: "1.5" |
| 738 | 773 | }) |
| 739 | 774 | }) : 'submenu'; |
| @@ -766,24 +801,50 @@ | ||
| 766 | 801 | showFlags, |
| 767 | 802 | showNames, |
| 768 | 803 | withSubmenuIcon |
| 769 | 804 | }) => { |
| 770 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, { | |
| 805 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)((react_jsx_runtime_production_min_namespaceFn().Fragment), { | |
| 771 | 806 | children: languages && languages.map(language => { |
| 772 | - return /*#__PURE__*/(0,jsx_runtime.jsxs)(external_this_wp_element_.Fragment, { | |
| 773 | - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherLinkElement, { | |
| 807 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_element_.Fragment, { | |
| 808 | + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherLinkElement, { | |
| 774 | 809 | language: language, |
| 775 | 810 | isTopLevel: languages.indexOf(language) === 0, |
| 776 | 811 | showFlags: showFlags, |
| 777 | 812 | showNames: showNames |
| 778 | - }), withSubmenuIcon && /*#__PURE__*/(0,jsx_runtime.jsx)("span", { | |
| 813 | + }), withSubmenuIcon && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", { | |
| 779 | 814 | className: "wp-block-navigation__submenu-icon", |
| 780 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(submenu, {}) | |
| 815 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(submenu, {}) | |
| 781 | 816 | })] |
| 782 | 817 | }, language.slug); |
| 783 | 818 | }) |
| 784 | 819 | }); |
| 785 | 820 | }; |
| 821 | +// EXTERNAL MODULE: external {"this":["wp","editor"]} | |
| 822 | +var external_this_wp_editor_ = __webpack_require__(2); | |
| 823 | +;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-current-language.js | |
| 824 | +/** | |
| 825 | + * WordPress dependencies | |
| 826 | + */ | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | +/** | |
| 831 | + * Custom hook to get the current language from the editor. | |
| 832 | + * | |
| 833 | + * @param {Array} languages The languages list. | |
| 834 | + * @return {Object|null} The current language, `null` if not found. | |
| 835 | + */ | |
| 836 | +const useCurrentLanguage = languages => { | |
| 837 | + const currentPost = (0,external_this_wp_data_.useSelect)(select => select(external_this_wp_editor_.store).getCurrentPost()); | |
| 838 | + if (!languages || !currentPost) { | |
| 839 | + return null; | |
| 840 | + } | |
| 841 | + const currentLanguageSlug = currentPost.lang ?? pllEditorCurrentLanguageSlug; | |
| 842 | + const currentLanguage = languages.find(language => { | |
| 843 | + return language.slug === currentLanguageSlug; | |
| 844 | + }); | |
| 845 | + return currentLanguage ? currentLanguage : null; | |
| 846 | +}; | |
| 786 | 847 | ;// ./js/src/blocks/navigation-language-switcher/components/navigation-switcher-container.js |
| 787 | 848 | /** |
| 788 | 849 | * WordPress dependencies |
| 789 | 850 | */ |
| @@ -822,9 +883,9 @@ | ||
| 822 | 883 | languages |
| 823 | 884 | } = (0,external_this_wp_element_.useContext)(LanguagesContext); |
| 824 | 885 | const currentLanguage = useCurrentLanguage(languages); |
| 825 | 886 | const curatedLanguages = useCuratedLanguages(languages, currentLanguage, dropdown); |
| 826 | - return /*#__PURE__*/(0,jsx_runtime.jsx)(switcher_ui_SwitcherUI, { | |
| 887 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(switcher_ui_SwitcherUI, { | |
| 827 | 888 | languages: curatedLanguages, |
| 828 | 889 | showFlags: Boolean(show_flags), |
| 829 | 890 | showNames: Boolean(show_names), |
| 830 | 891 | withSubmenuIcon: Boolean((showSubmenuIcon || openSubmenusOnClick) && dropdown) |
| @@ -869,21 +930,21 @@ | ||
| 869 | 930 | ToggleControlForceHome, |
| 870 | 931 | ToggleControlHideCurrent, |
| 871 | 932 | ToggleControlHideIfNoTranslations |
| 872 | 933 | } = createLanguageSwitcherEdit(props); |
| 873 | - return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { | |
| 934 | + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div", { | |
| 874 | 935 | ...(0,external_this_wp_blockEditor_.useBlockProps)(), |
| 875 | - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_blockEditor_.InspectorControls, { | |
| 876 | - children: /*#__PURE__*/(0,jsx_runtime.jsxs)(external_this_wp_components_.PanelBody, { | |
| 936 | + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_blockEditor_.InspectorControls, { | |
| 937 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_components_.PanelBody, { | |
| 877 | 938 | title: (0,external_this_wp_i18n_.__)('Language switcher settings', 'polylang'), |
| 878 | - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlDropdown, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlShowNames, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlShowFlags, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlForceHome, {}), !dropdown && /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlHideCurrent, {}), /*#__PURE__*/(0,jsx_runtime.jsx)(ToggleControlHideIfNoTranslations, {})] | |
| 939 | + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlDropdown, {}), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlShowNames, {}), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlShowFlags, {}), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlForceHome, {}), !dropdown && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlHideCurrent, {}), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(ToggleControlHideIfNoTranslations, {})] | |
| 879 | 940 | }) |
| 880 | - }), /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.Disabled, { | |
| 881 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(LanguagesContext.Provider, { | |
| 941 | + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.Disabled, { | |
| 942 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(LanguagesContext.Provider, { | |
| 882 | 943 | value: { |
| 883 | 944 | languages |
| 884 | 945 | }, |
| 885 | - children: /*#__PURE__*/(0,jsx_runtime.jsx)(NavigationSwitcherContainer, { | |
| 946 | + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(NavigationSwitcherContainer, { | |
| 886 | 947 | attributes: props.attributes, |
| 887 | 948 | context: props.context |
| 888 | 949 | }) |
| 889 | 950 | }) |