@elementor/editor-site-navigation 4.5.0-1204 → 4.5.0-1206

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-site-navigation",
3
- "version": "4.5.0-1204",
3
+ "version": "4.5.0-1206",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,15 +39,16 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor-app-bar": "4.5.0-1204",
43
- "@elementor/editor-sidebar": "4.5.0-1204",
44
- "@elementor/editor-documents": "4.5.0-1204",
45
- "@elementor/editor-panels": "4.5.0-1204",
46
- "@elementor/editor-v1-adapters": "4.5.0-1204",
47
- "@elementor/env": "4.5.0-1204",
42
+ "@elementor/editor-app-bar": "4.5.0-1206",
43
+ "@elementor/editor-documents": "4.5.0-1206",
44
+ "@elementor/editor-panels": "4.5.0-1206",
45
+ "@elementor/editor-sidebar": "4.5.0-1206",
46
+ "@elementor/editor-ui": "4.5.0-1206",
47
+ "@elementor/editor-v1-adapters": "4.5.0-1206",
48
+ "@elementor/env": "4.5.0-1206",
48
49
  "@elementor/icons": "~1.78.1",
49
- "@elementor/events": "4.5.0-1204",
50
- "@elementor/query": "4.5.0-1204",
50
+ "@elementor/events": "4.5.0-1206",
51
+ "@elementor/query": "4.5.0-1206",
51
52
  "@elementor/ui": "1.41.4",
52
53
  "@wordpress/api-fetch": "^6.42.0",
53
54
  "@wordpress/i18n": "^5.13.0"
package/src/api/post.ts CHANGED
@@ -22,9 +22,24 @@ export const postTypesMap = {
22
22
  plural_name: __( 'Pages', 'elementor' ),
23
23
  },
24
24
  rest_base: 'pages',
25
+ createCapability: 'edit_pages',
26
+ },
27
+ post: {
28
+ labels: {
29
+ singular_name: __( 'Post', 'elementor' ),
30
+ plural_name: __( 'Posts', 'elementor' ),
31
+ },
32
+ rest_base: 'posts',
33
+ createCapability: 'edit_posts',
25
34
  },
26
35
  };
27
36
 
37
+ export const panelPostTypeSlugs = Object.keys( postTypesMap ) as Slug[];
38
+
39
+ export function getPostTypeCreateCapability( postTypeSlug: Slug ): string {
40
+ return postTypesMap[ postTypeSlug ].createCapability;
41
+ }
42
+
28
43
  export const POST_PER_PAGE = 10;
29
44
 
