PluginProbe
Polylang / trunk
Polylang vtrunk
3.8.10 3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 All 234 releases
← All changes | js/build/blocks.js +901 -504 3.8.6 → trunk View file →
@@ -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"]; }());
@@ -40,15 +7,8 @@
40 7 module.exports = (function() { return this["React"]; }());
41 8
42 9 /***/ },
43 10
44 -/***/ 419
45 -(module) {
46 -
47 -module.exports = (function() { return this["lodash"]; }());
48 -
49 -/***/ },
50 -
51 11 /***/ 631
52 12 (module) {
53 13
54 14 module.exports = (function() { return this["wp"]["apiFetch"]; }());
@@ -110,8 +70,15 @@
110 70 module.exports = (function() { return this["wp"]["i18n"]; }());
111 71
112 72 /***/ },
113 73
74 +/***/ 672
75 +(module) {
76 +
77 +module.exports = (function() { return this["wp"]["notices"]; }());
78 +
79 +/***/ },
80 +
114 81 /***/ 933
115 82 (module) {
116 83
117 84 module.exports = (function() { return this["wp"]["primitives"]; }());
@@ -145,50 +112,46 @@
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 -/******/ const 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/value functions for harmony exports
163 -/******/ __webpack_require__.d = (exports, definition) => {
164 -/******/ if(Array.isArray(definition)) {
165 -/******/ var i = 0;
166 -/******/ while(i < definition.length) {
167 -/******/ var key = definition[i++];
168 -/******/ var binding = definition[i++];
169 -/******/ if(!__webpack_require__.o(exports, key)) {
170 -/******/ if(binding === 0) {
171 -/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
172 -/******/ } else {
173 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
174 -/******/ }
175 -/******/ } else if(binding === 0) { i++; }
176 -/******/ }
177 -/******/ } else {
178 -/******/ for(var key in definition) {
179 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
180 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
181 -/******/ }
182 -/******/ }
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] });
183 148 /******/ }
184 -/******/ };
185 -/******/ })();
149 +/******/ }
150 +/******/ };
186 151 /******/
187 152 /******/ /* webpack/runtime/hasOwnProperty shorthand */
188 -/******/ (() => {
189 -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
190 -/******/ })();
153 +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop));
191 154 /******/
192 155 /************************************************************************/
193 156 let __webpack_exports__ = {};
194 157 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
@@ -194,14 +157,47 @@
194 157 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
195 158 (() => {
196 159 "use strict";
197 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 +
198 193 // EXTERNAL MODULE: external {"this":["wp","blocks"]}
199 194 var external_this_wp_blocks_ = __webpack_require__(545);
200 195 // EXTERNAL MODULE: external {"this":["wp","primitives"]}
201 196 var external_this_wp_primitives_ = __webpack_require__(933);
202 -// EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
203 -var jsx_runtime = __webpack_require__(848);
197 +;// ./node_modules/react/jsx-runtime.js
198 +jsx_runtime_namespaceFn();
199 +
204 200 ;// ./node_modules/@wpsyntex/polylang-react-library/build/icons/translation.js
205 201 /**
206 202 * Translation icon - translation Dashicon.
207 203 */
@@ -211,337 +207,404 @@
211 207 */
212 208
213 209
214 210 const isPrimitivesComponents = 'undefined' !== typeof wp.primitives;
215 -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, {
216 212 width: "20",
217 213 height: "20",
218 214 xmlns: "http://www.w3.org/2000/svg",
219 215 viewBox: "0 0 20 20",
220 - 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, {
221 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"
222 218 })
223 219 }) : 'translation';
224 220 /* harmony default export */ const icons_translation = (translation);
225 -// EXTERNAL MODULE: external {"this":["wp","i18n"]}
226 -var external_this_wp_i18n_ = __webpack_require__(75);
221 +;// ./js/src/blocks/language-switcher/deprecated.js
222 +/**
223 + * Deprecated language switcher block.
224 + */
225 +
226 +const V2Attributes = {
227 + layout: 'vertical',
228 + show_labels: 'names',
229 + show_flags: false,
230 + force_home: false,
231 + hide_current: false,
232 + hide_if_no_translation: false,
233 + flag_aspect_ratio: '3:2',
234 + flag_border_radius: 0,
235 + flag_width: '18px',
236 + flag_label_spacing: '0.3em',
237 + className: ''
238 +};
239 +const v1 = {
240 + attributes: {
241 + dropdown: {
242 + type: 'boolean',
243 + default: false
244 + },
245 + show_names: {
246 + type: 'boolean',
247 + default: true
248 + },
249 + show_flags: {
250 + type: 'boolean',
251 + default: false
252 + },
253 + force_home: {
254 + type: 'boolean',
255 + default: false
256 + },
257 + hide_current: {
258 + type: 'boolean',
259 + default: false
260 + },
261 + hide_if_no_translation: {
262 + type: 'boolean',
263 + default: false
264 + },
265 + className: {
266 + type: 'string',
267 + default: ''
268 + }
269 + },
270 + isEligible: attributes => 'dropdown' in attributes || 'show_names' in attributes,
271 + migrate(attributes) {
272 + const {
273 + dropdown,
274 + show_names,
275 + show_flags,
276 + force_home,
277 + hide_current,
278 + hide_if_no_translation,
279 + className
280 + } = attributes;
281 + return {
282 + ...V2Attributes,
283 + layout: dropdown ? 'select' : 'vertical',
284 + show_labels: show_names ? 'names' : '',
285 + show_flags: show_names ? show_flags : true,
286 + force_home,
287 + hide_current,
288 + hide_if_no_translation,
289 + className: className || ''
290 + };
291 + }
292 +};
293 +/* harmony default export */ const deprecated = ([v1]);
227 294 // EXTERNAL MODULE: external {"this":["wp","blockEditor"]}
228 295 var external_this_wp_blockEditor_ = __webpack_require__(89);
229 296 // EXTERNAL MODULE: external {"this":["wp","components"]}
230 297 var external_this_wp_components_ = __webpack_require__(959);
231 -// EXTERNAL MODULE: external "lodash"
232 -var external_lodash_ = __webpack_require__(419);
233 -;// ./js/src/blocks/language-switcher-edit.js
298 +// EXTERNAL MODULE: external {"this":["wp","apiFetch"]}
299 +var external_this_wp_apiFetch_ = __webpack_require__(631);
300 +var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_);
301 +// EXTERNAL MODULE: external {"this":["wp","element"]}
302 +var external_this_wp_element_ = __webpack_require__(601);
303 +;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-languages-list.js
234 304 /**
235 - * Language switcher block edit.
305 + * WordPress dependencies
236 306 */
237 307
308 +
309 +
238 310 /**
239 - * External dependencies
311 + * Custom hook to get the languages list.
312 + *
313 + * @return {Array|null} The languages list, `null` if not loaded yet.
240 314 */
315 +const useLanguagesList = () => {
316 + const [languages, setLanguages] = (0,external_this_wp_element_.useState)(null);
317 + (0,external_this_wp_element_.useEffect)(() => {
318 + external_this_wp_apiFetch_default()({
319 + path: '/pll/v1/languages',
320 + method: 'GET'
321 + }).then(response => setLanguages(response));
322 + }, []);
323 + return languages;
324 +};
325 +;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-curated-languages.js
326 +/**
327 + * WordPress dependencies
328 + */
241 329
242 330
243 331 /**
332 + * Hook to curate the languages.
333 + * Returns an array of languages ensuring that the current language is always the first one.
334 + *
335 + * @param {Object[]} languages The languages.
336 + * @param {Object} currentLanguage The current language.
337 + * @param {boolean} reduceToOneItem Whether to reduce the languages to one item.
338 + * @return {Object[]} The curated languages.
339 + */
340 +const useCuratedLanguages = (languages, currentLanguage, reduceToOneItem) => {
341 + const curatedLanguages = (0,external_this_wp_element_.useMemo)(() => {
342 + if (!currentLanguage) {
343 + return [];
344 + }
345 + if (reduceToOneItem) {
346 + return [currentLanguage];
347 + }
348 + return [currentLanguage, ...languages.filter(language => {
349 + return language.slug !== currentLanguage.slug;
350 + })];
351 + }, [languages, currentLanguage, reduceToOneItem]);
352 + return curatedLanguages;
353 +};
354 +;// ./node_modules/@wpsyntex/polylang-react-library/build/icons/submenu.js
355 +/**
356 + * Submenu icon
357 + */
358 +
359 +/**
244 360 * WordPress dependencies
245 361 */
246 362
247 363
248 -const i18nAttributeStrings = pll_block_editor_blocks_settings;
249 -function createLanguageSwitcherEdit(props) {
250 - const createToggleAttribute = function (propName) {
251 - return () => {
252 - const value = props.attributes[propName];
253 - const {
254 - setAttributes
255 - } = props;
256 - let updatedAttributes = {
257 - [propName]: !value
258 - };
259 - let forcedAttributeName;
260 - let forcedAttributeUnchecked;
364 +const submenu_isPrimitivesComponents = 'undefined' !== typeof wp.primitives;
365 +const SubmenuIcon = () => submenu_isPrimitivesComponents ? /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_primitives_.SVG, {
366 + xmlns: "http://www.w3.org/2000/svg",
367 + width: "12",
368 + height: "12",
369 + viewBox: "0 0 12 12",
370 + fill: "none",
371 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_primitives_.Path, {
372 + d: "M1.50002 4L6.00002 8L10.5 4",
373 + strokeWidth: "1.5"
374 + })
375 +}) : 'submenu';
376 +/* harmony default export */ const submenu = (SubmenuIcon);
377 +;// ./js/src/blocks/components/switcher-link-element.js
261 378
262 - // Both show_names and show_flags attributes can't be unchecked together.
263 - switch (propName) {
264 - case 'show_names':
265 - forcedAttributeName = 'show_flags';
266 - forcedAttributeUnchecked = !props.attributes[forcedAttributeName];
267 - break;
268 - case 'show_flags':
269 - forcedAttributeName = 'show_names';
270 - forcedAttributeUnchecked = !props.attributes[forcedAttributeName];
271 - break;
272 - }
273 - if ('show_names' === propName || 'show_flags' === propName) {
274 - if (value && forcedAttributeUnchecked) {
275 - updatedAttributes = (0,external_lodash_.assign)(updatedAttributes, {
276 - [forcedAttributeName]: forcedAttributeUnchecked
277 - });
278 - }
279 - }
280 - setAttributes(updatedAttributes);
281 - };
282 - };
283 - const toggleDropdown = createToggleAttribute('dropdown');
284 - const toggleShowNames = createToggleAttribute('show_names');
285 - const toggleShowFlags = createToggleAttribute('show_flags');
286 - const toggleForceHome = createToggleAttribute('force_home');
287 - const toggleHideCurrent = createToggleAttribute('hide_current');
288 - const toggleHideIfNoTranslation = createToggleAttribute('hide_if_no_translation');
289 - const {
290 - dropdown,
291 - show_names,
292 - show_flags,
293 - force_home,
294 - hide_current,
295 - hide_if_no_translation
296 - } = props.attributes;
297 - function ToggleControlDropdown() {
298 - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, {
299 - label: i18nAttributeStrings.dropdown,
300 - checked: dropdown,
301 - onChange: toggleDropdown
302 - });
379 +/**
380 + * Switcher link element component.
381 + *
382 + * @param {Object} props Component props.
383 + * @param {ReactElement} props.flag Flag to display.
384 + * @param {string} props.label Label to display.
385 + * @param {string} props.labelSpacing CSS length for the space between flag and label.
386 + * @return {ReactElement} The Switcher element component.
387 + */
388 +const SwitcherLinkElement = ({
389 + flag,
390 + label,
391 + labelSpacing
392 +}) => {
393 + const hasLabel = '' !== label;
394 + const labelStyle = hasLabel && labelSpacing ? {
395 + '--pll-flag-label-spacing': labelSpacing
396 + } : undefined;
397 + return (
398 + /*#__PURE__*/
399 + // eslint-disable-next-line jsx-a11y/anchor-is-valid
400 + (0,react_jsx_runtime_production_min_namespaceFn().jsxs)("a", {
401 + href: '#',
402 + children: [flag, hasLabel && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", {
403 + className: "pll-switcher-label",
404 + style: labelStyle,
405 + children: label
406 + })]
407 + })
408 + );
409 +};
410 +;// ./js/src/blocks/components/switcher-utils.js
411 +/**
412 + * Returns the switcher wrapper class names.
413 + *
414 + * @param {string} layout The switcher layout.
415 + * @param {boolean} showFlags Whether flags are displayed.
416 + * @param {string} flagAspectRatio The flag aspect ratio.
417 + * @param {string} [alignment] The items alignment. Omitted when unset.
418 + * @return {string} The switcher class names.
419 + */
420 +const getSwitcherClassName = (layout, showFlags, flagAspectRatio, alignment) => {
421 + const classes = ['pll-switcher', `pll-layout-${layout}`];
422 + if (alignment) {
423 + classes.push(`pll-alignment-${alignment}`);
303 424 }
304 - function ToggleControlShowNames() {
305 - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, {
306 - label: i18nAttributeStrings.show_names,
307 - checked: show_names // eslint-disable-line camelcase
308 - ,
309 - onChange: toggleShowNames
310 - });
425 + if (showFlags) {
426 + classes.push(`pll-aspect-ratio-${flagAspectRatio.replace(':', '')}`);
311 427 }
312 - function ToggleControlShowFlags() {
313 - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, {
314 - label: i18nAttributeStrings.show_flags,
315 - checked: show_flags // eslint-disable-line camelcase
316 - ,
317 - onChange: toggleShowFlags
318 - });
319 - }
320 - function ToggleControlForceHome() {
321 - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, {
322 - label: i18nAttributeStrings.force_home,
323 - checked: force_home // eslint-disable-line camelcase
324 - ,
325 - onChange: toggleForceHome
326 - });
327 - }
328 - function ToggleControlHideCurrent() {
329 - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, {
330 - label: i18nAttributeStrings.hide_current,
331 - checked: hide_current // eslint-disable-line camelcase
332 - ,
333 - onChange: toggleHideCurrent
334 - });
335 - }
336 - function ToggleControlHideIfNoTranslations() {
337 - return /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.ToggleControl, {
338 - label: i18nAttributeStrings.hide_if_no_translation,
339 - checked: hide_if_no_translation // eslint-disable-line camelcase
340 - ,
341 - onChange: toggleHideIfNoTranslation
342 - });
343 - }
344 - return {
345 - ToggleControlDropdown,
346 - ToggleControlShowNames,
347 - ToggleControlShowFlags,
348 - ToggleControlForceHome,
349 - ToggleControlHideCurrent,
350 - ToggleControlHideIfNoTranslations
351 - };
352 -}
353 -// EXTERNAL MODULE: external {"this":["wp","element"]}
354 -var external_this_wp_element_ = __webpack_require__(601);
355 -;// ./js/src/blocks/languages-context.js
428 + return classes.join(' ');
429 +};
430 +
356 431 /**
357 - * WordPress dependencies.
432 + * Gets the label for a language.
433 + *
434 + * @param {Object} language The language object.
435 + * @param {string} showLabels Whether to show the names. Can be 'names', 'codes' or ''.
436 + * @return {string} The label for the language.
358 437 */
438 +const getLabel = (language, showLabels) => {
439 + let label = '';
440 + if (showLabels === 'names') {
441 + label = language.name;
442 + } else if (showLabels === 'codes') {
443 + label = language.slug.toUpperCase();
444 + }
445 + return label;
446 +};
359 447
360 -
361 448 /**
362 - * Context for the languages.
449 + * Returns the CSS length for the space between flag and label.
363 450 *
364 - * @type {React.Context<null>}
451 + * @param {string} showLabels Whether to show labels. Can be 'names', 'codes' or ''.
452 + * @param {string} flagLabelSpacing CSS length for the space between flag and label.
453 + * @return {string|undefined} The label spacing, or undefined when labels are hidden.
365 454 */
366 -const LanguagesContext = (0,external_this_wp_element_.createContext)(null);
367 -;// ./js/src/blocks/hooks/use-memoized-switcher-label.js
455 +const getLabelSpacing = (showLabels, flagLabelSpacing) => {
456 + if ('' === showLabels) {
457 + return undefined;
458 + }
459 + return flagLabelSpacing;
460 +};
461 +;// ./js/src/blocks/hooks/use-memoized-flag.js
368 462 /**
369 463 * WordPress dependencies
370 464 */
371 -// '@wordpress/element' is provided by WordPress core.
372 -// eslint-disable-next-line import/no-extraneous-dependencies
373 465
374 466
375 467 /**
376 - * Hook to memoize the switcher label.
468 + * Strips fixed dimensions from flag HTML markup.
377 469 *
378 - * @param {Object} language The language object.
379 - * @param {boolean} showFlags Whether to show the flags.
380 - * @param {boolean} showNames Whether to show the names.
381 - * @return {Object} The memoized switcher label containing the text and the flag.
470 + * @param {string} html The flag HTML markup.
471 + * @return {string} The flag HTML without fixed dimensions.
382 472 */
383 -const useMemoizedSwitcherLabel = (language, showFlags, showNames) => {
384 - const {
385 - text,
386 - flag
387 - } = (0,external_this_wp_element_.useMemo)(() => {
388 - let memoizedText = '';
389 - if (showNames) {
390 - if (showFlags) {
391 - memoizedText = ` ${language.name}`;
392 - } else {
393 - memoizedText = language.name;
394 - }
395 - }
396 - const memoizedFlag = showFlags ? language.flag : '';
397 - return {
398 - text: memoizedText,
399 - flag: memoizedFlag
400 - };
401 - }, [language, showFlags, showNames]);
402 - return {
403 - text,
404 - flag
405 - };
473 +
474 +const stripFlagDimensions = html => {
475 + return html.replace(/\s(?:width|height)=["'][^"']*["']/gi, '').replace(/\sstyle=["'][^"']*["']/gi, '');
406 476 };
407 -;// ./js/src/blocks/language-switcher/components/switcher-list-element.js
408 -/**
409 - * Internal dependencies
410 - */
411 477
412 -
413 478 /**
414 - * Switcher list element component.
479 + * Returns a memoized flag element for a language.
415 480 *
416 - * @param {Object} props Component props.
417 - * @param {Object} props.language Language object.
418 - * @param {boolean} props.showFlags Whether to show the flags.
419 - * @param {boolean} props.showNames Whether to show the names.
420 - * @return {ReactElement} The Switcher element component.
481 + * @param {Object} language The language object.
482 + * @param {boolean} showFlags Whether to show the flags.
483 + * @param {number} flagBorderRadius The border radius of the flags.
484 + * @param {string} flagWidth The width of the flags as a CSS length.
485 + * @return {ReactElement|null} The flag for the language.
421 486 */
422 -
423 -const SwitcherListElement = ({
424 - language,
425 - showFlags,
426 - showNames
427 -}) => {
428 - const {
429 - text,
430 - flag
431 - } = useMemoizedSwitcherLabel(language, showFlags, showNames);
432 - return /*#__PURE__*/(0,jsx_runtime.jsxs)("li", {
433 - children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
487 +const useMemoizedFlag = (language, showFlags, flagBorderRadius, flagWidth) => {
488 + return (0,external_this_wp_element_.useMemo)(() => {
489 + if (!showFlags || !language?.flag) {
490 + return null;
491 + }
492 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", {
493 + className: "pll-switcher-flag",
494 + style: {
495 + '--pll-flag-border-radius': flagBorderRadius,
496 + '--pll-flag-width': flagWidth
497 + },
434 498 dangerouslySetInnerHTML: {
435 - __html: flag
499 + __html: stripFlagDimensions(language.flag)
436 500 }
437 - }), " ", text, " "]
438 - });
501 + });
502 + }, [language?.flag, showFlags, flagBorderRadius, flagWidth]);
439 503 };
440 -;// ./js/src/blocks/language-switcher/components/switcher-ui.js
504 +;// ./js/src/blocks/components/switcher-language-link.js
441 505 /**
442 506 * Internal dependencies
443 507 */
444 508
445 509
510 +
511 +
446 512 /**
447 - * Switcher UI component.
513 + * Renders a language link for the switcher preview.
448 514 *
449 - * @param {Object} props The component props.
450 - * @param {Array} props.languages The languages to display.
451 - * @param {boolean} props.showFlags Whether to show the flags.
452 - * @param {boolean} props.showNames Whether to show the names.
453 - * @param {boolean} props.isDropdown Whether to show the dropdown.
454 - * @return {ReactElement} The Switcher UI component.
515 + * @param {Object} props Component props.
516 + * @param {Object} props.language The language object.
517 + * @param {string} props.showLabels Whether to show labels. Can be 'names', 'codes' or ''.
518 + * @param {boolean} props.showFlags Whether to show the flags.
519 + * @param {number} props.flagBorderRadius The border radius of the flags.
520 + * @param {string} props.flagWidth The width of the flags as a CSS length.
521 + * @param {string|undefined} props.labelSpacing CSS length for the space between flag and label.
522 + * @return {ReactElement} The language link element.
455 523 */
456 524
457 -const SwitcherUI = ({
458 - languages,
525 +const SwitcherLanguageLink = ({
526 + language,
527 + showLabels,
459 528 showFlags,
460 - showNames,
461 - isDropdown
529 + flagBorderRadius,
530 + flagWidth,
531 + labelSpacing
462 532 }) => {
463 - if (isDropdown) {
464 - return /*#__PURE__*/(0,jsx_runtime.jsx)("select", {
465 - children: languages.map(language => {
466 - return /*#__PURE__*/(0,jsx_runtime.jsx)("option", {
467 - value: language.slug,
468 - children: language.name
469 - }, language.slug);
470 - })
471 - });
472 - }
473 - return /*#__PURE__*/(0,jsx_runtime.jsx)("ul", {
474 - children: languages.map(language => {
475 - return /*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherListElement, {
476 - language: language,
477 - showFlags: showFlags,
478 - showNames: showNames
479 - }, language.slug);
480 - })
533 + const flag = useMemoizedFlag(language, showFlags, flagBorderRadius, flagWidth);
534 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherLinkElement, {
535 + label: getLabel(language, showLabels),
536 + flag: flag,
537 + labelSpacing: labelSpacing
481 538 });
482 539 };
483 540 // EXTERNAL MODULE: external {"this":["wp","data"]}
484 541 var external_this_wp_data_ = __webpack_require__(987);
485 -// EXTERNAL MODULE: external {"this":["wp","editor"]}
486 -var external_this_wp_editor_ = __webpack_require__(2);
487 -;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-current-language.js
542 +;// ./js/src/blocks/hooks/use-current-language-with-editor-context.js
488 543 /**
489 544 * WordPress dependencies
490 545 */
491 546
492 -// This package is not found in `@wordpress/scripts` like others (peer dependency).
493 -// eslint-disable-next-line import/no-unresolved
494 547
495 -
496 548 /**
497 - * Custom hook to get the current language from the editor.
549 + * Finds a language by slug.
498 550 *
499 - * @param {Array} languages The languages list.
500 - * @return {Object|null} The current language, `null` if not found.
551 + * @param {Array} languages The languages list.
552 + * @param {string} slug The language slug.
553 + * @return {Object|null} The language, `null` if not found.
501 554 */
502 -const useCurrentLanguage = languages => {
503 - const currentPost = (0,external_this_wp_data_.useSelect)(select => select(external_this_wp_editor_.store).getCurrentPost());
504 - if (!languages || !currentPost) {
555 +const findLanguageBySlug = (languages, slug) => {
556 + if (!languages || !slug) {
505 557 return null;
506 558 }
507 - const currentLanguageSlug = currentPost.lang ?? pllEditorCurrentLanguageSlug; // eslint-disable-line no-undef
508 -
509 559 const currentLanguage = languages.find(language => {
510 - return language.slug === currentLanguageSlug;
560 + return language.slug === slug;
511 561 });
512 562 return currentLanguage ? currentLanguage : null;
513 563 };
514 -;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-curated-languages.js
564 +
515 565 /**
516 - * WordPress dependencies
566 + * Resolves the current language in block editor contexts.
567 + *
568 + * The widgets editor does not load `@wordpress/editor`, so the `core/editor`
569 + * store may be unavailable. In that context, fall back to the current language
570 + * slug injected by PHP (default language when none is set).
571 + *
572 + * @param {Array} languages The languages list.
573 + * @return {Object|null} The current language, `null` if not found.
517 574 */
575 +const useCurrentLanguageWithEditorContext = languages => {
576 + return (0,external_this_wp_data_.useSelect)(select => {
577 + if (!languages) {
578 + return null;
579 + }
580 + const editorStore = select('core/editor');
581 + if (!editorStore) {
582 + return findLanguageBySlug(languages, pllEditorCurrentLanguageSlug // eslint-disable-line no-undef
583 + );
584 + }
585 + const currentPost = editorStore.getCurrentPost();
586 + if (!currentPost) {
587 + return null;
588 + }
589 + const currentLanguageSlug = currentPost.lang ?? pllEditorCurrentLanguageSlug; // eslint-disable-line no-undef
518 590
591 + return findLanguageBySlug(languages, currentLanguageSlug);
592 + }, [languages]);
593 +};
594 +;// ./js/src/blocks/languages-context.js
595 +/**
596 + * WordPress dependencies.
597 + */
519 598
599 +
520 600 /**
521 - * Hook to curate the languages.
522 - * Returns an array of languages ensuring that the current language is always the first one.
601 + * Context for the languages.
523 602 *
524 - * @param {Object[]} languages The languages.
525 - * @param {Object} currentLanguage The current language.
526 - * @param {boolean} reduceToOneItem Whether to reduce the languages to one item.
527 - * @return {Object[]} The curated languages.
603 + * @type {React.Context<null>}
528 604 */
529 -const useCuratedLanguages = (languages, currentLanguage, reduceToOneItem) => {
530 - const curatedLanguages = (0,external_this_wp_element_.useMemo)(() => {
531 - if (!currentLanguage) {
532 - return [];
533 - }
534 - if (reduceToOneItem) {
535 - return [currentLanguage];
536 - }
537 - return [currentLanguage, ...languages.filter(language => {
538 - return language.slug !== currentLanguage.slug;
539 - })];
540 - }, [languages, currentLanguage, reduceToOneItem]);
541 - return curatedLanguages;
542 -};
543 -;// ./js/src/blocks/language-switcher/components/switcher-container.js
605 +const LanguagesContext = (0,external_this_wp_element_.createContext)(null);
606 +;// ./js/src/blocks/language-switcher/rendered-switcher.js
544 607 /**
545 608 * WordPress dependencies
546 609 */
547 610
@@ -546,8 +609,13 @@
546 609 */
547 610
548 611
549 612 /**
613 + * External dependencies
614 + */
615 +
616 +
617 +/**
550 618 * Internal dependencies
551 619 */
552 620
553 621
@@ -552,40 +620,94 @@
552 620
553 621
554 622
555 623
624 +
556 625 /**
557 - * Switcher container component.
626 + * Rendered switcher component.
558 627 *
559 628 * @param {Object} props The component props.
560 629 * @param {Object} props.attributes The block attributes.
561 - * @return {ReactElement} The Switcher component.
630 + * @return {ReactElement} The rendered switcher.
562 631 */
563 632
564 -const SwitcherContainer = ({
633 +const RenderedSwitcher = ({
565 634 attributes
566 635 }) => {
567 636 const {
568 - dropdown,
637 + layout,
638 + show_labels,
569 639 show_flags,
570 - show_names
640 + flag_aspect_ratio,
641 + flag_border_radius,
642 + flag_width,
643 + flag_label_spacing,
644 + style
571 645 } = attributes;
572 646 const {
573 647 languages
574 648 } = (0,external_this_wp_element_.useContext)(LanguagesContext);
575 - const currentLanguage = useCurrentLanguage(languages);
576 - const curatedLanguages = useCuratedLanguages(languages, currentLanguage, dropdown);
577 - return /*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherUI, {
578 - languages: curatedLanguages,
649 + const currentLanguage = useCurrentLanguageWithEditorContext(languages);
650 + const curatedLanguages = useCuratedLanguages(languages, currentLanguage, false);
651 + const alignment = style?.typography?.textAlign;
652 + const switcherClassName = getSwitcherClassName(layout, show_flags, flag_aspect_ratio, alignment);
653 + const labelSpacing = getLabelSpacing(show_labels, flag_label_spacing);
654 + const linkProps = {
655 + showLabels: show_labels,
579 656 showFlags: show_flags,
580 - showNames: show_names,
581 - isDropdown: dropdown
657 + flagBorderRadius: flag_border_radius,
658 + flagWidth: flag_width,
659 + labelSpacing
660 + };
661 + if (layout === 'dropdown') {
662 + const currentLanguageItem = curatedLanguages[0];
663 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("nav", {
664 + className: switcherClassName,
665 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div", {
666 + className: "pll-switcher-inner",
667 + children: [currentLanguageItem && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherLanguageLink, {
668 + language: currentLanguageItem,
669 + ...linkProps
670 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("button", {
671 + className: "pll-submenu-toggle",
672 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(submenu, {})
673 + })]
674 + })
675 + });
676 + }
677 + if (layout === 'select') {
678 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("div", {
679 + className: switcherClassName,
680 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("select", {
681 + className: "pll-switcher-select",
682 + children: curatedLanguages.map(language => {
683 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("option", {
684 + value: language.slug,
685 + children: getLabel(language, show_labels)
686 + }, language.slug);
687 + })
688 + })
689 + });
690 + }
691 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("nav", {
692 + className: switcherClassName,
693 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("ul", {
694 + children: curatedLanguages.map(language => {
695 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("li", {
696 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherLanguageLink, {
697 + language: language,
698 + ...linkProps
699 + })
700 + }, language.slug);
701 + })
702 + })
582 703 });
583 704 };
584 -// EXTERNAL MODULE: external {"this":["wp","apiFetch"]}
585 -var external_this_wp_apiFetch_ = __webpack_require__(631);
586 -var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_);
587 -;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-languages-list.js
705 +// EXTERNAL MODULE: external {"this":["wp","i18n"]}
706 +var external_this_wp_i18n_ = __webpack_require__(75);
707 +// EXTERNAL MODULE: external {"this":["wp","notices"]}
708 +var external_this_wp_notices_ = __webpack_require__(672);
709 +;// ./js/src/blocks/components/switcher-controls.js
588 710 /**
589 711 * WordPress dependencies
590 712 */
591 713
@@ -590,22 +712,283 @@
590 712 */
591 713
592 714
593 715
716 +
717 +
718 +
719 +const CSS_LENGTH_UNITS = [{
720 + value: 'px',
721 + label: 'px'
722 +}, {
723 + value: 'em',
724 + label: 'em'
725 +}, {
726 + value: 'rem',
727 + label: 'rem'
728 +}, {
729 + value: 'vh',
730 + label: 'vh'
731 +}, {
732 + value: 'vw',
733 + label: 'vw'
734 +}];
735 +const LABEL_SPACING_DEFAULT_VALUE = '0.3em';
736 +const ALL_LAYOUT_OPTIONS = [{
737 + label: (0,external_this_wp_i18n_._x)('Horizontal', 'layout', 'polylang'),
738 + value: 'horizontal'
739 +}, {
740 + label: (0,external_this_wp_i18n_._x)('Vertical', 'layout', 'polylang'),
741 + value: 'vertical'
742 +}, {
743 + label: (0,external_this_wp_i18n_.__)('Dropdown', 'polylang'),
744 + value: 'dropdown'
745 +}, {
746 + label: (0,external_this_wp_i18n_.__)('Selector', 'polylang'),
747 + value: 'select'
748 +}];
749 +const ALL_LAYOUT_TOOLBAR_CONTROLS = [{
750 + title: (0,external_this_wp_i18n_._x)('Horizontal', 'layout', 'polylang'),
751 + layout: 'horizontal'
752 +}, {
753 + title: (0,external_this_wp_i18n_._x)('Vertical', 'layout', 'polylang'),
754 + layout: 'vertical'
755 +}, {
756 + title: (0,external_this_wp_i18n_.__)('Dropdown', 'polylang'),
757 + layout: 'dropdown'
758 +}];
759 +
594 760 /**
595 - * Custom hook to get the languages list.
761 + * Switcher controls component for toolbar and inspector controls.
596 762 *
597 - * @return {Array|null} The languages list, `null` if not loaded yet.
763 + * @param {Object} props The component props.
764 + * @param {Object} props.attributes The block attributes.
765 + * @param {Function} props.setAttributes The function to set the block attributes.
766 + * @param {Array<string>} props.layoutOptions Optional layout values to expose.
767 + * @return {React.ReactNode} The switcher controls component.
598 768 */
599 -const useLanguagesList = () => {
600 - const [languages, setLanguages] = (0,external_this_wp_element_.useState)(null);
601 - (0,external_this_wp_element_.useEffect)(() => {
602 - external_this_wp_apiFetch_default()({
603 - path: '/pll/v1/languages',
604 - method: 'GET'
605 - }).then(response => setLanguages(response));
606 - }, []);
607 - return languages;
769 +const SwitcherControls = ({
770 + attributes,
771 + setAttributes,
772 + layoutOptions = ['horizontal', 'vertical', 'dropdown', 'select']
773 +}) => {
774 + const {
775 + layout,
776 + show_labels,
777 + show_flags,
778 + force_home,
779 + hide_current,
780 + flag_aspect_ratio,
781 + flag_border_radius,
782 + flag_width,
783 + flag_label_spacing,
784 + hide_if_no_translation
785 + } = attributes;
786 + const {
787 + createWarningNotice
788 + } = (0,external_this_wp_data_.useDispatch)(external_this_wp_notices_.store);
789 + const layoutSelectOptions = ALL_LAYOUT_OPTIONS.filter(option => layoutOptions.includes(option.value));
790 + const layoutToolbarControls = ALL_LAYOUT_TOOLBAR_CONTROLS.filter(control => layoutOptions.includes(control.layout)).map(control => ({
791 + title: control.title,
792 + onClick: () => setAttributes({
793 + layout: control.layout
794 + })
795 + }));
796 + const labelOptions = [{
797 + label: (0,external_this_wp_i18n_.__)('Language names', 'polylang'),
798 + value: 'names'
799 + }, {
800 + label: (0,external_this_wp_i18n_.__)('Language codes', 'polylang'),
801 + value: 'codes'
802 + }];
803 + if (show_flags) {
804 + labelOptions.push({
805 + label: (0,external_this_wp_i18n_._x)('None', 'Labels', 'polylang'),
806 + value: ''
807 + });
808 + }
809 + const toolbarLabelControls = [{
810 + title: (0,external_this_wp_i18n_.__)('Language names', 'polylang'),
811 + onClick: () => setAttributes({
812 + show_labels: 'names'
813 + })
814 + }, {
815 + title: (0,external_this_wp_i18n_.__)('Language codes', 'polylang'),
816 + onClick: () => setAttributes({
817 + show_labels: 'codes'
818 + })
819 + }];
820 + if (show_flags) {
821 + toolbarLabelControls.push({
822 + title: (0,external_this_wp_i18n_._x)('None', 'Labels', 'polylang'),
823 + onClick: () => {
824 + if (!show_flags) {
825 + createWarningNotice((0,external_this_wp_i18n_.__)('Labels cannot be hidden if flags are not shown.', 'polylang'));
826 + return;
827 + }
828 + setAttributes({
829 + show_labels: '',
830 + flag_label_spacing: LABEL_SPACING_DEFAULT_VALUE
831 + });
832 + }
833 + });
834 + }
835 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)((react_jsx_runtime_production_min_namespaceFn().Fragment), {
836 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_blockEditor_.InspectorControls, {
837 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_components_.PanelBody, {
838 + title: (0,external_this_wp_i18n_.__)('Display', 'polylang'),
839 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.SelectControl, {
840 + label: (0,external_this_wp_i18n_.__)('Layout', 'polylang'),
841 + value: layout,
842 + options: layoutSelectOptions,
843 + onChange: value => {
844 + setAttributes({
845 + layout: value
846 + });
847 + if ('select' === value) {
848 + setAttributes({
849 + show_flags: false
850 + });
851 + if ('' === show_labels) {
852 + setAttributes({
853 + show_labels: 'names'
854 + });
855 + }
856 + }
857 + },
858 + __next40pxDefaultSize: true
859 + }), 'select' !== layout && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.SelectControl, {
860 + label: (0,external_this_wp_i18n_.__)('Labels', 'polylang'),
861 + value: show_labels,
862 + options: labelOptions,
863 + onChange: value => {
864 + if ('' === value) {
865 + if (!show_flags) {
866 + createWarningNotice((0,external_this_wp_i18n_.__)('Labels cannot be hidden if flags are not shown.', 'polylang'));
867 + return;
868 + }
869 + setAttributes({
870 + show_labels: value,
871 + flag_label_spacing: LABEL_SPACING_DEFAULT_VALUE
872 + });
873 + return;
874 + }
875 + setAttributes({
876 + show_labels: value
877 + });
878 + },
879 + __next40pxDefaultSize: true
880 + })]
881 + }), 'select' !== layout && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_components_.PanelBody, {
882 + title: (0,external_this_wp_i18n_.__)('Flags Settings', 'polylang'),
883 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, {
884 + label: (0,external_this_wp_i18n_.__)('Display flags', 'polylang'),
885 + checked: show_flags,
886 + onChange: value => {
887 + if ('' === show_labels && !value) {
888 + createWarningNotice((0,external_this_wp_i18n_.__)('Flags cannot be hidden if labels are not displayed.', 'polylang'));
889 + return;
890 + }
891 + setAttributes({
892 + show_flags: value
893 + });
894 + }
895 + }), show_flags && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)((react_jsx_runtime_production_min_namespaceFn().Fragment), {
896 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.RadioControl, {
897 + label: (0,external_this_wp_i18n_.__)('Aspect', 'polylang'),
898 + selected: flag_aspect_ratio,
899 + options: [{
900 + label: (0,external_this_wp_i18n_.__)('Landscape (3:2)', 'polylang'),
901 + value: '3:2'
902 + }, {
903 + label: (0,external_this_wp_i18n_.__)('Square (1:1)', 'polylang'),
904 + value: '1:1'
905 + }],
906 + onChange: value => setAttributes({
907 + flag_aspect_ratio: value
908 + })
909 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.RangeControl, {
910 + label: (0,external_this_wp_i18n_.__)('Border radius', 'polylang'),
911 + initialPosition: 0,
912 + value: flag_border_radius,
913 + min: 0,
914 + max: 100,
915 + step: 1,
916 + allowReset: true,
917 + resetFallbackValue: 0,
918 + onChange: value => setAttributes({
919 + flag_border_radius: value
920 + }),
921 + __next40pxDefaultSize: true
922 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.__experimentalUnitControl, {
923 + __next40pxDefaultSize: true,
924 + label: (0,external_this_wp_i18n_.__)('Size', 'polylang'),
925 + value: flag_width,
926 + units: CSS_LENGTH_UNITS,
927 + onChange: value => setAttributes({
928 + flag_width: value
929 + })
930 + }), '' !== show_labels && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.__experimentalUnitControl, {
931 + __next40pxDefaultSize: true,
932 + label: (0,external_this_wp_i18n_.__)('Label spacing', 'polylang'),
933 + value: flag_label_spacing,
934 + units: CSS_LENGTH_UNITS,
935 + onChange: value => setAttributes({
936 + flag_label_spacing: value
937 + })
938 + })]
939 + })]
940 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_components_.PanelBody, {
941 + title: (0,external_this_wp_i18n_.__)('Behavior', 'polylang'),
942 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, {
943 + label: (0,external_this_wp_i18n_.__)('Force link to front page', 'polylang'),
944 + checked: force_home,
945 + onChange: value => setAttributes({
946 + force_home: value
947 + })
948 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, {
949 + label: (0,external_this_wp_i18n_.__)('Hide the current language', 'polylang'),
950 + checked: hide_current,
951 + onChange: value => setAttributes({
952 + hide_current: value
953 + })
954 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToggleControl, {
955 + label: (0,external_this_wp_i18n_.__)('Hide languages with no translation', 'polylang'),
956 + checked: hide_if_no_translation,
957 + onChange: value => setAttributes({
958 + hide_if_no_translation: value
959 + })
960 + })]
961 + })]
962 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_blockEditor_.BlockControls, {
963 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_components_.ToolbarGroup, {
964 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToolbarDropdownMenu, {
965 + label: (0,external_this_wp_i18n_.__)('Layout', 'polylang'),
966 + controls: layoutToolbarControls
967 + }), 'select' !== layout && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToolbarButton, {
968 + icon: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", {
969 + className: "dashicons dashicons-flag"
970 + }),
971 + label: show_flags ? (0,external_this_wp_i18n_.__)('Hide flags', 'polylang') : (0,external_this_wp_i18n_.__)('Display flags', 'polylang'),
972 + onClick: () => {
973 + if (show_flags && '' === show_labels) {
974 + createWarningNotice((0,external_this_wp_i18n_.__)('Flags cannot be hidden if labels are not displayed.', 'polylang'));
975 + return;
976 + }
977 + setAttributes({
978 + show_flags: !show_flags
979 + });
980 + }
981 + }), 'select' !== layout && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.ToolbarDropdownMenu, {
982 + icon: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", {
983 + className: "dashicons dashicons-editor-textcolor"
984 + }),
985 + label: (0,external_this_wp_i18n_.__)('Labels', 'polylang'),
986 + controls: toolbarLabelControls
987 + })]
988 + })
989 + })]
990 + });
608 991 };
609 992 ;// ./js/src/blocks/language-switcher/edit.js
610 993 /**
611 994 * Edit callback for language switcher block.
@@ -616,9 +999,8 @@
616 999 */
617 1000
618 1001
619 1002
620 -
621 1003 /**
622 1004 * Internal dependencies
623 1005 */
624 1006
@@ -628,39 +1010,31 @@
628 1010
629 1011 /**
630 1012 * Edit callback for language switcher block.
631 1013 *
632 - * @param {Object} props Block properties.
1014 + * @param {Object} props Block properties.
1015 + * @param {Object} props.attributes Block attributes.
1016 + * @param {Function} props.setAttributes Function to set block attributes.
633 1017 * @return {ReactElement} The block content and controls.
634 1018 */
635 1019
636 -const Edit = props => {
637 - const {
638 - dropdown
639 - } = props.attributes;
1020 +const Edit = ({
1021 + attributes,
1022 + setAttributes
1023 +}) => {
640 1024 const languages = useLanguagesList();
641 - const {
642 - ToggleControlDropdown,
643 - ToggleControlShowNames,
644 - ToggleControlShowFlags,
645 - ToggleControlForceHome,
646 - ToggleControlHideCurrent,
647 - ToggleControlHideIfNoTranslations
648 - } = createLanguageSwitcherEdit(props);
649 - return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
1025 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div", {
650 1026 ...(0,external_this_wp_blockEditor_.useBlockProps)(),
651 - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_blockEditor_.InspectorControls, {
652 - children: /*#__PURE__*/(0,jsx_runtime.jsxs)(external_this_wp_components_.PanelBody, {
653 - title: (0,external_this_wp_i18n_.__)('Language switcher settings', 'polylang'),
654 - 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, {})]
655 - })
656 - }), /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.Disabled, {
657 - children: /*#__PURE__*/(0,jsx_runtime.jsx)(LanguagesContext.Provider, {
1027 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherControls, {
1028 + attributes: attributes,
1029 + setAttributes: setAttributes
1030 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.Disabled, {
1031 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(LanguagesContext.Provider, {
658 1032 value: {
659 1033 languages
660 1034 },
661 - children: /*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherContainer, {
662 - attributes: props.attributes
1035 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(RenderedSwitcher, {
1036 + attributes: attributes
663 1037 })
664 1038 })
665 1039 })]
666 1040 });
@@ -682,124 +1056,119 @@
682 1056 */
683 1057
684 1058
685 1059
1060 +
686 1061 (0,external_this_wp_blocks_.registerBlockType)(block_namespaceObject.UU, {
687 1062 icon: icons_translation,
688 - edit: Edit
1063 + edit: Edit,
1064 + deprecated: deprecated
689 1065 });
690 1066 // EXTERNAL MODULE: external {"this":["wp","hooks"]}
691 1067 var external_this_wp_hooks_ = __webpack_require__(873);
692 -;// ./js/src/blocks/navigation-language-switcher/components/switcher-link-element.js
1068 +;// ./js/src/blocks/navigation-language-switcher/deprecated.js
693 1069 /**
694 - * Internal dependencies
1070 + * Deprecated navigation language switcher block.
695 1071 */
696 1072
697 -
698 -/**
699 - * Switcher link element component.
700 - *
701 - * @param {Object} props Component props.
702 - * @param {Object} props.language Language object.
703 - * @param {boolean} props.isTopLevel Whether the language is the top level language.
704 - * @param {boolean} props.showFlags Whether to show the flags.
705 - * @param {boolean} props.showNames Whether to show the names.
706 - * @return {ReactElement} The Switcher element component.
707 - */
708 -
709 -const SwitcherLinkElement = ({
710 - language,
711 - isTopLevel,
712 - showFlags,
713 - showNames
714 -}) => {
715 - const {
716 - text,
717 - flag
718 - } = useMemoizedSwitcherLabel(language, showFlags, showNames);
719 - const prefix = isTopLevel ? '' : ' ';
720 - return (
721 - /*#__PURE__*/
722 - // eslint-disable-next-line jsx-a11y/anchor-is-valid
723 - (0,jsx_runtime.jsxs)("a", {
724 - href: '#',
725 - children: [prefix, /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
726 - dangerouslySetInnerHTML: {
727 - __html: flag
728 - }
729 - }), " ", text, " "]
730 - })
731 - );
1073 +const deprecated_V2Attributes = {
1074 + layout: 'horizontal',
1075 + show_labels: 'names',
1076 + show_flags: false,
1077 + force_home: false,
1078 + hide_current: false,
1079 + hide_if_no_translation: false,
1080 + flag_aspect_ratio: '3:2',
1081 + flag_border_radius: 0,
1082 + flag_width: '18px',
1083 + flag_label_spacing: '0.3em',
1084 + className: ''
732 1085 };
733 -;// ./node_modules/@wpsyntex/polylang-react-library/build/icons/submenu.js
1086 +const deprecated_v1 = {
1087 + attributes: {
1088 + dropdown: {
1089 + type: 'boolean',
1090 + default: false
1091 + },
1092 + show_names: {
1093 + type: 'boolean',
1094 + default: true
1095 + },
1096 + show_flags: {
1097 + type: 'boolean',
1098 + default: false
1099 + },
1100 + force_home: {
1101 + type: 'boolean',
1102 + default: false
1103 + },
1104 + hide_current: {
1105 + type: 'boolean',
1106 + default: false
1107 + },
1108 + hide_if_no_translation: {
1109 + type: 'boolean',
1110 + default: false
1111 + },
1112 + className: {
1113 + type: 'string',
1114 + default: ''
1115 + }
1116 + },
1117 + isEligible: attributes => 'dropdown' in attributes || 'show_names' in attributes,
1118 + migrate(attributes) {
1119 + const {
1120 + dropdown,
1121 + show_names,
1122 + show_flags,
1123 + force_home,
1124 + hide_current,
1125 + hide_if_no_translation,
1126 + className
1127 + } = attributes;
1128 + return {
1129 + ...deprecated_V2Attributes,
1130 + layout: dropdown ? 'dropdown' : 'horizontal',
1131 + show_labels: show_names ? 'names' : '',
1132 + show_flags: show_names ? show_flags : true,
1133 + force_home,
1134 + hide_current,
1135 + hide_if_no_translation,
1136 + className: className || ''
1137 + };
1138 + }
1139 +};
1140 +/* harmony default export */ const navigation_language_switcher_deprecated = ([deprecated_v1]);
1141 +// EXTERNAL MODULE: external {"this":["wp","editor"]}
1142 +var external_this_wp_editor_ = __webpack_require__(2);
1143 +;// ./node_modules/@wpsyntex/polylang-react-library/build/hooks/use-current-language.js
734 1144 /**
735 - * Submenu icon
736 - */
737 -
738 -/**
739 1145 * WordPress dependencies
740 1146 */
741 1147
1148 +// This package is not found in `@wordpress/scripts` like others (peer dependency).
1149 +// eslint-disable-next-line import/no-unresolved
742 1150
743 -const submenu_isPrimitivesComponents = 'undefined' !== typeof wp.primitives;
744 -const SubmenuIcon = () => submenu_isPrimitivesComponents ? /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_primitives_.SVG, {
745 - xmlns: "http://www.w3.org/2000/svg",
746 - width: "12",
747 - height: "12",
748 - viewBox: "0 0 12 12",
749 - fill: "none",
750 - children: /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_primitives_.Path, {
751 - d: "M1.50002 4L6.00002 8L10.5 4",
752 - strokeWidth: "1.5"
753 - })
754 -}) : 'submenu';
755 -/* harmony default export */ const submenu = (SubmenuIcon);
756 -;// ./js/src/blocks/navigation-language-switcher/components/switcher-ui.js
757 -/**
758 - * WordPress dependencies
759 - */
760 1151
761 -
762 1152 /**
763 - * Internal dependencies
764 - */
765 -
766 -
767 -
768 -/**
769 - * Switcher UI component.
1153 + * Custom hook to get the current language from the editor.
770 1154 *
771 - * @param {Object} props The component props.
772 - * @param {Array} props.languages The languages to display.
773 - * @param {boolean} props.showFlags Whether to show the flags.
774 - * @param {boolean} props.showNames Whether to show the names.
775 - * @param {boolean} props.withSubmenuIcon Whether to show the submenu icon.
776 - * @return {ReactElement} The Switcher UI component.
1155 + * @param {Array} languages The languages list.
1156 + * @return {Object|null} The current language, `null` if not found.
777 1157 */
1158 +const useCurrentLanguage = languages => {
1159 + const currentPost = (0,external_this_wp_data_.useSelect)(select => select(external_this_wp_editor_.store).getCurrentPost());
1160 + if (!languages || !currentPost) {
1161 + return null;
1162 + }
1163 + const currentLanguageSlug = currentPost.lang ?? pllEditorCurrentLanguageSlug; // eslint-disable-line no-undef
778 1164
779 -const switcher_ui_SwitcherUI = ({
780 - languages,
781 - showFlags,
782 - showNames,
783 - withSubmenuIcon
784 -}) => {
785 - return /*#__PURE__*/(0,jsx_runtime.jsx)(jsx_runtime.Fragment, {
786 - children: languages && languages.map(language => {
787 - return /*#__PURE__*/(0,jsx_runtime.jsxs)(external_this_wp_element_.Fragment, {
788 - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(SwitcherLinkElement, {
789 - language: language,
790 - isTopLevel: languages.indexOf(language) === 0,
791 - showFlags: showFlags,
792 - showNames: showNames
793 - }), withSubmenuIcon && /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
794 - className: "wp-block-navigation__submenu-icon",
795 - children: /*#__PURE__*/(0,jsx_runtime.jsx)(submenu, {})
796 - })]
797 - }, language.slug);
798 - })
1165 + const currentLanguage = languages.find(language => {
1166 + return language.slug === currentLanguageSlug;
799 1167 });
1168 + return currentLanguage ? currentLanguage : null;
800 1169 };
801 -;// ./js/src/blocks/navigation-language-switcher/components/navigation-switcher-container.js
1170 +;// ./js/src/blocks/navigation-language-switcher/rendered-switcher.js
802 1171 /**
803 1172 * WordPress dependencies
804 1173 */
805 1174
@@ -804,8 +1173,13 @@
804 1173 */
805 1174
806 1175
807 1176 /**
1177 + * External dependencies
1178 + */
1179 +
1180 +
1181 +/**
808 1182 * Internal dependencies
809 1183 */
810 1184
811 1185
@@ -811,24 +1185,27 @@
811 1185
812 1186
813 1187
814 1188 /**
815 - * Switcher container component.
1189 + * Rendered switcher component.
816 1190 *
817 1191 * @param {Object} props The component props.
818 1192 * @param {Object} props.attributes The block attributes.
819 1193 * @param {Object} props.context The block context.
820 - * @return {ReactElement} The Switcher component.
1194 + * @return {ReactElement} The rendered switcher.
821 1195 */
822 1196
823 -const NavigationSwitcherContainer = ({
1197 +const rendered_switcher_RenderedSwitcher = ({
824 1198 attributes,
825 1199 context
826 1200 }) => {
827 1201 const {
828 - dropdown,
1202 + layout,
1203 + show_labels,
829 1204 show_flags,
830 - show_names
1205 + flag_border_radius,
1206 + flag_width,
1207 + flag_label_spacing
831 1208 } = attributes;
832 1209 const {
833 1210 showSubmenuIcon,
834 1211 openSubmenusOnClick
@@ -836,14 +1213,31 @@
836 1213 const {
837 1214 languages
838 1215 } = (0,external_this_wp_element_.useContext)(LanguagesContext);
839 1216 const currentLanguage = useCurrentLanguage(languages);
840 - const curatedLanguages = useCuratedLanguages(languages, currentLanguage, dropdown);
841 - return /*#__PURE__*/(0,jsx_runtime.jsx)(switcher_ui_SwitcherUI, {
842 - languages: curatedLanguages,
843 - showFlags: Boolean(show_flags),
844 - showNames: Boolean(show_names),
845 - withSubmenuIcon: Boolean((showSubmenuIcon || openSubmenusOnClick) && dropdown)
1217 + const isDropdown = layout === 'dropdown';
1218 + const languagesToRender = useCuratedLanguages(languages, currentLanguage, isDropdown);
1219 + const labelSpacing = getLabelSpacing(show_labels, flag_label_spacing);
1220 + const withSubmenuIcon = isDropdown && (showSubmenuIcon || openSubmenusOnClick);
1221 + const linkProps = {
1222 + showLabels: show_labels,
1223 + showFlags: show_flags,
1224 + flagBorderRadius: flag_border_radius,
1225 + flagWidth: flag_width,
1226 + labelSpacing
1227 + };
1228 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)((react_jsx_runtime_production_min_namespaceFn().Fragment), {
1229 + children: languagesToRender.map(language => {
1230 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)(external_this_wp_element_.Fragment, {
1231 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherLanguageLink, {
1232 + language: language,
1233 + ...linkProps
1234 + }), withSubmenuIcon && /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)("span", {
1235 + className: "wp-block-navigation__submenu-icon",
1236 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(submenu, {})
1237 + })]
1238 + }, language.slug);
1239 + })
846 1240 });
847 1241 };
848 1242 ;// ./js/src/blocks/navigation-language-switcher/edit.js
849 1243 /**
@@ -855,9 +1249,8 @@
855 1249 */
856 1250
857 1251
858 1252
859 -
860 1253 /**
861 1254 * Internal dependencies
862 1255 */
863 1256
@@ -867,40 +1260,42 @@
867 1260
868 1261 /**
869 1262 * Edit callback for navigation language switcher block.
870 1263 *
871 - * @param {Object} props Block properties.
1264 + * @param {Object} props Block properties.
1265 + * @param {Object} props.attributes Block attributes.
1266 + * @param {Object} props.context Block context.
1267 + * @param {Function} props.setAttributes Function to set block attributes.
872 1268 * @return {ReactElement} The block content and controls.
873 1269 */
874 1270
875 -const edit_Edit = props => {
876 - const {
877 - dropdown
878 - } = props.attributes;
1271 +const edit_Edit = ({
1272 + attributes,
1273 + context,
1274 + setAttributes
1275 +}) => {
879 1276 const languages = useLanguagesList();
880 1277 const {
881 - ToggleControlDropdown,
882 - ToggleControlShowNames,
883 - ToggleControlShowFlags,
884 - ToggleControlForceHome,
885 - ToggleControlHideCurrent,
886 - ToggleControlHideIfNoTranslations
887 - } = createLanguageSwitcherEdit(props);
888 - return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
889 - ...(0,external_this_wp_blockEditor_.useBlockProps)(),
890 - children: [/*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_blockEditor_.InspectorControls, {
891 - children: /*#__PURE__*/(0,jsx_runtime.jsxs)(external_this_wp_components_.PanelBody, {
892 - title: (0,external_this_wp_i18n_.__)('Language switcher settings', 'polylang'),
893 - 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, {})]
894 - })
895 - }), /*#__PURE__*/(0,jsx_runtime.jsx)(external_this_wp_components_.Disabled, {
896 - children: /*#__PURE__*/(0,jsx_runtime.jsx)(LanguagesContext.Provider, {
1278 + show_flags,
1279 + flag_aspect_ratio
1280 + } = attributes;
1281 + const aspectRatioClass = show_flags && flag_aspect_ratio ? `pll-aspect-ratio-${flag_aspect_ratio.replace(':', '')}` : '';
1282 + return /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsxs)("div", {
1283 + ...(0,external_this_wp_blockEditor_.useBlockProps)({
1284 + className: aspectRatioClass || undefined
1285 + }),
1286 + children: [/*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(SwitcherControls, {
1287 + attributes: attributes,
1288 + setAttributes: setAttributes,
1289 + layoutOptions: ['horizontal', 'dropdown']
1290 + }), /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(external_this_wp_components_.Disabled, {
1291 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(LanguagesContext.Provider, {
897 1292 value: {
898 1293 languages
899 1294 },
900 - children: /*#__PURE__*/(0,jsx_runtime.jsx)(NavigationSwitcherContainer, {
901 - attributes: props.attributes,
902 - context: props.context
1295 + children: /*#__PURE__*/(0,react_jsx_runtime_production_min_namespaceFn().jsx)(rendered_switcher_RenderedSwitcher, {
1296 + attributes: attributes,
1297 + context: context
903 1298 })
904 1299 })
905 1300 })]
906 1301 });
@@ -994,8 +1389,9 @@
994 1389
995 1390
996 1391
997 1392
1393 +
998 1394 (0,external_this_wp_blocks_.registerBlockType)(Navigation_block_namespaceObject.UU, {
999 1395 icon: icons_translation,
1000 1396 transforms: {
1001 1397 from: [{
@@ -1003,9 +1399,10 @@
1003 1399 blocks: ['core/navigation-link'],
1004 1400 transform: () => (0,external_this_wp_blocks_.createBlock)(Navigation_block_namespaceObject.UU)
1005 1401 }]
1006 1402 },
1007 - edit: edit_Edit
1403 + edit: edit_Edit,
1404 + deprecated: navigation_language_switcher_deprecated
1008 1405 });
1009 1406
1010 1407 /**
1011 1408 * Hooks to the classic menu conversion to core/navigation block to be able to convert