| 1 |
(function(react, _elementor_editor_v1_adapters, _wordpress_i18n) { |
| 2 |
|
| 3 |
//#region \0rolldown/runtime.js |
| 4 |
var __defProp = Object.defineProperty; |
| 5 |
var __name = (target, value) => __defProp(target, "name", { |
| 6 |
value, |
| 7 |
configurable: true |
| 8 |
}); |
| 9 |
var __exportAll = (all, no_symbols) => { |
| 10 |
let target = {}; |
| 11 |
for (var name in all) { |
| 12 |
__defProp(target, name, { |
| 13 |
get: all[name], |
| 14 |
enumerable: true |
| 15 |
}); |
| 16 |
} |
| 17 |
if (!no_symbols) { |
| 18 |
__defProp(target, Symbol.toStringTag, { value: "Module" }); |
| 19 |
} |
| 20 |
return target; |
| 21 |
}; |
| 22 |
|
| 23 |
//#endregion |
| 24 |
|
| 25 |
//#region packages/packages/libs/editor-responsive/src/hooks/use-activate-breakpoint.ts |
| 26 |
function useActivateBreakpoint() { |
| 27 |
return (0, react.useCallback)((breakpoint) => { |
| 28 |
return (0, _elementor_editor_v1_adapters.__privateRunCommand)("panel/change-device-mode", { device: breakpoint }); |
| 29 |
}, []); |
| 30 |
} |
| 31 |
|
| 32 |
//#endregion |
| 33 |
//#region packages/packages/libs/editor-responsive/src/hooks/use-active-breakpoint.ts |
| 34 |
function useActiveBreakpoint() { |
| 35 |
return (0, _elementor_editor_v1_adapters.__privateUseListenTo)((0, _elementor_editor_v1_adapters.windowEvent)("elementor/device-mode/change"), getActiveBreakpoint); |
| 36 |
} |
| 37 |
function getActiveBreakpoint() { |
| 38 |
return window.elementor?.channels?.deviceMode?.request?.("currentMode") || null; |
| 39 |
} |
| 40 |
|
| 41 |
//#endregion |
| 42 |
//#region packages/packages/libs/editor-responsive/src/sync/utils/get-breakpoints-by-widths.ts |
| 43 |
function getBreakpointsByWidths() { |
| 44 |
const { breakpoints } = window.elementor?.config?.responsive || {}; |
| 45 |
if (!breakpoints || Object.entries(breakpoints).length === 0) return { |
| 46 |
minWidth: [], |
| 47 |
defaults: [], |
| 48 |
maxWidth: [] |
| 49 |
}; |
| 50 |
const minWidth = []; |
| 51 |
const maxWidth = []; |
| 52 |
const defaults = [{ |
| 53 |
id: "desktop", |
| 54 |
label: (0, _wordpress_i18n.__)("Desktop", "elementor") |
| 55 |
}]; |
| 56 |
Object.entries(breakpoints).forEach(([id, v1Breakpoint]) => { |
| 57 |
if (!v1Breakpoint.is_enabled) return; |
| 58 |
const breakpoint = { |
| 59 |
id, |
| 60 |
label: v1Breakpoint.label, |
| 61 |
width: v1Breakpoint.value, |
| 62 |
type: v1Breakpoint.direction === "min" ? "min-width" : "max-width" |
| 63 |
}; |
| 64 |
if (!breakpoint.width) defaults.push(breakpoint); |
| 65 |
else if (breakpoint.type === "min-width") minWidth.push(breakpoint); |
| 66 |
else if (breakpoint.type === "max-width") maxWidth.push(breakpoint); |
| 67 |
}); |
| 68 |
const byWidth = (a, b) => { |
| 69 |
return a.width && b.width ? b.width - a.width : 0; |
| 70 |
}; |
| 71 |
return { |
| 72 |
minWidth: minWidth.sort(byWidth), |
| 73 |
defaults, |
| 74 |
maxWidth: maxWidth.sort(byWidth) |
| 75 |
}; |
| 76 |
} |
| 77 |
|
| 78 |
//#endregion |
| 79 |
//#region packages/packages/libs/editor-responsive/src/sync/get-breakpoints.ts |
| 80 |
function getBreakpoints() { |
| 81 |
const { minWidth, defaults, maxWidth } = getBreakpointsByWidths(); |
| 82 |
return [ |
| 83 |
...minWidth, |
| 84 |
...defaults, |
| 85 |
...maxWidth |
| 86 |
]; |
| 87 |
} |
| 88 |
|
| 89 |
//#endregion |
| 90 |
//#region packages/packages/libs/editor-responsive/src/hooks/use-breakpoints.ts |
| 91 |
function useBreakpoints() { |
| 92 |
return (0, _elementor_editor_v1_adapters.__privateUseListenTo)((0, _elementor_editor_v1_adapters.v1ReadyEvent)(), getBreakpoints); |
| 93 |
} |
| 94 |
|
| 95 |
//#endregion |
| 96 |
//#region packages/packages/libs/editor-responsive/src/hooks/use-breakpoints-map.ts |
| 97 |
function useBreakpointsMap() { |
| 98 |
const breakpoints = useBreakpoints(); |
| 99 |
return (0, react.useMemo)(() => { |
| 100 |
const entries = breakpoints.map((breakpoint) => [breakpoint.id, breakpoint]); |
| 101 |
return Object.fromEntries(entries); |
| 102 |
}, [breakpoints]); |
| 103 |
} |
| 104 |
|
| 105 |
//#endregion |
| 106 |
//#region packages/packages/libs/editor-responsive/src/sync/get-breakpoints-tree.ts |
| 107 |
function getBreakpointsTree() { |
| 108 |
const { minWidth, defaults, maxWidth } = getBreakpointsByWidths(); |
| 109 |
const [rootBreakpoint] = defaults; |
| 110 |
const rootNode = { |
| 111 |
...rootBreakpoint, |
| 112 |
children: [] |
| 113 |
}; |
| 114 |
const buildBranch = (breakpoints) => { |
| 115 |
let last = rootNode; |
| 116 |
breakpoints.forEach((breakpoint) => { |
| 117 |
const newNode = { |
| 118 |
...breakpoint, |
| 119 |
children: [] |
| 120 |
}; |
| 121 |
last.children.push(newNode); |
| 122 |
last = newNode; |
| 123 |
}); |
| 124 |
}; |
| 125 |
buildBranch(minWidth); |
| 126 |
buildBranch(maxWidth); |
| 127 |
return rootNode; |
| 128 |
} |
| 129 |
|
| 130 |
//#endregion |
| 131 |
//#region packages/packages/libs/editor-responsive/src/index.ts |
| 132 |
var src_exports = /* @__PURE__ */ __exportAll({ |
| 133 |
getBreakpoints: () => getBreakpoints, |
| 134 |
getBreakpointsTree: () => getBreakpointsTree, |
| 135 |
useActivateBreakpoint: () => useActivateBreakpoint, |
| 136 |
useActiveBreakpoint: () => useActiveBreakpoint, |
| 137 |
useBreakpoints: () => useBreakpoints, |
| 138 |
useBreakpointsMap: () => useBreakpointsMap |
| 139 |
}); |
| 140 |
|
| 141 |
//#endregion |
| 142 |
//#region \0elementor-package-library-entry |
| 143 |
(window.elementorV2 = window.elementorV2 || {}).editorResponsive = src_exports; |
| 144 |
|
| 145 |
//#endregion |
| 146 |
})(React, elementorV2.editorV1Adapters, wp.i18n); |
| 147 |
window.elementorV2.editorResponsive?.init?.(); |
| 148 |
//# sourceMappingURL=editor-responsive.js.map |