@elementor/editor-site-navigation 0.22.5 → 0.22.7

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 (44) hide show
  1. package/CHANGELOG.md +38 -328
  2. package/dist/index.js +147 -156
  3. package/dist/index.mjs +168 -175
  4. package/package.json +49 -49
  5. package/src/api/post.ts +18 -18
  6. package/src/api/recent-posts.ts +1 -1
  7. package/src/api/settings.ts +4 -4
  8. package/src/api/user.ts +4 -4
  9. package/src/components/panel/actions-menu/action-menu-item.tsx +7 -10
  10. package/src/components/panel/actions-menu/actions/__tests__/set-home.test.tsx +12 -9
  11. package/src/components/panel/actions-menu/actions/delete.tsx +27 -25
  12. package/src/components/panel/actions-menu/actions/duplicate.tsx +5 -7
  13. package/src/components/panel/actions-menu/actions/rename.tsx +11 -13
  14. package/src/components/panel/actions-menu/actions/set-home.tsx +6 -8
  15. package/src/components/panel/actions-menu/actions/view.tsx +3 -5
  16. package/src/components/panel/error-snackbar.tsx +4 -3
  17. package/src/components/panel/panel.ts +1 -5
  18. package/src/components/panel/posts-list/__tests__/posts-collapsible-list.test.tsx +66 -19
  19. package/src/components/panel/posts-list/collapsible-list.tsx +38 -29
  20. package/src/components/panel/posts-list/error-state.tsx +35 -27
  21. package/src/components/panel/posts-list/list-items/edit-mode-template.tsx +18 -40
  22. package/src/components/panel/posts-list/list-items/list-item-create.tsx +5 -1
  23. package/src/components/panel/posts-list/list-items/list-item-duplicate.tsx +5 -1
  24. package/src/components/panel/posts-list/list-items/list-item-rename.tsx +3 -5
  25. package/src/components/panel/posts-list/list-items/list-item-view.tsx +20 -19
  26. package/src/components/panel/posts-list/posts-collapsible-list.tsx +22 -24
  27. package/src/components/shared/page-title-and-status.tsx +4 -2
  28. package/src/components/top-bar/__tests__/add-new-page.test.tsx +33 -16
  29. package/src/components/top-bar/__tests__/recently-edited.test.tsx +157 -120
  30. package/src/components/top-bar/chip-doc-type.tsx +1 -3
  31. package/src/components/top-bar/create-post-list-item.tsx +1 -1
  32. package/src/components/top-bar/indicator.tsx +17 -15
  33. package/src/components/top-bar/post-list-item.tsx +2 -6
  34. package/src/components/top-bar/recently-edited.tsx +13 -19
  35. package/src/contexts/post-list-context.tsx +40 -34
  36. package/src/env.ts +2 -2
  37. package/src/hooks/__tests__/use-posts.test.ts +19 -3
  38. package/src/hooks/use-create-page.ts +2 -2
  39. package/src/hooks/use-homepage.ts +1 -1
  40. package/src/hooks/use-posts.ts +1 -1
  41. package/src/hooks/use-toggle-button-props.ts +1 -5
  42. package/src/hooks/use-user.ts +1 -1
  43. package/src/icons-map.ts +1 -1
  44. package/src/types.ts +22 -22
