@wordpress/block-library 9.40.2-next.v.202602241322.0 → 9.40.2

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 (226) hide show
  1. package/build/comment-reply-link/edit.cjs +2 -1
  2. package/build/comment-reply-link/edit.cjs.map +2 -2
  3. package/build/comments/edit/placeholder.cjs +2 -1
  4. package/build/comments/edit/placeholder.cjs.map +2 -2
  5. package/build/cover/edit/index.cjs +39 -26
  6. package/build/cover/edit/index.cjs.map +2 -2
  7. package/build/cover/embed-video-utils.cjs +8 -6
  8. package/build/cover/embed-video-utils.cjs.map +2 -2
  9. package/build/embed/embed-preview.cjs +2 -1
  10. package/build/embed/embed-preview.cjs.map +2 -2
  11. package/build/html/block.json +2 -1
  12. package/build/html/modal.cjs +147 -230
  13. package/build/html/modal.cjs.map +3 -3
  14. package/build/icon/block.json +3 -12
  15. package/build/image/image.cjs +1 -1
  16. package/build/image/image.cjs.map +2 -2
  17. package/build/latest-comments/deprecated.cjs +33 -0
  18. package/build/latest-comments/deprecated.cjs.map +2 -2
  19. package/build/navigation/edit/index.cjs +123 -119
  20. package/build/navigation/edit/index.cjs.map +3 -3
  21. package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
  22. package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
  23. package/build/navigation/view.cjs +9 -2
  24. package/build/navigation/view.cjs.map +2 -2
  25. package/build/navigation-link/edit.cjs +2 -1
  26. package/build/navigation-link/edit.cjs.map +2 -2
  27. package/build/navigation-link/shared/controls.cjs +29 -52
  28. package/build/navigation-link/shared/controls.cjs.map +3 -3
  29. package/build/navigation-link/shared/use-handle-link-change.cjs +19 -3
  30. package/build/navigation-link/shared/use-handle-link-change.cjs.map +3 -3
  31. package/build/navigation-link/shared/use-link-preview.cjs +8 -9
  32. package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
  33. package/build/navigation-submenu/edit.cjs +8 -22
  34. package/build/navigation-submenu/edit.cjs.map +2 -2
  35. package/build/nextpage/block.json +0 -1
  36. package/build/page-list-item/edit.cjs +6 -3
  37. package/build/page-list-item/edit.cjs.map +2 -2
  38. package/build/paragraph/edit.cjs +1 -1
  39. package/build/paragraph/edit.cjs.map +1 -1
  40. package/build/post-navigation-link/block.json +3 -1
  41. package/build/post-navigation-link/edit.cjs +36 -2
  42. package/build/post-navigation-link/edit.cjs.map +3 -3
  43. package/build/post-navigation-link/index.cjs +0 -2
  44. package/build/post-navigation-link/index.cjs.map +3 -3
  45. package/build/post-title/block.json +3 -1
  46. package/build/post-title/deprecated.cjs +1 -82
  47. package/build/post-title/deprecated.cjs.map +3 -3
  48. package/build/post-title/edit.cjs +36 -10
  49. package/build/post-title/edit.cjs.map +3 -3
  50. package/build/query-title/block.json +3 -1
  51. package/build/query-title/deprecated.cjs +1 -70
  52. package/build/query-title/deprecated.cjs.map +3 -3
  53. package/build/query-title/edit.cjs +35 -17
  54. package/build/query-title/edit.cjs.map +3 -3
  55. package/build/shortcode/block.json +2 -1
  56. package/build/site-tagline/block.json +4 -6
  57. package/build/site-tagline/deprecated.cjs +1 -66
  58. package/build/site-tagline/deprecated.cjs.map +3 -3
  59. package/build/site-tagline/edit.cjs +28 -14
  60. package/build/site-tagline/edit.cjs.map +3 -3
  61. package/build/site-title/block.json +3 -1
  62. package/build/site-title/deprecated.cjs +1 -79
  63. package/build/site-title/deprecated.cjs.map +3 -3
  64. package/build/site-title/edit.cjs +30 -14
  65. package/build/site-title/edit.cjs.map +3 -3
  66. package/build/tabs-menu-item/block.json +26 -1
  67. package/build/tabs-menu-item/controls.cjs +100 -2
  68. package/build/tabs-menu-item/controls.cjs.map +3 -3
  69. package/build/tabs-menu-item/edit.cjs +65 -6
  70. package/build/tabs-menu-item/edit.cjs.map +2 -2
  71. package/build/tabs-menu-item/save.cjs +15 -1
  72. package/build/tabs-menu-item/save.cjs.map +2 -2
  73. package/build-module/comment-reply-link/edit.mjs +3 -2
  74. package/build-module/comment-reply-link/edit.mjs.map +2 -2
  75. package/build-module/comments/edit/placeholder.mjs +3 -2
  76. package/build-module/comments/edit/placeholder.mjs.map +2 -2
  77. package/build-module/cover/edit/index.mjs +47 -29
  78. package/build-module/cover/edit/index.mjs.map +2 -2
  79. package/build-module/cover/embed-video-utils.mjs +7 -5
  80. package/build-module/cover/embed-video-utils.mjs.map +2 -2
  81. package/build-module/embed/embed-preview.mjs +2 -1
  82. package/build-module/embed/embed-preview.mjs.map +2 -2
  83. package/build-module/html/block.json +2 -1
  84. package/build-module/html/modal.mjs +149 -232
  85. package/build-module/html/modal.mjs.map +2 -2
  86. package/build-module/icon/block.json +3 -12
  87. package/build-module/image/image.mjs +1 -1
  88. package/build-module/image/image.mjs.map +2 -2
  89. package/build-module/latest-comments/deprecated.mjs +33 -0
  90. package/build-module/latest-comments/deprecated.mjs.map +2 -2
  91. package/build-module/navigation/edit/index.mjs +123 -119
  92. package/build-module/navigation/edit/index.mjs.map +2 -2
  93. package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
  94. package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
  95. package/build-module/navigation/view.mjs +9 -2
  96. package/build-module/navigation/view.mjs.map +2 -2
  97. package/build-module/navigation-link/edit.mjs +2 -1
  98. package/build-module/navigation-link/edit.mjs.map +2 -2
  99. package/build-module/navigation-link/shared/controls.mjs +29 -53
  100. package/build-module/navigation-link/shared/controls.mjs.map +2 -2
  101. package/build-module/navigation-link/shared/use-handle-link-change.mjs +19 -3
  102. package/build-module/navigation-link/shared/use-handle-link-change.mjs.map +2 -2
  103. package/build-module/navigation-link/shared/use-link-preview.mjs +8 -9
  104. package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
  105. package/build-module/navigation-submenu/edit.mjs +9 -23
  106. package/build-module/navigation-submenu/edit.mjs.map +2 -2
  107. package/build-module/nextpage/block.json +0 -1
  108. package/build-module/page-list-item/edit.mjs +6 -3
  109. package/build-module/page-list-item/edit.mjs.map +2 -2
  110. package/build-module/paragraph/edit.mjs +2 -2
  111. package/build-module/paragraph/edit.mjs.map +1 -1
  112. package/build-module/post-navigation-link/block.json +3 -1
  113. package/build-module/post-navigation-link/edit.mjs +30 -3
  114. package/build-module/post-navigation-link/edit.mjs.map +2 -2
  115. package/build-module/post-navigation-link/index.mjs +0 -2
  116. package/build-module/post-navigation-link/index.mjs.map +2 -2
  117. package/build-module/post-title/block.json +3 -1
  118. package/build-module/post-title/deprecated.mjs +1 -82
  119. package/build-module/post-title/deprecated.mjs.map +2 -2
  120. package/build-module/post-title/edit.mjs +27 -10
  121. package/build-module/post-title/edit.mjs.map +2 -2
  122. package/build-module/query-title/block.json +3 -1
  123. package/build-module/query-title/deprecated.mjs +1 -70
  124. package/build-module/query-title/deprecated.mjs.map +2 -2
  125. package/build-module/query-title/edit.mjs +36 -17
  126. package/build-module/query-title/edit.mjs.map +2 -2
  127. package/build-module/shortcode/block.json +2 -1
  128. package/build-module/site-tagline/block.json +4 -6
  129. package/build-module/site-tagline/deprecated.mjs +1 -66
  130. package/build-module/site-tagline/deprecated.mjs.map +2 -2
  131. package/build-module/site-tagline/edit.mjs +29 -14
  132. package/build-module/site-tagline/edit.mjs.map +2 -2
  133. package/build-module/site-title/block.json +3 -1
  134. package/build-module/site-title/deprecated.mjs +1 -79
  135. package/build-module/site-title/deprecated.mjs.map +2 -2
  136. package/build-module/site-title/edit.mjs +31 -14
  137. package/build-module/site-title/edit.mjs.map +2 -2
  138. package/build-module/tabs-menu-item/block.json +26 -1
  139. package/build-module/tabs-menu-item/controls.mjs +104 -3
  140. package/build-module/tabs-menu-item/controls.mjs.map +2 -2
  141. package/build-module/tabs-menu-item/edit.mjs +66 -6
  142. package/build-module/tabs-menu-item/edit.mjs.map +2 -2
  143. package/build-module/tabs-menu-item/save.mjs +15 -1
  144. package/build-module/tabs-menu-item/save.mjs.map +2 -2
  145. package/build-style/editor-rtl.css +30 -6
  146. package/build-style/editor.css +30 -6
  147. package/build-style/html/editor-rtl.css +10 -6
  148. package/build-style/html/editor.css +10 -6
  149. package/build-style/icon/editor-rtl.css +5 -0
  150. package/build-style/icon/editor.css +5 -0
  151. package/build-style/navigation/style-rtl.css +15 -1
  152. package/build-style/navigation/style.css +15 -1
  153. package/build-style/navigation-link/editor-rtl.css +10 -0
  154. package/build-style/navigation-link/editor.css +10 -0
  155. package/build-style/navigation-overlay-close/style-rtl.css +3 -3
  156. package/build-style/navigation-overlay-close/style.css +3 -3
  157. package/build-style/style-rtl.css +30 -7
  158. package/build-style/style.css +30 -7
  159. package/build-style/tabs-menu-item/editor-rtl.css +5 -0
  160. package/build-style/tabs-menu-item/editor.css +5 -0
  161. package/build-style/tabs-menu-item/style-rtl.css +12 -3
  162. package/build-style/tabs-menu-item/style.css +12 -3
  163. package/package.json +38 -38
  164. package/src/accordion-item/index.php +17 -5
  165. package/src/comment-reply-link/edit.js +5 -2
  166. package/src/comments/edit/placeholder.js +5 -2
  167. package/src/cover/edit/index.js +72 -35
  168. package/src/cover/embed-video-utils.js +9 -7
  169. package/src/cover/index.php +8 -0
  170. package/src/details/index.php +47 -0
  171. package/src/embed/embed-preview.js +6 -5
  172. package/src/html/block.json +2 -1
  173. package/src/html/editor.scss +15 -5
  174. package/src/html/modal.js +32 -99
  175. package/src/icon/block.json +3 -12
  176. package/src/icon/editor.scss +5 -0
  177. package/src/icon/index.php +3 -1
  178. package/src/image/image.js +14 -15
  179. package/src/image/index.php +7 -5
  180. package/src/latest-comments/deprecated.js +33 -0
  181. package/src/navigation/edit/index.js +134 -130
  182. package/src/navigation/edit/navigation-menu-selector.js +2 -1
  183. package/src/navigation/index.php +62 -9
  184. package/src/navigation/style.scss +17 -1
  185. package/src/navigation/view.js +14 -2
  186. package/src/navigation-link/edit.js +1 -0
  187. package/src/navigation-link/editor.scss +18 -0
  188. package/src/navigation-link/shared/controls.js +35 -62
  189. package/src/navigation-link/shared/test/controls.js +5 -5
  190. package/src/navigation-link/shared/test/use-handle-link-change.test.js +212 -0
  191. package/src/navigation-link/shared/test/use-link-preview.test.js +19 -1
  192. package/src/navigation-link/shared/use-handle-link-change.js +36 -9
  193. package/src/navigation-link/shared/use-link-preview.js +14 -15
  194. package/src/navigation-overlay-close/style.scss +3 -3
  195. package/src/navigation-submenu/edit.js +11 -28
  196. package/src/nextpage/block.json +0 -1
  197. package/src/page-list-item/edit.js +8 -7
  198. package/src/paragraph/edit.js +2 -2
  199. package/src/post-featured-image/index.php +4 -2
  200. package/src/post-navigation-link/block.json +3 -1
  201. package/src/post-navigation-link/edit.js +35 -2
  202. package/src/post-navigation-link/index.js +0 -2
  203. package/src/post-title/block.json +3 -1
  204. package/src/post-title/deprecated.js +1 -86
  205. package/src/post-title/edit.js +18 -2
  206. package/src/query-title/block.json +3 -1
  207. package/src/query-title/deprecated.js +1 -74
  208. package/src/query-title/edit.js +27 -11
  209. package/src/shortcode/block.json +2 -1
  210. package/src/site-tagline/block.json +4 -6
  211. package/src/site-tagline/deprecated.js +1 -70
  212. package/src/site-tagline/edit.js +22 -9
  213. package/src/site-title/block.json +3 -1
  214. package/src/site-title/deprecated.js +1 -83
  215. package/src/site-title/edit.js +22 -9
  216. package/src/tabs-menu-item/block.json +26 -1
  217. package/src/tabs-menu-item/controls.js +108 -0
  218. package/src/tabs-menu-item/edit.js +79 -6
  219. package/src/tabs-menu-item/editor.scss +6 -0
  220. package/src/tabs-menu-item/save.js +26 -1
  221. package/src/tabs-menu-item/style.scss +14 -3
  222. package/build/post-navigation-link/deprecated.cjs +0 -100
  223. package/build/post-navigation-link/deprecated.cjs.map +0 -7
  224. package/build-module/post-navigation-link/deprecated.mjs +0 -69
  225. package/build-module/post-navigation-link/deprecated.mjs.map +0 -7
  226. package/src/post-navigation-link/deprecated.js +0 -72
