@elementor/editor-site-navigation 4.5.0-1208 → 4.5.0-1209
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +308 -234
- package/dist/index.mjs +274 -200
- package/package.json +10 -10
- package/src/api/post.ts +16 -0
- package/src/components/panel/actions-menu/actions/duplicate.tsx +3 -5
- package/src/components/panel/content-panel-header-add.tsx +35 -27
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +13 -4
- package/src/components/panel/section-add-button.tsx +4 -5
- package/src/components/panel/shell-panel-body-content.tsx +44 -0
- package/src/components/panel/shell.tsx +10 -15
- package/src/components/panel/user-load-error.tsx +16 -0
- package/src/env.ts +2 -0
- package/src/hooks/use-accessible-panel-post-types.ts +29 -0
- package/src/hooks/use-can-create.ts +9 -0
- package/src/init.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -61,11 +61,57 @@ var import_editor_sidebar = require("@elementor/editor-sidebar");
|
|
|
61
61
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
62
62
|
|
|
63
63
|
// src/components/panel/shell.tsx
|
|
64
|
-
var
|
|
65
|
-
var
|
|
64
|
+
var React26 = __toESM(require("react"));
|
|
65
|
+
var import_react9 = require("react");
|
|
66
66
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
67
|
-
var
|
|
68
|
-
var
|
|
67
|
+
var import_ui16 = require("@elementor/ui");
|
|
68
|
+
var import_i18n17 = require("@wordpress/i18n");
|
|
69
|
+
|
|
70
|
+
// src/contexts/content-panel-coordinator.tsx
|
|
71
|
+
var React = __toESM(require("react"));
|
|
72
|
+
var import_react = require("react");
|
|
73
|
+
var ContentPanelCoordinatorContext = (0, import_react.createContext)(null);
|
|
74
|
+
function ContentPanelCoordinatorProvider({ children }) {
|
|
75
|
+
const sectionsRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
76
|
+
const [searchQuery, setSearchQuery] = (0, import_react.useState)("");
|
|
77
|
+
const registerSection = (0, import_react.useCallback)((type, handlers) => {
|
|
78
|
+
sectionsRef.current.set(type, handlers);
|
|
79
|
+
}, []);
|
|
80
|
+
const unregisterSection = (0, import_react.useCallback)((type) => {
|
|
81
|
+
sectionsRef.current.delete(type);
|
|
82
|
+
}, []);
|
|
83
|
+
const requestCreate = (0, import_react.useCallback)((type) => {
|
|
84
|
+
const handlers = sectionsRef.current.get(type);
|
|
85
|
+
if (!handlers) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
handlers.setExpanded(true);
|
|
89
|
+
handlers.startCreate();
|
|
90
|
+
}, []);
|
|
91
|
+
const value = (0, import_react.useMemo)(
|
|
92
|
+
() => ({
|
|
93
|
+
registerSection,
|
|
94
|
+
unregisterSection,
|
|
95
|
+
requestCreate,
|
|
96
|
+
searchQuery,
|
|
97
|
+
setSearchQuery
|
|
98
|
+
}),
|
|
99
|
+
[registerSection, unregisterSection, requestCreate, searchQuery]
|
|
100
|
+
);
|
|
101
|
+
return /* @__PURE__ */ React.createElement(ContentPanelCoordinatorContext.Provider, { value }, children);
|
|
102
|
+
}
|
|
103
|
+
function useContentPanelCoordinator() {
|
|
104
|
+
const context = (0, import_react.useContext)(ContentPanelCoordinatorContext);
|
|
105
|
+
if (!context) {
|
|
106
|
+
throw new Error(
|
|
107
|
+
"The `useContentPanelCoordinator()` hook must be used within a `<ContentPanelCoordinatorProvider />`"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return context;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// src/hooks/use-accessible-panel-post-types.ts
|
|
114
|
+
var import_react2 = require("react");
|
|
69
115
|
|
|
70
116
|
// src/api/post.ts
|
|
71
117
|
var import_api_fetch = __toESM(require("@wordpress/api-fetch"));
|
|
@@ -92,6 +138,15 @@ var panelPostTypeSlugs = Object.keys(postTypesMap);
|
|
|
92
138
|
function getPostTypeCreateCapability(postTypeSlug) {
|
|
93
139
|
return postTypesMap[postTypeSlug].createCapability;
|
|
94
140
|
}
|
|
141
|
+
function getAccessiblePanelPostTypes(capabilities) {
|
|
142
|
+
return panelPostTypeSlugs.filter((slug) => capabilities[getPostTypeCreateCapability(slug)]);
|
|
143
|
+
}
|
|
144
|
+
function getCannotEditPanelItemMessage(postTypeSlug) {
|
|
145
|
+
if ("page" === postTypeSlug) {
|
|
146
|
+
return (0, import_i18n.__)("You cannot edit this page.", "elementor");
|
|
147
|
+
}
|
|
148
|
+
return (0, import_i18n.__)("You cannot edit this post.", "elementor");
|
|
149
|
+
}
|
|
95
150
|
var POST_PER_PAGE = 10;
|
|
96
151
|
var getRequest = async (postTypeSlug, page, search = "") => {
|
|
97
152
|
const baseUri = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
|
|
@@ -155,89 +210,56 @@ var duplicateRequest = (originalPost) => {
|
|
|
155
210
|
});
|
|
156
211
|
};
|
|
157
212
|
|
|
158
|
-
// src/
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const sectionsRef = (0, import_react.useRef)(/* @__PURE__ */ new Map());
|
|
164
|
-
const [searchQuery, setSearchQuery] = (0, import_react.useState)("");
|
|
165
|
-
const registerSection = (0, import_react.useCallback)((type, handlers) => {
|
|
166
|
-
sectionsRef.current.set(type, handlers);
|
|
167
|
-
}, []);
|
|
168
|
-
const unregisterSection = (0, import_react.useCallback)((type) => {
|
|
169
|
-
sectionsRef.current.delete(type);
|
|
170
|
-
}, []);
|
|
171
|
-
const requestCreate = (0, import_react.useCallback)((type) => {
|
|
172
|
-
const handlers = sectionsRef.current.get(type);
|
|
173
|
-
if (!handlers) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
handlers.setExpanded(true);
|
|
177
|
-
handlers.startCreate();
|
|
178
|
-
}, []);
|
|
179
|
-
const value = (0, import_react.useMemo)(
|
|
180
|
-
() => ({
|
|
181
|
-
registerSection,
|
|
182
|
-
unregisterSection,
|
|
183
|
-
requestCreate,
|
|
184
|
-
searchQuery,
|
|
185
|
-
setSearchQuery
|
|
186
|
-
}),
|
|
187
|
-
[registerSection, unregisterSection, requestCreate, searchQuery]
|
|
188
|
-
);
|
|
189
|
-
return /* @__PURE__ */ React.createElement(ContentPanelCoordinatorContext.Provider, { value }, children);
|
|
190
|
-
}
|
|
191
|
-
function useContentPanelCoordinator() {
|
|
192
|
-
const context = (0, import_react.useContext)(ContentPanelCoordinatorContext);
|
|
193
|
-
if (!context) {
|
|
194
|
-
throw new Error(
|
|
195
|
-
"The `useContentPanelCoordinator()` hook must be used within a `<ContentPanelCoordinatorProvider />`"
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
return context;
|
|
199
|
-
}
|
|
213
|
+
// src/env.ts
|
|
214
|
+
var import_env = require("@elementor/env");
|
|
215
|
+
var { env } = (0, import_env.parseEnv)("@elementor/editor-site-navigation", (envData) => {
|
|
216
|
+
return envData;
|
|
217
|
+
});
|
|
200
218
|
|
|
201
|
-
// src/
|
|
202
|
-
var
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
// src/hooks/use-user.ts
|
|
220
|
+
var import_query = require("@elementor/query");
|
|
221
|
+
|
|
222
|
+
// src/api/user.ts
|
|
223
|
+
var import_api_fetch2 = __toESM(require("@wordpress/api-fetch"));
|
|
224
|
+
var getUser = () => {
|
|
225
|
+
const baseUri = "/wp/v2/users/me";
|
|
226
|
+
const keys = ["capabilities"];
|
|
227
|
+
const queryParams = new URLSearchParams({
|
|
228
|
+
_fields: keys.join(","),
|
|
229
|
+
context: "edit"
|
|
230
|
+
});
|
|
231
|
+
const uri = baseUri + "?" + queryParams.toString();
|
|
232
|
+
return (0, import_api_fetch2.default)({ path: uri });
|
|
210
233
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
234
|
+
|
|
235
|
+
// src/hooks/use-user.ts
|
|
236
|
+
var userQueryKey = () => ["site-navigation", "user"];
|
|
237
|
+
function useUser() {
|
|
238
|
+
return (0, import_query.useQuery)({
|
|
239
|
+
queryKey: userQueryKey(),
|
|
240
|
+
queryFn: getUser,
|
|
241
|
+
staleTime: 30 * 60 * 1e3
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/hooks/use-accessible-panel-post-types.ts
|
|
246
|
+
function useAccessiblePanelPostTypes() {
|
|
247
|
+
const { data: user, isPending: isUserPending, isError: isUserError } = useUser();
|
|
248
|
+
const accessiblePostTypes = (0, import_react2.useMemo)(() => {
|
|
249
|
+
if (user?.capabilities) {
|
|
250
|
+
return getAccessiblePanelPostTypes(user.capabilities);
|
|
251
|
+
}
|
|
252
|
+
if (isUserError && env.can_access_site_content_panel) {
|
|
253
|
+
return panelPostTypeSlugs;
|
|
254
|
+
}
|
|
255
|
+
return [];
|
|
256
|
+
}, [user, isUserError]);
|
|
257
|
+
const showUserLoadError = isUserError && accessiblePostTypes.length === 0;
|
|
258
|
+
return {
|
|
259
|
+
accessiblePostTypes,
|
|
260
|
+
isUserPending,
|
|
261
|
+
showUserLoadError
|
|
220
262
|
};
|
|
221
|
-
return /* @__PURE__ */ React2.createElement(
|
|
222
|
-
PostListContext.Provider,
|
|
223
|
-
{
|
|
224
|
-
value: {
|
|
225
|
-
type,
|
|
226
|
-
editMode,
|
|
227
|
-
setEditMode,
|
|
228
|
-
resetEditMode,
|
|
229
|
-
setError
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
children
|
|
233
|
-
);
|
|
234
|
-
};
|
|
235
|
-
function usePostListContext() {
|
|
236
|
-
const context = (0, import_react2.useContext)(PostListContext);
|
|
237
|
-
if (!context) {
|
|
238
|
-
throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
|
|
239
|
-
}
|
|
240
|
-
return context;
|
|
241
263
|
}
|
|
242
264
|
|
|
243
265
|
// src/components/panel/content-panel-chrome.ts
|
|
@@ -293,44 +315,25 @@ var contentPanelListItemButtonSx = {
|
|
|
293
315
|
};
|
|
294
316
|
|
|
295
317
|
// src/components/panel/content-panel-header-add.tsx
|
|
296
|
-
var
|
|
318
|
+
var React3 = __toESM(require("react"));
|
|
297
319
|
var import_icons3 = require("@elementor/icons");
|
|
298
320
|
var import_ui2 = require("@elementor/ui");
|
|
299
321
|
var import_i18n2 = require("@wordpress/i18n");
|
|
300
322
|
|
|
301
|
-
// src/hooks/use-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
var getUser = () => {
|
|
307
|
-
const baseUri = "/wp/v2/users/me";
|
|
308
|
-
const keys = ["capabilities"];
|
|
309
|
-
const queryParams = new URLSearchParams({
|
|
310
|
-
_fields: keys.join(","),
|
|
311
|
-
context: "edit"
|
|
312
|
-
});
|
|
313
|
-
const uri = baseUri + "?" + queryParams.toString();
|
|
314
|
-
return (0, import_api_fetch2.default)({ path: uri });
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
// src/hooks/use-user.ts
|
|
318
|
-
var userQueryKey = () => ["site-navigation", "user"];
|
|
319
|
-
function useUser() {
|
|
320
|
-
return (0, import_query.useQuery)({
|
|
321
|
-
queryKey: userQueryKey(),
|
|
322
|
-
queryFn: getUser,
|
|
323
|
-
staleTime: 30 * 60 * 1e3
|
|
324
|
-
});
|
|
323
|
+
// src/hooks/use-can-create.ts
|
|
324
|
+
function useCanCreate(postTypeSlug) {
|
|
325
|
+
const { data: user } = useUser();
|
|
326
|
+
const capability = getPostTypeCreateCapability(postTypeSlug);
|
|
327
|
+
return !!user?.capabilities?.[capability];
|
|
325
328
|
}
|
|
326
329
|
|
|
327
330
|
// src/components/panel/content-panel-add-icon-button.tsx
|
|
328
|
-
var
|
|
331
|
+
var React2 = __toESM(require("react"));
|
|
329
332
|
var import_icons2 = require("@elementor/icons");
|
|
330
333
|
var import_ui = require("@elementor/ui");
|
|
331
334
|
var CONTENT_PANEL_ADD_ICON_SIZE = "tiny";
|
|
332
335
|
function ContentPanelAddIconButton(props) {
|
|
333
|
-
return /* @__PURE__ */
|
|
336
|
+
return /* @__PURE__ */ React2.createElement(import_ui.IconButton, { size: CONTENT_PANEL_ADD_ICON_SIZE, variant: "outlined", ...props }, /* @__PURE__ */ React2.createElement(import_icons2.PlusIcon, { fontSize: CONTENT_PANEL_ADD_ICON_SIZE }));
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
// src/components/panel/content-panel-header-add.tsx
|
|
@@ -338,45 +341,46 @@ var typeIcons = {
|
|
|
338
341
|
page: import_icons3.PageTypeIcon,
|
|
339
342
|
post: import_icons3.PostTypeIcon
|
|
340
343
|
};
|
|
344
|
+
function HeaderAddMenuItem({ slug, onSelect }) {
|
|
345
|
+
const canCreate = useCanCreate(slug);
|
|
346
|
+
const Icon = typeIcons[slug];
|
|
347
|
+
const singularName = postTypesMap[slug].labels.singular_name;
|
|
348
|
+
return /* @__PURE__ */ React3.createElement(import_ui2.MenuItem, { disabled: !canCreate, onClick: () => onSelect(slug) }, /* @__PURE__ */ React3.createElement(import_ui2.ListItemIcon, null, /* @__PURE__ */ React3.createElement(Icon, { fontSize: "small" })), /* @__PURE__ */ React3.createElement(import_ui2.ListItemText, { primary: singularName, primaryTypographyProps: { variant: "body2" } }));
|
|
349
|
+
}
|
|
341
350
|
function ContentPanelHeaderAdd() {
|
|
342
351
|
const { requestCreate } = useContentPanelCoordinator();
|
|
343
|
-
const {
|
|
352
|
+
const { accessiblePostTypes: accessibleSlugs } = useAccessiblePanelPostTypes();
|
|
344
353
|
const popupState = (0, import_ui2.usePopupState)({
|
|
345
354
|
variant: "popover",
|
|
346
355
|
popupId: "elementor-content-panel-header-add"
|
|
347
356
|
});
|
|
357
|
+
const canAddAny = accessibleSlugs.length > 0;
|
|
348
358
|
const buttonProps = (0, import_ui2.bindTrigger)(popupState);
|
|
349
359
|
const menuProps = (0, import_ui2.bindMenu)(popupState);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
/* @__PURE__ */ React4.createElement(import_ui2.ListItemIcon, null, /* @__PURE__ */ React4.createElement(Icon, { fontSize: "small" })),
|
|
367
|
-
/* @__PURE__ */ React4.createElement(import_ui2.ListItemText, { primary: singularName, primaryTypographyProps: { variant: "body2" } })
|
|
368
|
-
);
|
|
369
|
-
})));
|
|
360
|
+
const handleSelectType = (slug) => {
|
|
361
|
+
popupState.close();
|
|
362
|
+
requestAnimationFrame(() => {
|
|
363
|
+
requestCreate(slug);
|
|
364
|
+
});
|
|
365
|
+
};
|
|
366
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
367
|
+
ContentPanelAddIconButton,
|
|
368
|
+
{
|
|
369
|
+
"aria-label": (0, import_i18n2.__)("Add new", "elementor"),
|
|
370
|
+
...buttonProps,
|
|
371
|
+
disabled: !canAddAny
|
|
372
|
+
}
|
|
373
|
+
), /* @__PURE__ */ React3.createElement(import_ui2.Menu, { ...menuProps }, accessibleSlugs.map((slug) => /* @__PURE__ */ React3.createElement(HeaderAddMenuItem, { key: slug, onSelect: handleSelectType, slug }))));
|
|
370
374
|
}
|
|
371
375
|
|
|
372
376
|
// src/components/panel/content-panel-search.tsx
|
|
373
|
-
var
|
|
377
|
+
var React4 = __toESM(require("react"));
|
|
374
378
|
var import_icons4 = require("@elementor/icons");
|
|
375
379
|
var import_ui3 = require("@elementor/ui");
|
|
376
380
|
var import_i18n3 = require("@wordpress/i18n");
|
|
377
381
|
function ContentPanelSearch() {
|
|
378
382
|
const { searchQuery, setSearchQuery } = useContentPanelCoordinator();
|
|
379
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ React4.createElement(import_ui3.Box, { component: "search", sx: contentPanelSearchBoxSx, "aria-label": (0, import_i18n3.__)("Search site content", "elementor") }, /* @__PURE__ */ React4.createElement(
|
|
380
384
|
import_ui3.TextField,
|
|
381
385
|
{
|
|
382
386
|
fullWidth: true,
|
|
@@ -388,17 +392,17 @@ function ContentPanelSearch() {
|
|
|
388
392
|
"aria-label": (0, import_i18n3.__)("Search", "elementor")
|
|
389
393
|
},
|
|
390
394
|
InputProps: {
|
|
391
|
-
startAdornment: /* @__PURE__ */
|
|
395
|
+
startAdornment: /* @__PURE__ */ React4.createElement(import_ui3.InputAdornment, { position: "start" }, /* @__PURE__ */ React4.createElement(import_icons4.SearchIcon, { fontSize: "tiny" }))
|
|
392
396
|
}
|
|
393
397
|
}
|
|
394
398
|
));
|
|
395
399
|
}
|
|
396
400
|
|
|
397
401
|
// src/components/panel/error-snackbar.tsx
|
|
398
|
-
var
|
|
402
|
+
var React5 = __toESM(require("react"));
|
|
399
403
|
var import_ui4 = require("@elementor/ui");
|
|
400
404
|
var ErrorSnackbar = ({ open, onClose }) => {
|
|
401
|
-
return /* @__PURE__ */
|
|
405
|
+
return /* @__PURE__ */ React5.createElement(
|
|
402
406
|
import_ui4.Snackbar,
|
|
403
407
|
{
|
|
404
408
|
open,
|
|
@@ -408,7 +412,7 @@ var ErrorSnackbar = ({ open, onClose }) => {
|
|
|
408
412
|
horizontal: "left"
|
|
409
413
|
}
|
|
410
414
|
},
|
|
411
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Alert, { onClose, severity: "error", sx: { width: "100%" } }, /* @__PURE__ */ React5.createElement(
|
|
412
416
|
import_ui4.Typography,
|
|
413
417
|
{
|
|
414
418
|
component: "span",
|
|
@@ -422,9 +426,55 @@ var ErrorSnackbar = ({ open, onClose }) => {
|
|
|
422
426
|
};
|
|
423
427
|
var error_snackbar_default = ErrorSnackbar;
|
|
424
428
|
|
|
429
|
+
// src/components/panel/shell-panel-body-content.tsx
|
|
430
|
+
var React25 = __toESM(require("react"));
|
|
431
|
+
var import_ui15 = require("@elementor/ui");
|
|
432
|
+
|
|
433
|
+
// src/contexts/post-list-context.tsx
|
|
434
|
+
var React6 = __toESM(require("react"));
|
|
435
|
+
var import_react3 = require("react");
|
|
436
|
+
var defaultValues = {
|
|
437
|
+
type: "page",
|
|
438
|
+
editMode: { mode: "none", details: {} },
|
|
439
|
+
setEditMode: () => null,
|
|
440
|
+
resetEditMode: () => null,
|
|
441
|
+
setError: () => null
|
|
442
|
+
};
|
|
443
|
+
var PostListContext = (0, import_react3.createContext)(defaultValues);
|
|
444
|
+
var PostListContextProvider = ({
|
|
445
|
+
type,
|
|
446
|
+
setError,
|
|
447
|
+
children
|
|
448
|
+
}) => {
|
|
449
|
+
const [editMode, setEditMode] = (0, import_react3.useState)(defaultValues.editMode);
|
|
450
|
+
const resetEditMode = () => {
|
|
451
|
+
setEditMode(defaultValues.editMode);
|
|
452
|
+
};
|
|
453
|
+
return /* @__PURE__ */ React6.createElement(
|
|
454
|
+
PostListContext.Provider,
|
|
455
|
+
{
|
|
456
|
+
value: {
|
|
457
|
+
type,
|
|
458
|
+
editMode,
|
|
459
|
+
setEditMode,
|
|
460
|
+
resetEditMode,
|
|
461
|
+
setError
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
children
|
|
465
|
+
);
|
|
466
|
+
};
|
|
467
|
+
function usePostListContext() {
|
|
468
|
+
const context = (0, import_react3.useContext)(PostListContext);
|
|
469
|
+
if (!context) {
|
|
470
|
+
throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
|
|
471
|
+
}
|
|
472
|
+
return context;
|
|
473
|
+
}
|
|
474
|
+
|
|
425
475
|
// src/components/panel/posts-list/posts-collapsible-list.tsx
|
|
426
476
|
var React23 = __toESM(require("react"));
|
|
427
|
-
var
|
|
477
|
+
var import_react8 = require("react");
|
|
428
478
|
var import_ui13 = require("@elementor/ui");
|
|
429
479
|
var import_i18n15 = require("@wordpress/i18n");
|
|
430
480
|
|
|
@@ -494,8 +544,7 @@ var React7 = __toESM(require("react"));
|
|
|
494
544
|
var import_i18n4 = require("@wordpress/i18n");
|
|
495
545
|
function SectionAddButton({ onBeforeCreate }) {
|
|
496
546
|
const { type, setEditMode } = usePostListContext();
|
|
497
|
-
const
|
|
498
|
-
const createCapability = getPostTypeCreateCapability(type);
|
|
547
|
+
const canCreate = useCanCreate(type);
|
|
499
548
|
const singularName = postTypesMap[type].labels.singular_name;
|
|
500
549
|
const ariaLabel = (0, import_i18n4.sprintf)(
|
|
501
550
|
/* translators: %s: Post type singular name (e.g. Page, Post). */
|
|
@@ -506,7 +555,7 @@ function SectionAddButton({ onBeforeCreate }) {
|
|
|
506
555
|
ContentPanelAddIconButton,
|
|
507
556
|
{
|
|
508
557
|
"aria-label": ariaLabel,
|
|
509
|
-
disabled: !
|
|
558
|
+
disabled: !canCreate,
|
|
510
559
|
onClick: (event) => {
|
|
511
560
|
event.stopPropagation();
|
|
512
561
|
onBeforeCreate?.();
|
|
@@ -518,7 +567,7 @@ function SectionAddButton({ onBeforeCreate }) {
|
|
|
518
567
|
|
|
519
568
|
// src/components/panel/posts-list/collapsible-list.tsx
|
|
520
569
|
var React8 = __toESM(require("react"));
|
|
521
|
-
var
|
|
570
|
+
var import_react4 = require("react");
|
|
522
571
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
523
572
|
var import_ui5 = require("@elementor/ui");
|
|
524
573
|
var sectionHeaderListItemButtonSx = {
|
|
@@ -541,7 +590,7 @@ function CollapsibleList({
|
|
|
541
590
|
trailingActions,
|
|
542
591
|
children
|
|
543
592
|
}) {
|
|
544
|
-
const id = (0,
|
|
593
|
+
const id = (0, import_react4.useId)();
|
|
545
594
|
const labelId = `label-${id}`;
|
|
546
595
|
const contentId = `content-${id}`;
|
|
547
596
|
const sectionHeaderAriaLabel = getSectionHeaderAriaLabel(title, count);
|
|
@@ -706,7 +755,7 @@ function useInvalidatePosts(postTypeSlug) {
|
|
|
706
755
|
|
|
707
756
|
// src/components/panel/posts-list/list-items/edit-mode-template.tsx
|
|
708
757
|
var React10 = __toESM(require("react"));
|
|
709
|
-
var
|
|
758
|
+
var import_react5 = require("react");
|
|
710
759
|
var import_icons6 = require("@elementor/icons");
|
|
711
760
|
var import_ui7 = require("@elementor/ui");
|
|
712
761
|
var import_i18n6 = require("@wordpress/i18n");
|
|
@@ -748,10 +797,10 @@ var editRowInputSx = {
|
|
|
748
797
|
};
|
|
749
798
|
function EditModeTemplate({ postTitle, isLoading, callback }) {
|
|
750
799
|
const { resetEditMode } = usePostListContext();
|
|
751
|
-
const [title, setTitle] = (0,
|
|
752
|
-
const [touched, setTouched] = (0,
|
|
753
|
-
const [inputError, setInputError] = (0,
|
|
754
|
-
const closeButton = (0,
|
|
800
|
+
const [title, setTitle] = (0, import_react5.useState)(postTitle);
|
|
801
|
+
const [touched, setTouched] = (0, import_react5.useState)(false);
|
|
802
|
+
const [inputError, setInputError] = (0, import_react5.useState)(null);
|
|
803
|
+
const closeButton = (0, import_react5.useRef)();
|
|
755
804
|
const onBlur = (e) => {
|
|
756
805
|
if (closeButton.current === e.relatedTarget) {
|
|
757
806
|
return;
|
|
@@ -960,7 +1009,7 @@ var React14 = __toESM(require("react"));
|
|
|
960
1009
|
var import_ui8 = require("@elementor/ui");
|
|
961
1010
|
|
|
962
1011
|
// src/hooks/use-reverse-html-entities.ts
|
|
963
|
-
var
|
|
1012
|
+
var import_react6 = require("react");
|
|
964
1013
|
|
|
965
1014
|
// src/utils/post-title-plain.ts
|
|
966
1015
|
function getPostTitlePlain(renderedTitle) {
|
|
@@ -974,7 +1023,7 @@ function getPostTitlePlain(renderedTitle) {
|
|
|
974
1023
|
|
|
975
1024
|
// src/hooks/use-reverse-html-entities.ts
|
|
976
1025
|
function useReverseHtmlEntities(escapedHTML = "") {
|
|
977
|
-
return (0,
|
|
1026
|
+
return (0, import_react6.useMemo)(() => getPostTitlePlain(escapedHTML), [escapedHTML]);
|
|
978
1027
|
}
|
|
979
1028
|
|
|
980
1029
|
// src/components/shared/page-title-and-status.tsx
|
|
@@ -1024,7 +1073,7 @@ function PageTitleAndStatus({ title, status }) {
|
|
|
1024
1073
|
|
|
1025
1074
|
// src/components/panel/actions-menu/actions/delete.tsx
|
|
1026
1075
|
var React16 = __toESM(require("react"));
|
|
1027
|
-
var
|
|
1076
|
+
var import_react7 = require("react");
|
|
1028
1077
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
1029
1078
|
var import_icons7 = require("@elementor/icons");
|
|
1030
1079
|
var import_ui10 = require("@elementor/ui");
|
|
@@ -1047,7 +1096,7 @@ function ActionMenuItem({ title, icon: Icon, MenuItemProps }) {
|
|
|
1047
1096
|
|
|
1048
1097
|
// src/components/panel/actions-menu/actions/delete.tsx
|
|
1049
1098
|
function Delete({ post }) {
|
|
1050
|
-
const [isDialogOpen, setIsDialogOpen] = (0,
|
|
1099
|
+
const [isDialogOpen, setIsDialogOpen] = (0, import_react7.useState)(false);
|
|
1051
1100
|
const activeDocument = (0, import_editor_documents4.__useActiveDocument)();
|
|
1052
1101
|
const isPostActive = activeDocument?.id === post.id;
|
|
1053
1102
|
const userCanDelete = post.user_can.delete;
|
|
@@ -1112,8 +1161,7 @@ var import_icons8 = require("@elementor/icons");
|
|
|
1112
1161
|
var import_i18n10 = require("@wordpress/i18n");
|
|
1113
1162
|
function Duplicate({ post, popupState }) {
|
|
1114
1163
|
const { setEditMode, type } = usePostListContext();
|
|
1115
|
-
const
|
|
1116
|
-
const createCapability = getPostTypeCreateCapability(type);
|
|
1164
|
+
const canCreate = useCanCreate(type);
|
|
1117
1165
|
const onClick = () => {
|
|
1118
1166
|
popupState.close();
|
|
1119
1167
|
setEditMode({
|
|
@@ -1124,7 +1172,7 @@ function Duplicate({ post, popupState }) {
|
|
|
1124
1172
|
}
|
|
1125
1173
|
});
|
|
1126
1174
|
};
|
|
1127
|
-
const isDisabled = !
|
|
1175
|
+
const isDisabled = !canCreate;
|
|
1128
1176
|
return /* @__PURE__ */ React17.createElement(
|
|
1129
1177
|
ActionMenuItem,
|
|
1130
1178
|
{
|
|
@@ -1240,9 +1288,13 @@ function View({ post }) {
|
|
|
1240
1288
|
}
|
|
1241
1289
|
|
|
1242
1290
|
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
1243
|
-
var DisabledPostTooltip = ({
|
|
1291
|
+
var DisabledPostTooltip = ({
|
|
1292
|
+
children,
|
|
1293
|
+
isDisabled,
|
|
1294
|
+
postTypeSlug
|
|
1295
|
+
}) => {
|
|
1244
1296
|
if (isDisabled) {
|
|
1245
|
-
const title = /* @__PURE__ */ React21.createElement(import_ui12.Typography, { variant: "caption" },
|
|
1297
|
+
const title = /* @__PURE__ */ React21.createElement(import_ui12.Typography, { variant: "caption" }, getCannotEditPanelItemMessage(postTypeSlug), /* @__PURE__ */ React21.createElement("br", null), (0, import_i18n14.__)("To edit it directly, contact the site owner", "elementor"));
|
|
1246
1298
|
return /* @__PURE__ */ React21.createElement(import_ui12.Tooltip, { title, placement: "bottom", arrow: false }, /* @__PURE__ */ React21.createElement("span", null, children));
|
|
1247
1299
|
}
|
|
1248
1300
|
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, children);
|
|
@@ -1261,7 +1313,7 @@ function ListItemView({ post }) {
|
|
|
1261
1313
|
const title = isActive ? activeDocument?.title : post.title.rendered;
|
|
1262
1314
|
const isDisabled = !post.user_can.edit;
|
|
1263
1315
|
const menuTriggerProps = (0, import_ui12.bindTrigger)(popupState);
|
|
1264
|
-
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(DisabledPostTooltip, { isDisabled }, /* @__PURE__ */ React21.createElement(
|
|
1316
|
+
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(DisabledPostTooltip, { isDisabled, postTypeSlug: type }, /* @__PURE__ */ React21.createElement(
|
|
1265
1317
|
import_ui12.ListItem,
|
|
1266
1318
|
{
|
|
1267
1319
|
disablePadding: true,
|
|
@@ -1336,10 +1388,10 @@ var SEARCH_DEBOUNCE_MS = 300;
|
|
|
1336
1388
|
function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
1337
1389
|
const { type, editMode, setEditMode } = usePostListContext();
|
|
1338
1390
|
const { registerSection, unregisterSection, searchQuery } = useContentPanelCoordinator();
|
|
1339
|
-
const [isOpen, setIsOpen] = (0,
|
|
1391
|
+
const [isOpen, setIsOpen] = (0, import_react8.useState)(isOpenByDefault);
|
|
1340
1392
|
const trimmedSearch = searchQuery.trim();
|
|
1341
|
-
const [debouncedSearch, setDebouncedSearch] = (0,
|
|
1342
|
-
(0,
|
|
1393
|
+
const [debouncedSearch, setDebouncedSearch] = (0, import_react8.useState)(trimmedSearch);
|
|
1394
|
+
(0, import_react8.useEffect)(() => {
|
|
1343
1395
|
const handle = window.setTimeout(() => setDebouncedSearch(trimmedSearch), SEARCH_DEBOUNCE_MS);
|
|
1344
1396
|
return () => window.clearTimeout(handle);
|
|
1345
1397
|
}, [trimmedSearch]);
|
|
@@ -1353,14 +1405,14 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1353
1405
|
} = usePosts(type, debouncedSearch);
|
|
1354
1406
|
const { data: homepageId } = useHomepage();
|
|
1355
1407
|
const isPageType = type === "page";
|
|
1356
|
-
(0,
|
|
1408
|
+
(0, import_react8.useEffect)(() => {
|
|
1357
1409
|
registerSection(type, {
|
|
1358
1410
|
setExpanded: setIsOpen,
|
|
1359
1411
|
startCreate: () => setEditMode({ mode: "create", details: {} })
|
|
1360
1412
|
});
|
|
1361
1413
|
return () => unregisterSection(type);
|
|
1362
1414
|
}, [registerSection, unregisterSection, type, setEditMode]);
|
|
1363
|
-
const filteredPosts = (0,
|
|
1415
|
+
const filteredPosts = (0, import_react8.useMemo)(() => {
|
|
1364
1416
|
if (!posts) {
|
|
1365
1417
|
return [];
|
|
1366
1418
|
}
|
|
@@ -1376,7 +1428,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1376
1428
|
}) : mappedPosts;
|
|
1377
1429
|
return sorted;
|
|
1378
1430
|
}, [posts, isPageType, homepageId]);
|
|
1379
|
-
(0,
|
|
1431
|
+
(0, import_react8.useEffect)(() => {
|
|
1380
1432
|
if (debouncedSearch && filteredPosts.length > 0) {
|
|
1381
1433
|
setIsOpen(true);
|
|
1382
1434
|
}
|
|
@@ -1417,11 +1469,39 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
|
1417
1469
|
);
|
|
1418
1470
|
}
|
|
1419
1471
|
|
|
1472
|
+
// src/components/panel/user-load-error.tsx
|
|
1473
|
+
var React24 = __toESM(require("react"));
|
|
1474
|
+
var import_ui14 = require("@elementor/ui");
|
|
1475
|
+
var import_i18n16 = require("@wordpress/i18n");
|
|
1476
|
+
function UserLoadError() {
|
|
1477
|
+
return /* @__PURE__ */ React24.createElement(import_ui14.Box, { sx: { px: 2, py: 2 } }, /* @__PURE__ */ React24.createElement(import_ui14.Typography, { variant: "body2", color: "text.secondary" }, (0, import_i18n16.__)(
|
|
1478
|
+
"We couldn\u2019t load your content permissions. Try closing and reopening this panel.",
|
|
1479
|
+
"elementor"
|
|
1480
|
+
)));
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
// src/components/panel/shell-panel-body-content.tsx
|
|
1484
|
+
function ShellPanelBodyContent({
|
|
1485
|
+
accessiblePostTypes,
|
|
1486
|
+
isUserPending,
|
|
1487
|
+
onListError,
|
|
1488
|
+
showUserLoadError
|
|
1489
|
+
}) {
|
|
1490
|
+
if (isUserPending) {
|
|
1491
|
+
return /* @__PURE__ */ React25.createElement(import_ui15.Stack, { spacing: 1, sx: { px: 2, py: 1 } }, /* @__PURE__ */ React25.createElement(import_ui15.Skeleton, { animation: "wave", height: 28, variant: "rounded", width: "100%" }), /* @__PURE__ */ React25.createElement(import_ui15.Skeleton, { animation: "wave", height: 28, variant: "rounded", width: "80%" }));
|
|
1492
|
+
}
|
|
1493
|
+
if (showUserLoadError) {
|
|
1494
|
+
return /* @__PURE__ */ React25.createElement(UserLoadError, null);
|
|
1495
|
+
}
|
|
1496
|
+
return /* @__PURE__ */ React25.createElement(import_ui15.List, { dense: true, disablePadding: true, sx: { py: 0, width: "100%" } }, accessiblePostTypes.map((postTypeSlug, index) => /* @__PURE__ */ React25.createElement(PostListContextProvider, { key: postTypeSlug, type: postTypeSlug, setError: onListError }, /* @__PURE__ */ React25.createElement(PostsCollapsibleList, { isOpenByDefault: index === 0 }))));
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1420
1499
|
// src/components/panel/shell.tsx
|
|
1421
1500
|
var Shell = () => {
|
|
1422
|
-
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = (0,
|
|
1423
|
-
|
|
1424
|
-
|
|
1501
|
+
const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = (0, import_react9.useState)(false);
|
|
1502
|
+
const { accessiblePostTypes, isUserPending, showUserLoadError } = useAccessiblePanelPostTypes();
|
|
1503
|
+
return /* @__PURE__ */ React26.createElement(ContentPanelCoordinatorProvider, null, /* @__PURE__ */ React26.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React26.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React26.createElement(
|
|
1504
|
+
import_ui16.Stack,
|
|
1425
1505
|
{
|
|
1426
1506
|
alignItems: "center",
|
|
1427
1507
|
direction: "row",
|
|
@@ -1430,17 +1510,17 @@ var Shell = () => {
|
|
|
1430
1510
|
...contentPanelHeaderStackSx
|
|
1431
1511
|
}
|
|
1432
1512
|
},
|
|
1433
|
-
/* @__PURE__ */
|
|
1434
|
-
/* @__PURE__ */
|
|
1435
|
-
)), /* @__PURE__ */
|
|
1436
|
-
|
|
1513
|
+
/* @__PURE__ */ React26.createElement(import_editor_panels.PanelHeaderTitle, { sx: { flex: 1, minWidth: 0, textAlign: "start" } }, (0, import_i18n17.__)("Site content", "elementor")),
|
|
1514
|
+
/* @__PURE__ */ React26.createElement(ContentPanelHeaderAdd, null)
|
|
1515
|
+
)), /* @__PURE__ */ React26.createElement(import_ui16.Divider, null), /* @__PURE__ */ React26.createElement(import_editor_panels.PanelBody, null, /* @__PURE__ */ React26.createElement(ContentPanelSearch, null), /* @__PURE__ */ React26.createElement(
|
|
1516
|
+
ShellPanelBodyContent,
|
|
1437
1517
|
{
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
)
|
|
1518
|
+
accessiblePostTypes,
|
|
1519
|
+
isUserPending,
|
|
1520
|
+
onListError: () => setIsErrorSnackbarOpen(true),
|
|
1521
|
+
showUserLoadError
|
|
1522
|
+
}
|
|
1523
|
+
), /* @__PURE__ */ React26.createElement(error_snackbar_default, { open: isErrorSnackbarOpen, onClose: () => setIsErrorSnackbarOpen(false) }))));
|
|
1444
1524
|
};
|
|
1445
1525
|
var shell_default = Shell;
|
|
1446
1526
|
|
|
@@ -1451,26 +1531,26 @@ var { panel, usePanelStatus, usePanelActions } = (0, import_editor_panels2.creat
|
|
|
1451
1531
|
});
|
|
1452
1532
|
|
|
1453
1533
|
// src/components/top-bar/recently-edited.tsx
|
|
1454
|
-
var
|
|
1534
|
+
var React31 = __toESM(require("react"));
|
|
1455
1535
|
var import_editor_documents8 = require("@elementor/editor-documents");
|
|
1456
1536
|
var import_icons15 = require("@elementor/icons");
|
|
1457
|
-
var
|
|
1458
|
-
var
|
|
1537
|
+
var import_ui21 = require("@elementor/ui");
|
|
1538
|
+
var import_i18n19 = require("@wordpress/i18n");
|
|
1459
1539
|
|
|
1460
1540
|
// src/components/top-bar/create-post-list-item.tsx
|
|
1461
|
-
var
|
|
1541
|
+
var React27 = __toESM(require("react"));
|
|
1462
1542
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
1463
1543
|
var import_events = require("@elementor/events");
|
|
1464
1544
|
var import_icons13 = require("@elementor/icons");
|
|
1465
|
-
var
|
|
1466
|
-
var
|
|
1545
|
+
var import_ui17 = require("@elementor/ui");
|
|
1546
|
+
var import_i18n18 = require("@wordpress/i18n");
|
|
1467
1547
|
|
|
1468
1548
|
// src/hooks/use-create-page.ts
|
|
1469
|
-
var
|
|
1549
|
+
var import_react10 = require("react");
|
|
1470
1550
|
var import_api_fetch5 = __toESM(require("@wordpress/api-fetch"));
|
|
1471
1551
|
var endpointPath = "/elementor/v1/site-navigation/add-new-post";
|
|
1472
1552
|
function useCreatePage() {
|
|
1473
|
-
const [isLoading, setIsLoading] = (0,
|
|
1553
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
1474
1554
|
return {
|
|
1475
1555
|
create: () => {
|
|
1476
1556
|
setIsLoading(true);
|
|
@@ -1493,8 +1573,8 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
1493
1573
|
const navigateToDocument = (0, import_editor_documents6.__useNavigateToDocument)();
|
|
1494
1574
|
const { data: user } = useUser();
|
|
1495
1575
|
const { dispatchEvent, config } = (0, import_events.useMixpanel)();
|
|
1496
|
-
return /* @__PURE__ */
|
|
1497
|
-
|
|
1576
|
+
return /* @__PURE__ */ React27.createElement(
|
|
1577
|
+
import_ui17.MenuItem,
|
|
1498
1578
|
{
|
|
1499
1579
|
disabled: isLoading || !user?.capabilities?.edit_pages,
|
|
1500
1580
|
onClick: async () => {
|
|
@@ -1517,26 +1597,26 @@ function CreatePostListItem({ closePopup, ...props }) {
|
|
|
1517
1597
|
},
|
|
1518
1598
|
...props
|
|
1519
1599
|
},
|
|
1520
|
-
/* @__PURE__ */
|
|
1521
|
-
/* @__PURE__ */
|
|
1522
|
-
|
|
1600
|
+
/* @__PURE__ */ React27.createElement(import_ui17.ListItemIcon, null, isLoading ? /* @__PURE__ */ React27.createElement(import_ui17.CircularProgress, { size: "1.25rem" }) : /* @__PURE__ */ React27.createElement(import_icons13.PlusIcon, { fontSize: "small" })),
|
|
1601
|
+
/* @__PURE__ */ React27.createElement(
|
|
1602
|
+
import_ui17.ListItemText,
|
|
1523
1603
|
{
|
|
1524
1604
|
primaryTypographyProps: { variant: "body2" },
|
|
1525
|
-
primary: (0,
|
|
1605
|
+
primary: (0, import_i18n18.__)("Add new page", "elementor")
|
|
1526
1606
|
}
|
|
1527
1607
|
)
|
|
1528
1608
|
);
|
|
1529
1609
|
}
|
|
1530
1610
|
|
|
1531
1611
|
// src/components/top-bar/indicator.tsx
|
|
1532
|
-
var
|
|
1533
|
-
var
|
|
1612
|
+
var React28 = __toESM(require("react"));
|
|
1613
|
+
var import_ui18 = require("@elementor/ui");
|
|
1534
1614
|
function Indicator({ title, status }) {
|
|
1535
|
-
return /* @__PURE__ */
|
|
1615
|
+
return /* @__PURE__ */ React28.createElement(Tooltip2, { title }, /* @__PURE__ */ React28.createElement(import_ui18.Stack, { component: "span", direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React28.createElement(import_ui18.Typography, { component: "span", variant: "body2", sx: { maxWidth: "120px" }, noWrap: true }, title), status.value !== "publish" && /* @__PURE__ */ React28.createElement(import_ui18.Typography, { component: "span", variant: "body2", sx: { fontStyle: "italic" } }, "(", status.label, ")")));
|
|
1536
1616
|
}
|
|
1537
1617
|
function Tooltip2(props) {
|
|
1538
|
-
return /* @__PURE__ */
|
|
1539
|
-
|
|
1618
|
+
return /* @__PURE__ */ React28.createElement(
|
|
1619
|
+
import_ui18.Tooltip,
|
|
1540
1620
|
{
|
|
1541
1621
|
PopperProps: {
|
|
1542
1622
|
sx: {
|
|
@@ -1551,21 +1631,21 @@ function Tooltip2(props) {
|
|
|
1551
1631
|
}
|
|
1552
1632
|
|
|
1553
1633
|
// src/components/top-bar/post-list-item.tsx
|
|
1554
|
-
var
|
|
1634
|
+
var React30 = __toESM(require("react"));
|
|
1555
1635
|
var import_editor_documents7 = require("@elementor/editor-documents");
|
|
1556
1636
|
var import_events2 = require("@elementor/events");
|
|
1557
|
-
var
|
|
1637
|
+
var import_ui20 = require("@elementor/ui");
|
|
1558
1638
|
|
|
1559
1639
|
// src/components/top-bar/chip-doc-type.tsx
|
|
1560
|
-
var
|
|
1640
|
+
var React29 = __toESM(require("react"));
|
|
1561
1641
|
var import_icons14 = require("@elementor/icons");
|
|
1562
|
-
var
|
|
1642
|
+
var import_ui19 = require("@elementor/ui");
|
|
1563
1643
|
var iconsMap2 = getIconsMap();
|
|
1564
1644
|
function DocTypeChip({ postType, docType, label }) {
|
|
1565
1645
|
const color = "elementor_library" === postType ? "global" : "accent";
|
|
1566
1646
|
const Icon = iconsMap2[docType] || import_icons14.PostTypeIcon;
|
|
1567
|
-
return /* @__PURE__ */
|
|
1568
|
-
|
|
1647
|
+
return /* @__PURE__ */ React29.createElement(
|
|
1648
|
+
import_ui19.Chip,
|
|
1569
1649
|
{
|
|
1570
1650
|
component: "span",
|
|
1571
1651
|
size: "small",
|
|
@@ -1573,7 +1653,7 @@ function DocTypeChip({ postType, docType, label }) {
|
|
|
1573
1653
|
label,
|
|
1574
1654
|
"data-value": docType,
|
|
1575
1655
|
color,
|
|
1576
|
-
icon: /* @__PURE__ */
|
|
1656
|
+
icon: /* @__PURE__ */ React29.createElement(Icon, null),
|
|
1577
1657
|
sx: { ml: 1, cursor: "inherit" }
|
|
1578
1658
|
}
|
|
1579
1659
|
);
|
|
@@ -1584,8 +1664,8 @@ function PostListItem2({ post, closePopup, ...props }) {
|
|
|
1584
1664
|
const navigateToDocument = (0, import_editor_documents7.__useNavigateToDocument)();
|
|
1585
1665
|
const postTitle = useReverseHtmlEntities(post.title);
|
|
1586
1666
|
const { dispatchEvent, config } = (0, import_events2.useMixpanel)();
|
|
1587
|
-
return /* @__PURE__ */
|
|
1588
|
-
|
|
1667
|
+
return /* @__PURE__ */ React30.createElement(
|
|
1668
|
+
import_ui20.MenuItem,
|
|
1589
1669
|
{
|
|
1590
1670
|
disabled: !post.user_can.edit,
|
|
1591
1671
|
onClick: async () => {
|
|
@@ -1607,15 +1687,15 @@ function PostListItem2({ post, closePopup, ...props }) {
|
|
|
1607
1687
|
},
|
|
1608
1688
|
...props
|
|
1609
1689
|
},
|
|
1610
|
-
/* @__PURE__ */
|
|
1611
|
-
|
|
1690
|
+
/* @__PURE__ */ React30.createElement(
|
|
1691
|
+
import_ui20.ListItemText,
|
|
1612
1692
|
{
|
|
1613
1693
|
sx: { flexGrow: 0 },
|
|
1614
1694
|
primaryTypographyProps: { variant: "body2", noWrap: true },
|
|
1615
1695
|
primary: postTitle
|
|
1616
1696
|
}
|
|
1617
1697
|
),
|
|
1618
|
-
/* @__PURE__ */
|
|
1698
|
+
/* @__PURE__ */ React30.createElement(DocTypeChip, { postType: post.type.post_type, docType: post.type.doc_type, label: post.type.label })
|
|
1619
1699
|
);
|
|
1620
1700
|
}
|
|
1621
1701
|
|
|
@@ -1632,7 +1712,7 @@ function RecentlyEdited() {
|
|
|
1632
1712
|
return data.filter((post) => post.id !== document2?.id).splice(0, NUMBER_OF_RECENT_POSTS - 1);
|
|
1633
1713
|
};
|
|
1634
1714
|
const recentPosts = getRecentPosts();
|
|
1635
|
-
const popupState = (0,
|
|
1715
|
+
const popupState = (0, import_ui21.usePopupState)({
|
|
1636
1716
|
variant: "popover",
|
|
1637
1717
|
popupId: "elementor-v2-top-bar-recently-edited"
|
|
1638
1718
|
});
|
|
@@ -1640,13 +1720,13 @@ function RecentlyEdited() {
|
|
|
1640
1720
|
if (!document2) {
|
|
1641
1721
|
return null;
|
|
1642
1722
|
}
|
|
1643
|
-
const buttonProps = (0,
|
|
1644
|
-
return /* @__PURE__ */
|
|
1645
|
-
|
|
1723
|
+
const buttonProps = (0, import_ui21.bindTrigger)(popupState);
|
|
1724
|
+
return /* @__PURE__ */ React31.createElement(React31.Fragment, null, /* @__PURE__ */ React31.createElement(
|
|
1725
|
+
import_ui21.Button,
|
|
1646
1726
|
{
|
|
1647
1727
|
color: "inherit",
|
|
1648
1728
|
size: "small",
|
|
1649
|
-
endIcon: /* @__PURE__ */
|
|
1729
|
+
endIcon: /* @__PURE__ */ React31.createElement(import_icons15.ChevronDownIcon, { fontSize: "small" }),
|
|
1650
1730
|
...buttonProps,
|
|
1651
1731
|
onClick: (e) => {
|
|
1652
1732
|
const extendedWindow = window;
|
|
@@ -1665,46 +1745,40 @@ function RecentlyEdited() {
|
|
|
1665
1745
|
buttonProps.onClick(e);
|
|
1666
1746
|
}
|
|
1667
1747
|
},
|
|
1668
|
-
/* @__PURE__ */
|
|
1669
|
-
), /* @__PURE__ */
|
|
1670
|
-
|
|
1748
|
+
/* @__PURE__ */ React31.createElement(Indicator, { title: documentTitle, status: document2.status })
|
|
1749
|
+
), /* @__PURE__ */ React31.createElement(
|
|
1750
|
+
import_ui21.Menu,
|
|
1671
1751
|
{
|
|
1672
1752
|
MenuListProps: {
|
|
1673
|
-
subheader: /* @__PURE__ */
|
|
1753
|
+
subheader: /* @__PURE__ */ React31.createElement(import_ui21.ListSubheader, { sx: { color: "accent.main", fontStyle: "italic", fontWeight: "300" } }, (0, import_i18n19.__)("Recent", "elementor"))
|
|
1674
1754
|
},
|
|
1675
1755
|
PaperProps: { sx: { mt: 2.5, width: 320 } },
|
|
1676
|
-
...(0,
|
|
1756
|
+
...(0, import_ui21.bindMenu)(popupState)
|
|
1677
1757
|
},
|
|
1678
|
-
recentPosts.map((post) => /* @__PURE__ */
|
|
1679
|
-
recentPosts.length === 0 && /* @__PURE__ */
|
|
1680
|
-
|
|
1758
|
+
recentPosts.map((post) => /* @__PURE__ */ React31.createElement(PostListItem2, { key: post.id, post, closePopup: popupState.close })),
|
|
1759
|
+
recentPosts.length === 0 && /* @__PURE__ */ React31.createElement(import_ui21.MenuItem, { disabled: true }, /* @__PURE__ */ React31.createElement(
|
|
1760
|
+
import_ui21.ListItemText,
|
|
1681
1761
|
{
|
|
1682
1762
|
primaryTypographyProps: {
|
|
1683
1763
|
variant: "caption",
|
|
1684
1764
|
fontStyle: "italic"
|
|
1685
1765
|
},
|
|
1686
|
-
primary: (0,
|
|
1766
|
+
primary: (0, import_i18n19.__)("There are no other pages or templates on this site yet.", "elementor")
|
|
1687
1767
|
}
|
|
1688
1768
|
)),
|
|
1689
|
-
/* @__PURE__ */
|
|
1690
|
-
/* @__PURE__ */
|
|
1769
|
+
/* @__PURE__ */ React31.createElement(import_ui21.Divider, { disabled: recentPosts.length === 0 }),
|
|
1770
|
+
/* @__PURE__ */ React31.createElement(CreatePostListItem, { closePopup: popupState.close })
|
|
1691
1771
|
));
|
|
1692
1772
|
}
|
|
1693
1773
|
|
|
1694
|
-
// src/env.ts
|
|
1695
|
-
var import_env = require("@elementor/env");
|
|
1696
|
-
var { env } = (0, import_env.parseEnv)("@elementor/editor-site-navigation", (envData) => {
|
|
1697
|
-
return envData;
|
|
1698
|
-
});
|
|
1699
|
-
|
|
1700
1774
|
// src/hooks/use-toggle-button-props.ts
|
|
1701
1775
|
var import_icons16 = require("@elementor/icons");
|
|
1702
|
-
var
|
|
1776
|
+
var import_i18n20 = require("@wordpress/i18n");
|
|
1703
1777
|
function useToggleButtonProps() {
|
|
1704
1778
|
const { isOpen: selectedState, isBlocked } = usePanelStatus();
|
|
1705
1779
|
const { open, close } = usePanelActions();
|
|
1706
1780
|
return {
|
|
1707
|
-
title: (0,
|
|
1781
|
+
title: (0, import_i18n20.__)("Site content", "elementor"),
|
|
1708
1782
|
icon: import_icons16.PagesIcon,
|
|
1709
1783
|
onClick: () => {
|
|
1710
1784
|
const extendedWindow = window;
|
|
@@ -1727,7 +1801,7 @@ function useToggleButtonProps() {
|
|
|
1727
1801
|
// src/init.ts
|
|
1728
1802
|
function init() {
|
|
1729
1803
|
registerTopBarMenuItems();
|
|
1730
|
-
if (env.is_pages_panel_active) {
|
|
1804
|
+
if (env.is_pages_panel_active && env.can_access_site_content_panel) {
|
|
1731
1805
|
(0, import_editor_panels3.registerPanel)(panel);
|
|
1732
1806
|
registerButton();
|
|
1733
1807
|
}
|