PluginProbe
Elementor Website Builder – more than just a page builder / 3.14.0-beta4
Elementor Website Builder – more than just a page builder v3.14.0-beta4
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / assets / js / packages / editor-responsive.js

editor-responsive.js in Elementor Website Builder – more than just a page builder 3.14.0-beta4, at assets/js/packages/editor-responsive.js

360 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ "react":
6 /*!************************!*\
7 !*** external "React" ***!
8 \************************/
9 /***/ (function(module) {
10
11 module.exports = window["React"];
12
13 /***/ }),
14
15 /***/ "@elementor/editor-app-bar":
16 /*!*****************************************************************!*\
17 !*** external ["__UNSTABLE__elementorPackages","editorAppBar"] ***!
18 \*****************************************************************/
19 /***/ (function(module) {
20
21 module.exports = window["__UNSTABLE__elementorPackages"]["editorAppBar"];
22
23 /***/ }),
24
25 /***/ "@elementor/editor-v1-adapters":
26 /*!*********************************************************************!*\
27 !*** external ["__UNSTABLE__elementorPackages","editorV1Adapters"] ***!
28 \*********************************************************************/
29 /***/ (function(module) {
30
31 module.exports = window["__UNSTABLE__elementorPackages"]["editorV1Adapters"];
32
33 /***/ }),
34
35 /***/ "@elementor/icons":
36 /*!**********************************************************!*\
37 !*** external ["__UNSTABLE__elementorPackages","icons"] ***!
38 \**********************************************************/
39 /***/ (function(module) {
40
41 module.exports = window["__UNSTABLE__elementorPackages"]["icons"];
42
43 /***/ }),
44
45 /***/ "@elementor/store":
46 /*!**********************************************************!*\
47 !*** external ["__UNSTABLE__elementorPackages","store"] ***!
48 \**********************************************************/
49 /***/ (function(module) {
50
51 module.exports = window["__UNSTABLE__elementorPackages"]["store"];
52
53 /***/ }),
54
55 /***/ "@elementor/ui":
56 /*!*******************************************************!*\
57 !*** external ["__UNSTABLE__elementorPackages","ui"] ***!
58 \*******************************************************/
59 /***/ (function(module) {
60
61 module.exports = window["__UNSTABLE__elementorPackages"]["ui"];
62
63 /***/ }),
64
65 /***/ "@wordpress/i18n":
66 /*!******************************!*\
67 !*** external ["wp","i18n"] ***!
68 \******************************/
69 /***/ (function(module) {
70
71 module.exports = window["wp"]["i18n"];
72
73 /***/ })
74
75 /******/ });
76 /************************************************************************/
77 /******/ // The module cache
78 /******/ var __webpack_module_cache__ = {};
79 /******/
80 /******/ // The require function
81 /******/ function __webpack_require__(moduleId) {
82 /******/ // Check if module is in cache
83 /******/ var cachedModule = __webpack_module_cache__[moduleId];
84 /******/ if (cachedModule !== undefined) {
85 /******/ return cachedModule.exports;
86 /******/ }
87 /******/ // Create a new module (and put it into the cache)
88 /******/ var module = __webpack_module_cache__[moduleId] = {
89 /******/ // no module.id needed
90 /******/ // no module.loaded needed
91 /******/ exports: {}
92 /******/ };
93 /******/
94 /******/ // Execute the module function
95 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
96 /******/
97 /******/ // Return the exports of the module
98 /******/ return module.exports;
99 /******/ }
100 /******/
101 /************************************************************************/
102 /******/ /* webpack/runtime/make namespace object */
103 /******/ !function() {
104 /******/ // define __esModule on exports
105 /******/ __webpack_require__.r = function(exports) {
106 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
107 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
108 /******/ }
109 /******/ Object.defineProperty(exports, '__esModule', { value: true });
110 /******/ };
111 /******/ }();
112 /******/
113 /************************************************************************/
114 var __webpack_exports__ = {};
115 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
116 !function() {
117 /*!******************************************************************!*\
118 !*** ./node_modules/@elementor/editor-responsive/dist/index.mjs ***!
119 \******************************************************************/
120 __webpack_require__.r(__webpack_exports__);
121 /* harmony import */ var _elementor_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @elementor/store */ "@elementor/store");
122 /* harmony import */ var _elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @elementor/editor-v1-adapters */ "@elementor/editor-v1-adapters");
123 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
124 /* harmony import */ var _elementor_editor_app_bar__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @elementor/editor-app-bar */ "@elementor/editor-app-bar");
125 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react */ "react");
126 /* harmony import */ var _elementor_ui__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @elementor/ui */ "@elementor/ui");
127 /* harmony import */ var _elementor_icons__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @elementor/icons */ "@elementor/icons");
128 // src/store/index.ts
129
130 var initialState = {
131 entities: {},
132 activeId: null
133 };
134 function createSlice() {
135 return (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.addSlice)({
136 name: "breakpoints",
137 initialState,
138 reducers: {
139 init(state, action) {
140 state.activeId = action.payload.activeId;
141 state.entities = normalizeEntities(action.payload.entities);
142 },
143 activateBreakpoint(state, action) {
144 if (state.entities[action.payload]) {
145 state.activeId = action.payload;
146 }
147 }
148 }
149 });
150 }
151 function normalizeEntities(entities) {
152 return entities.reduce((acc, breakpoint) => {
153 return {
154 ...acc,
155 [breakpoint.id]: breakpoint
156 };
157 }, {});
158 }
159
160 // src/sync/sync-store.ts
161
162
163
164 function syncStore(slice) {
165 syncInitialization(slice);
166 syncOnChange(slice);
167 }
168 function syncInitialization(slice) {
169 const { init: init2 } = slice.actions;
170 (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.listenTo)(
171 (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.v1ReadyEvent)(),
172 () => {
173 (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.dispatch)(init2({
174 entities: getBreakpoints(),
175 activeId: getActiveBreakpoint()
176 }));
177 }
178 );
179 }
180 function syncOnChange(slice) {
181 const { activateBreakpoint } = slice.actions;
182 (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.listenTo)(
183 deviceModeChangeEvent(),
184 () => {
185 const activeBreakpoint = getActiveBreakpoint();
186 (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.dispatch)(activateBreakpoint(activeBreakpoint));
187 }
188 );
189 }
190 function getBreakpoints() {
191 const { breakpoints } = window.elementor?.config?.responsive || {};
192 if (!breakpoints) {
193 return [];
194 }
195 const entities = Object.entries(breakpoints).filter(([, breakpoint]) => breakpoint.is_enabled).map(([id, { value, direction, label }]) => {
196 return {
197 id,
198 label,
199 width: value,
200 type: direction === "min" ? "min-width" : "max-width"
201 };
202 });
203 entities.push({
204 id: "desktop",
205 label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)("Desktop", "elementor")
206 });
207 return entities;
208 }
209 function getActiveBreakpoint() {
210 const extendedWindow = window;
211 return extendedWindow.elementor?.channels?.deviceMode?.request?.("currentMode") || null;
212 }
213 function deviceModeChangeEvent() {
214 return (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.windowEvent)("elementor/device-mode/change");
215 }
216
217 // src/init.ts
218
219
220 // src/components/breakpoints-switcher.tsx
221
222
223
224 // src/hooks/use-breakpoints.ts
225
226
227 // src/store/selectors.ts
228
229 var selectEntities = (state) => state.breakpoints.entities;
230 var selectActiveId = (state) => state.breakpoints.activeId;
231 var selectActiveBreakpoint = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.createSelector)(
232 selectEntities,
233 selectActiveId,
234 (entities, activeId) => activeId && entities[activeId] ? entities[activeId] : null
235 );
236 var selectSortedBreakpoints = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.createSelector)(
237 selectEntities,
238 (entities) => {
239 const byWidth = (a, b) => {
240 return a.width && b.width ? b.width - a.width : 0;
241 };
242 const all = Object.values(entities);
243 const defaults = all.filter((breakpoint) => !breakpoint.width);
244 const minWidth = all.filter((breakpoint) => breakpoint.type === "min-width");
245 const maxWidth = all.filter((breakpoint) => breakpoint.type === "max-width");
246 return [
247 ...minWidth.sort(byWidth),
248 ...defaults,
249 ...maxWidth.sort(byWidth)
250 ];
251 }
252 );
253
254 // src/hooks/use-breakpoints.ts
255 function useBreakpoints() {
256 const all = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.useSelector)(selectSortedBreakpoints);
257 const active = (0,_elementor_store__WEBPACK_IMPORTED_MODULE_0__.useSelector)(selectActiveBreakpoint);
258 return {
259 all,
260 active
261 };
262 }
263
264 // src/components/breakpoints-switcher.tsx
265
266
267
268 // src/hooks/use-breakpoints-actions.ts
269
270
271 function useBreakpointsActions() {
272 const activate = (0,react__WEBPACK_IMPORTED_MODULE_4__.useCallback)((device) => {
273 return (0,_elementor_editor_v1_adapters__WEBPACK_IMPORTED_MODULE_1__.runCommand)("panel/change-device-mode", { device });
274 }, []);
275 return {
276 activate
277 };
278 }
279
280 // src/components/breakpoints-switcher.tsx
281 function BreakpointsSwitcher() {
282 const { all, active } = useBreakpoints();
283 const { activate } = useBreakpointsActions();
284 if (!all.length || !active) {
285 return null;
286 }
287 const onChange = (_, value) => activate(value);
288 return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_4__.createElement(_elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Tabs, { value: active.id, onChange, "aria-label": (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)("Switch Device", "elementor") }, all.map(({ id, label, type, width }) => {
289 const Icon = iconsMap[id];
290 const title = labelsMap[type || "default"].replace("%s", label).replace("%d", width?.toString() || "");
291 return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_4__.createElement(
292 _elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Tab,
293 {
294 value: id,
295 key: id,
296 "aria-label": title,
297 icon: /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_4__.createElement(Tooltip, { title }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_4__.createElement(Icon, null))
298 }
299 );
300 }));
301 }
302 function Tooltip(props) {
303 return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_4__.createElement(
304 _elementor_ui__WEBPACK_IMPORTED_MODULE_5__.Tooltip,
305 {
306 PopperProps: {
307 sx: {
308 "&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": {
309 mt: 7
310 }
311 }
312 },
313 ...props
314 }
315 );
316 }
317 var iconsMap = {
318 widescreen: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.WidescreenIcon,
319 desktop: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.DesktopIcon,
320 laptop: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.LaptopIcon,
321 tablet_extra: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.TabletLandscapeIcon,
322 tablet: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.TabletPortraitIcon,
323 mobile_extra: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.MobileLandscapeIcon,
324 mobile: _elementor_icons__WEBPACK_IMPORTED_MODULE_6__.MobilePortraitIcon
325 };
326 var labelsMap = {
327 default: "%s",
328 // translators: %s: Breakpoint label, %d: Breakpoint size.
329 "min-width": (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)("%s (%dpx and up)", "elementor"),
330 // translators: %s: Breakpoint label, %d: Breakpoint size.
331 "max-width": (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)("%s (up to %dpx)", "elementor")
332 };
333
334 // src/init.ts
335 function init() {
336 initStore();
337 registerAppBarUI();
338 }
339 function initStore() {
340 const slice = createSlice();
341 syncStore(slice);
342 }
343 function registerAppBarUI() {
344 (0,_elementor_editor_app_bar__WEBPACK_IMPORTED_MODULE_3__.injectIntoResponsive)({
345 id: "responsive-breakpoints-switcher",
346 filler: BreakpointsSwitcher,
347 options: {
348 priority: 20
349 // After document indication.
350 }
351 });
352 }
353
354 // src/index.ts
355 init();
356 //# sourceMappingURL=index.mjs.map
357 }();
358 (window.__UNSTABLE__elementorPackages = window.__UNSTABLE__elementorPackages || {}).editorResponsive = __webpack_exports__;
359 /******/ })()
360 ;