@elementor/editor-site-navigation 0.10.3 → 0.12.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.
- package/CHANGELOG.md +22 -0
- package/dist/index.js +445 -174
- package/dist/index.mjs +441 -161
- package/package.json +2 -2
- package/src/api/post.ts +14 -6
- package/src/components/panel/actions-menu/action-list-item.tsx +1 -1
- package/src/components/panel/{pages-actions → actions-menu/actions}/delete.tsx +5 -5
- package/src/components/panel/actions-menu/actions/duplicate.tsx +29 -0
- package/src/components/panel/actions-menu/actions/rename.tsx +25 -0
- package/src/components/panel/{pages-actions → actions-menu/actions}/set-home.tsx +4 -4
- package/src/components/panel/actions-menu/actions/view.tsx +25 -0
- package/src/components/panel/add-new-button.tsx +22 -0
- package/src/components/panel/{pages-list/__tests__/page-list-item.test.tsx → posts-list/__tests__/post-list-item.test.tsx} +21 -18
- package/src/components/panel/{pages-list/__tests__/pages-collapsible-list.test.tsx → posts-list/__tests__/posts-collapsible-list.test.tsx} +11 -14
- package/src/components/panel/{pages-list → posts-list}/collapsible-list.tsx +4 -4
- package/src/components/panel/posts-list/list-items/edit-mode-template.tsx +103 -0
- package/src/components/panel/posts-list/list-items/list-item-create.tsx +25 -0
- package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +29 -0
- package/src/components/panel/posts-list/list-items/list-item-rename.tsx +33 -0
- package/src/components/panel/posts-list/list-items/list-item-view.tsx +87 -0
- package/src/components/panel/posts-list/post-list-item.tsx +29 -0
- package/src/components/panel/posts-list/posts-collapsible-list.tsx +44 -0
- package/src/components/panel/shell.tsx +14 -13
- package/src/components/top-bar/__tests__/add-new-page.test.tsx +11 -12
- package/src/components/top-bar/__tests__/recently-edited.test.tsx +30 -30
- package/src/contexts/post-list-context.tsx +73 -0
- package/src/env.ts +2 -2
- package/src/hooks/__tests__/use-create-page.test.ts +6 -8
- package/src/hooks/__tests__/use-posts.test.ts +4 -6
- package/src/hooks/__tests__/use-recent-posts.test.ts +4 -4
- package/src/init.ts +1 -1
- package/src/components/panel/actions-menu/page-actions-menu.tsx +0 -29
- package/src/components/panel/add-new-page-button.tsx +0 -15
- package/src/components/panel/pages-actions/duplicate.tsx +0 -14
- package/src/components/panel/pages-actions/rename.tsx +0 -14
- package/src/components/panel/pages-actions/view.tsx +0 -14
- package/src/components/panel/pages-list/page-list-item.tsx +0 -66
- package/src/components/panel/pages-list/pages-collapsible-list.tsx +0 -37
package/dist/index.js
CHANGED
|
@@ -250,23 +250,120 @@ function RecentlyEdited() {
|
|
|
250
250
|
var import_editor_app_bar = require("@elementor/editor-app-bar");
|
|
251
251
|
|
|
252
252
|
// src/hooks/useToggleButtonProps.ts
|
|
253
|
-
var
|
|
254
|
-
var
|
|
253
|
+
var import_i18n14 = require("@wordpress/i18n");
|
|
254
|
+
var import_icons15 = require("@elementor/icons");
|
|
255
255
|
|
|
256
256
|
// src/components/panel/panel.ts
|
|
257
257
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
258
258
|
|
|
259
259
|
// src/components/panel/shell.tsx
|
|
260
|
-
var
|
|
260
|
+
var React24 = __toESM(require("react"));
|
|
261
261
|
var import_ui14 = require("@elementor/ui");
|
|
262
262
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
263
|
+
var import_i18n13 = require("@wordpress/i18n");
|
|
263
264
|
|
|
264
|
-
// src/components/panel/
|
|
265
|
-
var
|
|
265
|
+
// src/components/panel/posts-list/posts-collapsible-list.tsx
|
|
266
|
+
var React22 = __toESM(require("react"));
|
|
267
|
+
var import_icons13 = require("@elementor/icons");
|
|
268
|
+
var import_ui12 = require("@elementor/ui");
|
|
266
269
|
|
|
267
|
-
// src/
|
|
270
|
+
// src/hooks/use-posts.ts
|
|
271
|
+
var import_query = require("@elementor/query");
|
|
272
|
+
|
|
273
|
+
// src/api/post.ts
|
|
274
|
+
var import_api_fetch3 = __toESM(require("@wordpress/api-fetch"));
|
|
275
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
276
|
+
var postTypesMap = {
|
|
277
|
+
page: {
|
|
278
|
+
labels: {
|
|
279
|
+
singular_name: (0, import_i18n3.__)("Page", "elementor"),
|
|
280
|
+
plural_name: (0, import_i18n3.__)("Pages", "elementor")
|
|
281
|
+
},
|
|
282
|
+
rest_base: "pages"
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
var getRequest = (postTypeSlug) => {
|
|
286
|
+
const baseUri = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
|
|
287
|
+
const keys = ["id", "type", "title", "link", "status"];
|
|
288
|
+
const queryParams = new URLSearchParams({
|
|
289
|
+
status: "any",
|
|
290
|
+
per_page: "-1",
|
|
291
|
+
order: "asc",
|
|
292
|
+
_fields: keys.join(",")
|
|
293
|
+
});
|
|
294
|
+
const uri = baseUri + "?" + queryParams.toString();
|
|
295
|
+
return (0, import_api_fetch3.default)({ path: uri });
|
|
296
|
+
};
|
|
297
|
+
var createRequest = (postTypeSlug, newPost) => {
|
|
298
|
+
const path = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
|
|
299
|
+
return (0, import_api_fetch3.default)({
|
|
300
|
+
path,
|
|
301
|
+
method: "POST",
|
|
302
|
+
data: newPost
|
|
303
|
+
});
|
|
304
|
+
};
|
|
305
|
+
var updateRequest = (postTypeSlug, updatedPost) => {
|
|
306
|
+
const path = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
|
|
307
|
+
const { id, ...data } = updatedPost;
|
|
308
|
+
return (0, import_api_fetch3.default)({
|
|
309
|
+
path: `${path}/${id}`,
|
|
310
|
+
method: "POST",
|
|
311
|
+
data
|
|
312
|
+
});
|
|
313
|
+
};
|
|
314
|
+
var deleteRequest = (postTypeSlug, postId) => {
|
|
315
|
+
const path = `/wp/v2/${postTypesMap[postTypeSlug].rest_base}`;
|
|
316
|
+
return (0, import_api_fetch3.default)({
|
|
317
|
+
path: `${path}/${postId}`,
|
|
318
|
+
method: "DELETE"
|
|
319
|
+
});
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
// src/hooks/use-posts.ts
|
|
323
|
+
var postsQueryKey = (postTypeSlug) => ["site-navigation", "posts", postTypeSlug];
|
|
324
|
+
function usePosts(postTypeSlug) {
|
|
325
|
+
return (0, import_query.useQuery)({
|
|
326
|
+
queryKey: postsQueryKey(postTypeSlug),
|
|
327
|
+
queryFn: () => getRequest(postTypeSlug)
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// src/contexts/post-list-context.tsx
|
|
268
332
|
var React6 = __toESM(require("react"));
|
|
269
333
|
var import_react4 = require("react");
|
|
334
|
+
var defaultValues = {
|
|
335
|
+
type: "page",
|
|
336
|
+
editMode: { mode: "none", details: {} },
|
|
337
|
+
setEditMode: () => null,
|
|
338
|
+
resetEditMode: () => null
|
|
339
|
+
};
|
|
340
|
+
var PostListContext = (0, import_react4.createContext)(defaultValues);
|
|
341
|
+
var PostListContextProvider = ({
|
|
342
|
+
type,
|
|
343
|
+
children
|
|
344
|
+
}) => {
|
|
345
|
+
const [editMode, setEditMode] = (0, import_react4.useState)(defaultValues.editMode);
|
|
346
|
+
const resetEditMode = () => {
|
|
347
|
+
setEditMode(defaultValues.editMode);
|
|
348
|
+
};
|
|
349
|
+
return /* @__PURE__ */ React6.createElement(PostListContext.Provider, { value: {
|
|
350
|
+
type,
|
|
351
|
+
editMode,
|
|
352
|
+
setEditMode,
|
|
353
|
+
resetEditMode
|
|
354
|
+
} }, children);
|
|
355
|
+
};
|
|
356
|
+
function usePostListContext() {
|
|
357
|
+
const context = (0, import_react4.useContext)(PostListContext);
|
|
358
|
+
if (!context) {
|
|
359
|
+
throw new Error("The `usePostListContext()` hook must be used within an `<PostListContextProvider />`");
|
|
360
|
+
}
|
|
361
|
+
return context;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/components/panel/posts-list/collapsible-list.tsx
|
|
365
|
+
var React7 = __toESM(require("react"));
|
|
366
|
+
var import_react5 = require("react");
|
|
270
367
|
var import_ui6 = require("@elementor/ui");
|
|
271
368
|
var import_icons5 = require("@elementor/icons");
|
|
272
369
|
var RotateIcon = (0, import_ui6.styled)(import_icons5.ChevronDownIcon, {
|
|
@@ -283,45 +380,210 @@ function CollapsibleList({
|
|
|
283
380
|
isOpenByDefault = false,
|
|
284
381
|
children
|
|
285
382
|
}) {
|
|
286
|
-
const [isOpen, setIsOpen] = (0,
|
|
287
|
-
return /* @__PURE__ */
|
|
383
|
+
const [isOpen, setIsOpen] = (0, import_react5.useState)(isOpenByDefault);
|
|
384
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui6.ListItem, { disableGutters: true }, /* @__PURE__ */ React7.createElement(import_ui6.ListItemIcon, null, /* @__PURE__ */ React7.createElement(
|
|
288
385
|
import_ui6.IconButton,
|
|
289
386
|
{
|
|
290
387
|
onClick: () => setIsOpen((prev) => !prev),
|
|
291
388
|
sx: { color: "inherit" },
|
|
292
389
|
size: "small"
|
|
293
390
|
},
|
|
294
|
-
/* @__PURE__ */
|
|
295
|
-
)), /* @__PURE__ */
|
|
391
|
+
/* @__PURE__ */ React7.createElement(RotateIcon, { fontSize: "small", isOpen })
|
|
392
|
+
)), /* @__PURE__ */ React7.createElement(import_ui6.ListItemIcon, null, /* @__PURE__ */ React7.createElement(Icon, null)), /* @__PURE__ */ React7.createElement(import_ui6.ListItemText, null, label)), /* @__PURE__ */ React7.createElement(
|
|
296
393
|
import_ui6.Collapse,
|
|
297
394
|
{
|
|
298
395
|
in: isOpen,
|
|
299
396
|
timeout: "auto",
|
|
300
397
|
unmountOnExit: true
|
|
301
398
|
},
|
|
302
|
-
/* @__PURE__ */
|
|
399
|
+
/* @__PURE__ */ React7.createElement(import_ui6.List, { dense: true }, children)
|
|
303
400
|
));
|
|
304
401
|
}
|
|
305
402
|
|
|
306
|
-
// src/components/panel/
|
|
307
|
-
var
|
|
308
|
-
var import_ui12 = require("@elementor/ui");
|
|
403
|
+
// src/components/panel/posts-list/post-list-item.tsx
|
|
404
|
+
var React21 = __toESM(require("react"));
|
|
309
405
|
|
|
310
|
-
// src/components/panel/
|
|
311
|
-
var
|
|
406
|
+
// src/components/panel/posts-list/list-items/list-item-rename.tsx
|
|
407
|
+
var React9 = __toESM(require("react"));
|
|
408
|
+
|
|
409
|
+
// src/hooks/use-posts-actions.ts
|
|
410
|
+
var import_query2 = require("@elementor/query");
|
|
411
|
+
function usePostActions(postTypeSlug) {
|
|
412
|
+
const invalidatePosts = useInvalidatePosts(postTypeSlug);
|
|
413
|
+
const onSuccess = () => invalidatePosts({ exact: true });
|
|
414
|
+
const createPost = (0, import_query2.useMutation)(
|
|
415
|
+
(newPost) => createRequest(postTypeSlug, newPost),
|
|
416
|
+
{ onSuccess }
|
|
417
|
+
);
|
|
418
|
+
const updatePost = (0, import_query2.useMutation)(
|
|
419
|
+
(updatedPost) => updateRequest(postTypeSlug, updatedPost),
|
|
420
|
+
{ onSuccess }
|
|
421
|
+
);
|
|
422
|
+
const deletePost = (0, import_query2.useMutation)(
|
|
423
|
+
(postId) => deleteRequest(postTypeSlug, postId),
|
|
424
|
+
{ onSuccess }
|
|
425
|
+
);
|
|
426
|
+
return {
|
|
427
|
+
createPost,
|
|
428
|
+
updatePost,
|
|
429
|
+
deletePost
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function useInvalidatePosts(postTypeSlug) {
|
|
433
|
+
const queryClient = (0, import_query2.useQueryClient)();
|
|
434
|
+
return (options = {}) => {
|
|
435
|
+
const queryKey = postsQueryKey(postTypeSlug);
|
|
436
|
+
return queryClient.invalidateQueries(queryKey, options);
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/components/panel/posts-list/list-items/edit-mode-template.tsx
|
|
441
|
+
var React8 = __toESM(require("react"));
|
|
442
|
+
var import_react6 = require("react");
|
|
443
|
+
var import_ui7 = require("@elementor/ui");
|
|
444
|
+
var import_icons6 = require("@elementor/icons");
|
|
445
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
446
|
+
function EditModeTemplate({ postTitle, isLoading, callback }) {
|
|
447
|
+
const inputRef = (0, import_react6.useRef)();
|
|
448
|
+
const [inputError, setInputError] = (0, import_react6.useState)("");
|
|
449
|
+
const closeButton = (0, import_react6.useRef)();
|
|
450
|
+
const onBlur = (e) => {
|
|
451
|
+
if (closeButton.current === e.relatedTarget) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
runCallback();
|
|
455
|
+
};
|
|
456
|
+
const onFormSubmit = (e) => {
|
|
457
|
+
e.preventDefault();
|
|
458
|
+
runCallback();
|
|
459
|
+
};
|
|
460
|
+
const validateInput = () => {
|
|
461
|
+
let isValid = true;
|
|
462
|
+
if (inputRef.current?.value === "") {
|
|
463
|
+
isValid = false;
|
|
464
|
+
setInputError((0, import_i18n4.__)("Name is required", "elementor"));
|
|
465
|
+
}
|
|
466
|
+
return isValid;
|
|
467
|
+
};
|
|
468
|
+
const runCallback = () => {
|
|
469
|
+
if (!validateInput()) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
callback(inputRef.current?.value || "");
|
|
473
|
+
};
|
|
474
|
+
return /* @__PURE__ */ React8.createElement(
|
|
475
|
+
import_ui7.ListItem,
|
|
476
|
+
{
|
|
477
|
+
selected: true,
|
|
478
|
+
disablePadding: true,
|
|
479
|
+
secondaryAction: /* @__PURE__ */ React8.createElement(CloseButton, { isLoading, closeButton })
|
|
480
|
+
},
|
|
481
|
+
/* @__PURE__ */ React8.createElement(import_ui7.ListItemIcon, null),
|
|
482
|
+
/* @__PURE__ */ React8.createElement(import_ui7.Box, { component: "form", onSubmit: onFormSubmit }, /* @__PURE__ */ React8.createElement(
|
|
483
|
+
import_ui7.TextField,
|
|
484
|
+
{
|
|
485
|
+
autoFocus: true,
|
|
486
|
+
ref: inputRef,
|
|
487
|
+
defaultValue: postTitle,
|
|
488
|
+
disabled: isLoading,
|
|
489
|
+
error: !!inputError,
|
|
490
|
+
onBlur,
|
|
491
|
+
variant: "outlined",
|
|
492
|
+
size: "small"
|
|
493
|
+
}
|
|
494
|
+
))
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
function CloseButton({ isLoading, closeButton }) {
|
|
498
|
+
const { resetEditMode } = usePostListContext();
|
|
499
|
+
return /* @__PURE__ */ React8.createElement(
|
|
500
|
+
import_ui7.IconButton,
|
|
501
|
+
{
|
|
502
|
+
size: "small",
|
|
503
|
+
onClick: resetEditMode,
|
|
504
|
+
ref: closeButton,
|
|
505
|
+
disabled: isLoading
|
|
506
|
+
},
|
|
507
|
+
isLoading ? /* @__PURE__ */ React8.createElement(import_ui7.CircularProgress, null) : /* @__PURE__ */ React8.createElement(import_icons6.XIcon, { fontSize: "small" })
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/components/panel/posts-list/list-items/list-item-rename.tsx
|
|
512
|
+
function ListItemRename({ post }) {
|
|
513
|
+
const { type, resetEditMode } = usePostListContext();
|
|
514
|
+
const { updatePost } = usePostActions(type);
|
|
515
|
+
const renamePostCallback = (inputValue) => {
|
|
516
|
+
if (inputValue === post.title.rendered) {
|
|
517
|
+
resetEditMode();
|
|
518
|
+
}
|
|
519
|
+
updatePost.mutateAsync({
|
|
520
|
+
id: post.id,
|
|
521
|
+
title: inputValue
|
|
522
|
+
}, {
|
|
523
|
+
onSuccess: () => {
|
|
524
|
+
resetEditMode();
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.isLoading, callback: renamePostCallback });
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// src/components/panel/posts-list/list-items/list-item-create.tsx
|
|
532
|
+
var React10 = __toESM(require("react"));
|
|
533
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
534
|
+
function ListItemCreate() {
|
|
535
|
+
const { type, resetEditMode } = usePostListContext();
|
|
536
|
+
const { createPost } = usePostActions(type);
|
|
537
|
+
const createPostCallback = (inputValue) => {
|
|
538
|
+
createPost.mutateAsync({
|
|
539
|
+
title: inputValue,
|
|
540
|
+
status: "draft"
|
|
541
|
+
}, {
|
|
542
|
+
onSuccess: () => {
|
|
543
|
+
resetEditMode();
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
};
|
|
547
|
+
return /* @__PURE__ */ React10.createElement(EditModeTemplate, { postTitle: (0, import_i18n5.__)("New Page", "elementor"), isLoading: createPost.isLoading, callback: createPostCallback });
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
// src/components/panel/posts-list/list-items/list-item-duplicate.tsx
|
|
551
|
+
var React11 = __toESM(require("react"));
|
|
552
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
553
|
+
function ListItemDuplicate() {
|
|
554
|
+
const { type, editMode, resetEditMode } = usePostListContext();
|
|
555
|
+
const { createPost } = usePostActions(type);
|
|
556
|
+
if ("duplicate" !== editMode.mode) {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
const duplicatePostCallback = (inputValue) => {
|
|
560
|
+
createPost.mutateAsync({
|
|
561
|
+
title: inputValue,
|
|
562
|
+
status: "draft"
|
|
563
|
+
}, {
|
|
564
|
+
onSuccess: () => {
|
|
565
|
+
resetEditMode();
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
return /* @__PURE__ */ React11.createElement(EditModeTemplate, { postTitle: `${editMode.details.title} ${(0, import_i18n6.__)("copy", "elementor")}`, isLoading: createPost.isLoading, callback: duplicatePostCallback });
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
573
|
+
var React20 = __toESM(require("react"));
|
|
312
574
|
var import_ui11 = require("@elementor/ui");
|
|
313
|
-
var
|
|
575
|
+
var import_icons12 = require("@elementor/icons");
|
|
314
576
|
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
315
577
|
|
|
316
578
|
// src/components/shared/page-title-and-status.tsx
|
|
317
|
-
var
|
|
318
|
-
var
|
|
579
|
+
var React12 = __toESM(require("react"));
|
|
580
|
+
var import_ui8 = require("@elementor/ui");
|
|
319
581
|
var PageStatus = ({ status }) => {
|
|
320
582
|
if ("publish" === status) {
|
|
321
583
|
return null;
|
|
322
584
|
}
|
|
323
|
-
return /* @__PURE__ */
|
|
324
|
-
|
|
585
|
+
return /* @__PURE__ */ React12.createElement(
|
|
586
|
+
import_ui8.Typography,
|
|
325
587
|
{
|
|
326
588
|
component: "span",
|
|
327
589
|
variant: "body1",
|
|
@@ -339,8 +601,8 @@ var PageStatus = ({ status }) => {
|
|
|
339
601
|
};
|
|
340
602
|
var PageTitle = ({ title }) => {
|
|
341
603
|
const modifiedTitle = useReverseHtmlEntities(title);
|
|
342
|
-
return /* @__PURE__ */
|
|
343
|
-
|
|
604
|
+
return /* @__PURE__ */ React12.createElement(
|
|
605
|
+
import_ui8.Typography,
|
|
344
606
|
{
|
|
345
607
|
component: "span",
|
|
346
608
|
variant: "body1",
|
|
@@ -353,260 +615,269 @@ var PageTitle = ({ title }) => {
|
|
|
353
615
|
);
|
|
354
616
|
};
|
|
355
617
|
function PageTitleAndStatus({ page }) {
|
|
356
|
-
return /* @__PURE__ */
|
|
618
|
+
return /* @__PURE__ */ React12.createElement(import_ui8.Box, { display: "flex" }, /* @__PURE__ */ React12.createElement(PageTitle, { title: page.title.rendered }), "\xA0", /* @__PURE__ */ React12.createElement(PageStatus, { status: page.status }));
|
|
357
619
|
}
|
|
358
620
|
|
|
359
|
-
// src/components/panel/actions-menu/
|
|
621
|
+
// src/components/panel/actions-menu/actions/rename.tsx
|
|
360
622
|
var React15 = __toESM(require("react"));
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
// src/components/panel/pages-actions/rename.tsx
|
|
364
|
-
var React10 = __toESM(require("react"));
|
|
365
|
-
var import_icons6 = require("@elementor/icons");
|
|
366
|
-
var import_i18n3 = require("@wordpress/i18n");
|
|
623
|
+
var import_icons7 = require("@elementor/icons");
|
|
624
|
+
var import_i18n7 = require("@wordpress/i18n");
|
|
367
625
|
|
|
368
626
|
// src/components/panel/actions-menu/action-menu-item.tsx
|
|
369
|
-
var
|
|
627
|
+
var React14 = __toESM(require("react"));
|
|
370
628
|
|
|
371
629
|
// src/components/panel/actions-menu/action-list-item.tsx
|
|
372
|
-
var
|
|
373
|
-
var
|
|
630
|
+
var React13 = __toESM(require("react"));
|
|
631
|
+
var import_ui9 = require("@elementor/ui");
|
|
374
632
|
function ActionListItem({ title, icon: Icon, disabled, onClick }) {
|
|
375
|
-
return /* @__PURE__ */
|
|
376
|
-
|
|
633
|
+
return /* @__PURE__ */ React13.createElement(
|
|
634
|
+
import_ui9.ListItemButton,
|
|
377
635
|
{
|
|
378
636
|
disabled,
|
|
379
637
|
onClick
|
|
380
638
|
},
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
639
|
+
/* @__PURE__ */ React13.createElement(import_ui9.ListItemIcon, null, /* @__PURE__ */ React13.createElement(Icon, null)),
|
|
640
|
+
/* @__PURE__ */ React13.createElement(import_ui9.ListItemText, null, title)
|
|
383
641
|
);
|
|
384
642
|
}
|
|
385
643
|
|
|
386
644
|
// src/components/panel/actions-menu/action-menu-item.tsx
|
|
387
|
-
var
|
|
645
|
+
var import_ui10 = require("@elementor/ui");
|
|
388
646
|
function ActionMenuItem(props) {
|
|
389
|
-
return /* @__PURE__ */
|
|
647
|
+
return /* @__PURE__ */ React14.createElement(import_ui10.MenuItem, { disableGutters: true }, /* @__PURE__ */ React14.createElement(ActionListItem, { ...props }));
|
|
390
648
|
}
|
|
391
649
|
|
|
392
|
-
// src/components/panel/
|
|
393
|
-
function Rename() {
|
|
394
|
-
|
|
650
|
+
// src/components/panel/actions-menu/actions/rename.tsx
|
|
651
|
+
function Rename({ post }) {
|
|
652
|
+
const { setEditMode } = usePostListContext();
|
|
653
|
+
return /* @__PURE__ */ React15.createElement(
|
|
395
654
|
ActionMenuItem,
|
|
396
655
|
{
|
|
397
|
-
title: (0,
|
|
398
|
-
icon:
|
|
399
|
-
onClick: () =>
|
|
656
|
+
title: (0, import_i18n7.__)("Rename", "elementor"),
|
|
657
|
+
icon: import_icons7.EraseIcon,
|
|
658
|
+
onClick: () => {
|
|
659
|
+
setEditMode({
|
|
660
|
+
mode: "rename",
|
|
661
|
+
details: {
|
|
662
|
+
postId: post.id
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
}
|
|
400
666
|
}
|
|
401
667
|
);
|
|
402
668
|
}
|
|
403
669
|
|
|
404
|
-
// src/components/panel/
|
|
405
|
-
var
|
|
406
|
-
var
|
|
407
|
-
var
|
|
408
|
-
function Duplicate() {
|
|
409
|
-
|
|
670
|
+
// src/components/panel/actions-menu/actions/duplicate.tsx
|
|
671
|
+
var React16 = __toESM(require("react"));
|
|
672
|
+
var import_icons8 = require("@elementor/icons");
|
|
673
|
+
var import_i18n8 = require("@wordpress/i18n");
|
|
674
|
+
function Duplicate({ post, popupState }) {
|
|
675
|
+
const { setEditMode } = usePostListContext();
|
|
676
|
+
return /* @__PURE__ */ React16.createElement(
|
|
410
677
|
ActionMenuItem,
|
|
411
678
|
{
|
|
412
|
-
title: (0,
|
|
413
|
-
icon:
|
|
414
|
-
onClick: () =>
|
|
679
|
+
title: (0, import_i18n8.__)("Duplicate", "elementor"),
|
|
680
|
+
icon: import_icons8.CopyIcon,
|
|
681
|
+
onClick: () => {
|
|
682
|
+
popupState.close();
|
|
683
|
+
setEditMode({
|
|
684
|
+
mode: "duplicate",
|
|
685
|
+
details: {
|
|
686
|
+
postId: post.id,
|
|
687
|
+
title: post.title.rendered
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
}
|
|
415
691
|
}
|
|
416
692
|
);
|
|
417
693
|
}
|
|
418
694
|
|
|
419
|
-
// src/components/panel/
|
|
420
|
-
var
|
|
421
|
-
var
|
|
695
|
+
// src/components/panel/actions-menu/actions/delete.tsx
|
|
696
|
+
var React17 = __toESM(require("react"));
|
|
697
|
+
var import_icons9 = require("@elementor/icons");
|
|
422
698
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
423
|
-
var
|
|
424
|
-
function Delete({
|
|
699
|
+
var import_i18n9 = require("@wordpress/i18n");
|
|
700
|
+
function Delete({ post }) {
|
|
425
701
|
const activeDocument = (0, import_editor_documents4.useActiveDocument)();
|
|
426
|
-
const isActive = activeDocument?.id ===
|
|
427
|
-
return /* @__PURE__ */
|
|
702
|
+
const isActive = activeDocument?.id === post.id;
|
|
703
|
+
return /* @__PURE__ */ React17.createElement(
|
|
428
704
|
ActionMenuItem,
|
|
429
705
|
{
|
|
430
|
-
title: (0,
|
|
431
|
-
icon:
|
|
432
|
-
disabled:
|
|
706
|
+
title: (0, import_i18n9.__)("Delete", "elementor"),
|
|
707
|
+
icon: import_icons9.TrashIcon,
|
|
708
|
+
disabled: post.isHome || isActive,
|
|
433
709
|
onClick: () => null
|
|
434
710
|
}
|
|
435
711
|
);
|
|
436
712
|
}
|
|
437
713
|
|
|
438
|
-
// src/components/panel/
|
|
439
|
-
var
|
|
440
|
-
var
|
|
441
|
-
var
|
|
442
|
-
function View() {
|
|
443
|
-
|
|
714
|
+
// src/components/panel/actions-menu/actions/view.tsx
|
|
715
|
+
var React18 = __toESM(require("react"));
|
|
716
|
+
var import_icons10 = require("@elementor/icons");
|
|
717
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
718
|
+
function View({ post }) {
|
|
719
|
+
const { type } = usePostListContext();
|
|
720
|
+
const title = (0, import_i18n10.__)("View %s", "elementor").replace("%s", postTypesMap[type].labels.singular_name);
|
|
721
|
+
return /* @__PURE__ */ React18.createElement(
|
|
444
722
|
ActionMenuItem,
|
|
445
723
|
{
|
|
446
|
-
title
|
|
447
|
-
icon:
|
|
448
|
-
onClick: () =>
|
|
724
|
+
title,
|
|
725
|
+
icon: import_icons10.EyeIcon,
|
|
726
|
+
onClick: () => {
|
|
727
|
+
console.log(post);
|
|
728
|
+
}
|
|
449
729
|
}
|
|
450
730
|
);
|
|
451
731
|
}
|
|
452
732
|
|
|
453
|
-
// src/components/panel/
|
|
454
|
-
var
|
|
455
|
-
var
|
|
456
|
-
var
|
|
457
|
-
function SetHome({
|
|
458
|
-
return /* @__PURE__ */
|
|
733
|
+
// src/components/panel/actions-menu/actions/set-home.tsx
|
|
734
|
+
var React19 = __toESM(require("react"));
|
|
735
|
+
var import_icons11 = require("@elementor/icons");
|
|
736
|
+
var import_i18n11 = require("@wordpress/i18n");
|
|
737
|
+
function SetHome({ post }) {
|
|
738
|
+
return /* @__PURE__ */ React19.createElement(
|
|
459
739
|
ActionMenuItem,
|
|
460
740
|
{
|
|
461
|
-
title: (0,
|
|
462
|
-
icon:
|
|
463
|
-
disabled: !!
|
|
741
|
+
title: (0, import_i18n11.__)("Set as homepage", "elementor"),
|
|
742
|
+
icon: import_icons11.HomeIcon,
|
|
743
|
+
disabled: !!post.isHome,
|
|
464
744
|
onClick: () => null
|
|
465
745
|
}
|
|
466
746
|
);
|
|
467
747
|
}
|
|
468
748
|
|
|
469
|
-
// src/components/panel/
|
|
470
|
-
function
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
{
|
|
474
|
-
PaperProps: { sx: { mt: 4, width: 200 } },
|
|
475
|
-
MenuListProps: { dense: true },
|
|
476
|
-
...props
|
|
477
|
-
},
|
|
478
|
-
/* @__PURE__ */ React15.createElement(Rename, null),
|
|
479
|
-
/* @__PURE__ */ React15.createElement(Duplicate, null),
|
|
480
|
-
/* @__PURE__ */ React15.createElement(Delete, { page }),
|
|
481
|
-
/* @__PURE__ */ React15.createElement(View, null),
|
|
482
|
-
/* @__PURE__ */ React15.createElement(import_ui10.Divider, null),
|
|
483
|
-
/* @__PURE__ */ React15.createElement(SetHome, { page })
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
// src/components/panel/pages-list/page-list-item.tsx
|
|
488
|
-
function PageListItem({ page }) {
|
|
749
|
+
// src/components/panel/posts-list/list-items/list-item-view.tsx
|
|
750
|
+
function ListItemView({ post }) {
|
|
751
|
+
const activeDocument = (0, import_editor_documents5.useActiveDocument)();
|
|
752
|
+
const navigateToDocument = (0, import_editor_documents5.useNavigateToDocument)();
|
|
489
753
|
const popupState = (0, import_ui11.usePopupState)({
|
|
490
754
|
variant: "popover",
|
|
491
|
-
popupId: "
|
|
755
|
+
popupId: "post-actions",
|
|
756
|
+
disableAutoFocus: true
|
|
492
757
|
});
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
const isActive = activeDocument?.id === page.id;
|
|
496
|
-
return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
|
|
758
|
+
const isActive = activeDocument?.id === post.id;
|
|
759
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(
|
|
497
760
|
import_ui11.ListItem,
|
|
498
761
|
{
|
|
499
762
|
disablePadding: true,
|
|
500
|
-
secondaryAction: /* @__PURE__ */
|
|
763
|
+
secondaryAction: /* @__PURE__ */ React20.createElement(
|
|
501
764
|
import_ui11.ToggleButton,
|
|
502
765
|
{
|
|
503
766
|
value: true,
|
|
504
|
-
color: "secondary",
|
|
505
767
|
size: "small",
|
|
506
768
|
selected: popupState.isOpen,
|
|
507
769
|
...(0, import_ui11.bindTrigger)(popupState)
|
|
508
770
|
},
|
|
509
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ React20.createElement(import_icons12.DotsVerticalIcon, { fontSize: "small" })
|
|
510
772
|
)
|
|
511
773
|
},
|
|
512
|
-
/* @__PURE__ */
|
|
774
|
+
/* @__PURE__ */ React20.createElement(
|
|
513
775
|
import_ui11.ListItemButton,
|
|
514
776
|
{
|
|
515
777
|
selected: isActive,
|
|
516
|
-
onClick: () =>
|
|
778
|
+
onClick: () => {
|
|
779
|
+
if (!isActive) {
|
|
780
|
+
navigateToDocument(post.id);
|
|
781
|
+
}
|
|
782
|
+
},
|
|
517
783
|
dense: true
|
|
518
784
|
},
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
/* @__PURE__ */
|
|
785
|
+
/* @__PURE__ */ React20.createElement(import_ui11.ListItemIcon, null),
|
|
786
|
+
/* @__PURE__ */ React20.createElement(
|
|
521
787
|
import_ui11.ListItemText,
|
|
522
788
|
{
|
|
523
789
|
disableTypography: true
|
|
524
790
|
},
|
|
525
|
-
/* @__PURE__ */
|
|
791
|
+
/* @__PURE__ */ React20.createElement(PageTitleAndStatus, { page: post })
|
|
526
792
|
),
|
|
527
|
-
|
|
793
|
+
post.isHome && /* @__PURE__ */ React20.createElement(import_ui11.ListItemIcon, null, /* @__PURE__ */ React20.createElement(import_icons12.HomeIcon, { color: "disabled" }))
|
|
528
794
|
)
|
|
529
|
-
), /* @__PURE__ */
|
|
795
|
+
), /* @__PURE__ */ React20.createElement(
|
|
796
|
+
import_ui11.Menu,
|
|
797
|
+
{
|
|
798
|
+
PaperProps: { sx: { mt: 4, width: 200 } },
|
|
799
|
+
MenuListProps: { dense: true },
|
|
800
|
+
...(0, import_ui11.bindMenu)(popupState)
|
|
801
|
+
},
|
|
802
|
+
/* @__PURE__ */ React20.createElement(Rename, { post }),
|
|
803
|
+
/* @__PURE__ */ React20.createElement(Duplicate, { post, popupState }),
|
|
804
|
+
/* @__PURE__ */ React20.createElement(Delete, { post }),
|
|
805
|
+
/* @__PURE__ */ React20.createElement(View, { post }),
|
|
806
|
+
/* @__PURE__ */ React20.createElement(import_ui11.Divider, null),
|
|
807
|
+
/* @__PURE__ */ React20.createElement(SetHome, { post })
|
|
808
|
+
));
|
|
530
809
|
}
|
|
531
810
|
|
|
532
|
-
// src/
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
});
|
|
548
|
-
const uri = baseUri + "?" + queryParams.toString();
|
|
549
|
-
return (0, import_api_fetch3.default)({ path: uri });
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
// src/hooks/use-posts.ts
|
|
553
|
-
var postsQueryKey = (postTypeSlug) => ["site-navigation", "posts", postTypeSlug];
|
|
554
|
-
function usePosts(postTypeSlug) {
|
|
555
|
-
return (0, import_query.useQuery)({
|
|
556
|
-
queryKey: postsQueryKey(postTypeSlug),
|
|
557
|
-
queryFn: () => getRequest(postTypeSlug)
|
|
558
|
-
});
|
|
811
|
+
// src/components/panel/posts-list/post-list-item.tsx
|
|
812
|
+
function PostListItem2({ post }) {
|
|
813
|
+
const { editMode } = usePostListContext();
|
|
814
|
+
if ("rename" === editMode.mode && post?.id && post?.id === editMode.details.postId) {
|
|
815
|
+
return /* @__PURE__ */ React21.createElement(ListItemRename, { post });
|
|
816
|
+
}
|
|
817
|
+
if ("create" === editMode.mode && !post) {
|
|
818
|
+
return /* @__PURE__ */ React21.createElement(ListItemCreate, null);
|
|
819
|
+
}
|
|
820
|
+
if ("duplicate" === editMode.mode && !post) {
|
|
821
|
+
return /* @__PURE__ */ React21.createElement(ListItemDuplicate, null);
|
|
822
|
+
}
|
|
823
|
+
if (!post) {
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
return /* @__PURE__ */ React21.createElement(ListItemView, { post });
|
|
559
827
|
}
|
|
560
828
|
|
|
561
|
-
// src/components/panel/
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
const { data:
|
|
565
|
-
if (!
|
|
566
|
-
return /* @__PURE__ */
|
|
829
|
+
// src/components/panel/posts-list/posts-collapsible-list.tsx
|
|
830
|
+
function PostsCollapsibleList({ isOpenByDefault = false }) {
|
|
831
|
+
const { type, editMode } = usePostListContext();
|
|
832
|
+
const { data: posts, isLoading: postsLoading } = usePosts(type);
|
|
833
|
+
if (!posts || postsLoading) {
|
|
834
|
+
return /* @__PURE__ */ React22.createElement(import_ui12.Box, { spacing: 4, sx: { px: 6 } }, /* @__PURE__ */ React22.createElement(import_ui12.Skeleton, { variant: "text", sx: { fontSize: "2rem" } }), /* @__PURE__ */ React22.createElement(import_ui12.Skeleton, { variant: "rounded", width: "100%", height: "48" }));
|
|
567
835
|
}
|
|
568
|
-
const label =
|
|
569
|
-
return /* @__PURE__ */
|
|
836
|
+
const label = `${postTypesMap[type].labels.plural_name} (${posts.length.toString()})`;
|
|
837
|
+
return /* @__PURE__ */ React22.createElement(import_ui12.List, { dense: true }, /* @__PURE__ */ React22.createElement(
|
|
570
838
|
CollapsibleList,
|
|
571
839
|
{
|
|
572
840
|
label,
|
|
573
|
-
Icon:
|
|
574
|
-
isOpenByDefault
|
|
841
|
+
Icon: import_icons13.PageTypeIcon,
|
|
842
|
+
isOpenByDefault: isOpenByDefault || false
|
|
575
843
|
},
|
|
576
|
-
|
|
577
|
-
|
|
844
|
+
posts.map((post) => /* @__PURE__ */ React22.createElement(PostListItem2, { key: post.id, post })),
|
|
845
|
+
["duplicate", "create"].includes(editMode.mode) && /* @__PURE__ */ React22.createElement(PostListItem2, null)
|
|
846
|
+
));
|
|
578
847
|
}
|
|
579
848
|
|
|
580
|
-
// src/components/panel/
|
|
581
|
-
var
|
|
582
|
-
|
|
583
|
-
// src/components/panel/add-new-page-button.tsx
|
|
849
|
+
// src/components/panel/add-new-button.tsx
|
|
850
|
+
var React23 = __toESM(require("react"));
|
|
584
851
|
var import_ui13 = require("@elementor/ui");
|
|
585
|
-
var
|
|
586
|
-
var
|
|
587
|
-
function
|
|
588
|
-
|
|
852
|
+
var import_icons14 = require("@elementor/icons");
|
|
853
|
+
var import_i18n12 = require("@wordpress/i18n");
|
|
854
|
+
function AddNewButton() {
|
|
855
|
+
const { setEditMode } = usePostListContext();
|
|
856
|
+
return /* @__PURE__ */ React23.createElement(
|
|
589
857
|
import_ui13.Button,
|
|
590
858
|
{
|
|
859
|
+
size: "small",
|
|
591
860
|
sx: { mt: 4, mb: 4, mr: 5 },
|
|
592
|
-
startIcon: /* @__PURE__ */
|
|
593
|
-
onClick: () =>
|
|
861
|
+
startIcon: /* @__PURE__ */ React23.createElement(import_icons14.PlusIcon, null),
|
|
862
|
+
onClick: () => {
|
|
863
|
+
setEditMode({ mode: "create", details: {} });
|
|
864
|
+
}
|
|
594
865
|
},
|
|
595
|
-
"Add New"
|
|
866
|
+
(0, import_i18n12.__)("Add New", "elementor")
|
|
596
867
|
);
|
|
597
868
|
}
|
|
598
869
|
|
|
599
870
|
// src/components/panel/shell.tsx
|
|
600
871
|
var Shell = () => {
|
|
601
|
-
return /* @__PURE__ */
|
|
872
|
+
return /* @__PURE__ */ React24.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React24.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React24.createElement(import_editor_panels.PanelHeaderTitle, null, (0, import_i18n13.__)("Pages", "elementor"))), /* @__PURE__ */ React24.createElement(import_editor_panels.PanelBody, null, /* @__PURE__ */ React24.createElement(PostListContextProvider, { type: "page" }, /* @__PURE__ */ React24.createElement(
|
|
602
873
|
import_ui14.Box,
|
|
603
874
|
{
|
|
604
875
|
display: "flex",
|
|
605
876
|
justifyContent: "flex-end",
|
|
606
877
|
alignItems: "center"
|
|
607
878
|
},
|
|
608
|
-
/* @__PURE__ */
|
|
609
|
-
), /* @__PURE__ */
|
|
879
|
+
/* @__PURE__ */ React24.createElement(AddNewButton, null)
|
|
880
|
+
), /* @__PURE__ */ React24.createElement(PostsCollapsibleList, { isOpenByDefault: true }))));
|
|
610
881
|
};
|
|
611
882
|
var shell_default = Shell;
|
|
612
883
|
|
|
@@ -625,8 +896,8 @@ function useToggleButtonProps() {
|
|
|
625
896
|
const { isOpen, isBlocked } = usePanelStatus();
|
|
626
897
|
const { open, close } = usePanelActions();
|
|
627
898
|
return {
|
|
628
|
-
title: (0,
|
|
629
|
-
icon:
|
|
899
|
+
title: (0, import_i18n14.__)("Pages", "elementor"),
|
|
900
|
+
icon: import_icons15.PagesIcon,
|
|
630
901
|
onClick: () => isOpen ? close() : open(),
|
|
631
902
|
selected: isOpen,
|
|
632
903
|
disabled: isBlocked
|
|
@@ -645,7 +916,7 @@ var { env, validateEnv } = (0, import_env.parseEnv)("@elementor/editor-site-navi
|
|
|
645
916
|
// src/init.ts
|
|
646
917
|
function init() {
|
|
647
918
|
registerTopBarMenuItems();
|
|
648
|
-
if (env.
|
|
919
|
+
if (env.is_pages_panel_active) {
|
|
649
920
|
(0, import_editor_panels3.registerPanel)(panel);
|
|
650
921
|
registerButton();
|
|
651
922
|
}
|