30
45
  type WpPostsResponse = {
@@ -41,7 +56,7 @@ export type PostsResponse = {
41
56
  currentPage: number;
42
57
  };
43
58
 
44
- export const getRequest = async ( postTypeSlug: Slug, page: number ): Promise< PostsResponse > => {
59
+ export const getRequest = async ( postTypeSlug: Slug, page: number, search = '' ): Promise< PostsResponse > => {
45
60
  const baseUri = `/wp/v2/${ postTypesMap[ postTypeSlug ].rest_base }`;
46
61
 
47
62
  const keys: Array< keyof Post > = [ 'id', 'type', 'title', 'link', 'status', 'user_can' ];
@@ -54,6 +69,12 @@ export const getRequest = async ( postTypeSlug: Slug, page: number ): Promise< P
54
69
  _fields: keys.join( ',' ),
55
70
  } );
56
71
 
72
+ const trimmedSearch = search.trim();
73
+
74
+ if ( trimmedSearch ) {
75
+ queryParams.set( 'search', trimmedSearch );
76
+ }
77
+
57
78
  const uri = baseUri + '?' + queryParams.toString();
58
79
 
59
80
  const result = await apiFetch< WpPostsResponse >( { path: uri, parse: false } );
@@ -59,6 +59,17 @@ function DeleteDialog( {
59
59
  /* translators: %s: Post title. */
60
60
  const dialogTitle = sprintf( __( 'Delete "%s"?', 'elementor' ), post.title.rendered );
61
61
 
62
+ const dialogBody =
63
+ type === 'post'
64
+ ? __(
65
+ 'The post and its content will be deleted forever and we won’t be able to recover them.',
66
+ 'elementor'
67
+ )
68
+ : __(
69
+ 'The page and its content will be deleted forever and we won’t be able to recover them.',
70
+ 'elementor'
71
+ );
72
+
62
73
  const deletePage = async () => {
63
74
  try {
64
75
  await deletePost.mutateAsync( post.id );
@@ -81,12 +92,7 @@ function DeleteDialog( {
81
92
  <DialogTitle noWrap>{ dialogTitle }</DialogTitle>
82
93
  <Divider />
83
94
  <DialogContent>
84
- <DialogContentText>
85
- { __(
86
- 'The page and its content will be deleted forever and we won’t be able to recover them.',
87
- 'elementor'
88
- ) }
89
- </DialogContentText>
95
+ <DialogContentText>{ dialogBody }</DialogContentText>
90
96
  </DialogContent>
91
97
  <DialogActions>
92
98
  <Button
@@ -3,14 +3,16 @@ import { CopyIcon } from '@elementor/icons';
3
3
  import { type PopupState } from '@elementor/ui';
4
4
  import { __ } from '@wordpress/i18n';
5
5
 
6
+ import { getPostTypeCreateCapability } from '../../../../api/post';
6
7
  import { usePostListContext } from '../../../../contexts/post-list-context';
7
8
  import useUser from '../../../../hooks/use-user';
8
9
  import { type Post } from '../../../../types';
9
10
  import ActionMenuItem from '../action-menu-item';
10
11
 
11
12
  export default function Duplicate( { post, popupState }: { post: Post; popupState: PopupState } ) {
12
- const { setEditMode } = usePostListContext();
13
+ const { setEditMode, type } = usePostListContext();
13
14
  const { data: user } = useUser();
15
+ const createCapability = getPostTypeCreateCapability( type );
14
16
  const onClick = () => {
15
17
  popupState.close();
16
18
 
@@ -23,7 +25,7 @@ export default function Duplicate( { post, popupState }: { post: Post; popupStat
23
25
  } );
24
26
  };
25
27
 
26
- const isDisabled = ! user?.capabilities?.edit_pages;
28
+ const isDisabled = ! user?.capabilities?.[ createCapability ];
27
29
 
28
30
  return (
29
31
  <ActionMenuItem
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { PlusIcon } from '@elementor/icons';
3
+ import { IconButton, type IconButtonProps } from '@elementor/ui';
4
+
5
+ export const CONTENT_PANEL_ADD_ICON_SIZE = 'tiny';
6
+
7
+ type ContentPanelAddIconButtonProps = Omit< IconButtonProps, 'children' | 'size' | 'variant' >;
8
+
9
+ export default function ContentPanelAddIconButton( props: ContentPanelAddIconButtonProps ) {
10
+ return (
11
+ <IconButton size={ CONTENT_PANEL_ADD_ICON_SIZE } variant="outlined" { ...props }>
12
+ <PlusIcon fontSize={ CONTENT_PANEL_ADD_ICON_SIZE } />
13
+ </IconButton>
14
+ );
15
+ }
@@ -0,0 +1,65 @@
1
+ const CONTENT_PANEL_INSET_SPACING = 2;
2
+ const CONTENT_PANEL_LIST_ROW_GAP = 0.5;
3
+ const CONTENT_PANEL_LIST_ROW_INSET_INLINE = 0.75;
4
+ const CONTENT_PANEL_LIST_ROW_TITLE_FONT_SIZE = '0.75rem';
5
+ const CONTENT_PANEL_LIST_SECTION_BOTTOM_SPACING = 1;
6
+
7
+ const CONTENT_PANEL_SECTION_HEADER_PADDING_BLOCK = 1.25;
8
+ const CONTENT_PANEL_SECTION_HEADER_TRAILING_GAP = 0.75;
9
+ const CONTENT_PANEL_SEARCH_PADDING_BLOCK = 1.5;
10
+
11
+ export const contentPanelInsetPaddingSx = {
12
+ paddingInline: CONTENT_PANEL_INSET_SPACING,
13
+ };
14
+
15
+ export const contentPanelListRowPaddingSx = {
16
+ ...contentPanelInsetPaddingSx,
17
+ };
18
+
19
+ export const contentPanelHeaderStackSx = {
20
+ width: '100%',
21
+ };
22
+
23
+ export const contentPanelSearchBoxSx = {
24
+ ...contentPanelInsetPaddingSx,
25
+ py: CONTENT_PANEL_SEARCH_PADDING_BLOCK,
26
+ };
27
+
28
+ export const contentPanelSectionHeaderSx = {
29
+ ...contentPanelInsetPaddingSx,
30
+ py: CONTENT_PANEL_SECTION_HEADER_PADDING_BLOCK,
31
+ };
32
+
33
+ export const contentPanelSectionHeaderTrailingGap = CONTENT_PANEL_SECTION_HEADER_TRAILING_GAP;
34
+
35
+ export const contentPanelFullBleedDividerSx = {
36
+ marginInline: 0,
37
+ width: '100%',
38
+ };
39
+
40
+ export const contentPanelListRowTitleSx = {
41
+ fontSize: CONTENT_PANEL_LIST_ROW_TITLE_FONT_SIZE,
42
+ };
43
+
44
+ export const contentPanelListSectionListSx = {
45
+ display: 'flex',
46
+ flexDirection: 'column',
47
+ gap: CONTENT_PANEL_LIST_ROW_GAP,
48
+ paddingBlockEnd: CONTENT_PANEL_LIST_SECTION_BOTTOM_SPACING,
49
+ };
50
+
51
+ export const contentPanelListItemButtonSx = {
52
+ justifyContent: 'flex-start',
53
+ paddingInline: CONTENT_PANEL_LIST_ROW_INSET_INLINE,
54
+ textAlign: 'start',
55
+ width: '100%',
56
+ '&.Mui-selected': {
57
+ backgroundColor: 'action.selected',
58
+ },
59
+ '&.Mui-selected:hover': {
60
+ backgroundColor: 'action.selected',
61
+ },
62
+ '&:hover:not(.Mui-disabled)': {
63
+ backgroundColor: 'action.hover',
64
+ },
65
+ };
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+ import { PageTypeIcon, PostTypeIcon } from '@elementor/icons';
3
+ import { bindMenu, bindTrigger, ListItemIcon, ListItemText, Menu, MenuItem, usePopupState } from '@elementor/ui';
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ import { getPostTypeCreateCapability, panelPostTypeSlugs, postTypesMap, type Slug } from '../../api/post';
7
+ import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
8
+ import useUser from '../../hooks/use-user';
9
+ import ContentPanelAddIconButton from './content-panel-add-icon-button';
10
+
11
+ const typeIcons: Record< Slug, typeof PageTypeIcon > = {
12
+ page: PageTypeIcon,
13
+ post: PostTypeIcon,
14
+ };
15
+
16
+ export default function ContentPanelHeaderAdd() {
17
+ const { requestCreate } = useContentPanelCoordinator();
18
+ const { data: user } = useUser();
19
+ const popupState = usePopupState( {
20
+ variant: 'popover',
21
+ popupId: 'elementor-content-panel-header-add',
22
+ } );
23
+
24
+ const buttonProps = bindTrigger( popupState );
25
+ const menuProps = bindMenu( popupState );
26
+
27
+ return (
28
+ <>
29
+ <ContentPanelAddIconButton aria-label={ __( 'Add new', 'elementor' ) } { ...buttonProps } />
30
+ <Menu { ...menuProps }>
31
+ { panelPostTypeSlugs.map( ( slug ) => {
32
+ const Icon = typeIcons[ slug ];
33
+ const createCapability = getPostTypeCreateCapability( slug );
34
+ const singularName = postTypesMap[ slug ].labels.singular_name;
35
+
36
+ return (
37
+ <MenuItem
38
+ key={ slug }
39
+ disabled={ ! user?.capabilities?.[ createCapability ] }
40
+ onClick={ () => {
41
+ popupState.close();
42
+ requestAnimationFrame( () => {
43
+ requestCreate( slug );
44
+ } );
45
+ } }
46
+ >
47
+ <ListItemIcon>
48
+ <Icon fontSize="small" />
49
+ </ListItemIcon>
50
+ <ListItemText primary={ singularName } primaryTypographyProps={ { variant: 'body2' } } />
51
+ </MenuItem>
52
+ );
53
+ } ) }
54
+ </Menu>
55
+ </>
56
+ );
57
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import { SearchIcon } from '@elementor/icons';
3
+ import { Box, InputAdornment, TextField } from '@elementor/ui';
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ import { useContentPanelCoordinator } from '../../contexts/content-panel-coordinator';
7
+ import { contentPanelSearchBoxSx } from './content-panel-chrome';
8
+
9
+ export default function ContentPanelSearch() {
10
+ const { searchQuery, setSearchQuery } = useContentPanelCoordinator();
11
+
12
+ return (
13
+ <Box component="search" sx={ contentPanelSearchBoxSx } aria-label={ __( 'Search site content', 'elementor' ) }>
14
+ <TextField
15
+ fullWidth
16
+ size="tiny"
17
+ value={ searchQuery }
18
+ placeholder={ __( 'Search', 'elementor' ) }
19
+ onChange={ ( event: React.ChangeEvent< HTMLInputElement > ) => setSearchQuery( event.target.value ) }
20
+ inputProps={ {
21
+ 'aria-label': __( 'Search', 'elementor' ),
22
+ } }
23
+ InputProps={ {
24
+ startAdornment: (
25
+ <InputAdornment position="start">
26
+ <SearchIcon fontSize="tiny" />
27
+ </InputAdornment>
28
+ ),
29
+ } }
30
+ />
31
+ </Box>
32
+ );
33
+ }
@@ -1,85 +1,107 @@
1
1
  import * as React from 'react';
2
- import { type PropsWithChildren, useState } from 'react';
3
- import { ChevronDownIcon } from '@elementor/icons';
2
+ import { type PropsWithChildren, type ReactNode, useId } from 'react';
3
+ import { CollapseIcon } from '@elementor/editor-ui';
4
+ import { Box, Chip, Collapse, Divider, List, ListItemButton, ListItemText, Stack } from '@elementor/ui';
5
+
4
6
  import {
5
- Collapse,
6
- Divider,
7
- IconButton,
8
- List,
9
- ListItem,
10
- ListItemIcon,
11
- ListItemText,
12
- styled,
13
- type SvgIconProps,
14
- } from '@elementor/ui';
7
+ contentPanelListSectionListSx,
8
+ contentPanelSectionHeaderSx,
9
+ contentPanelSectionHeaderTrailingGap,
10
+ } from '../content-panel-chrome';
15
11
 
16
12
  type Props = {
17
- label: string;
18
- Icon: React.ForwardRefExoticComponent< Omit< SvgIconProps, 'ref' > >;
19
- isOpenByDefault?: boolean;
20
- };
21
-
22
- interface RotateIconProps extends SvgIconProps {
13
+ count: number;
23
14
  isOpen: boolean;
24
- }
15
+ onOpenChange: ( isOpen: boolean ) => void;
16
+ title: string;
17
+ trailingActions?: ReactNode;
18
+ };
25
19
 
26
- // TODO 21/06/2023 : Should replace this with future Rotate component that will be implemented in elementor-ui
27
- const RotateIcon = styled( ChevronDownIcon, {
28
- shouldForwardProp: ( prop ) => prop !== 'isOpen',
29
- } )< RotateIconProps >( ( { theme, isOpen } ) => ( {
30
- transform: isOpen ? 'rotate(0deg)' : 'rotate(-90deg)',
31
- transition: theme.transitions.create( 'transform', {
32
- duration: theme.transitions.duration.standard,
33
- } ),
34
- } ) );
20
+ const sectionHeaderListItemButtonSx = {
21
+ flexGrow: 1,
22
+ justifyContent: 'flex-start',
23
+ minWidth: 0,
24
+ textAlign: 'start',
25
+ '&:focus': { backgroundColor: 'transparent' },
26
+ '&:hover': { backgroundColor: 'transparent' },
27
+ '&.Mui-focusVisible': { backgroundColor: 'transparent' },
28
+ };
35
29
 
36
- const StyledListItemIcon = styled( ListItemIcon )( ( { theme } ) => ( {
37
- minWidth: theme.spacing( 4 ),
38
- } ) );
30
+ function getSectionHeaderAriaLabel( title: string, count: number ) {
31
+ return `${ title } (${ count.toString() })`;
32
+ }
39
33
 
40
34
  export default function CollapsibleList( {
41
- label,
42
- Icon,
43
- isOpenByDefault = false,
35
+ count,
36
+ isOpen,
37
+ onOpenChange,
38
+ title,
39
+ trailingActions,
44
40
  children,
45
41
  }: PropsWithChildren< Props > ) {
46
- const [ isOpen, setIsOpen ] = useState( isOpenByDefault );
42
+ const id = useId();
43
+ const labelId = `label-${ id }`;
44
+ const contentId = `content-${ id }`;
45
+ const sectionHeaderAriaLabel = getSectionHeaderAriaLabel( title, count );
46
+
47
+ const handleClick = () => onOpenChange( ! isOpen );
47
48
 
48
49
  return (
49
50
  <>
50
- <ListItem>
51
- <StyledListItemIcon
52
- sx={ {
53
- color: 'text.secondary',
54
- } }
51
+ <Box
52
+ sx={ {
53
+ ...contentPanelSectionHeaderSx,
54
+ alignItems: 'center',
55
+ display: 'flex',
56
+ flexDirection: 'row',
57
+ width: '100%',
58
+ } }
59
+ >
60
+ <ListItemButton
61
+ id={ labelId }
62
+ aria-controls={ contentId }
63
+ aria-expanded={ isOpen }
64
+ aria-label={ sectionHeaderAriaLabel }
65
+ dense
66
+ disableGutters
67
+ disableRipple
68
+ onClick={ handleClick }
69
+ sx={ sectionHeaderListItemButtonSx }
55
70
  >
56
- <IconButton
57
- onClick={ () => setIsOpen( ( prev ) => ! prev ) }
58
- size="small"
59
- sx={ {
60
- color: 'inherit',
61
- } }
71
+ <Stack alignItems="center" direction="row" flexGrow={ 1 } gap={ 0.5 } minWidth={ 0 } width="100%">
72
+ <Stack alignItems="center" direction="row" flex={ 1 } gap={ 0.5 } minWidth={ 0 }>
73
+ <ListItemText
74
+ secondary={ title }
75
+ secondaryTypographyProps={ {
76
+ color: 'text.primary',
77
+ fontWeight: 'bold',
78
+ variant: 'caption',
79
+ } }
80
+ sx={ { flexGrow: 0, flexShrink: 1, marginInlineEnd: 1 } }
81
+ />
82
+ <Chip label={ count } size="tiny" />
83
+ </Stack>
84
+ <CollapseIcon color="secondary" fontSize="tiny" open={ isOpen } sx={ { flexShrink: 0 } } />
85
+ </Stack>
86
+ </ListItemButton>
87
+ { trailingActions && (
88
+ <Stack
89
+ alignItems="center"
90
+ direction="row"
91
+ flexShrink={ 0 }
92
+ gap={ contentPanelSectionHeaderTrailingGap }
93
+ sx={ { marginInlineStart: 0.5 } }
62
94
  >
63
- <RotateIcon fontSize="small" isOpen={ isOpen } />
64
- </IconButton>
65
- </StyledListItemIcon>
66
- <StyledListItemIcon
67
- size="small"
68
- sx={ {
69
- color: 'inherit',
70
- } }
71
- >
72
- <Icon fontSize="small" />
73
- </StyledListItemIcon>
74
- <ListItemText
75
- primaryTypographyProps={ { variant: 'subtitle2', component: 'span' } }
76
- primary={ label }
77
- />
78
- </ListItem>
79
- <Collapse in={ isOpen } timeout="auto" unmountOnExit>
80
- <List dense>{ children }</List>
95
+ { trailingActions }
96
+ </Stack>
97
+ ) }
98
+ </Box>
99
+ <Collapse aria-labelledby={ labelId } id={ contentId } in={ isOpen } timeout="auto" unmountOnExit>
100
+ <List dense disablePadding sx={ contentPanelListSectionListSx }>
101
+ { children }
102
+ </List>
81
103
  </Collapse>
82
- <Divider sx={ { mt: 1 } } />
104
+ <Divider />
83
105
  </>
84
106
  );
85
107
  }
@@ -1,10 +1,15 @@
1
1
  import * as React from 'react';
2
2
  import { type FocusEvent, type FormEvent, type MutableRefObject, useRef, useState } from 'react';
3
3
  import { XIcon } from '@elementor/icons';
4
- import { Box, CircularProgress, IconButton, ListItem, ListItemText, TextField } from '@elementor/ui';
4
+ import { Box, CircularProgress, IconButton, ListItem, ListItemText } from '@elementor/ui';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
7
  import { usePostListContext } from '../../../../contexts/post-list-context';
8
+ import {
9
+ contentPanelListItemButtonSx,
10
+ contentPanelListRowPaddingSx,
11
+ contentPanelListRowTitleSx,
12
+ } from '../../content-panel-chrome';
8
13
 
9
14
  type Props = {
10
15
  postTitle: string;
@@ -12,7 +17,48 @@ type Props = {
12
17
  callback: ( inputValue: string ) => void;
13
18
  };
14
19
 
20
+ const EDIT_ROW_FOCUS_BORDER_WIDTH_PX = 2;
21
+ const EDIT_ROW_MIN_HEIGHT_PX = 36;
22
+
23
+ const editModeListItemButtonSx = {
24
+ ...contentPanelListItemButtonSx,
25
+ alignItems: 'center',
26
+ backgroundColor: 'transparent',
27
+ boxSizing: 'border-box',
28
+ minHeight: EDIT_ROW_MIN_HEIGHT_PX,
29
+ py: 0,
30
+ };
31
+
32
+ const editRowIndicatorSx = ( hasError: boolean ) => ( {
33
+ alignItems: 'center',
34
+ border: `${ EDIT_ROW_FOCUS_BORDER_WIDTH_PX }px solid`,
35
+ borderColor: hasError ? 'error.main' : 'secondary.main',
36
+ borderRadius: 0.5,
37
+ boxSizing: 'border-box',
38
+ display: 'flex',
39
+ flex: 1,
40
+ minHeight: 0,
41
+ minWidth: 0,
42
+ px: 1,
43
+ py: 0,
44
+ } );
45
+
46
+ const editRowInputSx = {
47
+ ...contentPanelListRowTitleSx,
48
+ backgroundColor: 'transparent',
49
+ border: 0,
50
+ color: 'text.secondary',
51
+ flex: 1,
52
+ fontFamily: 'inherit',
53
+ lineHeight: 1.25,
54
+ minWidth: 0,
55
+ outline: 0,
56
+ padding: 0,
57
+ width: '100%',
58
+ };
59
+
15
60
  export default function EditModeTemplate( { postTitle, isLoading, callback }: Props ) {
61
+ const { resetEditMode } = usePostListContext();
16
62
  const [ title, setTitle ] = useState( postTitle );
17
63
  const [ touched, setTouched ] = useState( false );
18
64
  const [ inputError, setInputError ] = useState< string | null >( null );
@@ -23,6 +69,11 @@ export default function EditModeTemplate( { postTitle, isLoading, callback }: Pr
23
69
  return;
24
70
  }
25
71
 
72
+ if ( ! touched ) {
73
+ resetEditMode();
74
+ return;
75
+ }
76
+
26
77
  runCallback();
27
78
  };
28
79
 
@@ -43,7 +94,7 @@ export default function EditModeTemplate( { postTitle, isLoading, callback }: Pr
43
94
  callback( title );
44
95
  };
45
96
 
46
- const onChange = ( e: React.ChangeEvent< { value: string } > ) => {
97
+ const onChange = ( e: React.ChangeEvent< HTMLInputElement > ) => {
47
98
  if ( ! touched ) {
48
99
  setTouched( true );
49
100
  }
@@ -59,25 +110,37 @@ export default function EditModeTemplate( { postTitle, isLoading, callback }: Pr
59
110
 
60
111
  return (
61
112
  <>
62
- <ListItem secondaryAction={ <CloseButton isLoading={ isLoading } closeButton={ closeButton } /> }>
63
- <Box width="100%" component="form" onSubmit={ onFormSubmit }>
64
- <TextField
65
- autoFocus // eslint-disable-line jsx-a11y/no-autofocus
66
- fullWidth
67
- value={ title }
68
- onChange={ onChange }
69
- disabled={ isLoading }
70
- error={ !! inputError }
71
- onBlur={ onBlur }
72
- variant="outlined"
73
- color="secondary"
74
- size="small"
75
- />
113
+ <ListItem
114
+ disablePadding
115
+ sx={ contentPanelListRowPaddingSx }
116
+ secondaryAction={ <CloseButton isLoading={ isLoading } closeButton={ closeButton } /> }
117
+ >
118
+ <Box
119
+ component="form"
120
+ onSubmit={ onFormSubmit }
121
+ sx={ { ...editModeListItemButtonSx, display: 'flex', width: '100%' } }
122
+ >
123
+ <Box sx={ editRowIndicatorSx( !! inputError ) }>
124
+ <Box
125
+ autoFocus // eslint-disable-line jsx-a11y/no-autofocus
126
+ aria-invalid={ !! inputError }
127
+ aria-label={ __( 'Name', 'elementor' ) }
128
+ component="input"
129
+ disabled={ isLoading }
130
+ onBlur={ onBlur }
131
+ onChange={ onChange }
132
+ sx={ editRowInputSx }
133
+ type="text"
134
+ value={ title }
135
+ />
136
+ </Box>
76
137
  </Box>
77
138
  </ListItem>
78
139
  { inputError && (
79
- <ListItem>
80
- <ListItemText sx={ { color: 'error.main' } }>{ inputError }</ListItemText>
140
+ <ListItem disablePadding sx={ contentPanelListRowPaddingSx }>
141
+ <ListItemText sx={ { color: 'error.main', ...contentPanelListRowTitleSx } }>
142
+ { inputError }
143
+ </ListItemText>
81
144
  </ListItem>
82
145
  ) }
83
146
  </>
@@ -93,8 +156,8 @@ function CloseButton( { isLoading, closeButton }: CloseButtonProps ) {
93
156
  const { resetEditMode } = usePostListContext();
94
157
 
95
158
  return (
96
- <IconButton size="small" color="secondary" onClick={ resetEditMode } ref={ closeButton } disabled={ isLoading }>
97
- { isLoading ? <CircularProgress /> : <XIcon fontSize="small" /> }
159
+ <IconButton size="tiny" color="secondary" onClick={ resetEditMode } ref={ closeButton } disabled={ isLoading }>
160
+ { isLoading ? <CircularProgress size="1rem" /> : <XIcon fontSize="tiny" /> }
98
161
  </IconButton>
99
162
  );
100
163
  }
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { __useNavigateToDocument as useNavigateToDocument } from '@elementor/editor-documents';
3
- import { __ } from '@wordpress/i18n';
3
+ import { __, sprintf } from '@wordpress/i18n';
4
4
 
5
+ import { postTypesMap } from '../../../../api/post';
5
6
  import { usePostListContext } from '../../../../contexts/post-list-context';
6
7
  import { usePostActions } from '../../../../hooks/use-posts-actions';
7
8
  import EditModeTemplate from './edit-mode-template';
@@ -27,9 +28,15 @@ export default function ListItemCreate() {
27
28
  }
28
29
  };
29
30
 
31
+ const newItemLabel = sprintf(
32
+ /* translators: %s: Post type singular name (e.g. Page, Post). */
33
+ __( 'New %s', 'elementor' ),
34
+ postTypesMap[ type ].labels.singular_name
35
+ );
36
+
30
37
  return (
31
38
  <EditModeTemplate
32
- postTitle={ __( 'New Page', 'elementor' ) }
39
+ postTitle={ newItemLabel }
33
40
  isLoading={ createPost.isPending }
34
41
  callback={ createPostCallback }
35
42
  />