@wordpress/block-library 9.24.0 → 9.25.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 (202) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/edit.js +29 -17
  3. package/build/button/edit.js.map +1 -1
  4. package/build/columns/edit.js +18 -22
  5. package/build/columns/edit.js.map +1 -1
  6. package/build/comment-author-name/edit.js +41 -12
  7. package/build/comment-author-name/edit.js.map +1 -1
  8. package/build/comment-date/edit.js +41 -12
  9. package/build/comment-date/edit.js.map +1 -1
  10. package/build/comment-edit-link/edit.js +27 -7
  11. package/build/comment-edit-link/edit.js.map +1 -1
  12. package/build/comments/edit/comments-inspector-controls.js +1 -3
  13. package/build/comments/edit/comments-inspector-controls.js.map +1 -1
  14. package/build/comments-pagination/edit.js +23 -9
  15. package/build/comments-pagination/edit.js.map +1 -1
  16. package/build/comments-title/edit.js +41 -12
  17. package/build/comments-title/edit.js.map +1 -1
  18. package/build/details/edit.js +27 -3
  19. package/build/details/edit.js.map +1 -1
  20. package/build/embed/edit.js +2 -4
  21. package/build/embed/edit.js.map +1 -1
  22. package/build/embed/embed-controls.js +41 -22
  23. package/build/embed/embed-controls.js.map +1 -1
  24. package/build/file/inspector.js +73 -30
  25. package/build/file/inspector.js.map +1 -1
  26. package/build/form/edit.js +67 -37
  27. package/build/form/edit.js.map +1 -1
  28. package/build/form-input/edit.js +47 -18
  29. package/build/form-input/edit.js.map +1 -1
  30. package/build/latest-posts/edit.js +154 -82
  31. package/build/latest-posts/edit.js.map +1 -1
  32. package/build/list/ordered-list-settings.js +131 -52
  33. package/build/list/ordered-list-settings.js.map +1 -1
  34. package/build/navigation/edit/index.js +93 -51
  35. package/build/navigation/edit/index.js.map +1 -1
  36. package/build/navigation/edit/overlay-menu-preview.js +43 -27
  37. package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
  38. package/build/navigation-link/index.js +3 -0
  39. package/build/navigation-link/index.js.map +1 -1
  40. package/build/navigation-link/transforms.js +2 -0
  41. package/build/navigation-link/transforms.js.map +1 -1
  42. package/build/navigation-link/update-attributes.js +1 -0
  43. package/build/navigation-link/update-attributes.js.map +1 -1
  44. package/build/navigation-submenu/index.js +3 -0
  45. package/build/navigation-submenu/index.js.map +1 -1
  46. package/build/post-comments-count/index.js +3 -1
  47. package/build/post-comments-count/index.js.map +1 -1
  48. package/build/post-comments-count/transforms.js +26 -0
  49. package/build/post-comments-count/transforms.js.map +1 -0
  50. package/build/post-comments-link/index.js +3 -1
  51. package/build/post-comments-link/index.js.map +1 -1
  52. package/build/post-comments-link/transforms.js +26 -0
  53. package/build/post-comments-link/transforms.js.map +1 -0
  54. package/build/post-title/edit.js +56 -18
  55. package/build/post-title/edit.js.map +1 -1
  56. package/build/query/edit/enhanced-pagination-modal.js +1 -1
  57. package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
  58. package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
  59. package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  60. package/build/rss/edit.js +120 -46
  61. package/build/rss/edit.js.map +1 -1
  62. package/build/separator/edit.js +52 -20
  63. package/build/separator/edit.js.map +1 -1
  64. package/build/shortcode/index.js +2 -1
  65. package/build/shortcode/index.js.map +1 -1
  66. package/build/social-link/variations.js +53 -48
  67. package/build/social-link/variations.js.map +1 -1
  68. package/build/social-links/edit.js +35 -45
  69. package/build/social-links/edit.js.map +1 -1
  70. package/build/video/tracks-editor.js +40 -12
  71. package/build/video/tracks-editor.js.map +1 -1
  72. package/build-module/button/edit.js +30 -18
  73. package/build-module/button/edit.js.map +1 -1
  74. package/build-module/columns/edit.js +18 -22
  75. package/build-module/columns/edit.js.map +1 -1
  76. package/build-module/comment-author-name/edit.js +42 -13
  77. package/build-module/comment-author-name/edit.js.map +1 -1
  78. package/build-module/comment-date/edit.js +42 -13
  79. package/build-module/comment-date/edit.js.map +1 -1
  80. package/build-module/comment-edit-link/edit.js +28 -8
  81. package/build-module/comment-edit-link/edit.js.map +1 -1
  82. package/build-module/comments/edit/comments-inspector-controls.js +1 -3
  83. package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
  84. package/build-module/comments-pagination/edit.js +24 -10
  85. package/build-module/comments-pagination/edit.js.map +1 -1
  86. package/build-module/comments-title/edit.js +42 -13
  87. package/build-module/comments-title/edit.js.map +1 -1
  88. package/build-module/details/edit.js +29 -5
  89. package/build-module/details/edit.js.map +1 -1
  90. package/build-module/embed/edit.js +2 -4
  91. package/build-module/embed/edit.js.map +1 -1
  92. package/build-module/embed/embed-controls.js +42 -23
  93. package/build-module/embed/embed-controls.js.map +1 -1
  94. package/build-module/file/inspector.js +74 -31
  95. package/build-module/file/inspector.js.map +1 -1
  96. package/build-module/form/edit.js +68 -38
  97. package/build-module/form/edit.js.map +1 -1
  98. package/build-module/form-input/edit.js +48 -19
  99. package/build-module/form-input/edit.js.map +1 -1
  100. package/build-module/latest-posts/edit.js +155 -83
  101. package/build-module/latest-posts/edit.js.map +1 -1
  102. package/build-module/list/ordered-list-settings.js +132 -53
  103. package/build-module/list/ordered-list-settings.js.map +1 -1
  104. package/build-module/navigation/edit/index.js +94 -52
  105. package/build-module/navigation/edit/index.js.map +1 -1
  106. package/build-module/navigation/edit/overlay-menu-preview.js +44 -28
  107. package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
  108. package/build-module/navigation-link/index.js +3 -0
  109. package/build-module/navigation-link/index.js.map +1 -1
  110. package/build-module/navigation-link/transforms.js +2 -0
  111. package/build-module/navigation-link/transforms.js.map +1 -1
  112. package/build-module/navigation-link/update-attributes.js +1 -0
  113. package/build-module/navigation-link/update-attributes.js.map +1 -1
  114. package/build-module/navigation-submenu/index.js +3 -0
  115. package/build-module/navigation-submenu/index.js.map +1 -1
  116. package/build-module/post-comments-count/index.js +3 -1
  117. package/build-module/post-comments-count/index.js.map +1 -1
  118. package/build-module/post-comments-count/transforms.js +19 -0
  119. package/build-module/post-comments-count/transforms.js.map +1 -0
  120. package/build-module/post-comments-link/index.js +3 -1
  121. package/build-module/post-comments-link/index.js.map +1 -1
  122. package/build-module/post-comments-link/transforms.js +19 -0
  123. package/build-module/post-comments-link/transforms.js.map +1 -0
  124. package/build-module/post-title/edit.js +57 -19
  125. package/build-module/post-title/edit.js.map +1 -1
  126. package/build-module/query/edit/enhanced-pagination-modal.js +1 -1
  127. package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
  128. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -6
  129. package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
  130. package/build-module/rss/edit.js +121 -47
  131. package/build-module/rss/edit.js.map +1 -1
  132. package/build-module/separator/edit.js +54 -22
  133. package/build-module/separator/edit.js.map +1 -1
  134. package/build-module/shortcode/index.js +2 -1
  135. package/build-module/shortcode/index.js.map +1 -1
  136. package/build-module/social-link/variations.js +53 -48
  137. package/build-module/social-link/variations.js.map +1 -1
  138. package/build-module/social-links/edit.js +37 -47
  139. package/build-module/social-links/edit.js.map +1 -1
  140. package/build-module/video/tracks-editor.js +41 -13
  141. package/build-module/video/tracks-editor.js.map +1 -1
  142. package/build-style/editor-rtl.css +9 -4
  143. package/build-style/editor.css +9 -4
  144. package/build-style/gallery/style-rtl.css +1 -0
  145. package/build-style/gallery/style.css +1 -0
  146. package/build-style/navigation/editor-rtl.css +8 -3
  147. package/build-style/navigation/editor.css +8 -3
  148. package/build-style/pullquote/editor-rtl.css +1 -1
  149. package/build-style/pullquote/editor.css +1 -1
  150. package/build-style/pullquote/style-rtl.css +2 -3
  151. package/build-style/pullquote/style.css +2 -3
  152. package/build-style/pullquote/theme-rtl.css +2 -2
  153. package/build-style/pullquote/theme.css +2 -2
  154. package/build-style/style-rtl.css +3 -3
  155. package/build-style/style.css +3 -3
  156. package/build-style/theme-rtl.css +2 -2
  157. package/build-style/theme.css +2 -2
  158. package/package.json +35 -35
  159. package/src/button/edit.js +44 -29
  160. package/src/columns/edit.js +20 -31
  161. package/src/comment-author-name/edit.js +54 -13
  162. package/src/comment-date/edit.js +50 -15
  163. package/src/comment-edit-link/edit.js +39 -11
  164. package/src/comments/edit/comments-inspector-controls.js +0 -2
  165. package/src/comments-pagination/edit.js +29 -9
  166. package/src/comments-title/edit.js +53 -15
  167. package/src/details/edit.js +36 -4
  168. package/src/embed/edit.js +3 -5
  169. package/src/embed/embed-controls.js +55 -33
  170. package/src/file/inspector.js +99 -45
  171. package/src/form/edit.js +91 -46
  172. package/src/form-input/edit.js +56 -18
  173. package/src/gallery/style.scss +1 -0
  174. package/src/latest-posts/edit.js +206 -98
  175. package/src/list/ordered-list-settings.js +172 -62
  176. package/src/navigation/edit/index.js +127 -64
  177. package/src/navigation/edit/overlay-menu-preview.js +43 -26
  178. package/src/navigation/editor.scss +8 -4
  179. package/src/navigation-link/block.json +3 -0
  180. package/src/navigation-link/index.php +4 -0
  181. package/src/navigation-link/transforms.js +2 -1
  182. package/src/navigation-link/update-attributes.js +1 -0
  183. package/src/navigation-submenu/block.json +3 -0
  184. package/src/navigation-submenu/index.php +4 -0
  185. package/src/post-comments-count/index.js +2 -0
  186. package/src/post-comments-count/transforms.js +20 -0
  187. package/src/post-comments-link/index.js +2 -0
  188. package/src/post-comments-link/transforms.js +20 -0
  189. package/src/post-title/edit.js +76 -24
  190. package/src/pullquote/editor.scss +1 -1
  191. package/src/pullquote/style.scss +2 -3
  192. package/src/pullquote/theme.scss +2 -2
  193. package/src/query/edit/enhanced-pagination-modal.js +1 -5
  194. package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -13
  195. package/src/rss/edit.js +141 -55
  196. package/src/separator/edit.js +66 -21
  197. package/src/shortcode/block.json +2 -1
  198. package/src/site-title/index.php +1 -1
  199. package/src/social-link/index.php +49 -49
  200. package/src/social-link/variations.js +53 -48
  201. package/src/social-links/edit.js +39 -60
  202. package/src/video/tracks-editor.js +57 -16
