@elementor/editor-site-navigation 0.26.0 → 0.28.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/index.js +726 -730
  3. package/dist/index.mjs +767 -771
  4. package/package.json +12 -13
  5. package/src/api/post.ts +2 -1
  6. package/src/api/recent-posts.ts +2 -1
  7. package/src/components/panel/actions-menu/action-menu-item.tsx +2 -2
  8. package/src/components/panel/actions-menu/actions/delete.tsx +7 -6
  9. package/src/components/panel/actions-menu/actions/duplicate.tsx +4 -3
  10. package/src/components/panel/actions-menu/actions/rename.tsx +3 -2
  11. package/src/components/panel/actions-menu/actions/set-home.tsx +5 -4
  12. package/src/components/panel/actions-menu/actions/view.tsx +3 -2
  13. package/src/components/panel/add-new-button.tsx +2 -1
  14. package/src/components/panel/error-snackbar.tsx +1 -1
  15. package/src/components/panel/panel.ts +1 -0
  16. package/src/components/panel/posts-list/collapsible-list.tsx +4 -4
  17. package/src/components/panel/posts-list/error-state.tsx +1 -1
  18. package/src/components/panel/posts-list/list-items/edit-mode-template.tsx +3 -2
  19. package/src/components/panel/posts-list/list-items/list-item-create.tsx +2 -1
  20. package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +2 -1
  21. package/src/components/panel/posts-list/list-items/list-item-rename.tsx +4 -3
  22. package/src/components/panel/posts-list/list-items/list-item-view.tsx +11 -10
  23. package/src/components/panel/posts-list/post-list-item.tsx +4 -3
  24. package/src/components/panel/posts-list/posts-collapsible-list.tsx +6 -5
  25. package/src/components/panel/shell.tsx +2 -1
  26. package/src/components/shared/page-title-and-status.tsx +1 -0
  27. package/src/components/top-bar/chip-doc-type.tsx +2 -1
  28. package/src/components/top-bar/create-post-list-item.tsx +4 -3
  29. package/src/components/top-bar/indicator.tsx +2 -2
  30. package/src/components/top-bar/post-list-item.tsx +4 -3
  31. package/src/components/top-bar/recently-edited.tsx +15 -14
  32. package/src/contexts/post-list-context.tsx +3 -2
  33. package/src/hooks/use-create-page.ts +1 -1
  34. package/src/hooks/use-homepage-actions.ts +2 -1
  35. package/src/hooks/use-homepage.ts +1 -0
  36. package/src/hooks/use-posts-actions.ts +11 -2
  37. package/src/hooks/use-posts.ts +3 -2
  38. package/src/hooks/use-recent-posts.ts +1 -0
  39. package/src/hooks/use-rename-active-document.ts +1 -1
  40. package/src/hooks/use-toggle-button-props.ts +2 -1
  41. package/src/hooks/use-user.ts +1 -0
  42. package/src/icons-map.ts +4 -5
  43. package/src/init.ts +3 -2
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  // src/icons-map.ts
2
2
  import {
3
- PostTypeIcon,
4
- PageTypeIcon,
3
+ ContainerTemplateIcon,
5
4
  PageTemplateIcon,
6
- SectionTemplateIcon,
7
- ContainerTemplateIcon
5
+ PageTypeIcon,
6
+ PostTypeIcon,
7
+ SectionTemplateIcon
8
8
  } from "@elementor/icons";