@@ -11,7 +11,14 @@ jest.mock( '@wordpress/api-fetch', () => ( {
11
11
  const pages = [
12
12
  { id: 1, type: 'page', title: { rendered: 'Home' }, status: 'draft', link: 'www.test.demo' },
13
13
  { id: 2, type: 'page', title: { rendered: 'About' }, status: 'publish', link: 'www.test.demo' },
14
- { id: 3, type: 'page', title: { rendered: 'Services' }, status: 'publish', link: 'www.test.demo', isHome: true },
14
+ {
15
+ id: 3,
16
+ type: 'page',
17
+ title: { rendered: 'Services' },
18
+ status: 'publish',
19
+ link: 'www.test.demo',
20
+ isHome: true,
21
+ },
15
22
  ];
16
23
 
17
24
  const url = new URL( 'http:/example.com' + param.path );
@@ -51,14 +58,23 @@ describe( '@elementor/site-settings/use-posts', () => {
51
58
  const pages = [
52
59
  { id: 1, type: 'page', title: { rendered: 'Home' }, status: 'draft', link: 'www.test.demo' },
53
60
  { id: 2, type: 'page', title: { rendered: 'About' }, status: 'publish', link: 'www.test.demo' },
54
- { id: 3, type: 'page', title: { rendered: 'Services' }, status: 'publish', link: 'www.test.demo', isHome: true },
61
+ {
62
+ id: 3,
63
+ type: 'page',
64
+ title: { rendered: 'Services' },
65
+ status: 'publish',
66
+ link: 'www.test.demo',
67
+ isHome: true,
68
+ },
55
69
  ];
56
70
 
57
71
  // Act.
58
72
  const { component } = renderHookWithQuery( () => usePosts( 'page' ) );
59
73
 
60
74
  // Assert.
61
- const expectedPath = `/wp/v2/pages?status=any&order=asc&page=1&per_page=${ POST_PER_PAGE }&_fields=${ encodeURIComponent( 'id,type,title,link,status,user_can' ) }`;
75
+ const expectedPath = `/wp/v2/pages?status=any&order=asc&page=1&per_page=${ POST_PER_PAGE }&_fields=${ encodeURIComponent(
76
+ 'id,type,title,link,status,user_can'
77
+ ) }`;
62
78
 
63
79
  expect( apiFetch ).toHaveBeenCalledWith( {
64
80
  parse: false,
@@ -2,8 +2,8 @@ import apiFetch from '@wordpress/api-fetch';
2
2
  import { useState } from 'react';
3
3
 
4
4
  export interface NewPost {
5
- id: number,
6
- edit_url: string,
5
+ id: number;
6
+ edit_url: string;
7
7
  }
8
8
 
9
9
  export const endpointPath = '/elementor/v1/site-navigation/add-new-post';
@@ -3,7 +3,7 @@ import { getSettings } from '../api/settings';
3
3
 
4
4
  export const settingsQueryKey = () => [ 'site-navigation', 'homepage' ];
5
5
 
6
- export function useHomepage( ) {
6
+ export function useHomepage() {
7
7
  return useQuery( {
8
8
  queryKey: settingsQueryKey(),
9
9
  queryFn: () => getSettings(),
@@ -4,7 +4,7 @@ import { Post } from '../types';
4
4
 
5
5
  export const postsQueryKey = ( postTypeSlug: string ) => [ 'site-navigation', 'posts', postTypeSlug ];
6
6
 
7
- const flattenData = ( data?: {pages: PostsResponse[]} ) => {
7
+ const flattenData = ( data?: { pages: PostsResponse[] } ) => {
8
8
  if ( ! data ) {
9
9
  return data;
10
10
  }
@@ -9,11 +9,7 @@ export function useToggleButtonProps() {
9
9
  return {
10
10
  title: __( 'Pages', 'elementor' ),
11
11
  icon: PagesIcon,
12
- onClick: () => (
13
- isOpen
14
- ? close()
15
- : open()
16
- ),
12
+ onClick: () => ( isOpen ? close() : open() ),
17
13
  selected: isOpen,
18
14
  disabled: isBlocked,
19
15
  };
@@ -3,7 +3,7 @@ import { getUser } from '../api/user';
3
3
 
4
4
  export const userQueryKey = () => [ 'site-navigation', 'user' ];
5
5
 
6
- export default function useUser( ) {
6
+ export default function useUser() {
7
7
  return useQuery( {
8
8
  queryKey: userQueryKey(),
9
9
  queryFn: () => getUser(),
package/src/icons-map.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  import * as React from 'react';
10
10
 
11
11
  type IconsMap = {
12
- [key: string]: React.ElementType;
12
+ [ key: string ]: React.ElementType;
13
13
  };
14
14
 
15
15
  const initialIconsMap: IconsMap = {
package/src/types.ts CHANGED
@@ -14,33 +14,33 @@ export type Post = {
14
14
  };
15
15
 
16
16
  export type RecentPost = {
17
- id: number,
18
- title: string,
19
- edit_url: string,
17
+ id: number;
18
+ title: string;
19
+ edit_url: string;
20
20
  type: {
21
- post_type: string,
22
- doc_type: string,
23
- label: string,
24
- },
25
- date_modified: number,
21
+ post_type: string;
22
+ doc_type: string;
23
+ label: string;
24
+ };
25
+ date_modified: number;
26
26
  user_can: {
27
- edit: boolean,
28
- },
29
- }
27
+ edit: boolean;
28
+ };
29
+ };
30
30
 
31
31
  export type ExtendedWindow = Window & {
32
32
  elementor: {
33
33
  editorEvents: {
34
- dispatchEvent: ( name: string, data: Record<string, string> ) => void
34
+ dispatchEvent: ( name: string, data: Record< string, string > ) => void;
35
35
  config: {
36
- locations: Record<string, string>,
37
- secondaryLocations: Record<string, string>,
38
- triggers: Record<string, string>,
39
- elements: Record<string, string>
36
+ locations: Record< string, string >;
37
+ secondaryLocations: Record< string, string >;
38
+ triggers: Record< string, string >;
39
+ elements: Record< string, string >;
40
40
  names: {
41
- topBar: Record<string, string>
42
- }
43
- }
44
- }
45
- }
46
- }
41
+ topBar: Record< string, string >;
42
+ };
43
+ };
44
+ };
45
+ };
46
+ };