@@ -2,88 +2,6 @@
2
2
  * Internal dependencies
3
3
  */
4
4
  import migrateFontFamily from '../utils/migrate-font-family';
5
- import migrateTextAlign from '../utils/migrate-text-align';
6
-
7
- const v2 = {
8
- attributes: {
9
- textAlign: {
10
- type: 'string',
11
- },
12
- level: {
13
- type: 'number',
14
- default: 1,
15
- },
16
- levelOptions: {
17
- type: 'array',
18
- default: [ 0, 1, 2, 3, 4, 5, 6 ],
19
- },
20
- isLink: {
21
- type: 'boolean',
22
- default: true,
23
- role: 'content',
24
- },
25
- linkTarget: {
26
- type: 'string',
27
- default: '_self',
28
- role: 'content',
29
- },
30
- },
31
- supports: {
32
- anchor: true,
33
- align: [ 'wide', 'full' ],
34
- html: false,
35
- color: {
36
- gradients: true,
37
- link: true,
38
- __experimentalDefaultControls: {
39
- background: true,
40
- text: true,
41
- link: true,
42
- },
43
- },
44
- spacing: {
45
- padding: true,
46
- margin: true,
47
- __experimentalDefaultControls: {
48
- margin: false,
49
- padding: false,
50
- },
51
- },
52
- typography: {
53
- fontSize: true,
54
- lineHeight: true,
55
- __experimentalFontFamily: true,
56
- __experimentalTextTransform: true,
57
- __experimentalTextDecoration: true,
58
- __experimentalFontStyle: true,
59
- __experimentalFontWeight: true,
60
- __experimentalLetterSpacing: true,
61
- __experimentalWritingMode: true,
62
- __experimentalDefaultControls: {
63
- fontSize: true,
64
- },
65
- },
66
- interactivity: {
67
- clientNavigation: true,
68
- },
69
- __experimentalBorder: {
70
- radius: true,
71
- color: true,
72
- width: true,
73
- style: true,
74
- },
75
- },
76
- migrate: migrateTextAlign,
77
- isEligible( attributes ) {
78
- return (
79
- !! attributes.textAlign ||
80
- !! attributes.className?.match(
81
- /\bhas-text-align-(left|center|right)\b/
82
- )
83
- );
84
- },
85
- save: () => null,
86
- };
87
5
 