9
9
  var initialIconsMap = {
10
10
  page: PageTemplateIcon,
@@ -21,329 +21,107 @@ function getIconsMap() {
21
21
  return iconsMap;
22
22
  }
23
23
 
24
- // src/components/top-bar/recently-edited.tsx
25
- import * as React5 from "react";
26
- import {
27
- bindMenu,
28
- usePopupState,
29
- bindTrigger,
30
- Menu,
31
- Button,
32
- ListSubheader,
33
- Divider,
34
- ListItemText as ListItemText3,
35
- MenuItem as MenuItem3
36
- } from "@elementor/ui";
37
- import { ChevronDownIcon } from "@elementor/icons";
38
- import {
39
- __useActiveDocument as useActiveDocument,
40
- __useHostDocument as useHostDocument
41
- } from "@elementor/editor-documents";
24
+ // src/init.ts
25
+ import { injectIntoPageIndication, toolsMenu } from "@elementor/editor-app-bar";
26
+ import { __registerPanel } from "@elementor/editor-panels";
42
27
 
43
- // src/components/top-bar/indicator.tsx
28
+ // src/components/panel/panel.ts
29
+ import { __createPanel } from "@elementor/editor-panels";
30
+
31
+ // src/components/panel/shell.tsx
32
+ import * as React20 from "react";
33
+ import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
34
+ import { __ as __13 } from "@wordpress/i18n";
35
+
36
+ // src/contexts/post-list-context.tsx
44
37
  import * as React from "react";
45
- import { Typography, Stack, Tooltip as BaseTooltip } from "@elementor/ui";
46
- function Indicator({ title, status }) {
47
- return /* @__PURE__ */ React.createElement(Tooltip, { title }, /* @__PURE__ */ React.createElement(Stack, { component: "span", direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React.createElement(Typography, { component: "span", variant: "body2", sx: { maxWidth: "120px" }, noWrap: true }, title), status.value !== "publish" && /* @__PURE__ */ React.createElement(Typography, { component: "span", variant: "body2", sx: { fontStyle: "italic" } }, "(", status.label, ")")));
48
- }
49
- function Tooltip(props) {
38
+ import { createContext, useContext, useState } from "react";
39
+ var defaultValues = {
40
+ type: "page",
41
+ editMode: { mode: "none", details: {} },
42
+ setEditMode: () => null,
43
+ resetEditMode: () => null,
44
+ setError: () => null
45
+ };
46
+ var PostListContext = createContext(defaultValues);
47
+ var PostListContextProvider = ({
48
+ type,
49
+ setError,
50
+ children
51
+ }) => {
52
+ const [editMode, setEditMode] = useState(defaultValues.editMode);
53
+ const resetEditMode = () => {
54
+ setEditMode(defaultValues.editMode);
55
+ };
50
56
  return /* @__PURE__ */ React.createElement(
51
- BaseTooltip,
57
+ PostListContext.Provider,
52
58
  {
53
- PopperProps: {
54
- sx: {
55
- "&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": {
56
- mt: 2.7
57
- }
58
- }
59
- },
60
- ...props
61
- }
59
+ value: {
60
+ type,
61
+ editMode,
62
+ setEditMode,
63
+ resetEditMode,
64
+ setError
65
+ }
66
+ },
67
+ children
62
68
  );
63
- }
64
-
65
- // src/hooks/use-recent-posts.ts
66
- import { useQuery } from "@elementor/query";
67
-
68
- // src/api/recent-posts.ts
69
- import apiFetch from "@wordpress/api-fetch";
70
- var baseUrl = "/elementor/v1/site-navigation/recent-posts";
71
- var NUMBER_OF_RECENT_POSTS = 6;
72
- var getRequest = () => {
73
- const queryParams = new URLSearchParams({
74
- posts_per_page: `${NUMBER_OF_RECENT_POSTS}`
75
- });
76
- const path = `${baseUrl}?${queryParams.toString()}`;
77
- return apiFetch({ path });
78
69
  };
79
-
80
- // src/hooks/use-recent-posts.ts
81
- var recentPostsQueryKey = ["site-navigation", "recent-posts"];
82
- function useRecentPosts() {
83
- return useQuery({
84
- queryKey: recentPostsQueryKey,
85
- queryFn: () => getRequest()
86
- });
70
+ function usePostListContext() {
71
+ const context = useContext(PostListContext);
72
+ if (!context) {
73
+ throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
74
+ }
75
+ return context;
87
76
  }
88
77
 
89
- // src/components/top-bar/recently-edited.tsx
90
- import { __ as __2 } from "@wordpress/i18n";
91
-
92
- // src/components/top-bar/chip-doc-type.tsx
93
- import { PostTypeIcon as PostTypeIcon2 } from "@elementor/icons";
94
- import { Chip } from "@elementor/ui";
78
+ // src/components/panel/error-snackbar.tsx
95
79
  import * as React2 from "react";
96
- var iconsMap2 = getIconsMap();
97
- function DocTypeChip({ postType, docType, label }) {
98
- const color = "elementor_library" === postType ? "global" : "primary";
99
- const Icon = iconsMap2[docType] || PostTypeIcon2;
80
+ import { Alert, Snackbar, Typography } from "@elementor/ui";
81
+ var ErrorSnackbar = ({ open, onClose }) => {
100
82
  return /* @__PURE__ */ React2.createElement(
101
- Chip,
102
- {
103
- component: "span",
104
- size: "small",
105
- variant: "outlined",
106
- label,
107
- "data-value": docType,
108
- color,
109
- icon: /* @__PURE__ */ React2.createElement(Icon, null),
110
- sx: { ml: 1, cursor: "inherit" }
111
- }
112
- );
113
- }
114
-
115
- // src/components/top-bar/post-list-item.tsx
116
- import { MenuItem, ListItemText } from "@elementor/ui";
117
- import * as React3 from "react";
118
- import { __useNavigateToDocument as useNavigateToDocument } from "@elementor/editor-documents";
119
-
120
- // src/hooks/use-reverse-html-entities.ts
121
- import { useMemo } from "react";
122
- function useReverseHtmlEntities(escapedHTML = "") {
123
- return useMemo(() => {
124
- const textarea = document.createElement("textarea");
125
- textarea.innerHTML = escapedHTML;
126
- const { value } = textarea;
127
- textarea.remove();
128
- return value;
129
- }, [escapedHTML]);
130
- }
131
-
132
- // src/components/top-bar/post-list-item.tsx
133
- function PostListItem({ post, closePopup, ...props }) {
134
- const navigateToDocument = useNavigateToDocument();
135
- const postTitle = useReverseHtmlEntities(post.title);
136
- return /* @__PURE__ */ React3.createElement(
137
- MenuItem,
83
+ Snackbar,
138
84
  {
139
- disabled: !post.user_can.edit,
140
- onClick: async () => {
141
- closePopup();
142
- await navigateToDocument(post.id);
143
- },
144
- ...props
145
- },
146
- /* @__PURE__ */ React3.createElement(
147
- ListItemText,
148
- {
149
- sx: { flexGrow: 0 },
150
- primaryTypographyProps: { variant: "body2", noWrap: true },
151
- primary: postTitle
85
+ open,
86
+ onClose,
87
+ anchorOrigin: {
88
+ vertical: "bottom",
89
+ horizontal: "left"
152
90
  }
153
- ),
154
- /* @__PURE__ */ React3.createElement(DocTypeChip, { postType: post.type.post_type, docType: post.type.doc_type, label: post.type.label })
155
- );
156
- }
157
-
158
- // src/components/top-bar/create-post-list-item.tsx
159
- import { CircularProgress, ListItemIcon, ListItemText as ListItemText2, MenuItem as MenuItem2 } from "@elementor/ui";
160
- import * as React4 from "react";
161
-
162
- // src/hooks/use-create-page.ts
163
- import apiFetch2 from "@wordpress/api-fetch";
164
- import { useState } from "react";
165
- var endpointPath = "/elementor/v1/site-navigation/add-new-post";
166
- function useCreatePage() {
167
- const [isLoading, setIsLoading] = useState(false);
168
- return {
169
- create: () => {
170
- setIsLoading(true);
171
- return addNewPage().then((newPost) => newPost).finally(() => setIsLoading(false));
172
91
  },
173
- isLoading
174
- };
175
- }
176
- async function addNewPage() {
177
- return await apiFetch2({
178
- path: endpointPath,
179
- method: "POST",
180
- data: { post_type: "page" }
181
- });
182
- }
183
-
184
- // src/components/top-bar/create-post-list-item.tsx
185
- import { PlusIcon } from "@elementor/icons";
186
- import { __ } from "@wordpress/i18n";
187
- import { __useNavigateToDocument as useNavigateToDocument2 } from "@elementor/editor-documents";
188
-
189
- // src/hooks/use-user.ts
190
- import { useQuery as useQuery2 } from "@elementor/query";
191
-
192
- // src/api/user.ts
193
- import apiFetch3 from "@wordpress/api-fetch";
194
- var getUser = () => {
195
- const baseUri = "/wp/v2/users/me";
196
- const keys = ["capabilities"];
197
- const queryParams = new URLSearchParams({
198
- _fields: keys.join(","),
199
- context: "edit"
200
- });
201
- const uri = baseUri + "?" + queryParams.toString();
202
- return apiFetch3({ path: uri });
203
- };
204
-
205
- // src/hooks/use-user.ts
206
- var userQueryKey = () => ["site-navigation", "user"];
207
- function useUser() {
208
- return useQuery2({
209
- queryKey: userQueryKey(),
210
- queryFn: () => getUser()
211
- });
212
- }
213
-
214
- // src/components/top-bar/create-post-list-item.tsx
215
- function CreatePostListItem({ closePopup, ...props }) {
216
- const { create, isLoading } = useCreatePage();
217
- const navigateToDocument = useNavigateToDocument2();
218
- const { data: user } = useUser();
219
- return /* @__PURE__ */ React4.createElement(
220
- MenuItem2,
221
- {
222
- disabled: isLoading || !user?.capabilities?.edit_pages,
223
- onClick: async () => {
224
- const { id } = await create();
225
- closePopup();
226
- await navigateToDocument(id);
227
- },
228
- ...props
229
- },
230
- /* @__PURE__ */ React4.createElement(ListItemIcon, null, isLoading ? /* @__PURE__ */ React4.createElement(CircularProgress, { size: "1.25rem" }) : /* @__PURE__ */ React4.createElement(PlusIcon, { fontSize: "small" })),
231
- /* @__PURE__ */ React4.createElement(
232
- ListItemText2,
92
+ /* @__PURE__ */ React2.createElement(Alert, { onClose, severity: "error", sx: { width: "100%" } }, /* @__PURE__ */ React2.createElement(
93
+ Typography,
233
94
  {
234
- primaryTypographyProps: { variant: "body2" },
235
- primary: __("Add new page", "elementor")
236
- }
237
- )
238
- );
239
- }
240
-
241
- // src/components/top-bar/recently-edited.tsx
242
- function RecentlyEdited() {
243
- const activeDocument = useActiveDocument();
244
- const hostDocument = useHostDocument();
245
- const document2 = activeDocument && activeDocument.type.value !== "kit" ? activeDocument : hostDocument;
246
- const { data } = useRecentPosts();
247
- const getRecentPosts = () => {
248
- if (!data) {
249
- return [];
250
- }
251
- return data.filter((post) => post.id !== document2?.id).splice(0, NUMBER_OF_RECENT_POSTS - 1);
252
- };
253
- const recentPosts = getRecentPosts();
254
- const popupState = usePopupState({
255
- variant: "popover",
256
- popupId: "elementor-v2-top-bar-recently-edited"
257
- });
258
- const documentTitle = useReverseHtmlEntities(document2?.title);
259
- if (!document2) {
260
- return null;
261
- }
262
- const buttonProps = bindTrigger(popupState);
263
- return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
264
- Button,
265
- {
266
- color: "inherit",
267
- size: "small",
268
- endIcon: /* @__PURE__ */ React5.createElement(ChevronDownIcon, { fontSize: "small" }),
269
- ...buttonProps,
270
- onClick: (e) => {
271
- const extendedWindow = window;
272
- const config = extendedWindow?.elementor?.editorEvents?.config;
273
- if (config) {
274
- extendedWindow.elementor.editorEvents.dispatchEvent(config.names.topBar.documentNameDropdown, {
275
- location: config.locations.topBar,
276
- secondaryLocation: config.secondaryLocations.documentNameDropdown,
277
- trigger: config.triggers.dropdownClick,
278
- element: config.elements.dropdown
279
- });
95
+ component: "span",
96
+ sx: {
97
+ fontWeight: "bold"
280
98
  }
281
- buttonProps.onClick(e);
282
- }
283
- },
284
- /* @__PURE__ */ React5.createElement(Indicator, { title: documentTitle, status: document2.status })
285
- ), /* @__PURE__ */ React5.createElement(
286
- Menu,
287
- {
288
- MenuListProps: {
289
- subheader: /* @__PURE__ */ React5.createElement(ListSubheader, { color: "primary", sx: { fontStyle: "italic", fontWeight: "300" } }, __2("Recent", "elementor"))
290
99
  },
291
- PaperProps: { sx: { mt: 2.5, width: 320 } },
292
- ...bindMenu(popupState)
293
- },
294
- recentPosts.map((post) => /* @__PURE__ */ React5.createElement(PostListItem, { key: post.id, post, closePopup: popupState.close })),
295
- recentPosts.length === 0 && /* @__PURE__ */ React5.createElement(MenuItem3, { disabled: true }, /* @__PURE__ */ React5.createElement(
296
- ListItemText3,
297
- {
298
- primaryTypographyProps: {
299
- variant: "caption",
300
- fontStyle: "italic"
301
- },
302
- primary: __2("There are no other pages or templates on this site yet.", "elementor")
303
- }
304
- )),
305
- /* @__PURE__ */ React5.createElement(Divider, { disabled: recentPosts.length === 0 }),
306
- /* @__PURE__ */ React5.createElement(CreatePostListItem, { closePopup: popupState.close })
307
- ));
308
- }
309
-
310
- // src/init.ts
311
- import { injectIntoPageIndication, toolsMenu } from "@elementor/editor-app-bar";
312
-
313
- // src/hooks/use-toggle-button-props.ts
314
- import { __ as __16 } from "@wordpress/i18n";
315
- import { PagesIcon } from "@elementor/icons";
316
-
317
- // src/components/panel/panel.ts
318
- import { __createPanel } from "@elementor/editor-panels";
319
-
320
- // src/components/panel/shell.tsx
321
- import * as React25 from "react";
322
- import { Panel, PanelBody, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
323
- import { __ as __15 } from "@wordpress/i18n";
100
+ "We couldn\u2019t complete the action."
101
+ ), " ", "Please try again")
102
+ );
103
+ };
104
+ var error_snackbar_default = ErrorSnackbar;
324
105
 
325
106
  // src/components/panel/posts-list/posts-collapsible-list.tsx
326
- import * as React23 from "react";
107
+ import * as React19 from "react";
327
108
  import { PageTypeIcon as PageTypeIcon2 } from "@elementor/icons";
328
- import { Skeleton, Box as Box4, List as List2, Button as Button4, CircularProgress as CircularProgress5 } from "@elementor/ui";
329
-
330
- // src/hooks/use-posts.ts
331
- import { useInfiniteQuery } from "@elementor/query";
109
+ import { Box as Box4, Button as Button3, CircularProgress as CircularProgress4, List as List2, Skeleton } from "@elementor/ui";
332
110
 
333
111
  // src/api/post.ts
334
- import apiFetch4 from "@wordpress/api-fetch";
335
- import { __ as __3 } from "@wordpress/i18n";
112
+ import apiFetch from "@wordpress/api-fetch";
113
+ import { __ } from "@wordpress/i18n";
336
114
  var postTypesMap = {
337
115
  page: {
338
116
  labels: {
339
- singular_name: __3("Page", "elementor"),
340
- plural_name: __3("Pages", "elementor")
117
+ singular_name: __("Page", "elementor"),
118
+ plural_name: __("Pages", "elementor")
341
119
  },
342
120
  rest_base: "pages"
343
121
  }
344
122
  };
345
123
  var POST_PER_PAGE = 10;
346
- var getRequest2 = async (postTypeSlug, page) => {
124
+ var getRequest = async (postTypeSlug, page) => {
347
125
  const baseUri = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
348
126
  const keys = ["id", "type", "title", "link", "status", "user_can"];
349
127
  const queryParams = new URLSearchParams({
@@ -354,7 +132,7 @@ var getRequest2 = async (postTypeSlug, page) => {
354
132
  _fields: keys.join(",")
355
133
  });
356
134
  const uri = baseUri + "?" + queryParams.toString();
357
- const result = await apiFetch4({ path: uri, parse: false });
135
+ const result = await apiFetch({ path: uri, parse: false });
358
136
  const data = await result.json();
359
137
  const totalPages = Number(result.headers.get("x-wp-totalpages"));
360
138
  const totalPosts = Number(result.headers.get("x-wp-total"));
@@ -367,7 +145,7 @@ var getRequest2 = async (postTypeSlug, page) => {
367
145
  };
368
146
  var createRequest = (postTypeSlug, newPost) => {
369
147
  const path = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
370
- return apiFetch4({
148
+ return apiFetch({
371
149
  path,
372
150
  method: "POST",
373
151
  data: newPost
@@ -376,7 +154,7 @@ var createRequest = (postTypeSlug, newPost) => {
376
154
  var updateRequest = (postTypeSlug, updatedPost) => {
377
155
  const path = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
378
156
  const { id, ...data } = updatedPost;
379
- return apiFetch4({
157
+ return apiFetch({
380
158
  path: `${path}/${id}`,
381
159
  method: "POST",
382
160
  data
@@ -384,14 +162,14 @@ var updateRequest = (postTypeSlug, updatedPost) => {
384
162
  };
385
163
  var deleteRequest = (postTypeSlug, postId) => {
386
164
  const path = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
387
- return apiFetch4({
165
+ return apiFetch({
388
166
  path: `${path}/${postId}`,
389
167
  method: "DELETE"
390
168
  });
391
169
  };
392
170
  var duplicateRequest = (originalPost) => {
393
171
  const path = `/elementor/v1/site-navigation/duplicate-post`;
394
- return apiFetch4({
172
+ return apiFetch({
395
173
  path,
396
174
  method: "POST",
397
175
  data: {
@@ -401,7 +179,35 @@ var duplicateRequest = (originalPost) => {
401
179
  });
402
180
  };
403
181
 
182
+ // src/hooks/use-homepage.ts
183
+ import { useQuery } from "@elementor/query";
184
+
185
+ // src/api/settings.ts
186
+ import apiFetch2 from "@wordpress/api-fetch";
187
+ var getSettings = () => {
188
+ const baseUri = "/elementor/v1/site-navigation/homepage";
189
+ const uri = baseUri;
190
+ return apiFetch2({ path: uri });
191
+ };
192
+ var updateSettings = (settings) => {
193
+ return apiFetch2({
194
+ path: "/wp/v2/settings",
195
+ method: "POST",
196
+ data: settings
197
+ });
198
+ };
199
+
200
+ // src/hooks/use-homepage.ts
201
+ var settingsQueryKey = () => ["site-navigation", "homepage"];
202
+ function useHomepage() {
203
+ return useQuery({
204
+ queryKey: settingsQueryKey(),
205
+ queryFn: () => getSettings()
206
+ });
207
+ }
208
+
404
209
  // src/hooks/use-posts.ts
210
+ import { useInfiniteQuery } from "@elementor/query";
405
211
  var postsQueryKey = (postTypeSlug) => ["site-navigation", "posts", postTypeSlug];
406
212
  var flattenData = (data) => {
407
213
  if (!data) {
@@ -416,7 +222,7 @@ var flattenData = (data) => {
416
222
  function usePosts(postTypeSlug) {
417
223
  const query = useInfiniteQuery({
418
224
  queryKey: postsQueryKey(postTypeSlug),
419
- queryFn: ({ pageParam = 1 }) => getRequest2(postTypeSlug, pageParam),
225
+ queryFn: ({ pageParam = 1 }) => getRequest(postTypeSlug, pageParam),
420
226
  initialPageParam: 1,
421
227
  getNextPageParam: (lastPage) => {
422
228
  return lastPage.currentPage < lastPage.totalPages ? lastPage.currentPage + 1 : void 0;
@@ -425,63 +231,73 @@ function usePosts(postTypeSlug) {
425
231
  return { ...query, data: { posts: flattenData(query.data), total: query.data?.pages[0]?.totalPosts ?? 0 } };
426
232
  }
427
233
 
428
- // src/contexts/post-list-context.tsx
429
- import * as React6 from "react";
430
- import { useState as useState2, useContext, createContext } from "react";
431
- var defaultValues = {
432
- type: "page",
433
- editMode: { mode: "none", details: {} },
434
- setEditMode: () => null,
435
- resetEditMode: () => null,
436
- setError: () => null
234
+ // src/components/panel/add-new-button.tsx
235
+ import * as React3 from "react";
236
+ import { PlusIcon } from "@elementor/icons";
237
+ import { Button } from "@elementor/ui";
238
+ import { __ as __2 } from "@wordpress/i18n";
239
+
240
+ // src/hooks/use-user.ts
241
+ import { useQuery as useQuery2 } from "@elementor/query";
242
+
243
+ // src/api/user.ts
244
+ import apiFetch3 from "@wordpress/api-fetch";
245
+ var getUser = () => {
246
+ const baseUri = "/wp/v2/users/me";
247
+ const keys = ["capabilities"];
248
+ const queryParams = new URLSearchParams({
249
+ _fields: keys.join(","),
250
+ context: "edit"
251
+ });
252
+ const uri = baseUri + "?" + queryParams.toString();
253
+ return apiFetch3({ path: uri });
437
254
  };
438
- var PostListContext = createContext(defaultValues);
439
- var PostListContextProvider = ({
440
- type,
441
- setError,
442
- children
443
- }) => {
444
- const [editMode, setEditMode] = useState2(defaultValues.editMode);
445
- const resetEditMode = () => {
446
- setEditMode(defaultValues.editMode);
447
- };
448
- return /* @__PURE__ */ React6.createElement(
449
- PostListContext.Provider,
255
+
256
+ // src/hooks/use-user.ts
257
+ var userQueryKey = () => ["site-navigation", "user"];
258
+ function useUser() {
259
+ return useQuery2({
260
+ queryKey: userQueryKey(),
261
+ queryFn: () => getUser()
262
+ });
263
+ }
264
+
265
+ // src/components/panel/add-new-button.tsx
266
+ function AddNewButton() {
267
+ const { setEditMode } = usePostListContext();
268
+ const { data: user } = useUser();
269
+ return /* @__PURE__ */ React3.createElement(
270
+ Button,
450
271
  {
451
- value: {
452
- type,
453
- editMode,
454
- setEditMode,
455
- resetEditMode,
456
- setError
272
+ size: "small",
273
+ startIcon: /* @__PURE__ */ React3.createElement(PlusIcon, null),
274
+ disabled: !user?.capabilities?.edit_pages,
275
+ onClick: () => {
276
+ setEditMode({ mode: "create", details: {} });
277
+ },
278
+ sx: {
279
+ px: 1.5
457
280
  }
458
281
  },
459
- children
282
+ __2("Add New", "elementor")
460
283
  );
461
- };
462
- function usePostListContext() {
463
- const context = useContext(PostListContext);
464
- if (!context) {
465
- throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
466
- }
467
- return context;
468
284
  }
469
285
 
470
286
  // src/components/panel/posts-list/collapsible-list.tsx
471
- import * as React7 from "react";
472
- import { useState as useState3 } from "react";
287
+ import * as React4 from "react";
288
+ import { useState as useState2 } from "react";
289
+ import { ChevronDownIcon } from "@elementor/icons";
473
290
  import {
474
291
  Collapse,
292
+ Divider,
475
293
  IconButton,
476
294
  List,
477
295
  ListItem,
478
- ListItemIcon as ListItemIcon2,
479
- ListItemText as ListItemText4,
480
- styled,
481
- Divider as Divider2
296
+ ListItemIcon,
297
+ ListItemText,
298
+ styled
482
299
  } from "@elementor/ui";
483
- import { ChevronDownIcon as ChevronDownIcon2 } from "@elementor/icons";
484
- var RotateIcon = styled(ChevronDownIcon2, {
300
+ var RotateIcon = styled(ChevronDownIcon, {
485
301
  shouldForwardProp: (prop) => prop !== "isOpen"
486
302
  })(({ theme, isOpen }) => ({
487
303
  transform: isOpen ? "rotate(0deg)" : "rotate(-90deg)",
@@ -489,7 +305,7 @@ var RotateIcon = styled(ChevronDownIcon2, {
489
305
  duration: theme.transitions.duration.standard
490
306
  })
491
307
  }));
492
- var StyledListItemIcon = styled(ListItemIcon2)(({ theme }) => ({
308
+ var StyledListItemIcon = styled(ListItemIcon)(({ theme }) => ({
493
309
  minWidth: theme.spacing(4)
494
310
  }));
495
311
  function CollapsibleList({
@@ -498,15 +314,15 @@ function CollapsibleList({
498
314
  isOpenByDefault = false,
499
315
  children
500
316
  }) {
501
- const [isOpen, setIsOpen] = useState3(isOpenByDefault);
502
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(ListItem, null, /* @__PURE__ */ React7.createElement(
317
+ const [isOpen, setIsOpen] = useState2(isOpenByDefault);
318
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(ListItem, null, /* @__PURE__ */ React4.createElement(
503
319
  StyledListItemIcon,
504
320
  {
505
321
  sx: {
506
322
  color: "text.secondary"
507
323
  }
508
324
  },
509
- /* @__PURE__ */ React7.createElement(
325
+ /* @__PURE__ */ React4.createElement(
510
326
  IconButton,
511
327
  {
512
328
  onClick: () => setIsOpen((prev) => !prev),
@@ -515,9 +331,9 @@ function CollapsibleList({
515
331
  color: "inherit"
516
332
  }
517
333
  },
518
- /* @__PURE__ */ React7.createElement(RotateIcon, { fontSize: "small", isOpen })
334
+ /* @__PURE__ */ React4.createElement(RotateIcon, { fontSize: "small", isOpen })
519
335
  )
520
- ), /* @__PURE__ */ React7.createElement(
336
+ ), /* @__PURE__ */ React4.createElement(
521
337
  StyledListItemIcon,
522
338
  {
523
339
  size: "small",
@@ -525,24 +341,88 @@ function CollapsibleList({
525
341
  color: "inherit"
526
342
  }
527
343
  },
528
- /* @__PURE__ */ React7.createElement(Icon, { fontSize: "small" })
529
- ), /* @__PURE__ */ React7.createElement(
530
- ListItemText4,
344
+ /* @__PURE__ */ React4.createElement(Icon, { fontSize: "small" })
345
+ ), /* @__PURE__ */ React4.createElement(
346
+ ListItemText,
531
347
  {
532
348
  primaryTypographyProps: { variant: "subtitle2", component: "span" },
533
349
  primary: label
534
350
  }
535
- )), /* @__PURE__ */ React7.createElement(Collapse, { in: isOpen, timeout: "auto", unmountOnExit: true }, /* @__PURE__ */ React7.createElement(List, { dense: true }, children)), /* @__PURE__ */ React7.createElement(Divider2, { sx: { mt: 1 } }));
351
+ )), /* @__PURE__ */ React4.createElement(Collapse, { in: isOpen, timeout: "auto", unmountOnExit: true }, /* @__PURE__ */ React4.createElement(List, { dense: true }, children)), /* @__PURE__ */ React4.createElement(Divider, { sx: { mt: 1 } }));
352
+ }
353
+
354
+ // src/components/panel/posts-list/error-state.tsx
355
+ import * as React5 from "react";
356
+ import { Error404TemplateIcon } from "@elementor/icons";
357
+ import { Box, Link, Typography as Typography2 } from "@elementor/ui";
358
+ import { __ as __3 } from "@wordpress/i18n";
359
+ function ErrorState() {
360
+ return /* @__PURE__ */ React5.createElement(
361
+ Box,
362
+ {
363
+ sx: {
364
+ display: "flex",
365
+ flexDirection: "column",
366
+ justifyContent: "center",
367
+ alignItems: "center",
368
+ pt: "40px",
369
+ gap: "16px"
370
+ }
371
+ },
372
+ /* @__PURE__ */ React5.createElement(Error404TemplateIcon, null),
373
+ /* @__PURE__ */ React5.createElement(
374
+ Box,
375
+ {
376
+ sx: {
377
+ display: "flex",
378
+ flexDirection: "column",
379
+ justifyContent: "center",
380
+ alignItems: "center",
381
+ gap: "8px"
382
+ }
383
+ },
384
+ /* @__PURE__ */ React5.createElement(Typography2, { variant: "body1", color: "text.primary" }, __3("We couldn\u2019t display your pages.", "elementor")),
385
+ /* @__PURE__ */ React5.createElement(Box, null, /* @__PURE__ */ React5.createElement(Typography2, { variant: "body2", color: "text.primary", sx: { textAlign: "center" } }, __3("It\u2019s probably a temporary issue.", "elementor")), /* @__PURE__ */ React5.createElement(Typography2, { variant: "body2", color: "text.primary", sx: { textAlign: "center" } }, __3("If the problem persists,", "elementor"), " ", /* @__PURE__ */ React5.createElement(Link, { target: "_blank", href: "https://go.elementor.com/wp-editor-support-open-ticket/" }, "Notify support")))
386
+ )
387
+ );
536
388
  }
537
389
 
538
390
  // src/components/panel/posts-list/post-list-item.tsx
539
- import * as React20 from "react";
391
+ import * as React18 from "react";
540
392
 
541
- // src/components/panel/posts-list/list-items/list-item-rename.tsx
542
- import * as React9 from "react";
393
+ // src/components/panel/posts-list/list-items/list-item-create.tsx
394
+ import * as React7 from "react";
395
+ import { __useNavigateToDocument as useNavigateToDocument } from "@elementor/editor-documents";
396
+ import { __ as __5 } from "@wordpress/i18n";
397
+
398
+ // src/hooks/use-posts-actions.ts
399
+ import { useMutation, useQueryClient } from "@elementor/query";
400
+
401
+ // src/hooks/use-recent-posts.ts
402
+ import { useQuery as useQuery3 } from "@elementor/query";
403
+
404
+ // src/api/recent-posts.ts
405
+ import apiFetch4 from "@wordpress/api-fetch";
406
+ var baseUrl = "/elementor/v1/site-navigation/recent-posts";
407
+ var NUMBER_OF_RECENT_POSTS = 6;
408
+ var getRequest2 = () => {
409
+ const queryParams = new URLSearchParams({
410
+ posts_per_page: `${NUMBER_OF_RECENT_POSTS}`
411
+ });
412
+ const path = `${baseUrl}?${queryParams.toString()}`;
413
+ return apiFetch4({ path });
414
+ };
415
+
416
+ // src/hooks/use-recent-posts.ts
417
+ var recentPostsQueryKey = ["site-navigation", "recent-posts"];
418
+ function useRecentPosts() {
419
+ return useQuery3({
420
+ queryKey: recentPostsQueryKey,
421
+ queryFn: () => getRequest2()
422
+ });
423
+ }
543
424
 
544
425
  // src/hooks/use-posts-actions.ts
545
- import { useQueryClient, useMutation } from "@elementor/query";
546
426
  function usePostActions(postTypeSlug) {
547
427
  const invalidatePosts = useInvalidatePosts(postTypeSlug);
548
428
  const onSuccess = () => invalidatePosts({ exact: true });
@@ -579,15 +459,15 @@ function useInvalidatePosts(postTypeSlug) {
579
459
  }
580
460
 
581
461
  // src/components/panel/posts-list/list-items/edit-mode-template.tsx
582
- import * as React8 from "react";
583
- import { useState as useState4, useRef } from "react";
584
- import { Box, ListItem as ListItem2, TextField, IconButton as IconButton2, CircularProgress as CircularProgress2, ListItemText as ListItemText5 } from "@elementor/ui";
462
+ import * as React6 from "react";
463
+ import { useRef, useState as useState3 } from "react";
585
464
  import { XIcon } from "@elementor/icons";
465
+ import { Box as Box2, CircularProgress, IconButton as IconButton2, ListItem as ListItem2, ListItemText as ListItemText2, TextField } from "@elementor/ui";
586
466
  import { __ as __4 } from "@wordpress/i18n";
587
467
  function EditModeTemplate({ postTitle, isLoading, callback }) {
588
- const [title, setTitle] = useState4(postTitle);
589
- const [touched, setTouched] = useState4(false);
590
- const [inputError, setInputError] = useState4(null);
468
+ const [title, setTitle] = useState3(postTitle);
469
+ const [touched, setTouched] = useState3(false);
470
+ const [inputError, setInputError] = useState3(null);
591
471
  const closeButton = useRef();
592
472
  const onBlur = (e) => {
593
473
  if (closeButton.current === e.relatedTarget) {
@@ -620,7 +500,7 @@ function EditModeTemplate({ postTitle, isLoading, callback }) {
620
500
  }
621
501
  setTitle(value);
622
502
  };
623
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(ListItem2, { secondaryAction: /* @__PURE__ */ React8.createElement(CloseButton, { isLoading, closeButton }) }, /* @__PURE__ */ React8.createElement(Box, { width: "100%", component: "form", onSubmit: onFormSubmit }, /* @__PURE__ */ React8.createElement(
503
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(ListItem2, { secondaryAction: /* @__PURE__ */ React6.createElement(CloseButton, { isLoading, closeButton }) }, /* @__PURE__ */ React6.createElement(Box2, { width: "100%", component: "form", onSubmit: onFormSubmit }, /* @__PURE__ */ React6.createElement(
624
504
  TextField,
625
505
  {
626
506
  autoFocus: true,
@@ -634,75 +514,18 @@ function EditModeTemplate({ postTitle, isLoading, callback }) {
634
514
  color: "secondary",
635
515
  size: "small"
636
516
  }
637
- ))), inputError && /* @__PURE__ */ React8.createElement(ListItem2, null, /* @__PURE__ */ React8.createElement(ListItemText5, { sx: { color: "error.main" } }, inputError)));
517
+ ))), inputError && /* @__PURE__ */ React6.createElement(ListItem2, null, /* @__PURE__ */ React6.createElement(ListItemText2, { sx: { color: "error.main" } }, inputError)));
638
518
  }
639
519
  function CloseButton({ isLoading, closeButton }) {
640
520
  const { resetEditMode } = usePostListContext();
641
- return /* @__PURE__ */ React8.createElement(IconButton2, { size: "small", color: "secondary", onClick: resetEditMode, ref: closeButton, disabled: isLoading }, isLoading ? /* @__PURE__ */ React8.createElement(CircularProgress2, null) : /* @__PURE__ */ React8.createElement(XIcon, { fontSize: "small" }));
642
- }
643
-
644
- // src/components/panel/posts-list/list-items/list-item-rename.tsx
645
- import { __useActiveDocument as useActiveDocument2 } from "@elementor/editor-documents";
646
-
647
- // src/hooks/use-rename-active-document.ts
648
- import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
649
- function getV1DocumentsManager() {
650
- const documentsManager = window.elementor?.documents;
651
- if (!documentsManager) {
652
- throw new Error("Elementor Editor V1 documents manager not found");
653
- }
654
- return documentsManager;
655
- }
656
- function useRenameActiveDocument() {
657
- return async (title) => {
658
- const currentDocument = getV1DocumentsManager().getCurrent();
659
- const container = currentDocument.container;
660
- await runCommand("document/elements/settings", {
661
- container,
662
- settings: { post_title: title }
663
- });
664
- };
665
- }
666
-
667
- // src/components/panel/posts-list/list-items/list-item-rename.tsx
668
- function ListItemRename({ post }) {
669
- const { type, resetEditMode } = usePostListContext();
670
- const { updatePost } = usePostActions(type);
671
- const { setError } = usePostListContext();
672
- const activeDocument = useActiveDocument2();
673
- const rename = useRenameActiveDocument();
674
- const isActive = activeDocument?.id === post.id;
675
- const title = isActive ? activeDocument?.title : post.title.rendered;
676
- const renamePostCallback = async (inputValue) => {
677
- if (inputValue === title) {
678
- resetEditMode();
679
- }
680
- try {
681
- if (isActive) {
682
- await rename(inputValue);
683
- } else {
684
- await updatePost.mutateAsync({
685
- id: post.id,
686
- title: inputValue
687
- });
688
- }
689
- } catch {
690
- setError();
691
- } finally {
692
- resetEditMode();
693
- }
694
- };
695
- return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: title, isLoading: updatePost.isPending, callback: renamePostCallback });
521
+ return /* @__PURE__ */ React6.createElement(IconButton2, { size: "small", color: "secondary", onClick: resetEditMode, ref: closeButton, disabled: isLoading }, isLoading ? /* @__PURE__ */ React6.createElement(CircularProgress, null) : /* @__PURE__ */ React6.createElement(XIcon, { fontSize: "small" }));
696
522
  }
697
523
 
698
524
  // src/components/panel/posts-list/list-items/list-item-create.tsx
699
- import * as React10 from "react";
700
- import { __ as __5 } from "@wordpress/i18n";
701
- import { __useNavigateToDocument as useNavigateToDocument3 } from "@elementor/editor-documents";
702
525
  function ListItemCreate() {
703
526
  const { type, resetEditMode } = usePostListContext();
704
527
  const { createPost } = usePostActions(type);
705
- const navigateToDocument = useNavigateToDocument3();
528
+ const navigateToDocument = useNavigateToDocument();
706
529
  const { setError } = usePostListContext();
707
530
  const createPostCallback = async (inputValue) => {
708
531
  try {
@@ -717,7 +540,7 @@ function ListItemCreate() {
717
540
  resetEditMode();
718
541
  }
719
542
  };
720
- return /* @__PURE__ */ React10.createElement(
543
+ return /* @__PURE__ */ React7.createElement(
721
544
  EditModeTemplate,
722
545
  {
723
546
  postTitle: __5("New Page", "elementor"),
@@ -728,12 +551,12 @@ function ListItemCreate() {
728
551
  }
729
552
 
730
553
  // src/components/panel/posts-list/list-items/list-item-duplicate.tsx
731
- import * as React11 from "react";
554
+ import * as React8 from "react";
555
+ import { __useNavigateToDocument as useNavigateToDocument2 } from "@elementor/editor-documents";
732
556
  import { __ as __6 } from "@wordpress/i18n";
733
- import { __useNavigateToDocument as useNavigateToDocument4 } from "@elementor/editor-documents";
734
557
  function ListItemDuplicate() {
735
558
  const { type, editMode, resetEditMode } = usePostListContext();
736
- const navigateToDocument = useNavigateToDocument4();
559
+ const navigateToDocument = useNavigateToDocument2();
737
560
  const { duplicatePost } = usePostActions(type);
738
561
  const { setError } = usePostListContext();
739
562
  if ("duplicate" !== editMode.mode) {
@@ -752,7 +575,7 @@ function ListItemDuplicate() {
752
575
  resetEditMode();
753
576
  }
754
577
  };
755
- return /* @__PURE__ */ React11.createElement(
578
+ return /* @__PURE__ */ React8.createElement(
756
579
  EditModeTemplate,
757
580
  {
758
581
  postTitle: `${editMode.details.title} ${__6("copy", "elementor")}`,
@@ -762,172 +585,185 @@ function ListItemDuplicate() {
762
585
  );
763
586
  }
764
587
 
588
+ // src/components/panel/posts-list/list-items/list-item-rename.tsx
589
+ import * as React9 from "react";
590
+ import { __useActiveDocument as useActiveDocument } from "@elementor/editor-documents";
591
+
592
+ // src/hooks/use-rename-active-document.ts
593
+ import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
594
+ function getV1DocumentsManager() {
595
+ const documentsManager = window.elementor?.documents;
596
+ if (!documentsManager) {
597
+ throw new Error("Elementor Editor V1 documents manager not found");
598
+ }
599
+ return documentsManager;
600
+ }
601
+ function useRenameActiveDocument() {
602
+ return async (title) => {
603
+ const currentDocument = getV1DocumentsManager().getCurrent();
604
+ const container = currentDocument.container;
605
+ await runCommand("document/elements/settings", {
606
+ container,
607
+ settings: { post_title: title }
608
+ });
609
+ };
610
+ }
611
+
612
+ // src/components/panel/posts-list/list-items/list-item-rename.tsx
613
+ function ListItemRename({ post }) {
614
+ const { type, resetEditMode } = usePostListContext();
615
+ const { updatePost } = usePostActions(type);
616
+ const { setError } = usePostListContext();
617
+ const activeDocument = useActiveDocument();
618
+ const rename = useRenameActiveDocument();
619
+ const isActive = activeDocument?.id === post.id;
620
+ const title = isActive ? activeDocument?.title : post.title.rendered;
621
+ const renamePostCallback = async (inputValue) => {
622
+ if (inputValue === title) {
623
+ resetEditMode();
624
+ }
625
+ try {
626
+ if (isActive) {
627
+ await rename(inputValue);
628
+ } else {
629
+ await updatePost.mutateAsync({
630
+ id: post.id,
631
+ title: inputValue
632
+ });
633
+ }
634
+ } catch {
635
+ setError();
636
+ } finally {
637
+ resetEditMode();
638
+ }
639
+ };
640
+ return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: title, isLoading: updatePost.isPending, callback: renamePostCallback });
641
+ }
642
+
765
643
  // src/components/panel/posts-list/list-items/list-item-view.tsx
766
- import * as React19 from "react";
644
+ import * as React17 from "react";
767
645
  import {
768
- bindMenu as bindMenu2,
769
- bindTrigger as bindTrigger2,
770
- Divider as Divider4,
646
+ __useActiveDocument as useActiveDocument3,
647
+ __useNavigateToDocument as useNavigateToDocument3
648
+ } from "@elementor/editor-documents";
649
+ import { DotsVerticalIcon, HomeIcon as HomeIcon2 } from "@elementor/icons";
650
+ import {
651
+ bindMenu,
652
+ bindTrigger,
653
+ Divider as Divider3,
771
654
  IconButton as IconButton3,
772
655
  ListItem as ListItem3,
773
656
  ListItemButton,
774
- ListItemText as ListItemText7,
775
- Menu as Menu2,
776
- Tooltip as Tooltip2,
777
- Typography as Typography3,
778
- usePopupState as usePopupState2
657
+ ListItemText as ListItemText4,
658
+ Menu,
659
+ Tooltip,
660
+ Typography as Typography4,
661
+ usePopupState
779
662
  } from "@elementor/ui";
780
- import { DotsVerticalIcon, HomeIcon as HomeIcon2 } from "@elementor/icons";
781
- import {
782
- __useActiveDocument as useActiveDocument4,
783
- __useNavigateToDocument as useNavigateToDocument5
784
- } from "@elementor/editor-documents";
663
+ import { __ as __12 } from "@wordpress/i18n";
664
+
665
+ // src/components/shared/page-title-and-status.tsx
666
+ import * as React10 from "react";
667
+ import { Box as Box3, Typography as Typography3 } from "@elementor/ui";
668
+
669
+ // src/hooks/use-reverse-html-entities.ts
670
+ import { useMemo } from "react";
671
+ function useReverseHtmlEntities(escapedHTML = "") {
672
+ return useMemo(() => {
673
+ const textarea = document.createElement("textarea");
674
+ textarea.innerHTML = escapedHTML;
675
+ const { value } = textarea;
676
+ textarea.remove();
677
+ return value;
678
+ }, [escapedHTML]);
679
+ }
785
680
 
786
681
  // src/components/shared/page-title-and-status.tsx
787
- import * as React12 from "react";
788
- import { Box as Box2, Typography as Typography2 } from "@elementor/ui";
789
682
  var PageStatus = ({ status }) => {
790
683
  if ("publish" === status) {
791
684
  return null;
792
685
  }
793
- return /* @__PURE__ */ React12.createElement(
794
- Typography2,
795
- {
796
- component: "span",
797
- variant: "body2",
798
- color: "text.secondary",
799
- sx: {
800
- textTransform: "capitalize",
801
- fontStyle: "italic",
802
- whiteSpace: "nowrap",
803
- flexBasis: "content"
804
- }
805
- },
806
- "(",
807
- status,
808
- ")"
809
- );
810
- };
811
- var PageTitle = ({ title }) => {
812
- const modifiedTitle = useReverseHtmlEntities(title);
813
- return /* @__PURE__ */ React12.createElement(
814
- Typography2,
686
+ return /* @__PURE__ */ React10.createElement(
687
+ Typography3,
815
688
  {
816
689
  component: "span",
817
- variant: "body2",
818
- color: "text.secondary",
819
- noWrap: true,
820
- sx: {
821
- flexBasis: "auto"
822
- }
823
- },
824
- modifiedTitle
825
- );
826
- };
827
- function PageTitleAndStatus({ title, status }) {
828
- return /* @__PURE__ */ React12.createElement(Box2, { display: "flex" }, /* @__PURE__ */ React12.createElement(PageTitle, { title }), "\xA0", /* @__PURE__ */ React12.createElement(PageStatus, { status }));
829
- }
830
-
831
- // src/components/panel/actions-menu/actions/rename.tsx
832
- import * as React14 from "react";
833
- import { EraseIcon } from "@elementor/icons";
834
- import { __ as __7 } from "@wordpress/i18n";
835
-
836
- // src/components/panel/actions-menu/action-menu-item.tsx
837
- import * as React13 from "react";
838
- import { ListItemIcon as ListItemIcon3, ListItemText as ListItemText6, MenuItem as MenuItem4 } from "@elementor/ui";
839
- function ActionMenuItem({ title, icon: Icon, MenuItemProps: MenuItemProps3 }) {
840
- return /* @__PURE__ */ React13.createElement(MenuItem4, { ...MenuItemProps3 }, /* @__PURE__ */ React13.createElement(
841
- ListItemIcon3,
842
- {
843
- sx: {
844
- color: "inherit"
845
- }
846
- },
847
- /* @__PURE__ */ React13.createElement(Icon, null)
848
- ), /* @__PURE__ */ React13.createElement(ListItemText6, { primary: title }));
849
- }
850
-
851
- // src/components/panel/actions-menu/actions/rename.tsx
852
- function Rename({ post }) {
853
- const { setEditMode } = usePostListContext();
854
- return /* @__PURE__ */ React14.createElement(
855
- ActionMenuItem,
856
- {
857
- title: __7("Rename", "elementor"),
858
- icon: EraseIcon,
859
- MenuItemProps: {
860
- disabled: !post.user_can.edit,
861
- onClick: () => {
862
- setEditMode({
863
- mode: "rename",
864
- details: {
865
- postId: post.id
866
- }
867
- });
868
- }
690
+ variant: "body2",
691
+ color: "text.secondary",
692
+ sx: {
693
+ textTransform: "capitalize",
694
+ fontStyle: "italic",
695
+ whiteSpace: "nowrap",
696
+ flexBasis: "content"
869
697
  }
870
- }
698
+ },
699
+ "(",
700
+ status,
701
+ ")"
871
702
  );
872
- }
873
-
874
- // src/components/panel/actions-menu/actions/duplicate.tsx
875
- import * as React15 from "react";
876
- import { CopyIcon } from "@elementor/icons";
877
- import { __ as __8 } from "@wordpress/i18n";
878
- function Duplicate({ post, popupState }) {
879
- const { setEditMode } = usePostListContext();
880
- const { data: user } = useUser();
881
- const onClick = () => {
882
- popupState.close();
883
- setEditMode({
884
- mode: "duplicate",
885
- details: {
886
- postId: post.id,
887
- title: post.title.rendered
888
- }
889
- });
890
- };
891
- const isDisabled = !user?.capabilities?.edit_pages;
892
- return /* @__PURE__ */ React15.createElement(
893
- ActionMenuItem,
703
+ };
704
+ var PageTitle = ({ title }) => {
705
+ const modifiedTitle = useReverseHtmlEntities(title);
706
+ return /* @__PURE__ */ React10.createElement(
707
+ Typography3,
894
708
  {
895
- title: __8("Duplicate", "elementor"),
896
- icon: CopyIcon,
897
- MenuItemProps: {
898
- disabled: isDisabled,
899
- onClick
709
+ component: "span",
710
+ variant: "body2",
711
+ color: "text.secondary",
712
+ noWrap: true,
713
+ sx: {
714
+ flexBasis: "auto"
900
715
  }
901
- }
716
+ },
717
+ modifiedTitle
902
718
  );
719
+ };
720
+ function PageTitleAndStatus({ title, status }) {
721
+ return /* @__PURE__ */ React10.createElement(Box3, { display: "flex" }, /* @__PURE__ */ React10.createElement(PageTitle, { title }), "\xA0", /* @__PURE__ */ React10.createElement(PageStatus, { status }));
903
722
  }
904
723
 
905
724
  // src/components/panel/actions-menu/actions/delete.tsx
906
- import * as React16 from "react";
725
+ import * as React12 from "react";
726
+ import { useState as useState4 } from "react";
727
+ import { __useActiveDocument as useActiveDocument2 } from "@elementor/editor-documents";
907
728
  import { TrashIcon } from "@elementor/icons";
908
- import { __ as __9, sprintf } from "@wordpress/i18n";
909
729
  import {
910
730
  Button as Button2,
911
- CircularProgress as CircularProgress3,
731
+ CircularProgress as CircularProgress2,
912
732
  Dialog,
913
733
  DialogActions,
914
734
  DialogContent,
915
735
  DialogContentText,
916
736
  DialogTitle,
917
- Divider as Divider3
737
+ Divider as Divider2
918
738
  } from "@elementor/ui";
919
- import { useState as useState5 } from "react";
920
- import { __useActiveDocument as useActiveDocument3 } from "@elementor/editor-documents";
739
+ import { __ as __7, sprintf } from "@wordpress/i18n";
740
+
741
+ // src/components/panel/actions-menu/action-menu-item.tsx
742
+ import * as React11 from "react";
743
+ import { ListItemIcon as ListItemIcon2, ListItemText as ListItemText3, MenuItem } from "@elementor/ui";
744
+ function ActionMenuItem({ title, icon: Icon, MenuItemProps }) {
745
+ return /* @__PURE__ */ React11.createElement(MenuItem, { ...MenuItemProps }, /* @__PURE__ */ React11.createElement(
746
+ ListItemIcon2,
747
+ {
748
+ sx: {
749
+ color: "inherit"
750
+ }
751
+ },
752
+ /* @__PURE__ */ React11.createElement(Icon, null)
753
+ ), /* @__PURE__ */ React11.createElement(ListItemText3, { primary: title }));
754
+ }
755
+
756
+ // src/components/panel/actions-menu/actions/delete.tsx
921
757
  function Delete({ post }) {
922
- const [isDialogOpen, setIsDialogOpen] = useState5(false);
923
- const activeDocument = useActiveDocument3();
758
+ const [isDialogOpen, setIsDialogOpen] = useState4(false);
759
+ const activeDocument = useActiveDocument2();
924
760
  const isPostActive = activeDocument?.id === post.id;
925
761
  const userCanDelete = post.user_can.delete;
926
762
  const isDisabled = !userCanDelete || post.isHome || isPostActive;
927
- return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
763
+ return /* @__PURE__ */ React12.createElement(React12.Fragment, null, /* @__PURE__ */ React12.createElement(
928
764
  ActionMenuItem,
929
765
  {
930
- title: __9("Delete", "elementor"),
766
+ title: __7("Delete", "elementor"),
931
767
  icon: TrashIcon,
932
768
  MenuItemProps: {
933
769
  disabled: isDisabled,
@@ -935,7 +771,7 @@ function Delete({ post }) {
935
771
  sx: { "&:hover": { color: "error.main" } }
936
772
  }
937
773
  }
938
- ), isDialogOpen && /* @__PURE__ */ React16.createElement(DeleteDialog, { post, setIsDialogOpen }));
774
+ ), isDialogOpen && /* @__PURE__ */ React12.createElement(DeleteDialog, { post, setIsDialogOpen }));
939
775
  }
940
776
  function DeleteDialog({
941
777
  post,
@@ -944,7 +780,7 @@ function DeleteDialog({
944
780
  const { type } = usePostListContext();
945
781
  const { deletePost } = usePostActions(type);
946
782
  const { setError } = usePostListContext();
947
- const dialogTitle = sprintf(__9('Delete "%s"?', "elementor"), post.title.rendered);
783
+ const dialogTitle = sprintf(__7('Delete "%s"?', "elementor"), post.title.rendered);
948
784
  const deletePage = async () => {
949
785
  try {
950
786
  await deletePost.mutateAsync(post.id);
@@ -959,10 +795,10 @@ function DeleteDialog({
959
795
  }
960
796
  setIsDialogOpen(false);
961
797
  };
962
- return /* @__PURE__ */ React16.createElement(Dialog, { open: true, onClose: handleCancel, "aria-labelledby": "delete-dialog" }, /* @__PURE__ */ React16.createElement(DialogTitle, { noWrap: true }, dialogTitle), /* @__PURE__ */ React16.createElement(Divider3, null), /* @__PURE__ */ React16.createElement(DialogContent, null, /* @__PURE__ */ React16.createElement(DialogContentText, null, __9(
798
+ return /* @__PURE__ */ React12.createElement(Dialog, { open: true, onClose: handleCancel, "aria-labelledby": "delete-dialog" }, /* @__PURE__ */ React12.createElement(DialogTitle, { noWrap: true }, dialogTitle), /* @__PURE__ */ React12.createElement(Divider2, null), /* @__PURE__ */ React12.createElement(DialogContent, null, /* @__PURE__ */ React12.createElement(DialogContentText, null, __7(
963
799
  "The page and its content will be deleted forever and we won\u2019t be able to recover them.",
964
800
  "elementor"
965
- ))), /* @__PURE__ */ React16.createElement(DialogActions, null, /* @__PURE__ */ React16.createElement(
801
+ ))), /* @__PURE__ */ React12.createElement(DialogActions, null, /* @__PURE__ */ React12.createElement(
966
802
  Button2,
967
803
  {
968
804
  variant: "contained",
@@ -970,63 +806,75 @@ function DeleteDialog({
970
806
  onClick: handleCancel,
971
807
  disabled: deletePost.isPending
972
808
  },
973
- __9("Cancel", "elementor")
974
- ), /* @__PURE__ */ React16.createElement(Button2, { variant: "contained", color: "error", onClick: deletePage, disabled: deletePost.isPending }, !deletePost.isPending ? __9("Delete", "elementor") : /* @__PURE__ */ React16.createElement(CircularProgress3, null))));
809
+ __7("Cancel", "elementor")
810
+ ), /* @__PURE__ */ React12.createElement(Button2, { variant: "contained", color: "error", onClick: deletePage, disabled: deletePost.isPending }, !deletePost.isPending ? __7("Delete", "elementor") : /* @__PURE__ */ React12.createElement(CircularProgress2, null))));
975
811
  }
976
812
 
977
- // src/components/panel/actions-menu/actions/view.tsx
978
- import * as React17 from "react";
979
- import { EyeIcon } from "@elementor/icons";
980
- import { __ as __10 } from "@wordpress/i18n";
981
- function View({ post }) {
982
- const { type } = usePostListContext();
983
- const title = __10("View %s", "elementor").replace("%s", postTypesMap[type].labels.singular_name);
984
- return /* @__PURE__ */ React17.createElement(
813
+ // src/components/panel/actions-menu/actions/duplicate.tsx
814
+ import * as React13 from "react";
815
+ import { CopyIcon } from "@elementor/icons";
816
+ import { __ as __8 } from "@wordpress/i18n";
817
+ function Duplicate({ post, popupState }) {
818
+ const { setEditMode } = usePostListContext();
819
+ const { data: user } = useUser();
820
+ const onClick = () => {
821
+ popupState.close();
822
+ setEditMode({
823
+ mode: "duplicate",
824
+ details: {
825
+ postId: post.id,
826
+ title: post.title.rendered
827
+ }
828
+ });
829
+ };
830
+ const isDisabled = !user?.capabilities?.edit_pages;
831
+ return /* @__PURE__ */ React13.createElement(
985
832
  ActionMenuItem,
986
833
  {
987
- title,
988
- icon: EyeIcon,
834
+ title: __8("Duplicate", "elementor"),
835
+ icon: CopyIcon,
989
836
  MenuItemProps: {
990
- onClick: () => window.open(post.link, "_blank")
837
+ disabled: isDisabled,
838
+ onClick
839
+ }
840
+ }
841
+ );
842
+ }
843
+
844
+ // src/components/panel/actions-menu/actions/rename.tsx
845
+ import * as React14 from "react";
846
+ import { EraseIcon } from "@elementor/icons";
847
+ import { __ as __9 } from "@wordpress/i18n";
848
+ function Rename({ post }) {
849
+ const { setEditMode } = usePostListContext();
850
+ return /* @__PURE__ */ React14.createElement(
851
+ ActionMenuItem,
852
+ {
853
+ title: __9("Rename", "elementor"),
854
+ icon: EraseIcon,
855
+ MenuItemProps: {
856
+ disabled: !post.user_can.edit,
857
+ onClick: () => {
858
+ setEditMode({
859
+ mode: "rename",
860
+ details: {
861
+ postId: post.id
862
+ }
863
+ });
864
+ }
991
865
  }
992
866
  }
993
867
  );
994
868
  }
995
869
 
996
870
  // src/components/panel/actions-menu/actions/set-home.tsx
997
- import * as React18 from "react";
871
+ import * as React15 from "react";
998
872
  import { HomeIcon } from "@elementor/icons";
999
- import { __ as __11 } from "@wordpress/i18n";
873
+ import { CircularProgress as CircularProgress3 } from "@elementor/ui";
874
+ import { __ as __10 } from "@wordpress/i18n";
1000
875
 
1001
876
  // src/hooks/use-homepage-actions.ts
1002
877
  import { useMutation as useMutation2, useQueryClient as useQueryClient2 } from "@elementor/query";
1003
-
1004
- // src/api/settings.ts
1005
- import apiFetch5 from "@wordpress/api-fetch";
1006
- var getSettings = () => {
1007
- const baseUri = "/elementor/v1/site-navigation/homepage";
1008
- const uri = baseUri;
1009
- return apiFetch5({ path: uri });
1010
- };
1011
- var updateSettings = (settings) => {
1012
- return apiFetch5({
1013
- path: "/wp/v2/settings",
1014
- method: "POST",
1015
- data: settings
1016
- });
1017
- };
1018
-
1019
- // src/hooks/use-homepage.ts
1020
- import { useQuery as useQuery3 } from "@elementor/query";
1021
- var settingsQueryKey = () => ["site-navigation", "homepage"];
1022
- function useHomepage() {
1023
- return useQuery3({
1024
- queryKey: settingsQueryKey(),
1025
- queryFn: () => getSettings()
1026
- });
1027
- }
1028
-
1029
- // src/hooks/use-homepage-actions.ts
1030
878
  function useHomepageActions() {
1031
879
  const invalidateSettings = useInvalidateSettings();
1032
880
  const onSuccess = async () => invalidateSettings({ exact: true });
@@ -1045,7 +893,6 @@ function useInvalidateSettings() {
1045
893
  }
1046
894
 
1047
895
  // src/components/panel/actions-menu/actions/set-home.tsx
1048
- import { CircularProgress as CircularProgress4 } from "@elementor/ui";
1049
896
  function SetHome({ post, closeMenu }) {
1050
897
  const { updateSettingsMutation } = useHomepageActions();
1051
898
  const { setError } = usePostListContext();
@@ -1063,11 +910,11 @@ function SetHome({ post, closeMenu }) {
1063
910
  const isPostPublished = post.status === "publish";
1064
911
  const isPostHomepage = !!post.isHome;
1065
912
  const isDisabled = !canManageOptions || isPostHomepage || !isPostPublished || updateSettingsMutation.isPending;
1066
- return /* @__PURE__ */ React18.createElement(
913
+ return /* @__PURE__ */ React15.createElement(
1067
914
  ActionMenuItem,
1068
915
  {
1069
- title: __11("Set as homepage", "elementor"),
1070
- icon: !updateSettingsMutation.isPending ? HomeIcon : CircularProgress4,
916
+ title: __10("Set as homepage", "elementor"),
917
+ icon: !updateSettingsMutation.isPending ? HomeIcon : CircularProgress3,
1071
918
  MenuItemProps: {
1072
919
  disabled: isDisabled,
1073
920
  onClick: handleClick
@@ -1076,19 +923,37 @@ function SetHome({ post, closeMenu }) {
1076
923
  );
1077
924
  }
1078
925
 
926
+ // src/components/panel/actions-menu/actions/view.tsx
927
+ import * as React16 from "react";
928
+ import { EyeIcon } from "@elementor/icons";
929
+ import { __ as __11 } from "@wordpress/i18n";
930
+ function View({ post }) {
931
+ const { type } = usePostListContext();
932
+ const title = __11("View %s", "elementor").replace("%s", postTypesMap[type].labels.singular_name);
933
+ return /* @__PURE__ */ React16.createElement(
934
+ ActionMenuItem,
935
+ {
936
+ title,
937
+ icon: EyeIcon,
938
+ MenuItemProps: {
939
+ onClick: () => window.open(post.link, "_blank")
940
+ }
941
+ }
942
+ );
943
+ }
944
+
1079
945
  // src/components/panel/posts-list/list-items/list-item-view.tsx
1080
- import { __ as __12 } from "@wordpress/i18n";
1081
946
  var DisabledPostTooltip = ({ children, isDisabled }) => {
1082
947
  if (isDisabled) {
1083
- const title = /* @__PURE__ */ React19.createElement(Typography3, { variant: "caption" }, "You cannot edit this page.", /* @__PURE__ */ React19.createElement("br", null), "To edit it directly, contact the site owner");
1084
- return /* @__PURE__ */ React19.createElement(Tooltip2, { title, placement: "bottom", arrow: false }, children);
948
+ const title = /* @__PURE__ */ React17.createElement(Typography4, { variant: "caption" }, "You cannot edit this page.", /* @__PURE__ */ React17.createElement("br", null), "To edit it directly, contact the site owner");
949
+ return /* @__PURE__ */ React17.createElement(Tooltip, { title, placement: "bottom", arrow: false }, children);
1085
950
  }
1086
- return /* @__PURE__ */ React19.createElement(React19.Fragment, null, children);
951
+ return /* @__PURE__ */ React17.createElement(React17.Fragment, null, children);
1087
952
  };
1088
953
  function ListItemView({ post }) {
1089
- const activeDocument = useActiveDocument4();
1090
- const navigateToDocument = useNavigateToDocument5();
1091
- const popupState = usePopupState2({
954
+ const activeDocument = useActiveDocument3();
955
+ const navigateToDocument = useNavigateToDocument3();
956
+ const popupState = usePopupState({
1092
957
  variant: "popover",
1093
958
  popupId: "post-actions",
1094
959
  disableAutoFocus: true
@@ -1097,120 +962,59 @@ function ListItemView({ post }) {
1097
962
  const status = isActive ? activeDocument?.status.value : post.status;
1098
963
  const title = isActive ? activeDocument?.title : post.title.rendered;
1099
964
  const isDisabled = !post.user_can.edit;
1100
- return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(DisabledPostTooltip, { isDisabled }, /* @__PURE__ */ React19.createElement(
965
+ return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(DisabledPostTooltip, { isDisabled }, /* @__PURE__ */ React17.createElement(
1101
966
  ListItem3,
1102
967
  {
1103
968
  disablePadding: true,
1104
- secondaryAction: /* @__PURE__ */ React19.createElement(IconButton3, { value: true, size: "small", ...bindTrigger2(popupState) }, /* @__PURE__ */ React19.createElement(DotsVerticalIcon, { fontSize: "small" }))
969
+ secondaryAction: /* @__PURE__ */ React17.createElement(IconButton3, { value: true, size: "small", ...bindTrigger(popupState) }, /* @__PURE__ */ React17.createElement(DotsVerticalIcon, { fontSize: "small" }))
1105
970
  },
1106
- /* @__PURE__ */ React19.createElement(
971
+ /* @__PURE__ */ React17.createElement(
1107
972
  ListItemButton,
1108
973
  {
1109
974
  selected: isActive,
1110
- disabled: isDisabled,
1111
- onClick: () => {
1112
- if (!isActive) {
1113
- navigateToDocument(post.id);
1114
- }
1115
- },
1116
- dense: true
1117
- },
1118
- /* @__PURE__ */ React19.createElement(ListItemText7, { disableTypography: true }, /* @__PURE__ */ React19.createElement(PageTitleAndStatus, { title, status })),
1119
- post.isHome && /* @__PURE__ */ React19.createElement(HomeIcon2, { titleAccess: __12("Homepage", "elementor"), color: "disabled" })
1120
- )
1121
- )), /* @__PURE__ */ React19.createElement(
1122
- Menu2,
1123
- {
1124
- PaperProps: { sx: { mt: 2, width: 200 } },
1125
- MenuListProps: { dense: true },
1126
- ...bindMenu2(popupState)
1127
- },
1128
- /* @__PURE__ */ React19.createElement(Rename, { post }),
1129
- /* @__PURE__ */ React19.createElement(Duplicate, { post, popupState }),
1130
- /* @__PURE__ */ React19.createElement(Delete, { post }),
1131
- /* @__PURE__ */ React19.createElement(View, { post }),
1132
- /* @__PURE__ */ React19.createElement(Divider4, null),
1133
- /* @__PURE__ */ React19.createElement(SetHome, { post, closeMenu: () => popupState.close() })
1134
- ));
1135
- }
1136
-
1137
- // src/components/panel/posts-list/post-list-item.tsx
1138
- function PostListItem2({ post }) {
1139
- const { editMode } = usePostListContext();
1140
- if ("rename" === editMode.mode && post?.id && post?.id === editMode.details.postId) {
1141
- return /* @__PURE__ */ React20.createElement(ListItemRename, { post });
1142
- }
1143
- if ("create" === editMode.mode && !post) {
1144
- return /* @__PURE__ */ React20.createElement(ListItemCreate, null);
1145
- }
1146
- if ("duplicate" === editMode.mode && !post) {
1147
- return /* @__PURE__ */ React20.createElement(ListItemDuplicate, null);
1148
- }
1149
- if (!post) {
1150
- return null;
1151
- }
1152
- return /* @__PURE__ */ React20.createElement(ListItemView, { post });
1153
- }
1154
-
1155
- // src/components/panel/add-new-button.tsx
1156
- import * as React21 from "react";
1157
- import { Button as Button3 } from "@elementor/ui";
1158
- import { PlusIcon as PlusIcon2 } from "@elementor/icons";
1159
- import { __ as __13 } from "@wordpress/i18n";
1160
- function AddNewButton() {
1161
- const { setEditMode } = usePostListContext();
1162
- const { data: user } = useUser();
1163
- return /* @__PURE__ */ React21.createElement(
1164
- Button3,
1165
- {
1166
- size: "small",
1167
- startIcon: /* @__PURE__ */ React21.createElement(PlusIcon2, null),
1168
- disabled: !user?.capabilities?.edit_pages,
1169
- onClick: () => {
1170
- setEditMode({ mode: "create", details: {} });
1171
- },
1172
- sx: {
1173
- px: 1.5
1174
- }
1175
- },
1176
- __13("Add New", "elementor")
1177
- );
1178
- }
1179
-
1180
- // src/components/panel/posts-list/error-state.tsx
1181
- import { Error404TemplateIcon } from "@elementor/icons";
1182
- import { Box as Box3, Link, Typography as Typography4 } from "@elementor/ui";
1183
- import { __ as __14 } from "@wordpress/i18n";
1184
- import * as React22 from "react";
1185
- function ErrorState() {
1186
- return /* @__PURE__ */ React22.createElement(
1187
- Box3,
1188
- {
1189
- sx: {
1190
- display: "flex",
1191
- flexDirection: "column",
1192
- justifyContent: "center",
1193
- alignItems: "center",
1194
- pt: "40px",
1195
- gap: "16px"
1196
- }
1197
- },
1198
- /* @__PURE__ */ React22.createElement(Error404TemplateIcon, null),
1199
- /* @__PURE__ */ React22.createElement(
1200
- Box3,
1201
- {
1202
- sx: {
1203
- display: "flex",
1204
- flexDirection: "column",
1205
- justifyContent: "center",
1206
- alignItems: "center",
1207
- gap: "8px"
1208
- }
975
+ disabled: isDisabled,
976
+ onClick: () => {
977
+ if (!isActive) {
978
+ navigateToDocument(post.id);
979
+ }
980
+ },
981
+ dense: true
1209
982
  },
1210
- /* @__PURE__ */ React22.createElement(Typography4, { variant: "body1", color: "text.primary" }, __14("We couldn\u2019t display your pages.", "elementor")),
1211
- /* @__PURE__ */ React22.createElement(Box3, null, /* @__PURE__ */ React22.createElement(Typography4, { variant: "body2", color: "text.primary", sx: { textAlign: "center" } }, __14("It\u2019s probably a temporary issue.", "elementor")), /* @__PURE__ */ React22.createElement(Typography4, { variant: "body2", color: "text.primary", sx: { textAlign: "center" } }, __14("If the problem persists,", "elementor"), " ", /* @__PURE__ */ React22.createElement(Link, { target: "_blank", href: "https://go.elementor.com/wp-editor-support-open-ticket/" }, "Notify support")))
983
+ /* @__PURE__ */ React17.createElement(ListItemText4, { disableTypography: true }, /* @__PURE__ */ React17.createElement(PageTitleAndStatus, { title, status })),
984
+ post.isHome && /* @__PURE__ */ React17.createElement(HomeIcon2, { titleAccess: __12("Homepage", "elementor"), color: "disabled" })
1212
985
  )
1213
- );
986
+ )), /* @__PURE__ */ React17.createElement(
987
+ Menu,
988
+ {
989
+ PaperProps: { sx: { mt: 2, width: 200 } },
990
+ MenuListProps: { dense: true },
991
+ ...bindMenu(popupState)
992
+ },
993
+ /* @__PURE__ */ React17.createElement(Rename, { post }),
994
+ /* @__PURE__ */ React17.createElement(Duplicate, { post, popupState }),
995
+ /* @__PURE__ */ React17.createElement(Delete, { post }),
996
+ /* @__PURE__ */ React17.createElement(View, { post }),
997
+ /* @__PURE__ */ React17.createElement(Divider3, null),
998
+ /* @__PURE__ */ React17.createElement(SetHome, { post, closeMenu: () => popupState.close() })
999
+ ));
1000
+ }
1001
+
1002
+ // src/components/panel/posts-list/post-list-item.tsx
1003
+ function PostListItem({ post }) {
1004
+ const { editMode } = usePostListContext();
1005
+ if ("rename" === editMode.mode && post?.id && post?.id === editMode.details.postId) {
1006
+ return /* @__PURE__ */ React18.createElement(ListItemRename, { post });
1007
+ }
1008
+ if ("create" === editMode.mode && !post) {
1009
+ return /* @__PURE__ */ React18.createElement(ListItemCreate, null);
1010
+ }
1011
+ if ("duplicate" === editMode.mode && !post) {
1012
+ return /* @__PURE__ */ React18.createElement(ListItemDuplicate, null);
1013
+ }
1014
+ if (!post) {
1015
+ return null;
1016
+ }
1017
+ return /* @__PURE__ */ React18.createElement(ListItemView, { post });
1214
1018
  }
1215
1019
 
1216
1020
  // src/components/panel/posts-list/posts-collapsible-list.tsx
@@ -1226,10 +1030,10 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
1226
1030
  } = usePosts(type);
1227
1031
  const { data: homepageId } = useHomepage();
1228
1032
  if (postsError) {
1229
- return /* @__PURE__ */ React23.createElement(ErrorState, null);
1033
+ return /* @__PURE__ */ React19.createElement(ErrorState, null);
1230
1034
  }
1231
1035
  if (!posts || postsLoading) {
1232
- return /* @__PURE__ */ React23.createElement(Box4, { sx: { px: 5 } }, /* @__PURE__ */ React23.createElement(Box4, { display: "flex", justifyContent: "flex-end", alignItems: "center" }, /* @__PURE__ */ React23.createElement(Skeleton, { sx: { my: 4 }, animation: "wave", variant: "rounded", width: "110px", height: "28px" })), /* @__PURE__ */ React23.createElement(Box4, null, /* @__PURE__ */ React23.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "100%", height: "24px" }), /* @__PURE__ */ React23.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "70%", height: "24px" }), /* @__PURE__ */ React23.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "70%", height: "24px" }), /* @__PURE__ */ React23.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "70%", height: "24px" })));
1036
+ return /* @__PURE__ */ React19.createElement(Box4, { sx: { px: 5 } }, /* @__PURE__ */ React19.createElement(Box4, { display: "flex", justifyContent: "flex-end", alignItems: "center" }, /* @__PURE__ */ React19.createElement(Skeleton, { sx: { my: 4 }, animation: "wave", variant: "rounded", width: "110px", height: "28px" })), /* @__PURE__ */ React19.createElement(Box4, null, /* @__PURE__ */ React19.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "100%", height: "24px" }), /* @__PURE__ */ React19.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "70%", height: "24px" }), /* @__PURE__ */ React19.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "70%", height: "24px" }), /* @__PURE__ */ React19.createElement(Skeleton, { sx: { my: 3 }, animation: "wave", variant: "rounded", width: "70%", height: "24px" })));
1233
1037
  }
1234
1038
  const label = `${postTypesMap[type].labels.plural_name} (${total.toString()})`;
1235
1039
  const mappedPosts = posts.map((post) => {
@@ -1247,7 +1051,7 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
1247
1051
  }
1248
1052
  return 0;
1249
1053
  });
1250
- return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(
1054
+ return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(
1251
1055
  Box4,
1252
1056
  {
1253
1057
  display: "flex",
@@ -1258,10 +1062,10 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
1258
1062
  px: 2
1259
1063
  }
1260
1064
  },
1261
- /* @__PURE__ */ React23.createElement(AddNewButton, null)
1262
- ), /* @__PURE__ */ React23.createElement(List2, { dense: true }, /* @__PURE__ */ React23.createElement(CollapsibleList, { label, Icon: PageTypeIcon2, isOpenByDefault: isOpenByDefault || false }, sortedPosts.map((post) => {
1263
- return /* @__PURE__ */ React23.createElement(PostListItem2, { key: post.id, post });
1264
- }), ["duplicate", "create"].includes(editMode.mode) && /* @__PURE__ */ React23.createElement(PostListItem2, null), hasNextPage && /* @__PURE__ */ React23.createElement(
1065
+ /* @__PURE__ */ React19.createElement(AddNewButton, null)
1066
+ ), /* @__PURE__ */ React19.createElement(List2, { dense: true }, /* @__PURE__ */ React19.createElement(CollapsibleList, { label, Icon: PageTypeIcon2, isOpenByDefault: isOpenByDefault || false }, sortedPosts.map((post) => {
1067
+ return /* @__PURE__ */ React19.createElement(PostListItem, { key: post.id, post });
1068
+ }), ["duplicate", "create"].includes(editMode.mode) && /* @__PURE__ */ React19.createElement(PostListItem, null), hasNextPage && /* @__PURE__ */ React19.createElement(
1265
1069
  Box4,
1266
1070
  {
1267
1071
  sx: {
@@ -1269,42 +1073,14 @@ function PostsCollapsibleList({ isOpenByDefault = false }) {
1269
1073
  justifyContent: "center"
1270
1074
  }
1271
1075
  },
1272
- /* @__PURE__ */ React23.createElement(Button4, { onClick: fetchNextPage, color: "secondary" }, isFetchingNextPage ? /* @__PURE__ */ React23.createElement(CircularProgress5, null) : "Load More")
1076
+ /* @__PURE__ */ React19.createElement(Button3, { onClick: fetchNextPage, color: "secondary" }, isFetchingNextPage ? /* @__PURE__ */ React19.createElement(CircularProgress4, null) : "Load More")
1273
1077
  ))));
1274
1078
  }
1275
1079
 
1276
- // src/components/panel/error-snackbar.tsx
1277
- import { Snackbar, Alert, Typography as Typography5 } from "@elementor/ui";
1278
- import * as React24 from "react";
1279
- var ErrorSnackbar = ({ open, onClose }) => {
1280
- return /* @__PURE__ */ React24.createElement(
1281
- Snackbar,
1282
- {
1283
- open,
1284
- onClose,
1285
- anchorOrigin: {
1286
- vertical: "bottom",
1287
- horizontal: "left"
1288
- }
1289
- },
1290
- /* @__PURE__ */ React24.createElement(Alert, { onClose, severity: "error", sx: { width: "100%" } }, /* @__PURE__ */ React24.createElement(
1291
- Typography5,
1292
- {
1293
- component: "span",
1294
- sx: {
1295
- fontWeight: "bold"
1296
- }
1297
- },
1298
- "We couldn\u2019t complete the action."
1299
- ), " ", "Please try again")
1300
- );
1301
- };
1302
- var error_snackbar_default = ErrorSnackbar;
1303
-
1304
1080
  // src/components/panel/shell.tsx
1305
1081
  var Shell = () => {
1306
- const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = React25.useState(false);
1307
- return /* @__PURE__ */ React25.createElement(Panel, null, /* @__PURE__ */ React25.createElement(PanelHeader, null, /* @__PURE__ */ React25.createElement(PanelHeaderTitle, null, __15("Pages", "elementor"))), /* @__PURE__ */ React25.createElement(PanelBody, null, /* @__PURE__ */ React25.createElement(PostListContextProvider, { type: "page", setError: () => setIsErrorSnackbarOpen(true) }, /* @__PURE__ */ React25.createElement(PostsCollapsibleList, { isOpenByDefault: true })), /* @__PURE__ */ React25.createElement(error_snackbar_default, { open: isErrorSnackbarOpen, onClose: () => setIsErrorSnackbarOpen(false) })));
1082
+ const [isErrorSnackbarOpen, setIsErrorSnackbarOpen] = React20.useState(false);
1083
+ return /* @__PURE__ */ React20.createElement(Panel, null, /* @__PURE__ */ React20.createElement(PanelHeader, null, /* @__PURE__ */ React20.createElement(PanelHeaderTitle, null, __13("Pages", "elementor"))), /* @__PURE__ */ React20.createElement(PanelBody, null, /* @__PURE__ */ React20.createElement(PostListContextProvider, { type: "page", setError: () => setIsErrorSnackbarOpen(true) }, /* @__PURE__ */ React20.createElement(PostsCollapsibleList, { isOpenByDefault: true })), /* @__PURE__ */ React20.createElement(error_snackbar_default, { open: isErrorSnackbarOpen, onClose: () => setIsErrorSnackbarOpen(false) })));
1308
1084
  };
1309
1085
  var shell_default = Shell;
1310
1086
 
@@ -1314,7 +1090,236 @@ var { panel, usePanelStatus, usePanelActions } = __createPanel({
1314
1090
  component: shell_default
1315
1091
  });
1316
1092
 
1093
+ // src/components/top-bar/recently-edited.tsx
1094
+ import * as React25 from "react";
1095
+ import {
1096
+ __useActiveDocument as useActiveDocument4,
1097
+ __useHostDocument as useHostDocument
1098
+ } from "@elementor/editor-documents";
1099
+ import { ChevronDownIcon as ChevronDownIcon2 } from "@elementor/icons";
1100
+ import {
1101
+ bindMenu as bindMenu2,
1102
+ bindTrigger as bindTrigger2,
1103
+ Button as Button4,
1104
+ Divider as Divider4,
1105
+ ListItemText as ListItemText7,
1106
+ ListSubheader,
1107
+ Menu as Menu2,
1108
+ MenuItem as MenuItem4,
1109
+ usePopupState as usePopupState2
1110
+ } from "@elementor/ui";
1111
+ import { __ as __15 } from "@wordpress/i18n";
1112
+
1113
+ // src/components/top-bar/create-post-list-item.tsx
1114
+ import * as React21 from "react";
1115
+ import { __useNavigateToDocument as useNavigateToDocument4 } from "@elementor/editor-documents";
1116
+ import { PlusIcon as PlusIcon2 } from "@elementor/icons";
1117
+ import { CircularProgress as CircularProgress5, ListItemIcon as ListItemIcon3, ListItemText as ListItemText5, MenuItem as MenuItem2 } from "@elementor/ui";
1118
+ import { __ as __14 } from "@wordpress/i18n";
1119
+
1120
+ // src/hooks/use-create-page.ts
1121
+ import { useState as useState6 } from "react";
1122
+ import apiFetch5 from "@wordpress/api-fetch";
1123
+ var endpointPath = "/elementor/v1/site-navigation/add-new-post";
1124
+ function useCreatePage() {
1125
+ const [isLoading, setIsLoading] = useState6(false);
1126
+ return {
1127
+ create: () => {
1128
+ setIsLoading(true);
1129
+ return addNewPage().then((newPost) => newPost).finally(() => setIsLoading(false));
1130
+ },
1131
+ isLoading
1132
+ };
1133
+ }
1134
+ async function addNewPage() {
1135
+ return await apiFetch5({
1136
+ path: endpointPath,
1137
+ method: "POST",
1138
+ data: { post_type: "page" }
1139
+ });
1140
+ }
1141
+
1142
+ // src/components/top-bar/create-post-list-item.tsx
1143
+ function CreatePostListItem({ closePopup, ...props }) {
1144
+ const { create, isLoading } = useCreatePage();
1145
+ const navigateToDocument = useNavigateToDocument4();
1146
+ const { data: user } = useUser();
1147
+ return /* @__PURE__ */ React21.createElement(
1148
+ MenuItem2,
1149
+ {
1150
+ disabled: isLoading || !user?.capabilities?.edit_pages,
1151
+ onClick: async () => {
1152
+ const { id } = await create();
1153
+ closePopup();
1154
+ await navigateToDocument(id);
1155
+ },
1156
+ ...props
1157
+ },
1158
+ /* @__PURE__ */ React21.createElement(ListItemIcon3, null, isLoading ? /* @__PURE__ */ React21.createElement(CircularProgress5, { size: "1.25rem" }) : /* @__PURE__ */ React21.createElement(PlusIcon2, { fontSize: "small" })),
1159
+ /* @__PURE__ */ React21.createElement(
1160
+ ListItemText5,
1161
+ {
1162
+ primaryTypographyProps: { variant: "body2" },
1163
+ primary: __14("Add new page", "elementor")
1164
+ }
1165
+ )
1166
+ );
1167
+ }
1168
+
1169
+ // src/components/top-bar/indicator.tsx
1170
+ import * as React22 from "react";
1171
+ import { Stack, Tooltip as BaseTooltip, Typography as Typography5 } from "@elementor/ui";
1172
+ function Indicator({ title, status }) {
1173
+ return /* @__PURE__ */ React22.createElement(Tooltip2, { title }, /* @__PURE__ */ React22.createElement(Stack, { component: "span", direction: "row", alignItems: "center", spacing: 0.5 }, /* @__PURE__ */ React22.createElement(Typography5, { component: "span", variant: "body2", sx: { maxWidth: "120px" }, noWrap: true }, title), status.value !== "publish" && /* @__PURE__ */ React22.createElement(Typography5, { component: "span", variant: "body2", sx: { fontStyle: "italic" } }, "(", status.label, ")")));
1174
+ }
1175
+ function Tooltip2(props) {
1176
+ return /* @__PURE__ */ React22.createElement(
1177
+ BaseTooltip,
1178
+ {
1179
+ PopperProps: {
1180
+ sx: {
1181
+ "&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": {
1182
+ mt: 2.7
1183
+ }
1184
+ }
1185
+ },
1186
+ ...props
1187
+ }
1188
+ );
1189
+ }
1190
+
1191
+ // src/components/top-bar/post-list-item.tsx
1192
+ import * as React24 from "react";
1193
+ import { __useNavigateToDocument as useNavigateToDocument5 } from "@elementor/editor-documents";
1194
+ import { ListItemText as ListItemText6, MenuItem as MenuItem3 } from "@elementor/ui";
1195
+
1196
+ // src/components/top-bar/chip-doc-type.tsx
1197
+ import * as React23 from "react";
1198
+ import { PostTypeIcon as PostTypeIcon2 } from "@elementor/icons";
1199
+ import { Chip } from "@elementor/ui";
1200
+ var iconsMap2 = getIconsMap();
1201
+ function DocTypeChip({ postType, docType, label }) {
1202
+ const color = "elementor_library" === postType ? "global" : "primary";
1203
+ const Icon = iconsMap2[docType] || PostTypeIcon2;
1204
+ return /* @__PURE__ */ React23.createElement(
1205
+ Chip,
1206
+ {
1207
+ component: "span",
1208
+ size: "small",
1209
+ variant: "outlined",
1210
+ label,
1211
+ "data-value": docType,
1212
+ color,
1213
+ icon: /* @__PURE__ */ React23.createElement(Icon, null),
1214
+ sx: { ml: 1, cursor: "inherit" }
1215
+ }
1216
+ );
1217
+ }
1218
+
1219
+ // src/components/top-bar/post-list-item.tsx
1220
+ function PostListItem2({ post, closePopup, ...props }) {
1221
+ const navigateToDocument = useNavigateToDocument5();
1222
+ const postTitle = useReverseHtmlEntities(post.title);
1223
+ return /* @__PURE__ */ React24.createElement(
1224
+ MenuItem3,
1225
+ {
1226
+ disabled: !post.user_can.edit,
1227
+ onClick: async () => {
1228
+ closePopup();
1229
+ await navigateToDocument(post.id);
1230
+ },
1231
+ ...props
1232
+ },
1233
+ /* @__PURE__ */ React24.createElement(
1234
+ ListItemText6,
1235
+ {
1236
+ sx: { flexGrow: 0 },
1237
+ primaryTypographyProps: { variant: "body2", noWrap: true },
1238
+ primary: postTitle
1239
+ }
1240
+ ),
1241
+ /* @__PURE__ */ React24.createElement(DocTypeChip, { postType: post.type.post_type, docType: post.type.doc_type, label: post.type.label })
1242
+ );
1243
+ }
1244
+
1245
+ // src/components/top-bar/recently-edited.tsx
1246
+ function RecentlyEdited() {
1247
+ const activeDocument = useActiveDocument4();
1248
+ const hostDocument = useHostDocument();
1249
+ const document2 = activeDocument && activeDocument.type.value !== "kit" ? activeDocument : hostDocument;
1250
+ const { data } = useRecentPosts();
1251
+ const getRecentPosts = () => {
1252
+ if (!data) {
1253
+ return [];
1254
+ }
1255
+ return data.filter((post) => post.id !== document2?.id).splice(0, NUMBER_OF_RECENT_POSTS - 1);
1256
+ };
1257
+ const recentPosts = getRecentPosts();
1258
+ const popupState = usePopupState2({
1259
+ variant: "popover",
1260
+ popupId: "elementor-v2-top-bar-recently-edited"
1261
+ });
1262
+ const documentTitle = useReverseHtmlEntities(document2?.title);
1263
+ if (!document2) {
1264
+ return null;
1265
+ }
1266
+ const buttonProps = bindTrigger2(popupState);
1267
+ return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(
1268
+ Button4,
1269
+ {
1270
+ color: "inherit",
1271
+ size: "small",
1272
+ endIcon: /* @__PURE__ */ React25.createElement(ChevronDownIcon2, { fontSize: "small" }),
1273
+ ...buttonProps,
1274
+ onClick: (e) => {
1275
+ const extendedWindow = window;
1276
+ const config = extendedWindow?.elementor?.editorEvents?.config;
1277
+ if (config) {
1278
+ extendedWindow.elementor.editorEvents.dispatchEvent(config.names.topBar.documentNameDropdown, {
1279
+ location: config.locations.topBar,
1280
+ secondaryLocation: config.secondaryLocations.documentNameDropdown,
1281
+ trigger: config.triggers.dropdownClick,
1282
+ element: config.elements.dropdown
1283
+ });
1284
+ }
1285
+ buttonProps.onClick(e);
1286
+ }
1287
+ },
1288
+ /* @__PURE__ */ React25.createElement(Indicator, { title: documentTitle, status: document2.status })
1289
+ ), /* @__PURE__ */ React25.createElement(
1290
+ Menu2,
1291
+ {
1292
+ MenuListProps: {
1293
+ subheader: /* @__PURE__ */ React25.createElement(ListSubheader, { color: "primary", sx: { fontStyle: "italic", fontWeight: "300" } }, __15("Recent", "elementor"))
1294
+ },
1295
+ PaperProps: { sx: { mt: 2.5, width: 320 } },
1296
+ ...bindMenu2(popupState)
1297
+ },
1298
+ recentPosts.map((post) => /* @__PURE__ */ React25.createElement(PostListItem2, { key: post.id, post, closePopup: popupState.close })),
1299
+ recentPosts.length === 0 && /* @__PURE__ */ React25.createElement(MenuItem4, { disabled: true }, /* @__PURE__ */ React25.createElement(
1300
+ ListItemText7,
1301
+ {
1302
+ primaryTypographyProps: {
1303
+ variant: "caption",
1304
+ fontStyle: "italic"
1305
+ },
1306
+ primary: __15("There are no other pages or templates on this site yet.", "elementor")
1307
+ }
1308
+ )),
1309
+ /* @__PURE__ */ React25.createElement(Divider4, { disabled: recentPosts.length === 0 }),
1310
+ /* @__PURE__ */ React25.createElement(CreatePostListItem, { closePopup: popupState.close })
1311
+ ));
1312
+ }
1313
+
1314
+ // src/env.ts
1315
+ import { parseEnv } from "@elementor/env";
1316
+ var { env, validateEnv } = parseEnv("@elementor/editor-site-navigation", (envData) => {
1317
+ return envData;
1318
+ });
1319
+
1317
1320
  // src/hooks/use-toggle-button-props.ts
1321
+ import { PagesIcon } from "@elementor/icons";
1322
+ import { __ as __16 } from "@wordpress/i18n";
1318
1323
  function useToggleButtonProps() {
1319
1324
  const { isOpen, isBlocked } = usePanelStatus();
1320
1325
  const { open, close } = usePanelActions();
@@ -1327,15 +1332,6 @@ function useToggleButtonProps() {
1327
1332
  };
1328
1333
  }
1329
1334
 
1330
- // src/init.ts
1331
- import { __registerPanel } from "@elementor/editor-panels";
1332
-
1333
- // src/env.ts
1334
- import { parseEnv } from "@elementor/env";
1335
- var { env, validateEnv } = parseEnv("@elementor/editor-site-navigation", (envData) => {
1336
- return envData;
1337
- });
1338
-
1339
1335
  // src/init.ts
1340
1336
  function init() {
1341
1337
  registerTopBarMenuItems();