| 1 |
(function(_elementor_locations, _elementor_utils, react, _elementor_editor_ui, _elementor_ui) { |
| 2 |
|
| 3 |
//#region \0rolldown/runtime.js |
| 4 |
var __create = Object.create; |
| 5 |
var __defProp = Object.defineProperty; |
| 6 |
var __name = (target, value) => __defProp(target, "name", { |
| 7 |
value, |
| 8 |
configurable: true |
| 9 |
}); |
| 10 |
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; |
| 11 |
var __getOwnPropNames = Object.getOwnPropertyNames; |
| 12 |
var __getProtoOf = Object.getPrototypeOf; |
| 13 |
var __hasOwnProp = Object.prototype.hasOwnProperty; |
| 14 |
var __exportAll = (all, no_symbols) => { |
| 15 |
let target = {}; |
| 16 |
for (var name in all) { |
| 17 |
__defProp(target, name, { |
| 18 |
get: all[name], |
| 19 |
enumerable: true |
| 20 |
}); |
| 21 |
} |
| 22 |
if (!no_symbols) { |
| 23 |
__defProp(target, Symbol.toStringTag, { value: "Module" }); |
| 24 |
} |
| 25 |
return target; |
| 26 |
}; |
| 27 |
var __copyProps = (to, from, except, desc) => { |
| 28 |
if (from && typeof from === "object" || typeof from === "function") { |
| 29 |
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { |
| 30 |
key = keys[i]; |
| 31 |
if (!__hasOwnProp.call(to, key) && key !== except) { |
| 32 |
__defProp(to, key, { |
| 33 |
get: ((k) => from[k]).bind(null, key), |
| 34 |
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable |
| 35 |
}); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
return to; |
| 40 |
}; |
| 41 |
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { |
| 42 |
value: mod, |
| 43 |
enumerable: true |
| 44 |
}) : target, mod)); |
| 45 |
|
| 46 |
//#endregion |
| 47 |
react = __toESM(react); |
| 48 |
|
| 49 |
//#region packages/packages/libs/menus/src/create-register-item.tsx |
| 50 |
function createRegisterItem(locations, component, notify) { |
| 51 |
return ({ id, group = "default", priority = 10, overwrite = false, props: _props, useProps: _useProps }) => { |
| 52 |
if (!(group in locations)) return; |
| 53 |
const Component = component; |
| 54 |
const useProps = _useProps || (() => _props); |
| 55 |
const InjectedComponent = (props) => { |
| 56 |
const componentProps = useProps(); |
| 57 |
return /* @__PURE__ */ react.createElement(Component, { |
| 58 |
...props, |
| 59 |
...componentProps |
| 60 |
}); |
| 61 |
}; |
| 62 |
locations[group].inject({ |
| 63 |
id, |
| 64 |
component: InjectedComponent, |
| 65 |
options: { |
| 66 |
priority, |
| 67 |
overwrite |
| 68 |
} |
| 69 |
}); |
| 70 |
notify(); |
| 71 |
}; |
| 72 |
} |
| 73 |
|
| 74 |
//#endregion |
| 75 |
//#region packages/packages/libs/menus/src/create-use-menu-items.ts |
| 76 |
function createUseMenuItems(locations, subscribe) { |
| 77 |
let snapshot = null; |
| 78 |
subscribe(() => { |
| 79 |
snapshot = null; |
| 80 |
}); |
| 81 |
const getMenuItems = () => { |
| 82 |
if (snapshot) return snapshot; |
| 83 |
snapshot = Object.entries(locations).reduce((carry, [groupName, location]) => { |
| 84 |
const items = location.getInjections().map((injection) => ({ |
| 85 |
id: injection.id, |
| 86 |
MenuItem: injection.component |
| 87 |
})); |
| 88 |
return { |
| 89 |
...carry, |
| 90 |
[groupName]: items |
| 91 |
}; |
| 92 |
}, {}); |
| 93 |
return snapshot; |
| 94 |
}; |
| 95 |
return () => (0, react.useSyncExternalStore)(subscribe, getMenuItems); |
| 96 |
} |
| 97 |
|
| 98 |
//#endregion |
| 99 |
//#region packages/packages/libs/menus/src/create-menu.ts |
| 100 |
function createSubscription() { |
| 101 |
const listeners = /* @__PURE__ */ new Set(); |
| 102 |
return { |
| 103 |
subscribe: (listener) => { |
| 104 |
listeners.add(listener); |
| 105 |
return () => listeners.delete(listener); |
| 106 |
}, |
| 107 |
notify: () => listeners.forEach((listener) => listener()) |
| 108 |
}; |
| 109 |
} |
| 110 |
function createMenu({ groups = [], components }) { |
| 111 |
const locations = createLocations([...groups, "default"]); |
| 112 |
const { subscribe, notify } = createSubscription(); |
| 113 |
const registerFns = createRegisterFns(locations, components, notify); |
| 114 |
return { |
| 115 |
useMenuItems: createUseMenuItems(locations, subscribe), |
| 116 |
...registerFns |
| 117 |
}; |
| 118 |
} |
| 119 |
function createLocations(groups) { |
| 120 |
return groups.reduce((acc, group) => { |
| 121 |
acc[group] = (0, _elementor_locations.createLocation)(); |
| 122 |
return acc; |
| 123 |
}, {}); |
| 124 |
} |
| 125 |
function createRegisterFns(locations, components, notify) { |
| 126 |
return Object.entries(components).reduce((acc, [key, component]) => { |
| 127 |
const name = `register${(0, _elementor_utils.capitalize)(key)}`; |
| 128 |
return { |
| 129 |
...acc, |
| 130 |
[name]: createRegisterItem(locations, component, notify) |
| 131 |
}; |
| 132 |
}, {}); |
| 133 |
} |
| 134 |
|
| 135 |
//#endregion |
| 136 |
//#region packages/packages/libs/menus/src/action.tsx |
| 137 |
var SIZE = "tiny"; |
| 138 |
function Action({ title, visible = true, icon: Icon, onClick }) { |
| 139 |
if (!visible) return null; |
| 140 |
return /* @__PURE__ */ react.createElement(_elementor_ui.Tooltip, { |
| 141 |
placement: "top", |
| 142 |
title, |
| 143 |
arrow: true |
| 144 |
}, /* @__PURE__ */ react.createElement(_elementor_ui.IconButton, { |
| 145 |
"aria-label": title, |
| 146 |
size: SIZE, |
| 147 |
onClick |
| 148 |
}, /* @__PURE__ */ react.createElement(Icon, { fontSize: SIZE }))); |
| 149 |
} |
| 150 |
|
| 151 |
//#endregion |
| 152 |
//#region packages/packages/libs/menus/src/controls-actions.ts |
| 153 |
var controlActionsMenu = createMenu({ components: { |
| 154 |
Action, |
| 155 |
PopoverAction: _elementor_editor_ui.PopoverAction |
| 156 |
} }); |
| 157 |
|
| 158 |
//#endregion |
| 159 |
//#region packages/packages/libs/menus/src/index.ts |
| 160 |
var src_exports = /* @__PURE__ */ __exportAll({ |
| 161 |
controlActionsMenu: () => controlActionsMenu, |
| 162 |
createMenu: () => createMenu |
| 163 |
}); |
| 164 |
|
| 165 |
//#endregion |
| 166 |
//#region \0elementor-package-library-entry |
| 167 |
(window.elementorV2 = window.elementorV2 || {}).menus = src_exports; |
| 168 |
|
| 169 |
//#endregion |
| 170 |
})(elementorV2.locations, elementorV2.utils, React, elementorV2.editorUi, elementorV2.ui); |
| 171 |
window.elementorV2.menus?.init?.(); |
| 172 |
//# sourceMappingURL=menus.js.map |