88
6
  const v1 = {
89
7
  attributes: {
@@ -141,4 +59,4 @@ const v1 = {
141
59
  *
142
60
  * See block-deprecation.md
143
61
  */
144
- export default [ v2, v1 ];
62
+ export default [ v1 ];
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -6,6 +11,7 @@ import { store as coreStore } from '@wordpress/core-data';
6
11
  import { __ } from '@wordpress/i18n';
7
12
  import {
8
13
  RichText,
14
+ AlignmentControl,
9
15
  InspectorControls,
10
16
  BlockControls,
11
17
  useBlockProps,
@@ -24,14 +30,13 @@ import { decodeEntities } from '@wordpress/html-entities';
24
30
  * Internal dependencies
25
31
  */
26
32
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
27
- import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';
28
33
 
29
- export default function SiteTitleEdit( props ) {
30
- useDeprecatedTextAlign( props );
31
-
32
- const { attributes, setAttributes, insertBlocksAfter } = props;
33
-
34
- const { level, levelOptions, isLink, linkTarget } = attributes;
34
+ export default function SiteTitleEdit( {
35
+ attributes,
36
+ setAttributes,
37
+ insertBlocksAfter,
38
+ } ) {
39
+ const { level, levelOptions, textAlign, isLink, linkTarget } = attributes;
35
40
  const { canUserEdit, title } = useSelect( ( select ) => {
36
41
  const { canUser, getEntityRecord, getEditedEntityRecord } =
37
42
  select( coreStore );
@@ -59,8 +64,10 @@ export default function SiteTitleEdit( props ) {
59
64
 
60
65
  const TagName = level === 0 ? 'p' : `h${ level }`;
61
66
  const blockProps = useBlockProps( {
62
- className:
63
- ! canUserEdit && ! title && 'wp-block-site-title__placeholder',
67
+ className: clsx( {
68
+ [ `has-text-align-${ textAlign }` ]: textAlign,
69
+ 'wp-block-site-title__placeholder': ! canUserEdit && ! title,
70
+ } ),
64
71
  } );
65
72
  const siteTitleContent = canUserEdit ? (
66
73
  <TagName { ...blockProps }>
@@ -107,6 +114,12 @@ export default function SiteTitleEdit( props ) {
107
114
  setAttributes( { level: newLevel } )
108
115
  }
109
116
  />
117
+ <AlignmentControl
118
+ value={ textAlign }
119
+ onChange={ ( nextAlign ) => {
120
+ setAttributes( { textAlign: nextAlign } );
121
+ } }
122
+ />
110
123
  </BlockControls>
111
124
  ) }
112
125
  <InspectorControls>
@@ -18,7 +18,32 @@
18
18
  "core/tabs-activeTabIndex",
19
19
  "core/tabs-editorActiveTabIndex"
20
20
  ],
21
- "attributes": {},
21
+ "attributes": {
22
+ "activeBackgroundColor": {
23
+ "type": "string"
24
+ },
25
+ "customActiveBackgroundColor": {
26
+ "type": "string"
27
+ },
28
+ "activeTextColor": {
29
+ "type": "string"
30
+ },
31
+ "customActiveTextColor": {
32
+ "type": "string"
33
+ },
34
+ "hoverBackgroundColor": {
35
+ "type": "string"
36
+ },
37
+ "customHoverBackgroundColor": {
38
+ "type": "string"
39
+ },
40
+ "hoverTextColor": {
41
+ "type": "string"
42
+ },
43
+ "customHoverTextColor": {
44
+ "type": "string"
45
+ }
46
+ },
22
47
  "supports": {
23
48
  "html": false,
24
49
  "reusable": false,
@@ -9,7 +9,10 @@ import clsx from 'clsx';
9
9
  import { __, isRTL } from '@wordpress/i18n';
10
10
  import {
11
11
  BlockControls,
12
+ InspectorControls,
12
13
  store as blockEditorStore,
14
+ __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
15
+ __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
13
16
  } from '@wordpress/block-editor';
14
17
  import { ToolbarGroup, ToolbarItem, Button } from '@wordpress/components';
15
18
  import {
@@ -160,12 +163,32 @@ function TabBlockMover( {
160
163
  }
161
164
 
162
165
  export default function Controls( {
166
+ attributes,
167
+ setAttributes,
168
+ clientId,
163
169
  tabsClientId,
164
170
  tabClientId,
165
171
  tabIndex,
166
172
  tabsCount,
167
173
  tabsMenuClientId,
174
+ activeBackgroundColor,
175
+ setActiveBackgroundColor,
176
+ activeTextColor,
177
+ setActiveTextColor,
178
+ hoverBackgroundColor,
179
+ setHoverBackgroundColor,
180
+ hoverTextColor,
181
+ setHoverTextColor,
168
182
  } ) {
183
+ const {
184
+ customActiveBackgroundColor,
185
+ customActiveTextColor,
186
+ customHoverBackgroundColor,
187
+ customHoverTextColor,
188
+ } = attributes;
189
+
190
+ const colorSettings = useMultipleOriginColorsAndGradients();
191
+
169
192
  return (
170
193
  <>
171
194
  <TabBlockMover
@@ -177,6 +200,91 @@ export default function Controls( {
177
200
  />
178
201
  <AddTabToolbarControl tabsClientId={ tabsClientId } />
179
202
  <RemoveTabToolbarControl tabsClientId={ tabsClientId } />
203
+ <InspectorControls group="color">
204
+ <ColorGradientSettingsDropdown
205
+ settings={ [
206
+ {
207
+ label: __( 'Active background' ),
208
+ colorValue:
209
+ activeBackgroundColor?.color ??
210
+ customActiveBackgroundColor,
211
+ onColorChange: ( value ) => {
212
+ setActiveBackgroundColor( value );
213
+ setAttributes( {
214
+ customActiveBackgroundColor: value,
215
+ } );
216
+ },
217
+ resetAllFilter: () => {
218
+ setActiveBackgroundColor( undefined );
219
+ setAttributes( {
220
+ customActiveBackgroundColor: undefined,
221
+ } );
222
+ },
223
+ clearable: true,
224
+ },
225
+ {
226
+ label: __( 'Active text' ),
227
+ colorValue:
228
+ activeTextColor?.color ?? customActiveTextColor,
229
+ onColorChange: ( value ) => {
230
+ setActiveTextColor( value );
231
+ setAttributes( {
232
+ customActiveTextColor: value,
233
+ } );
234
+ },
235
+ resetAllFilter: () => {
236
+ setActiveTextColor( undefined );
237
+ setAttributes( {
238
+ customActiveTextColor: undefined,
239
+ } );
240
+ },
241
+ clearable: true,
242
+ },
243
+ {
244
+ label: __( 'Hover background' ),
245
+ colorValue:
246
+ hoverBackgroundColor?.color ??
247
+ customHoverBackgroundColor,
248
+ onColorChange: ( value ) => {
249
+ setHoverBackgroundColor( value );
250
+ setAttributes( {
251
+ customHoverBackgroundColor: value,
252
+ } );
253
+ },
254
+ resetAllFilter: () => {
255
+ setHoverBackgroundColor( undefined );
256
+ setAttributes( {
257
+ customHoverBackgroundColor: undefined,
258
+ } );
259
+ },
260
+ clearable: true,
261
+ },
262
+ {
263
+ label: __( 'Hover text' ),
264
+ colorValue:
265
+ hoverTextColor?.color ?? customHoverTextColor,
266
+ onColorChange: ( value ) => {
267
+ setHoverTextColor( value );
268
+ setAttributes( {
269
+ customHoverTextColor: value,
270
+ } );
271
+ },
272
+ resetAllFilter: () => {
273
+ setHoverTextColor( undefined );
274
+ setAttributes( {
275
+ customHoverTextColor: undefined,
276
+ } );
277
+ },
278
+ clearable: true,
279
+ },
280
+ ] }
281
+ panelId={ clientId }
282
+ disableCustomColors={ false }
283
+ __experimentalIsRenderedInSidebar
284
+ __next40pxDefaultSize
285
+ { ...colorSettings }
286
+ />
287
+ </InspectorControls>
180
288
  </>
181
289
  );
182
290
  }
@@ -9,6 +9,7 @@ import clsx from 'clsx';
9
9
  import { __, sprintf } from '@wordpress/i18n';
10
10
  import {
11
11
  useBlockProps,
12
+ withColors,
12
13
  store as blockEditorStore,
13
14
  RichText,
14
15
  } from '@wordpress/block-editor';
@@ -21,9 +22,19 @@ import { useCallback, useMemo } from '@wordpress/element';
21
22
  import slugFromLabel from '../tab/slug-from-label';
22
23
  import Controls from './controls';
23
24
 
24
- export default function Edit( {
25
+ function Edit( {
26
+ attributes,
27
+ setAttributes,
25
28
  context,
26
29
  clientId,
30
+ activeBackgroundColor,
31
+ setActiveBackgroundColor,
32
+ activeTextColor,
33
+ setActiveTextColor,
34
+ hoverBackgroundColor,
35
+ setHoverBackgroundColor,
36
+ hoverTextColor,
37
+ setHoverTextColor,
27
38
  __unstableLayoutClassNames: layoutClassNames,
28
39
  } ) {
29
40
  // Context from tabs-menu (per-item context via BlockContextProvider)
@@ -127,6 +138,47 @@ export default function Edit( {
127
138
  ]
128
139
  );
129
140
 
141
+ // Build CSS custom properties for active/hover color states
142
+ const customColorStyles = useMemo( () => {
143
+ const styles = {};
144
+
145
+ // Active/hover colors from custom attributes
146
+ const activeBg =
147
+ activeBackgroundColor?.color ||
148
+ attributes.customActiveBackgroundColor;
149
+ const activeText =
150
+ activeTextColor?.color || attributes.customActiveTextColor;
151
+ const hoverBg =
152
+ hoverBackgroundColor?.color ||
153
+ attributes.customHoverBackgroundColor;
154
+ const hoverText =
155
+ hoverTextColor?.color || attributes.customHoverTextColor;
156
+
157
+ if ( activeBg ) {
158
+ styles[ '--custom-tab-active-color' ] = activeBg;
159
+ }
160
+ if ( activeText ) {
161
+ styles[ '--custom-tab-active-text-color' ] = activeText;
162
+ }
163
+ if ( hoverBg ) {
164
+ styles[ '--custom-tab-hover-color' ] = hoverBg;
165
+ }
166
+ if ( hoverText ) {
167
+ styles[ '--custom-tab-hover-text-color' ] = hoverText;
168
+ }
169
+
170
+ return styles;
171
+ }, [
172
+ activeBackgroundColor?.color,
173
+ attributes.customActiveBackgroundColor,
174
+ activeTextColor?.color,
175
+ attributes.customActiveTextColor,
176
+ hoverBackgroundColor?.color,
177
+ attributes.customHoverBackgroundColor,
178
+ hoverTextColor?.color,
179
+ attributes.customHoverTextColor,
180
+ ] );
181
+
130
182
  const tabPanelId = tabId || `tab-${ tabIndex }`;
131
183
  const tabLabelId = `${ tabPanelId }--tab`;
132
184
 
@@ -136,6 +188,7 @@ export default function Edit( {
136
188
  'is-active': isActiveTab,
137
189
  'is-selected': isSelectedTab,
138
190
  } ),
191
+ style: customColorStyles,
139
192
  'aria-controls': tabPanelId,
140
193
  'aria-selected': isActiveTab,
141
194
  id: tabLabelId,
@@ -147,11 +200,24 @@ export default function Edit( {
147
200
  return (
148
201
  <>
149
202
  <Controls
150
- tabsClientId={ tabsClientId }
151
- tabClientId={ tabClientId }
152
- tabIndex={ tabIndex }
153
- tabsCount={ tabsList.length }
154
- tabsMenuClientId={ tabsMenuClientId }
203
+ { ...{
204
+ attributes,
205
+ setAttributes,
206
+ clientId,
207
+ tabsClientId,
208
+ tabClientId,
209
+ tabIndex,
210
+ tabsCount: tabsList.length,
211
+ tabsMenuClientId,
212
+ activeBackgroundColor,
213
+ setActiveBackgroundColor,
214
+ activeTextColor,
215
+ setActiveTextColor,
216
+ hoverBackgroundColor,
217
+ setHoverBackgroundColor,
218
+ hoverTextColor,
219
+ setHoverTextColor,
220
+ } }
155
221
  />
156
222
  <div { ...blockProps }>
157
223
  <RichText
@@ -169,3 +235,10 @@ export default function Edit( {
169
235
  </>
170
236
  );
171
237
  }
238
+
239
+ export default withColors(
240
+ 'activeBackgroundColor',
241
+ 'activeTextColor',
242
+ 'hoverBackgroundColor',
243
+ 'hoverTextColor'
244
+ )( Edit );
@@ -1,5 +1,6 @@
1
1
  .wp-block-tabs-menu-item {
2
2
  &.is-selected {
3
+ outline: 2px solid var(--wp-admin-theme-color, #007cba);
3
4
  outline-offset: 2px;
4
5
  }
5
6
  }
@@ -11,4 +12,9 @@
11
12
  .wp-block-tabs-menu-item {
12
13
  flex-basis: 100% !important;
13
14
  }
15
+
16
+ &:hover > .wp-block-tabs-menu-item {
17
+ background-color: var(--custom-tab-hover-color, #eaeaea) !important;
18
+ color: var(--custom-tab-hover-text-color, #000) !important;
19
+ }
14
20
  }
@@ -3,9 +3,34 @@
3
3
  */
4
4
  import { useBlockProps } from '@wordpress/block-editor';
5
5
 
6
- export default function save() {
6
+ export default function save( { attributes } ) {
7
+ // Build CSS custom properties for active/hover colors
8
+ const customColorStyles = {};
9
+
10
+ // Active/hover colors from custom attributes
11
+ if ( attributes.customActiveBackgroundColor ) {
12
+ customColorStyles[ '--custom-tab-active-color' ] =
13
+ attributes.customActiveBackgroundColor;
14
+ }
15
+ if ( attributes.customActiveTextColor ) {
16
+ customColorStyles[ '--custom-tab-active-text-color' ] =
17
+ attributes.customActiveTextColor;
18
+ }
19
+ if ( attributes.customHoverBackgroundColor ) {
20
+ customColorStyles[ '--custom-tab-hover-color' ] =
21
+ attributes.customHoverBackgroundColor;
22
+ }
23
+ if ( attributes.customHoverTextColor ) {
24
+ customColorStyles[ '--custom-tab-hover-text-color' ] =
25
+ attributes.customHoverTextColor;
26
+ }
27
+
28
+ // useBlockProps.save includes all core style engine classes and styles
29
+ // The button content is replaced by PHP during rendering, so we output
30
+ // an empty button as a template.
7
31
  const blockProps = useBlockProps.save( {
8
32
  className: 'wp-block-tabs-menu-item__template',
33
+ style: customColorStyles,
9
34
  type: 'button',
10
35
  role: 'tab',
11
36
  } );
@@ -15,7 +15,8 @@
15
15
  -webkit-appearance: none;
16
16
 
17
17
  margin: 0;
18
- padding: var(--wp--preset--spacing--20, 0.5em) var(--wp--preset--spacing--30, 1em);
18
+ padding-block: var(--tab-padding-block, var(--wp--preset--spacing--20, 0.5em));
19
+ padding-inline: var(--tab-padding-inline, var(--wp--preset--spacing--30, 1em));
19
20
 
20
21
  // Inherit typography from parent
21
22
  font-size: inherit;
@@ -26,13 +27,23 @@
26
27
  text-transform: inherit;
27
28
  text-align: inherit;
28
29
 
30
+ &:focus {
31
+ outline: none;
32
+ }
33
+
29
34
  &:focus-visible {
35
+ outline: 2px solid var(--tab-border-color-active, #000);
30
36
  outline-offset: 2px;
31
37
  }
32
38
 
39
+ &:hover {
40
+ background-color: var(--custom-tab-hover-color, #eaeaea) !important;
41
+ color: var(--custom-tab-hover-text-color, #000) !important;
42
+ }
43
+
33
44
  &[aria-selected="true"],
34
45
  &.is-active {
35
- background-color: #000;
36
- color: #fff;
46
+ background-color: var(--custom-tab-active-color, #000) !important;
47
+ color: var(--custom-tab-active-text-color, #fff) !important;
37
48
  }
38
49
  }
@@ -1,100 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/block-library/src/post-navigation-link/deprecated.js
31
- var deprecated_exports = {};
32
- __export(deprecated_exports, {
33
- default: () => deprecated_default
34
- });
35
- module.exports = __toCommonJS(deprecated_exports);
36
- var import_migrate_text_align = __toESM(require("../utils/migrate-text-align.cjs"));
37
- var v1 = {
38
- attributes: {
39
- textAlign: {
40
- type: "string"
41
- },
42
- type: {
43
- type: "string",
44
- default: "next"
45
- },
46
- label: {
47
- type: "string",
48
- role: "content"
49
- },
50
- showTitle: {
51
- type: "boolean",
52
- default: false
53
- },
54
- linkLabel: {
55
- type: "boolean",
56
- default: false
57
- },
58
- arrow: {
59
- type: "string",
60
- default: "none"
61
- },
62
- taxonomy: {
63
- type: "string",
64
- default: ""
65
- }
66
- },
67
- supports: {
68
- anchor: true,
69
- reusable: false,
70
- html: false,
71
- color: {
72
- link: true
73
- },
74
- typography: {
75
- fontSize: true,
76
- lineHeight: true,
77
- __experimentalFontFamily: true,
78
- __experimentalFontWeight: true,
79
- __experimentalFontStyle: true,
80
- __experimentalTextTransform: true,
81
- __experimentalTextDecoration: true,
82
- __experimentalLetterSpacing: true,
83
- __experimentalDefaultControls: {
84
- fontSize: true
85
- }
86
- },
87
- interactivity: {
88
- clientNavigation: true
89
- }
90
- },
91
- migrate: import_migrate_text_align.default,
92
- isEligible(attributes) {
93
- return !!attributes.textAlign || !!attributes.className?.match(
94
- /\bhas-text-align-(left|center|right)\b/
95
- );
96
- },
97
- save: () => null
98
- };
99
- var deprecated_default = [v1];
100
- //# sourceMappingURL=deprecated.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/post-navigation-link/deprecated.js"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport migrateTextAlign from '../utils/migrate-text-align';\n\nconst v1 = {\n\tattributes: {\n\t\ttextAlign: {\n\t\t\ttype: 'string',\n\t\t},\n\t\ttype: {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'next',\n\t\t},\n\t\tlabel: {\n\t\t\ttype: 'string',\n\t\t\trole: 'content',\n\t\t},\n\t\tshowTitle: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t\tlinkLabel: {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t\tarrow: {\n\t\t\ttype: 'string',\n\t\t\tdefault: 'none',\n\t\t},\n\t\ttaxonomy: {\n\t\t\ttype: 'string',\n\t\t\tdefault: '',\n\t\t},\n\t},\n\tsupports: {\n\t\tanchor: true,\n\t\treusable: false,\n\t\thtml: false,\n\t\tcolor: {\n\t\t\tlink: true,\n\t\t},\n\t\ttypography: {\n\t\t\tfontSize: true,\n\t\t\tlineHeight: true,\n\t\t\t__experimentalFontFamily: true,\n\t\t\t__experimentalFontWeight: true,\n\t\t\t__experimentalFontStyle: true,\n\t\t\t__experimentalTextTransform: true,\n\t\t\t__experimentalTextDecoration: true,\n\t\t\t__experimentalLetterSpacing: true,\n\t\t\t__experimentalDefaultControls: {\n\t\t\t\tfontSize: true,\n\t\t\t},\n\t\t},\n\t\tinteractivity: {\n\t\t\tclientNavigation: true,\n\t\t},\n\t},\n\tmigrate: migrateTextAlign,\n\tisEligible( attributes ) {\n\t\treturn (\n\t\t\t!! attributes.textAlign ||\n\t\t\t!! attributes.className?.match(\n\t\t\t\t/\\bhas-text-align-(left|center|right)\\b/\n\t\t\t)\n\t\t);\n\t},\n\tsave: () => null,\n};\n\nexport default [ v1 ];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,gCAA6B;AAE7B,IAAM,KAAK;AAAA,EACV,YAAY;AAAA,IACX,WAAW;AAAA,MACV,MAAM;AAAA,IACP;AAAA,IACA,MAAM;AAAA,MACL,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACP;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,WAAW;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,OAAO;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA,UAAU;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,EACD;AAAA,EACA,UAAU;AAAA,IACT,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,MACN,MAAM;AAAA,IACP;AAAA,IACA,YAAY;AAAA,MACX,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,0BAA0B;AAAA,MAC1B,0BAA0B;AAAA,MAC1B,yBAAyB;AAAA,MACzB,6BAA6B;AAAA,MAC7B,8BAA8B;AAAA,MAC9B,6BAA6B;AAAA,MAC7B,+BAA+B;AAAA,QAC9B,UAAU;AAAA,MACX;AAAA,IACD;AAAA,IACA,eAAe;AAAA,MACd,kBAAkB;AAAA,IACnB;AAAA,EACD;AAAA,EACA,SAAS,0BAAAA;AAAA,EACT,WAAY,YAAa;AACxB,WACC,CAAC,CAAE,WAAW,aACd,CAAC,CAAE,WAAW,WAAW;AAAA,MACxB;AAAA,IACD;AAAA,EAEF;AAAA,EACA,MAAM,MAAM;AACb;AAEA,IAAO,qBAAQ,CAAE,EAAG;",
6
- "names": ["migrateTextAlign"]
7
- }