| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ // The require scope |
| 4 |
/******/ var __webpack_require__ = {}; |
| 5 |
/******/ |
| 6 |
/************************************************************************/ |
| 7 |
/******/ /* webpack/runtime/define property getters */ |
| 8 |
/******/ !function() { |
| 9 |
/******/ // define getter functions for harmony exports |
| 10 |
/******/ __webpack_require__.d = function(exports, definition) { |
| 11 |
/******/ for(var key in definition) { |
| 12 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 13 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 14 |
/******/ } |
| 15 |
/******/ } |
| 16 |
/******/ }; |
| 17 |
/******/ }(); |
| 18 |
/******/ |
| 19 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 20 |
/******/ !function() { |
| 21 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
| 22 |
/******/ }(); |
| 23 |
/******/ |
| 24 |
/******/ /* webpack/runtime/make namespace object */ |
| 25 |
/******/ !function() { |
| 26 |
/******/ // define __esModule on exports |
| 27 |
/******/ __webpack_require__.r = function(exports) { |
| 28 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 29 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 30 |
/******/ } |
| 31 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 32 |
/******/ }; |
| 33 |
/******/ }(); |
| 34 |
/******/ |
| 35 |
/************************************************************************/ |
| 36 |
var __webpack_exports__ = {}; |
| 37 |
// ESM COMPAT FLAG |
| 38 |
__webpack_require__.r(__webpack_exports__); |
| 39 |
|
| 40 |
// EXPORTS |
| 41 |
__webpack_require__.d(__webpack_exports__, { |
| 42 |
"documentOptionsMenu": function() { return /* reexport */ documentOptionsMenu; } |
| 43 |
}); |
| 44 |
|
| 45 |
;// CONCATENATED MODULE: external "React" |
| 46 |
var external_React_namespaceObject = React; |
| 47 |
;// CONCATENATED MODULE: external "wp.i18n" |
| 48 |
var external_wp_i18n_namespaceObject = wp.i18n; |
| 49 |
;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.ui" |
| 50 |
var external_UNSTABLE_elementorPackages_ui_namespaceObject = __UNSTABLE__elementorPackages.ui; |
| 51 |
;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.topBar" |
| 52 |
var external_UNSTABLE_elementorPackages_topBar_namespaceObject = __UNSTABLE__elementorPackages.topBar; |
| 53 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/menus.ts |
| 54 |
|
| 55 |
const documentOptionsMenu = (0,external_UNSTABLE_elementorPackages_topBar_namespaceObject.createMenu)({ |
| 56 |
name: 'document-options', |
| 57 |
groups: ['save'] |
| 58 |
}); |
| 59 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/components/top-bar/primary-action-menu.tsx |
| 60 |
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
const { |
| 66 |
useMenuItems |
| 67 |
} = documentOptionsMenu; |
| 68 |
|
| 69 |
// CSS hack to hide dividers when a group is rendered empty (due to a limitation in our locations' mechanism). |
| 70 |
// It doesn't cover all the cases (i.e. when there are multiple dividers at the end), but it's good enough for our use-case. |
| 71 |
const StyledPopoverMenu = (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.styled)(external_UNSTABLE_elementorPackages_topBar_namespaceObject.PopoverMenu)` |
| 72 |
& > .MuiPopover-paper > .MuiList-root > .MuiDivider-root { |
| 73 |
&:only-child, /* A divider is being rendered lonely */ |
| 74 |
&:last-child, /* The last group renders empty but renders a divider */ |
| 75 |
& + .MuiDivider-root /* Multiple dividers due to multiple empty groups */ { |
| 76 |
display: none; |
| 77 |
} |
| 78 |
} |
| 79 |
`; |
| 80 |
function PrimaryActionMenu(props) { |
| 81 |
const { |
| 82 |
save: saveActions, |
| 83 |
default: defaultActions |
| 84 |
} = useMenuItems(); |
| 85 |
return /*#__PURE__*/external_React_namespaceObject.createElement(StyledPopoverMenu, _extends({}, props, { |
| 86 |
anchorOrigin: { |
| 87 |
vertical: 'bottom', |
| 88 |
horizontal: 'right' |
| 89 |
}, |
| 90 |
transformOrigin: { |
| 91 |
vertical: 'top', |
| 92 |
horizontal: 'right' |
| 93 |
}, |
| 94 |
PaperProps: { |
| 95 |
sx: { |
| 96 |
mt: 2, |
| 97 |
ml: 3 |
| 98 |
} |
| 99 |
} |
| 100 |
}), saveActions.map(({ |
| 101 |
MenuItem, |
| 102 |
id |
| 103 |
}, index) => [index > 0 && /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_topBar_namespaceObject.Divider, { |
| 104 |
key: `${id}-divider` |
| 105 |
}), /*#__PURE__*/external_React_namespaceObject.createElement(MenuItem, { |
| 106 |
key: id |
| 107 |
})]), defaultActions.length > 0 && /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_topBar_namespaceObject.Divider, null), defaultActions.map(({ |
| 108 |
MenuItem, |
| 109 |
id |
| 110 |
}) => /*#__PURE__*/external_React_namespaceObject.createElement(MenuItem, { |
| 111 |
key: id |
| 112 |
}))); |
| 113 |
} |
| 114 |
;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.documents" |
| 115 |
var external_UNSTABLE_elementorPackages_documents_namespaceObject = __UNSTABLE__elementorPackages.documents; |
| 116 |
;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.icons" |
| 117 |
var external_UNSTABLE_elementorPackages_icons_namespaceObject = __UNSTABLE__elementorPackages.icons; |
| 118 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/components/top-bar/primary-action.tsx |
| 119 |
function primary_action_extends() { primary_action_extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return primary_action_extends.apply(this, arguments); } |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
function PrimaryAction() { |
| 127 |
const document = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocument)(); |
| 128 |
const { |
| 129 |
save |
| 130 |
} = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocumentActions)(); |
| 131 |
const popupState = (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.usePopupState)({ |
| 132 |
variant: 'popover', |
| 133 |
popupId: 'document-save-options' |
| 134 |
}); |
| 135 |
if (!document) { |
| 136 |
return null; |
| 137 |
} |
| 138 |
const isDisabled = !isEnabled(document); |
| 139 |
|
| 140 |
// When the document is being saved, the spinner should not appear. |
| 141 |
// Usually happens when the Kit is being saved. |
| 142 |
const shouldShowSpinner = document.isSaving && !isDisabled; |
| 143 |
return /*#__PURE__*/external_React_namespaceObject.createElement(external_React_namespaceObject.Fragment, null, /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.ButtonGroup, { |
| 144 |
size: "large", |
| 145 |
variant: "contained" |
| 146 |
}, /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Button, { |
| 147 |
onClick: () => !document.isSaving && save(), |
| 148 |
sx: { |
| 149 |
width: '120px' |
| 150 |
}, |
| 151 |
disabled: isDisabled |
| 152 |
}, shouldShowSpinner ? /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.CircularProgress, null) : getLabel(document)), /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Tooltip, { |
| 153 |
title: (0,external_wp_i18n_namespaceObject.__)('Save Options', 'elementor'), |
| 154 |
PopperProps: { |
| 155 |
sx: { |
| 156 |
'&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom': { |
| 157 |
mt: 3, |
| 158 |
mr: 1 |
| 159 |
} |
| 160 |
} |
| 161 |
} |
| 162 |
}, /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_ui_namespaceObject.Button, primary_action_extends({ |
| 163 |
sx: { |
| 164 |
px: 0 |
| 165 |
} |
| 166 |
}, (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.bindTrigger)(popupState)), /*#__PURE__*/external_React_namespaceObject.createElement(external_UNSTABLE_elementorPackages_icons_namespaceObject.ChevronDownIcon, null)))), /*#__PURE__*/external_React_namespaceObject.createElement(PrimaryActionMenu, primary_action_extends({}, (0,external_UNSTABLE_elementorPackages_ui_namespaceObject.bindMenu)(popupState), { |
| 167 |
onClick: popupState.close |
| 168 |
}))); |
| 169 |
} |
| 170 |
function getLabel(document) { |
| 171 |
return document.userCan.publish ? (0,external_wp_i18n_namespaceObject.__)('Publish', 'elementor') : (0,external_wp_i18n_namespaceObject.__)('Submit', 'elementor'); |
| 172 |
} |
| 173 |
function isEnabled(document) { |
| 174 |
if (document.type.value === 'kit') { |
| 175 |
return false; |
| 176 |
} |
| 177 |
return document.isDirty || document.status.value === 'draft'; |
| 178 |
} |
| 179 |
;// CONCATENATED MODULE: external "__UNSTABLE__elementorPackages.v1Adapters" |
| 180 |
var external_UNSTABLE_elementorPackages_v1Adapters_namespaceObject = __UNSTABLE__elementorPackages.v1Adapters; |
| 181 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/hooks/use-document-preview-props.ts |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
function useDocumentPreviewProps() { |
| 187 |
const document = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocument)(); |
| 188 |
return { |
| 189 |
icon: external_UNSTABLE_elementorPackages_icons_namespaceObject.EyeIcon, |
| 190 |
title: (0,external_wp_i18n_namespaceObject.__)('Preview Changes', 'elementor'), |
| 191 |
onClick: () => document && (0,external_UNSTABLE_elementorPackages_v1Adapters_namespaceObject.runCommand)('editor/documents/preview', { |
| 192 |
id: document.id, |
| 193 |
force: true |
| 194 |
}) |
| 195 |
}; |
| 196 |
} |
| 197 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/hooks/use-document-save-draft-props.ts |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
function useDocumentSaveDraftProps() { |
| 202 |
const document = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocument)(); |
| 203 |
const { |
| 204 |
saveDraft |
| 205 |
} = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocumentActions)(); |
| 206 |
return { |
| 207 |
icon: external_UNSTABLE_elementorPackages_icons_namespaceObject.FileReportIcon, |
| 208 |
title: (0,external_wp_i18n_namespaceObject.__)('Save Draft', 'elementor'), |
| 209 |
onClick: saveDraft, |
| 210 |
disabled: !document || document.isSaving || document.isSavingDraft || !document.isDirty |
| 211 |
}; |
| 212 |
} |
| 213 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/hooks/use-document-save-template-props.ts |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
function useDocumentSaveTemplateProps() { |
| 218 |
const { |
| 219 |
saveTemplate |
| 220 |
} = (0,external_UNSTABLE_elementorPackages_documents_namespaceObject.useActiveDocumentActions)(); |
| 221 |
return { |
| 222 |
icon: external_UNSTABLE_elementorPackages_icons_namespaceObject.FolderIcon, |
| 223 |
title: (0,external_wp_i18n_namespaceObject.__)('Save as Template', 'elementor'), |
| 224 |
onClick: saveTemplate |
| 225 |
}; |
| 226 |
} |
| 227 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/init.ts |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
function init() { |
| 235 |
registerTopBarMenuItems(); |
| 236 |
} |
| 237 |
function registerTopBarMenuItems() { |
| 238 |
(0,external_UNSTABLE_elementorPackages_topBar_namespaceObject.injectIntoPrimaryAction)({ |
| 239 |
name: 'document-primary-action', |
| 240 |
filler: PrimaryAction |
| 241 |
}); |
| 242 |
external_UNSTABLE_elementorPackages_topBar_namespaceObject.utilitiesMenu.registerAction({ |
| 243 |
name: 'document-preview-button', |
| 244 |
priority: 30, |
| 245 |
// After help. |
| 246 |
useProps: useDocumentPreviewProps |
| 247 |
}); |
| 248 |
documentOptionsMenu.registerAction({ |
| 249 |
group: 'save', |
| 250 |
name: 'document-save-draft', |
| 251 |
priority: 10, |
| 252 |
// Before save as template. |
| 253 |
useProps: useDocumentSaveDraftProps |
| 254 |
}); |
| 255 |
documentOptionsMenu.registerAction({ |
| 256 |
group: 'save', |
| 257 |
name: 'document-save-as-template', |
| 258 |
priority: 20, |
| 259 |
// After save draft. |
| 260 |
useProps: useDocumentSaveTemplateProps |
| 261 |
}); |
| 262 |
} |
| 263 |
;// CONCATENATED MODULE: ./packages/documents-ui/src/index.ts |
| 264 |
|
| 265 |
|
| 266 |
init(); |
| 267 |
(window.__UNSTABLE__elementorPackages = window.__UNSTABLE__elementorPackages || {}).documentsUi = __webpack_exports__; |
| 268 |
/******/ })() |
| 269 |
; |