package/src/form/edit.js CHANGED
@@ -9,12 +9,18 @@ import {
9
9
  InspectorControls,
10
10
  store as blockEditorStore,
11
11
  } from '@wordpress/block-editor';
12
- import { TextControl, SelectControl, PanelBody } from '@wordpress/components';
12
+ import {
13
+ SelectControl,
14
+ TextControl,
15
+ __experimentalToolsPanel as ToolsPanel,
16
+ __experimentalToolsPanelItem as ToolsPanelItem,
17
+ } from '@wordpress/components';
13
18
  import { useSelect } from '@wordpress/data';
14
19
 
15
20
  /**
16
21
  * Internal dependencies
17
22
  */
23
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
18
24
  import {
19
25
  formSubmissionNotificationSuccess,
20
26
  formSubmissionNotificationError,
@@ -51,6 +57,17 @@ const TEMPLATE = [
51
57
  ];
52
58
 
53
59
  const Edit = ( { attributes, setAttributes, clientId } ) => {
60
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
61
+
62
+ const resetAllSettings = () => {
63
+ setAttributes( {
64
+ submissionMethod: 'email',
65
+ email: undefined,
66
+ action: undefined,
67
+ method: 'post',
68
+ } );
69
+ };
70
+
54
71
  const { action, method, email, submissionMethod } = attributes;
55
72
  const blockProps = useBlockProps();
56
73
 
@@ -75,58 +92,86 @@ const Edit = ( { attributes, setAttributes, clientId } ) => {
75
92
  return (
76
93
  <>
77
94
  <InspectorControls>
78
- <PanelBody title={ __( 'Settings' ) }>
79
- <SelectControl
80
- __nextHasNoMarginBottom
81
- __next40pxDefaultSize
95
+ <ToolsPanel
96
+ dropdownMenuProps={ dropdownMenuProps }
97
+ label={ __( 'Settings' ) }
98
+ resetAll={ resetAllSettings }
99
+ >
100
+ <ToolsPanelItem
101
+ hasValue={ () => submissionMethod !== 'email' }
82
102
  label={ __( 'Submissions method' ) }
83
- options={ [
84
- // TODO: Allow plugins to add their own submission methods.
85
- {
86
- label: __( 'Send email' ),
87
- value: 'email',
88
- },
89
- {
90
- label: __( '- Custom -' ),
91
- value: 'custom',
92
- },
93
- ] }
94
- value={ submissionMethod }
95
- onChange={ ( value ) =>
96
- setAttributes( { submissionMethod: value } )
97
- }
98
- help={
99
- submissionMethod === 'custom'
100
- ? __(
101
- 'Select the method to use for form submissions. Additional options for the "custom" mode can be found in the "Advanced" section.'
102
- )
103
- : __(
104
- 'Select the method to use for form submissions.'
105
- )
103
+ onDeselect={ () =>
104
+ setAttributes( {
105
+ submissionMethod: 'email',
106
+ } )
106
107
  }
107
- />
108
- { submissionMethod === 'email' && (
109
- <TextControl
108
+ isShownByDefault
109
+ >
110
+ <SelectControl
110
111
  __nextHasNoMarginBottom
111
112
  __next40pxDefaultSize
112
- autoComplete="off"
113
+ label={ __( 'Submissions method' ) }
114
+ options={ [
115
+ // TODO: Allow plugins to add their own submission methods.
116
+ {
117
+ label: __( 'Send email' ),
118
+ value: 'email',
119
+ },
120
+ {
121
+ label: __( '- Custom -' ),
122
+ value: 'custom',
123
+ },
124
+ ] }
125
+ value={ submissionMethod }
126
+ onChange={ ( value ) =>
127
+ setAttributes( { submissionMethod: value } )
128
+ }
129
+ help={
130
+ submissionMethod === 'custom'
131
+ ? __(
132
+ 'Select the method to use for form submissions. Additional options for the "custom" mode can be found in the "Advanced" section.'
133
+ )
134
+ : __(
135
+ 'Select the method to use for form submissions.'
136
+ )
137
+ }
138
+ />
139
+ </ToolsPanelItem>
140
+ { submissionMethod === 'email' && (
141
+ <ToolsPanelItem
142
+ hasValue={ () => !! email }
113
143
  label={ __( 'Email for form submissions' ) }
114
- value={ email }
115
- required
116
- onChange={ ( value ) => {
117
- setAttributes( { email: value } );
144
+ onDeselect={ () =>
118
145
  setAttributes( {
119
- action: `mailto:${ value }`,
120
- } );
121
- setAttributes( { method: 'post' } );
122
- } }
123
- help={ __(
124
- 'The email address where form submissions will be sent. Separate multiple email addresses with a comma.'
125
- ) }
126
- type="email"
127
- />
146
+ email: undefined,
147
+ action: undefined,
148
+ method: 'post',
149
+ } )
150
+ }
151
+ isShownByDefault
152
+ >
153
+ <TextControl
154
+ __nextHasNoMarginBottom
155
+ __next40pxDefaultSize
156
+ autoComplete="off"
157
+ label={ __( 'Email for form submissions' ) }
158
+ value={ email || '' }
159
+ required
160
+ onChange={ ( value ) => {
161
+ setAttributes( { email: value } );
162
+ setAttributes( {
163
+ action: `mailto:${ value }`,
164
+ } );
165
+ setAttributes( { method: 'post' } );
166
+ } }
167
+ help={ __(
168
+ 'The email address where form submissions will be sent. Separate multiple email addresses with a comma.'
169
+ ) }
170
+ type="email"
171
+ />
172
+ </ToolsPanelItem>
128
173
  ) }
129
- </PanelBody>
174
+ </ToolsPanel>
130
175
  </InspectorControls>
131
176
  { submissionMethod !== 'email' && (
132
177
  <InspectorControls group="advanced">
@@ -14,14 +14,24 @@ import {
14
14
  __experimentalUseBorderProps as useBorderProps,
15
15
  __experimentalUseColorProps as useColorProps,
16
16
  } from '@wordpress/block-editor';
17
- import { PanelBody, TextControl, CheckboxControl } from '@wordpress/components';
18
-
17
+ import {
18
+ TextControl,
19
+ CheckboxControl,
20
+ __experimentalToolsPanel as ToolsPanel,
21
+ __experimentalToolsPanelItem as ToolsPanelItem,
22
+ } from '@wordpress/components';
19
23
  import { useRef } from '@wordpress/element';
20
24
 
25
+ /**
26
+ * Internal dependencies
27
+ */
28
+ import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
29
+
21
30
  function InputFieldBlock( { attributes, setAttributes, className } ) {
22
31
  const { type, name, label, inlineLabel, required, placeholder, value } =
23
32
  attributes;
24
33
  const blockProps = useBlockProps();
34
+ const dropdownMenuProps = useToolsPanelDropdownMenuProps();
25
35
  const ref = useRef();
26
36
  const TagName = type === 'textarea' ? 'textarea' : 'input';
27
37
 
@@ -38,30 +48,58 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
38
48
  <>
39
49
  { 'hidden' !== type && (
40
50
  <InspectorControls>
41
- <PanelBody title={ __( 'Settings' ) }>
51
+ <ToolsPanel
52
+ label={ __( 'Settings' ) }
53
+ resetAll={ () => {
54
+ setAttributes( {
55
+ inlineLabel: false,
56
+ required: false,
57
+ } );
58
+ } }
59
+ dropdownMenuProps={ dropdownMenuProps }
60
+ >
42
61
  { 'checkbox' !== type && (
62
+ <ToolsPanelItem
63
+ label={ __( 'Inline label' ) }
64
+ hasValue={ () => !! inlineLabel }
65
+ onDeselect={ () =>
66
+ setAttributes( { inlineLabel: false } )
67
+ }
68
+ isShownByDefault
69
+ >
70
+ <CheckboxControl
71
+ __nextHasNoMarginBottom
72
+ label={ __( 'Inline label' ) }
73
+ checked={ inlineLabel }
74
+ onChange={ ( newVal ) => {
75
+ setAttributes( {
76
+ inlineLabel: newVal,
77
+ } );
78
+ } }
79
+ />
80
+ </ToolsPanelItem>
81
+ ) }
82
+
83
+ <ToolsPanelItem
84
+ label={ __( 'Required' ) }
85
+ hasValue={ () => !! required }
86
+ onDeselect={ () =>
87
+ setAttributes( { required: false } )
88
+ }
89
+ isShownByDefault
90
+ >
43
91
  <CheckboxControl
44
92
  __nextHasNoMarginBottom
45
- label={ __( 'Inline label' ) }
46
- checked={ inlineLabel }
93
+ label={ __( 'Required' ) }
94
+ checked={ required }
47
95
  onChange={ ( newVal ) => {
48
96
  setAttributes( {
49
- inlineLabel: newVal,
97
+ required: newVal,
50
98
  } );
51
99
  } }
52
100
  />
53
- ) }
54
- <CheckboxControl
55
- __nextHasNoMarginBottom
56
- label={ __( 'Required' ) }
57
- checked={ required }
58
- onChange={ ( newVal ) => {
59
- setAttributes( {
60
- required: newVal,
61
- } );
62
- } }
63
- />
64
- </PanelBody>
101
+ </ToolsPanelItem>
102
+ </ToolsPanel>
65
103
  </InspectorControls>
66
104
  ) }
67
105
  <InspectorControls group="advanced">
@@ -58,6 +58,7 @@ figure.wp-block-gallery.has-nested-images {
58
58
  content: "";
59
59
  height: 100%;
60
60
  max-height: 40%;
61
+ pointer-events: none;
61
62
 
62
63
  // Blur the background under the gradient scrim.
63
64
  backdrop-filter: blur(3px);
@@ -7,7 +7,6 @@ import clsx from 'clsx';
7
7
  * WordPress dependencies
8
8
  */
9
9
  import {
10
- PanelBody,
11
10
  Placeholder,
12
11
  QueryControls,
13
12
  RadioControl,
@@ -328,131 +327,240 @@ function Controls( { attributes, setAttributes, postCount } ) {
328
327
  />
329
328
  </ToolsPanelItem>
330
329
  </ToolsPanel>
331
- <PanelBody title={ __( 'Featured image' ) }>
332
- <ToggleControl
333
- __nextHasNoMarginBottom
330
+ <ToolsPanel
331
+ label={ __( 'Featured image' ) }
332
+ resetAll={ () =>
333
+ setAttributes( {
334
+ displayFeaturedImage: false,
335
+ featuredImageAlign: undefined,
336
+ featuredImageSizeSlug: 'thumbnail',
337
+ featuredImageSizeWidth: null,
338
+ featuredImageSizeHeight: null,
339
+ addLinkToFeaturedImage: false,
340
+ } )
341
+ }
342
+ dropdownMenuProps={ dropdownMenuProps }
343
+ >
344
+ <ToolsPanelItem
345
+ hasValue={ () => !! displayFeaturedImage }
334
346
  label={ __( 'Display featured image' ) }
335
- checked={ displayFeaturedImage }
336
- onChange={ ( value ) =>
337
- setAttributes( { displayFeaturedImage: value } )
347
+ onDeselect={ () =>
348
+ setAttributes( { displayFeaturedImage: false } )
338
349
  }
339
- />
350
+ isShownByDefault
351
+ >
352
+ <ToggleControl
353
+ __nextHasNoMarginBottom
354
+ label={ __( 'Display featured image' ) }
355
+ checked={ displayFeaturedImage }
356
+ onChange={ ( value ) =>
357
+ setAttributes( { displayFeaturedImage: value } )
358
+ }
359
+ />
360
+ </ToolsPanelItem>
340
361
  { displayFeaturedImage && (
341
362
  <>
342
- <ImageSizeControl
343
- onChange={ ( value ) => {
344
- const newAttrs = {};
345
- if ( value.hasOwnProperty( 'width' ) ) {
346
- newAttrs.featuredImageSizeWidth =
347
- value.width;
348
- }
349
- if ( value.hasOwnProperty( 'height' ) ) {
350
- newAttrs.featuredImageSizeHeight =
351
- value.height;
352
- }
353
- setAttributes( newAttrs );
354
- } }
355
- slug={ featuredImageSizeSlug }
356
- width={ featuredImageSizeWidth }
357
- height={ featuredImageSizeHeight }
358
- imageWidth={ defaultImageWidth }
359
- imageHeight={ defaultImageHeight }
360
- imageSizeOptions={ imageSizeOptions }
361
- imageSizeHelp={ __(
362
- 'Select the size of the source image.'
363
- ) }
364
- onChangeImage={ ( value ) =>
363
+ <ToolsPanelItem
364
+ hasValue={ () =>
365
+ featuredImageSizeSlug !== 'thumbnail' ||
366
+ featuredImageSizeWidth !== null ||
367
+ featuredImageSizeHeight !== null
368
+ }
369
+ label={ __( 'Image size' ) }
370
+ onDeselect={ () =>
365
371
  setAttributes( {
366
- featuredImageSizeSlug: value,
367
- featuredImageSizeWidth: undefined,
368
- featuredImageSizeHeight: undefined,
372
+ featuredImageSizeSlug: 'thumbnail',
373
+ featuredImageSizeWidth: null,
374
+ featuredImageSizeHeight: null,
369
375
  } )
370
376
  }
371
- />
372
- <ToggleGroupControl
373
- className="editor-latest-posts-image-alignment-control"
374
- __nextHasNoMarginBottom
375
- __next40pxDefaultSize
377
+ isShownByDefault
378
+ >
379
+ <ImageSizeControl
380
+ onChange={ ( value ) => {
381
+ const newAttrs = {};
382
+ if ( value.hasOwnProperty( 'width' ) ) {
383
+ newAttrs.featuredImageSizeWidth =
384
+ value.width;
385
+ }
386
+ if ( value.hasOwnProperty( 'height' ) ) {
387
+ newAttrs.featuredImageSizeHeight =
388
+ value.height;
389
+ }
390
+ setAttributes( newAttrs );
391
+ } }
392
+ slug={ featuredImageSizeSlug }
393
+ width={ featuredImageSizeWidth }
394
+ height={ featuredImageSizeHeight }
395
+ imageWidth={ defaultImageWidth }
396
+ imageHeight={ defaultImageHeight }
397
+ imageSizeOptions={ imageSizeOptions }
398
+ imageSizeHelp={ __(
399
+ 'Select the size of the source image.'
400
+ ) }
401
+ onChangeImage={ ( value ) =>
402
+ setAttributes( {
403
+ featuredImageSizeSlug: value,
404
+ featuredImageSizeWidth: undefined,
405
+ featuredImageSizeHeight: undefined,
406
+ } )
407
+ }
408
+ />
409
+ </ToolsPanelItem>
410
+ <ToolsPanelItem
411
+ hasValue={ () => !! featuredImageAlign }
376
412
  label={ __( 'Image alignment' ) }
377
- value={ featuredImageAlign || 'none' }
378
- onChange={ ( value ) =>
413
+ onDeselect={ () =>
379
414
  setAttributes( {
380
- featuredImageAlign:
381
- value !== 'none' ? value : undefined,
415
+ featuredImageAlign: undefined,
382
416
  } )
383
417
  }
418
+ isShownByDefault
384
419
  >
385
- { imageAlignmentOptions.map(
386
- ( { value, icon, label } ) => {
387
- return (
388
- <ToggleGroupControlOptionIcon
389
- key={ value }
390
- value={ value }
391
- icon={ icon }
392
- label={ label }
393
- />
394
- );
420
+ <ToggleGroupControl
421
+ className="editor-latest-posts-image-alignment-control"
422
+ __nextHasNoMarginBottom
423
+ __next40pxDefaultSize
424
+ label={ __( 'Image alignment' ) }
425
+ value={ featuredImageAlign || 'none' }
426
+ onChange={ ( value ) =>
427
+ setAttributes( {
428
+ featuredImageAlign:
429
+ value !== 'none'
430
+ ? value
431
+ : undefined,
432
+ } )
395
433
  }
396
- ) }
397
- </ToggleGroupControl>
398
- <ToggleControl
399
- __nextHasNoMarginBottom
434
+ >
435
+ { imageAlignmentOptions.map(
436
+ ( { value, icon, label } ) => {
437
+ return (
438
+ <ToggleGroupControlOptionIcon
439
+ key={ value }
440
+ value={ value }
441
+ icon={ icon }
442
+ label={ label }
443
+ />
444
+ );
445
+ }
446
+ ) }
447
+ </ToggleGroupControl>
448
+ </ToolsPanelItem>
449
+ <ToolsPanelItem
450
+ hasValue={ () => !! addLinkToFeaturedImage }
400
451
  label={ __( 'Add link to featured image' ) }
401
- checked={ addLinkToFeaturedImage }
402
- onChange={ ( value ) =>
452
+ onDeselect={ () =>
403
453
  setAttributes( {
404
- addLinkToFeaturedImage: value,
454
+ addLinkToFeaturedImage: false,
405
455
  } )
406
456
  }
407
- />
457
+ isShownByDefault
458
+ >
459
+ <ToggleControl
460
+ __nextHasNoMarginBottom
461
+ label={ __( 'Add link to featured image' ) }
462
+ checked={ addLinkToFeaturedImage }
463
+ onChange={ ( value ) =>
464
+ setAttributes( {
465
+ addLinkToFeaturedImage: value,
466
+ } )
467
+ }
468
+ />
469
+ </ToolsPanelItem>
408
470
  </>
409
471
  ) }
410
- </PanelBody>
411
- <PanelBody title={ __( 'Sorting and filtering' ) }>
412
- <QueryControls
413
- { ...{ order, orderBy } }
414
- numberOfItems={ postsToShow }
415
- onOrderChange={ ( value ) =>
416
- setAttributes( { order: value } )
417
- }
418
- onOrderByChange={ ( value ) =>
419
- setAttributes( { orderBy: value } )
420
- }
421
- onNumberOfItemsChange={ ( value ) =>
422
- setAttributes( { postsToShow: value } )
472
+ </ToolsPanel>
473
+
474
+ <ToolsPanel
475
+ label={ __( 'Sorting and filtering' ) }
476
+ resetAll={ () =>
477
+ setAttributes( {
478
+ order: 'desc',
479
+ orderBy: 'date',
480
+ postsToShow: 5,
481
+ categories: undefined,
482
+ selectedAuthor: undefined,
483
+ columns: 3,
484
+ } )
485
+ }
486
+ dropdownMenuProps={ dropdownMenuProps }
487
+ >
488
+ <ToolsPanelItem
489
+ hasValue={ () =>
490
+ order !== 'desc' ||
491
+ orderBy !== 'date' ||
492
+ postsToShow !== 5 ||
493
+ categories?.length > 0 ||
494
+ !! selectedAuthor
423
495
  }
424
- categorySuggestions={ categorySuggestions }
425
- onCategoryChange={ selectCategories }
426
- selectedCategories={ categories }
427
- onAuthorChange={ ( value ) =>
496
+ label={ __( 'Sort and filter' ) }
497
+ onDeselect={ () =>
428
498
  setAttributes( {
429
- selectedAuthor:
430
- '' !== value ? Number( value ) : undefined,
499
+ order: 'desc',
500
+ orderBy: 'date',
501
+ postsToShow: 5,
502
+ categories: undefined,
503
+ selectedAuthor: undefined,
431
504
  } )
432
505
  }
433
- authorList={ authorList ?? [] }
434
- selectedAuthorId={ selectedAuthor }
435
- />
506
+ isShownByDefault
507
+ >
508
+ <QueryControls
509
+ { ...{ order, orderBy } }
510
+ numberOfItems={ postsToShow }
511
+ onOrderChange={ ( value ) =>
512
+ setAttributes( { order: value } )
513
+ }
514
+ onOrderByChange={ ( value ) =>
515
+ setAttributes( { orderBy: value } )
516
+ }
517
+ onNumberOfItemsChange={ ( value ) =>
518
+ setAttributes( { postsToShow: value } )
519
+ }
520
+ categorySuggestions={ categorySuggestions }
521
+ onCategoryChange={ selectCategories }
522
+ selectedCategories={ categories }
523
+ onAuthorChange={ ( value ) =>
524
+ setAttributes( {
525
+ selectedAuthor:
526
+ '' !== value ? Number( value ) : undefined,
527
+ } )
528
+ }
529
+ authorList={ authorList ?? [] }
530
+ selectedAuthorId={ selectedAuthor }
531
+ />
532
+ </ToolsPanelItem>
436
533
 
437
534
  { postLayout === 'grid' && (
438
- <RangeControl
439
- __nextHasNoMarginBottom
440
- __next40pxDefaultSize
535
+ <ToolsPanelItem
536
+ hasValue={ () => columns !== 3 }
441
537
  label={ __( 'Columns' ) }
442
- value={ columns }
443
- onChange={ ( value ) =>
444
- setAttributes( { columns: value } )
445
- }
446
- min={ 2 }
447
- max={
448
- ! postCount
449
- ? MAX_POSTS_COLUMNS
450
- : Math.min( MAX_POSTS_COLUMNS, postCount )
538
+ onDeselect={ () =>
539
+ setAttributes( {
540
+ columns: 3,
541
+ } )
451
542
  }
452
- required
453
- />
543
+ isShownByDefault
544
+ >
545
+ <RangeControl
546
+ __nextHasNoMarginBottom
547
+ __next40pxDefaultSize
548
+ label={ __( 'Columns' ) }
549
+ value={ columns }
550
+ onChange={ ( value ) =>
551
+ setAttributes( { columns: value } )
552
+ }
553
+ min={ 2 }
554
+ max={
555
+ ! postCount
556
+ ? MAX_POSTS_COLUMNS
557
+ : Math.min( MAX_POSTS_COLUMNS, postCount )
558
+ }
559
+ required
560
+ />
561
+ </ToolsPanelItem>
454
562
  ) }
455
- </PanelBody>
563
+ </ToolsPanel>
456
564
  </>
457
565
  );
458
566
  }