@wordpress/block-library 9.38.1-next.v.0 → 9.39.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 (273) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/button/index.cjs +3 -0
  3. package/build/button/index.cjs.map +2 -2
  4. package/build/comments-title/block.json +1 -3
  5. package/build/comments-title/deprecated.cjs +148 -24
  6. package/build/comments-title/deprecated.cjs.map +3 -3
  7. package/build/comments-title/edit.cjs +17 -31
  8. package/build/comments-title/edit.cjs.map +3 -3
  9. package/build/cover/edit/block-controls.cjs +10 -2
  10. package/build/cover/edit/block-controls.cjs.map +2 -2
  11. package/build/cover/edit/embed-video-url-input.cjs +6 -2
  12. package/build/cover/edit/embed-video-url-input.cjs.map +2 -2
  13. package/build/details/index.cjs +3 -0
  14. package/build/details/index.cjs.map +2 -2
  15. package/build/heading/index.cjs +3 -0
  16. package/build/heading/index.cjs.map +2 -2
  17. package/build/image/index.cjs +1 -1
  18. package/build/image/index.cjs.map +2 -2
  19. package/build/index.cjs +6 -0
  20. package/build/index.cjs.map +2 -2
  21. package/build/list-item/index.cjs +3 -0
  22. package/build/list-item/index.cjs.map +2 -2
  23. package/build/more/index.cjs +1 -1
  24. package/build/more/index.cjs.map +2 -2
  25. package/build/navigation/edit/index.cjs +23 -2
  26. package/build/navigation/edit/index.cjs.map +2 -2
  27. package/build/navigation-submenu/index.cjs +2 -2
  28. package/build/navigation-submenu/index.cjs.map +2 -2
  29. package/build/paragraph/index.cjs +1 -1
  30. package/build/paragraph/index.cjs.map +2 -2
  31. package/build/post-excerpt/edit.cjs +1 -1
  32. package/build/post-excerpt/edit.cjs.map +2 -2
  33. package/build/tab/add-tab-toolbar-control.cjs +31 -9
  34. package/build/tab/add-tab-toolbar-control.cjs.map +2 -2
  35. package/build/tab/block.json +18 -4
  36. package/build/tab/controls.cjs +4 -8
  37. package/build/tab/controls.cjs.map +3 -3
  38. package/build/tab/edit.cjs +46 -118
  39. package/build/tab/edit.cjs.map +3 -3
  40. package/build/tab/remove-tab-toolbar-control.cjs +91 -0
  41. package/build/tab/remove-tab-toolbar-control.cjs.map +7 -0
  42. package/build/tab/save.cjs +2 -2
  43. package/build/tab/save.cjs.map +2 -2
  44. package/build/tab-panels/block.json +70 -0
  45. package/build/tab-panels/edit.cjs +63 -0
  46. package/build/tab-panels/edit.cjs.map +7 -0
  47. package/build/tab-panels/icon.cjs +29 -0
  48. package/build/tab-panels/icon.cjs.map +7 -0
  49. package/build/tab-panels/index.cjs +58 -0
  50. package/build/tab-panels/index.cjs.map +7 -0
  51. package/build/tab-panels/save.cjs +33 -0
  52. package/build/tab-panels/save.cjs.map +7 -0
  53. package/build/tabs/block.json +61 -90
  54. package/build/tabs/controls.cjs +19 -221
  55. package/build/tabs/controls.cjs.map +3 -3
  56. package/build/tabs/deprecated.cjs +179 -0
  57. package/build/tabs/deprecated.cjs.map +7 -0
  58. package/build/tabs/edit.cjs +84 -62
  59. package/build/tabs/edit.cjs.map +3 -3
  60. package/build/tabs/index.cjs +3 -1
  61. package/build/tabs/index.cjs.map +3 -3
  62. package/build/tabs/save.cjs +6 -9
  63. package/build/tabs/save.cjs.map +2 -2
  64. package/build/tabs-menu/block.json +77 -0
  65. package/build/tabs-menu/edit.cjs +204 -0
  66. package/build/tabs-menu/edit.cjs.map +7 -0
  67. package/build/tabs-menu/icon.cjs +29 -0
  68. package/build/tabs-menu/icon.cjs.map +7 -0
  69. package/build/tabs-menu/index.cjs +58 -0
  70. package/build/tabs-menu/index.cjs.map +7 -0
  71. package/build/tabs-menu/save.cjs +35 -0
  72. package/build/tabs-menu/save.cjs.map +7 -0
  73. package/build/tabs-menu-item/block.json +98 -0
  74. package/build/tabs-menu-item/controls.cjs +247 -0
  75. package/build/tabs-menu-item/controls.cjs.map +7 -0
  76. package/build/tabs-menu-item/edit.cjs +272 -0
  77. package/build/tabs-menu-item/edit.cjs.map +7 -0
  78. package/build/tabs-menu-item/icon.cjs +29 -0
  79. package/build/tabs-menu-item/icon.cjs.map +7 -0
  80. package/build/tabs-menu-item/index.cjs +58 -0
  81. package/build/tabs-menu-item/index.cjs.map +7 -0
  82. package/build/tabs-menu-item/save.cjs +50 -0
  83. package/build/tabs-menu-item/save.cjs.map +7 -0
  84. package/build/template-part/edit/index.cjs +1 -1
  85. package/build/template-part/edit/index.cjs.map +2 -2
  86. package/build/utils/caption.cjs +4 -6
  87. package/build/utils/caption.cjs.map +3 -3
  88. package/build/video/edit.cjs +4 -2
  89. package/build/video/edit.cjs.map +2 -2
  90. package/build-module/button/index.mjs +3 -0
  91. package/build-module/button/index.mjs.map +2 -2
  92. package/build-module/comments-title/block.json +1 -3
  93. package/build-module/comments-title/deprecated.mjs +148 -24
  94. package/build-module/comments-title/deprecated.mjs.map +2 -2
  95. package/build-module/comments-title/edit.mjs +17 -32
  96. package/build-module/comments-title/edit.mjs.map +2 -2
  97. package/build-module/cover/edit/block-controls.mjs +11 -3
  98. package/build-module/cover/edit/block-controls.mjs.map +2 -2
  99. package/build-module/cover/edit/embed-video-url-input.mjs +6 -2
  100. package/build-module/cover/edit/embed-video-url-input.mjs.map +2 -2
  101. package/build-module/details/index.mjs +3 -0
  102. package/build-module/details/index.mjs.map +2 -2
  103. package/build-module/heading/index.mjs +3 -0
  104. package/build-module/heading/index.mjs.map +2 -2
  105. package/build-module/image/index.mjs +1 -1
  106. package/build-module/image/index.mjs.map +2 -2
  107. package/build-module/index.mjs +6 -0
  108. package/build-module/index.mjs.map +2 -2
  109. package/build-module/list-item/index.mjs +3 -0
  110. package/build-module/list-item/index.mjs.map +2 -2
  111. package/build-module/more/index.mjs +1 -1
  112. package/build-module/more/index.mjs.map +2 -2
  113. package/build-module/navigation/edit/index.mjs +23 -2
  114. package/build-module/navigation/edit/index.mjs.map +2 -2
  115. package/build-module/navigation-submenu/index.mjs +2 -2
  116. package/build-module/navigation-submenu/index.mjs.map +2 -2
  117. package/build-module/paragraph/index.mjs +1 -1
  118. package/build-module/paragraph/index.mjs.map +2 -2
  119. package/build-module/post-excerpt/edit.mjs +1 -1
  120. package/build-module/post-excerpt/edit.mjs.map +2 -2
  121. package/build-module/tab/add-tab-toolbar-control.mjs +32 -10
  122. package/build-module/tab/add-tab-toolbar-control.mjs.map +2 -2
  123. package/build-module/tab/block.json +18 -4
  124. package/build-module/tab/controls.mjs +4 -8
  125. package/build-module/tab/controls.mjs.map +2 -2
  126. package/build-module/tab/edit.mjs +48 -128
  127. package/build-module/tab/edit.mjs.map +2 -2
  128. package/build-module/tab/remove-tab-toolbar-control.mjs +73 -0
  129. package/build-module/tab/remove-tab-toolbar-control.mjs.map +7 -0
  130. package/build-module/tab/save.mjs +2 -2
  131. package/build-module/tab/save.mjs.map +2 -2
  132. package/build-module/tab-panels/block.json +70 -0
  133. package/build-module/tab-panels/edit.mjs +36 -0
  134. package/build-module/tab-panels/edit.mjs.map +7 -0
  135. package/build-module/tab-panels/icon.mjs +8 -0
  136. package/build-module/tab-panels/icon.mjs.map +7 -0
  137. package/build-module/tab-panels/index.mjs +20 -0
  138. package/build-module/tab-panels/index.mjs.map +7 -0
  139. package/build-module/tab-panels/save.mjs +12 -0
  140. package/build-module/tab-panels/save.mjs.map +7 -0
  141. package/build-module/tabs/block.json +61 -90
  142. package/build-module/tabs/controls.mjs +21 -228
  143. package/build-module/tabs/controls.mjs.map +2 -2
  144. package/build-module/tabs/deprecated.mjs +158 -0
  145. package/build-module/tabs/deprecated.mjs.map +7 -0
  146. package/build-module/tabs/edit.mjs +87 -64
  147. package/build-module/tabs/edit.mjs.map +2 -2
  148. package/build-module/tabs/index.mjs +3 -1
  149. package/build-module/tabs/index.mjs.map +2 -2
  150. package/build-module/tabs/save.mjs +7 -10
  151. package/build-module/tabs/save.mjs.map +2 -2
  152. package/build-module/tabs-menu/block.json +77 -0
  153. package/build-module/tabs-menu/edit.mjs +186 -0
  154. package/build-module/tabs-menu/edit.mjs.map +7 -0
  155. package/build-module/tabs-menu/icon.mjs +8 -0
  156. package/build-module/tabs-menu/icon.mjs.map +7 -0
  157. package/build-module/tabs-menu/index.mjs +20 -0
  158. package/build-module/tabs-menu/index.mjs.map +7 -0
  159. package/build-module/tabs-menu/save.mjs +14 -0
  160. package/build-module/tabs-menu/save.mjs.map +7 -0
  161. package/build-module/tabs-menu-item/block.json +98 -0
  162. package/build-module/tabs-menu-item/controls.mjs +227 -0
  163. package/build-module/tabs-menu-item/controls.mjs.map +7 -0
  164. package/build-module/tabs-menu-item/edit.mjs +253 -0
  165. package/build-module/tabs-menu-item/edit.mjs.map +7 -0
  166. package/build-module/tabs-menu-item/icon.mjs +8 -0
  167. package/build-module/tabs-menu-item/icon.mjs.map +7 -0
  168. package/build-module/tabs-menu-item/index.mjs +20 -0
  169. package/build-module/tabs-menu-item/index.mjs.map +7 -0
  170. package/build-module/tabs-menu-item/save.mjs +29 -0
  171. package/build-module/tabs-menu-item/save.mjs.map +7 -0
  172. package/build-module/template-part/edit/index.mjs +1 -1
  173. package/build-module/template-part/edit/index.mjs.map +2 -2
  174. package/build-module/utils/caption.mjs +1 -3
  175. package/build-module/utils/caption.mjs.map +2 -2
  176. package/build-module/video/edit.mjs +4 -2
  177. package/build-module/video/edit.mjs.map +2 -2
  178. package/build-style/editor-rtl.css +16 -21
  179. package/build-style/editor.css +16 -21
  180. package/build-style/gallery/style-rtl.css +1 -1
  181. package/build-style/gallery/style.css +1 -1
  182. package/build-style/style-rtl.css +42 -153
  183. package/build-style/style.css +42 -153
  184. package/build-style/tab/style-rtl.css +7 -1
  185. package/build-style/tab/style.css +7 -1
  186. package/build-style/tab-panels/style-rtl.css +4 -0
  187. package/build-style/tab-panels/style.css +4 -0
  188. package/build-style/tabs/style-rtl.css +1 -167
  189. package/build-style/tabs/style.css +1 -167
  190. package/build-style/tabs-menu/editor-rtl.css +4 -0
  191. package/build-style/tabs-menu/editor.css +4 -0
  192. package/build-style/tabs-menu/style-rtl.css +8 -0
  193. package/build-style/tabs-menu/style.css +8 -0
  194. package/build-style/tabs-menu-item/editor-rtl.css +16 -0
  195. package/build-style/tabs-menu-item/editor.css +16 -0
  196. package/build-style/tabs-menu-item/style-rtl.css +34 -0
  197. package/build-style/tabs-menu-item/style.css +34 -0
  198. package/package.json +37 -37
  199. package/src/button/index.js +4 -0
  200. package/src/comments-title/block.json +1 -3
  201. package/src/comments-title/deprecated.js +153 -23
  202. package/src/comments-title/edit.js +9 -25
  203. package/src/cover/edit/block-controls.js +14 -3
  204. package/src/cover/edit/embed-video-url-input.js +6 -2
  205. package/src/details/index.js +4 -0
  206. package/src/editor.scss +2 -1
  207. package/src/gallery/style.scss +1 -1
  208. package/src/heading/index.js +4 -0
  209. package/src/image/index.js +4 -1
  210. package/src/index.js +6 -0
  211. package/src/list-item/index.js +4 -0
  212. package/src/more/index.js +4 -1
  213. package/src/navigation/edit/index.js +28 -4
  214. package/src/navigation-submenu/index.js +6 -3
  215. package/src/paragraph/index.js +4 -1
  216. package/src/post-excerpt/edit.js +1 -1
  217. package/src/post-excerpt/index.php +39 -16
  218. package/src/style.scss +3 -0
  219. package/src/tab/add-tab-toolbar-control.js +36 -11
  220. package/src/tab/block.json +18 -4
  221. package/src/tab/controls.js +4 -5
  222. package/src/tab/edit.js +75 -150
  223. package/src/tab/index.php +5 -63
  224. package/src/tab/remove-tab-toolbar-control.js +103 -0
  225. package/src/tab/save.js +1 -3
  226. package/src/tab/style.scss +8 -1
  227. package/src/tab-panels/block.json +70 -0
  228. package/src/tab-panels/edit.js +44 -0
  229. package/src/tab-panels/icon.js +10 -0
  230. package/src/tab-panels/index.js +21 -0
  231. package/src/tab-panels/save.js +11 -0
  232. package/src/tab-panels/style.scss +4 -0
  233. package/src/tabs/block.json +61 -90
  234. package/src/tabs/controls.js +7 -221
  235. package/src/tabs/deprecated.js +214 -0
  236. package/src/tabs/edit.js +108 -68
  237. package/src/tabs/index.js +2 -0
  238. package/src/tabs/index.php +86 -191
  239. package/src/tabs/save.js +6 -13
  240. package/src/tabs/style.scss +1 -187
  241. package/src/tabs-menu/block.json +77 -0
  242. package/src/tabs-menu/edit.js +251 -0
  243. package/src/tabs-menu/editor.scss +6 -0
  244. package/src/tabs-menu/icon.js +10 -0
  245. package/src/tabs-menu/index.js +21 -0
  246. package/src/tabs-menu/index.php +74 -0
  247. package/src/tabs-menu/save.js +18 -0
  248. package/src/tabs-menu/style.scss +8 -0
  249. package/src/tabs-menu-item/block.json +98 -0
  250. package/src/tabs-menu-item/controls.js +262 -0
  251. package/src/tabs-menu-item/edit.js +322 -0
  252. package/src/tabs-menu-item/editor.scss +20 -0
  253. package/src/tabs-menu-item/icon.js +10 -0
  254. package/src/tabs-menu-item/index.js +21 -0
  255. package/src/tabs-menu-item/index.php +82 -0
  256. package/src/tabs-menu-item/save.js +44 -0
  257. package/src/tabs-menu-item/style.scss +42 -0
  258. package/src/template-part/edit/index.js +1 -3
  259. package/src/utils/caption.js +1 -7
  260. package/src/video/edit.js +4 -2
  261. package/build/tab/tabs-list.cjs +0 -132
  262. package/build/tab/tabs-list.cjs.map +0 -7
  263. package/build/tabs/style-engine.cjs +0 -119
  264. package/build/tabs/style-engine.cjs.map +0 -7
  265. package/build-module/tab/tabs-list.mjs +0 -101
  266. package/build-module/tab/tabs-list.mjs.map +0 -7
  267. package/build-module/tabs/style-engine.mjs +0 -101
  268. package/build-module/tabs/style-engine.mjs.map +0 -7
  269. package/build-style/tabs/editor-rtl.css +0 -26
  270. package/build-style/tabs/editor.css +0 -26
  271. package/src/tab/tabs-list.js +0 -122
  272. package/src/tabs/editor.scss +0 -30
  273. package/src/tabs/style-engine.js +0 -164
@@ -2,161 +2,28 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { ToggleControl, PanelBody, TextControl } from '@wordpress/components';
6
- import { useMemo } from '@wordpress/element';
7
- import {
8
- ContrastChecker,
9
- InspectorControls,
10
- __experimentalColorGradientSettingsDropdown as ColorGradientSettingsDropdown,
11
- __experimentalUseMultipleOriginColorsAndGradients as useMultipleOriginColorsAndGradients,
12
- } from '@wordpress/block-editor';
5
+ import { PanelBody, TextControl } from '@wordpress/components';
6
+ import { InspectorControls } from '@wordpress/block-editor';
13
7
 
14
8
  /**
15
9
  * Internal dependencies
16
10
  */
17
11
  import AddTabToolbarControl from '../tab/add-tab-toolbar-control';
12
+ import RemoveTabToolbarControl from '../tab/remove-tab-toolbar-control';
18
13
 
19
- function ContrastCheckerMatrix( { attributes } ) {
14
+ export default function Controls( { attributes, setAttributes, clientId } ) {
20
15
  const {
21
- className,
22
- fontSize,
23
- tabActiveColor,
24
- customTabActiveColor,
25
- tabActiveTextColor,
26
- customTabActiveTextColor,
27
- tabInactiveColor,
28
- customTabInactiveColor,
29
- tabTextColor,
30
- customTabTextColor,
31
- tabHoverColor,
32
- customTabHoverColor,
33
- tabHoverTextColor,
34
- customTabHoverTextColor,
35
- } = attributes;
36
-
37
- const activeBackground = useMemo( () => {
38
- if ( className?.includes( 'is-style-links' ) ) {
39
- return '#fff';
40
- }
41
- if ( tabActiveColor?.color ) {
42
- return tabActiveColor.color;
43
- }
44
- return customTabActiveColor;
45
- }, [ tabActiveColor, customTabActiveColor, className ] );
46
-
47
- const activeText = useMemo( () => {
48
- if ( tabActiveTextColor?.color ) {
49
- return tabActiveTextColor.color;
50
- }
51
- return customTabActiveTextColor;
52
- }, [ tabActiveTextColor, customTabActiveTextColor ] );
53
-
54
- const inactiveBackground = useMemo( () => {
55
- if ( className?.includes( 'is-style-links' ) ) {
56
- return '#fff';
57
- }
58
- if ( tabInactiveColor?.color ) {
59
- return tabInactiveColor.color;
60
- }
61
- return customTabInactiveColor;
62
- }, [ tabInactiveColor, customTabInactiveColor, className ] );
63
-
64
- const inactiveText = useMemo( () => {
65
- if ( tabTextColor?.color ) {
66
- return tabTextColor.color;
67
- }
68
- return customTabTextColor;
69
- }, [ tabTextColor, customTabTextColor ] );
70
-
71
- const hoverBackground = useMemo( () => {
72
- if ( tabHoverColor?.color ) {
73
- return tabHoverColor.color;
74
- }
75
- return customTabHoverColor;
76
- }, [ tabHoverColor, customTabHoverColor ] );
77
-
78
- const hoverText = useMemo( () => {
79
- if ( tabHoverTextColor?.color ) {
80
- return tabHoverTextColor.color;
81
- }
82
- return customTabHoverTextColor;
83
- }, [ tabHoverTextColor, customTabHoverTextColor ] );
84
-
85
- return (
86
- <>
87
- <ContrastChecker
88
- backgroundColor={ activeBackground }
89
- fontSize={ fontSize }
90
- textColor={ activeText }
91
- />
92
- <ContrastChecker
93
- backgroundColor={ inactiveBackground }
94
- fontSize={ fontSize }
95
- textColor={ inactiveText }
96
- />
97
- <ContrastChecker
98
- backgroundColor={ hoverBackground }
99
- fontSize={ fontSize }
100
- textColor={ hoverText }
101
- />
102
- </>
103
- );
104
- }
105
-
106
- export default function Controls( {
107
- attributes,
108
- setAttributes,
109
- clientId,
110
- tabInactiveColor,
111
- setTabInactiveColor,
112
- tabHoverColor,
113
- setTabHoverColor,
114
- tabActiveColor,
115
- setTabActiveColor,
116
- tabTextColor,
117
- setTabTextColor,
118
- tabActiveTextColor,
119
- setTabActiveTextColor,
120
- tabHoverTextColor,
121
- setTabHoverTextColor,
122
- } ) {
123
- const {
124
- customTabInactiveColor,
125
- customTabActiveColor,
126
- customTabHoverColor,
127
- customTabTextColor,
128
- customTabActiveTextColor,
129
- customTabHoverTextColor,
130
- orientation,
131
16
  metadata = {
132
17
  name: '',
133
18
  },
134
19
  } = attributes;
135
- /**
136
- * Get the color settings for the block.
137
- */
138
- const colorSettings = useMultipleOriginColorsAndGradients();
139
20
 
140
21
  return (
141
22
  <>
142
- <AddTabToolbarControl
143
- tabsClientId={ clientId }
144
- attributes={ attributes }
145
- />
23
+ <AddTabToolbarControl tabsClientId={ clientId } />
24
+ <RemoveTabToolbarControl tabsClientId={ clientId } />
146
25
  <InspectorControls>
147
- <PanelBody title={ __( 'Tabs Settings' ) }>
148
- <ToggleControl
149
- label={ __( 'Vertical Tabs' ) }
150
- checked={ 'vertical' === orientation }
151
- onChange={ () =>
152
- setAttributes( {
153
- orientation:
154
- 'vertical' === orientation
155
- ? 'horizontal'
156
- : 'vertical',
157
- } )
158
- }
159
- />
26
+ <PanelBody title={ __( 'Settings' ) }>
160
27
  <TextControl
161
28
  label={ __( 'Tabs Title' ) }
162
29
  help={ __(
@@ -173,87 +40,6 @@ export default function Controls( {
173
40
  />
174
41
  </PanelBody>
175
42
  </InspectorControls>
176
- <InspectorControls group="color">
177
- <ColorGradientSettingsDropdown
178
- settings={ [
179
- {
180
- label: __( 'Tab Active Background' ),
181
- colorValue:
182
- tabActiveColor?.color ?? customTabActiveColor,
183
- onColorChange: ( value ) => {
184
- setTabActiveColor( value );
185
- setAttributes( {
186
- customTabActiveColor: value,
187
- } );
188
- },
189
- },
190
- {
191
- label: __( 'Tab Active Text' ),
192
- colorValue:
193
- tabActiveTextColor?.color ??
194
- customTabActiveTextColor,
195
- onColorChange: ( value ) => {
196
- setTabActiveTextColor( value );
197
- setAttributes( {
198
- customTabActiveTextColor: value,
199
- } );
200
- },
201
- },
202
- {
203
- label: __( 'Tab Inactive Background' ),
204
- colorValue:
205
- tabInactiveColor?.color ??
206
- customTabInactiveColor,
207
- onColorChange: ( value ) => {
208
- setTabInactiveColor( value );
209
- setAttributes( {
210
- customTabInactiveColor: value,
211
- } );
212
- },
213
- },
214
- {
215
- label: __( 'Tab Inactive Text' ),
216
- colorValue:
217
- tabTextColor?.color ?? customTabTextColor,
218
- onColorChange: ( value ) => {
219
- setTabTextColor( value );
220
- setAttributes( {
221
- customTabTextColor: value,
222
- } );
223
- },
224
- },
225
- {
226
- label: __( 'Tab Hover Background' ),
227
- colorValue:
228
- tabHoverColor?.color ?? customTabHoverColor,
229
- onColorChange: ( value ) => {
230
- setTabHoverColor( value );
231
- setAttributes( {
232
- customTabHoverColor: value,
233
- } );
234
- },
235
- },
236
- {
237
- label: __( 'Tab Hover Text' ),
238
- colorValue:
239
- tabHoverTextColor?.color ??
240
- customTabHoverTextColor,
241
- onColorChange: ( value ) => {
242
- setTabHoverTextColor( value );
243
- setAttributes( {
244
- customTabHoverTextColor: value,
245
- } );
246
- },
247
- },
248
- ] }
249
- panelId={ clientId }
250
- disableCustomColors={ false }
251
- __experimentalIsRenderedInSidebar
252
- __next40pxDefaultSize
253
- { ...colorSettings }
254
- />
255
- <ContrastCheckerMatrix attributes={ attributes } />
256
- </InspectorControls>
257
43
  </>
258
44
  );
259
45
  }
@@ -0,0 +1,214 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
+ import { createBlock } from '@wordpress/blocks';
6
+
7
+ /**
8
+ * The old attributes before restructuring.
9
+ * Maintain during experimental phase to allow for migration.
10
+ *
11
+ * TODO: Should be removed after the experimental phase before release into main block library.
12
+ */
13
+ const v1Attributes = {
14
+ tabsId: {
15
+ type: 'string',
16
+ default: '',
17
+ },
18
+ orientation: {
19
+ type: 'string',
20
+ default: 'horizontal',
21
+ enum: [ 'horizontal', 'vertical' ],
22
+ },
23
+ activeTabIndex: {
24
+ type: 'number',
25
+ default: 0,
26
+ },
27
+ tabInactiveColor: {
28
+ type: 'string',
29
+ },
30
+ customTabInactiveColor: {
31
+ type: 'string',
32
+ },
33
+ tabHoverColor: {
34
+ type: 'string',
35
+ },
36
+ customTabHoverColor: {
37
+ type: 'string',
38
+ },
39
+ tabActiveColor: {
40
+ type: 'string',
41
+ },
42
+ customTabActiveColor: {
43
+ type: 'string',
44
+ },
45
+ tabTextColor: {
46
+ type: 'string',
47
+ },
48
+ customTabTextColor: {
49
+ type: 'string',
50
+ },
51
+ tabActiveTextColor: {
52
+ type: 'string',
53
+ },
54
+ customTabActiveTextColor: {
55
+ type: 'string',
56
+ },
57
+ tabHoverTextColor: {
58
+ type: 'string',
59
+ },
60
+ customTabHoverTextColor: {
61
+ type: 'string',
62
+ },
63
+ };
64
+
65
+ /**
66
+ * The old save function before restructuring.
67
+ * This renders the tab blocks directly as children with a tabs list placeholder.
68
+ *
69
+ * @param {Object} root0 Component props.
70
+ * @param {Object} root0.attributes Block attributes.
71
+ */
72
+ function v1Save( { attributes } ) {
73
+ const blockProps = useBlockProps.save();
74
+ const innerBlocksProps = useInnerBlocksProps.save( {} );
75
+ const title = attributes?.metadata?.name || 'Tab Contents';
76
+
77
+ return (
78
+ <div { ...blockProps }>
79
+ <h3 className="tabs__title">{ title }</h3>
80
+ <ul className="tabs__list"></ul>
81
+ { innerBlocksProps.children }
82
+ </div>
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Migration function to convert old tabs structure to new structure.
88
+ *
89
+ * Old structure:
90
+ * - core/tabs (with color attributes and tab innerblocks)
91
+ * - core/tab
92
+ * - core/tab
93
+ *
94
+ * New structure:
95
+ * - core/tabs (orientation only)
96
+ * - core/tabs-menu (with color attributes)
97
+ * - core/tab-panels
98
+ * - core/tab
99
+ * - core/tab
100
+ *
101
+ * @param {Object} attributes Block attributes.
102
+ * @param {Array} innerBlocks Inner blocks array.
103
+ */
104
+ function v1Migrate( attributes, innerBlocks ) {
105
+ // Extract color attributes for tabs-menu
106
+ const tabsMenuAttributes = {
107
+ // Map inactive colors to core background/text supports
108
+ backgroundColor: attributes.tabInactiveColor,
109
+ textColor: attributes.tabTextColor,
110
+ // Map custom inactive colors
111
+ style: {
112
+ color: {
113
+ background: attributes.customTabInactiveColor,
114
+ text: attributes.customTabTextColor,
115
+ },
116
+ },
117
+ // Active colors
118
+ activeBackgroundColor: attributes.tabActiveColor,
119
+ customActiveBackgroundColor: attributes.customTabActiveColor,
120
+ activeTextColor: attributes.tabActiveTextColor,
121
+ customActiveTextColor: attributes.customTabActiveTextColor,
122
+ // Hover colors
123
+ hoverBackgroundColor: attributes.tabHoverColor,
124
+ customHoverBackgroundColor: attributes.customTabHoverColor,
125
+ hoverTextColor: attributes.tabHoverTextColor,
126
+ customHoverTextColor: attributes.customTabHoverTextColor,
127
+ };
128
+
129
+ // Clean up undefined values from style object
130
+ if ( tabsMenuAttributes.style?.color ) {
131
+ if ( ! tabsMenuAttributes.style.color.background ) {
132
+ delete tabsMenuAttributes.style.color.background;
133
+ }
134
+ if ( ! tabsMenuAttributes.style.color.text ) {
135
+ delete tabsMenuAttributes.style.color.text;
136
+ }
137
+ if ( Object.keys( tabsMenuAttributes.style.color ).length === 0 ) {
138
+ delete tabsMenuAttributes.style.color;
139
+ }
140
+ if ( Object.keys( tabsMenuAttributes.style ).length === 0 ) {
141
+ delete tabsMenuAttributes.style;
142
+ }
143
+ }
144
+
145
+ // Clean up undefined top-level attributes
146
+ Object.keys( tabsMenuAttributes ).forEach( ( key ) => {
147
+ if ( tabsMenuAttributes[ key ] === undefined ) {
148
+ delete tabsMenuAttributes[ key ];
149
+ }
150
+ } );
151
+
152
+ // Create tabs-menu block
153
+ const tabsMenuBlock = createBlock( 'core/tabs-menu', tabsMenuAttributes );
154
+
155
+ // Create tab-panels block with existing tab innerblocks
156
+ const tabPanelsBlock = createBlock( 'core/tab-panels', {}, innerBlocks );
157
+
158
+ // Return new attributes (stripped of color attrs) and new innerblocks structure
159
+ const newAttributes = {
160
+ tabsId: attributes.tabsId,
161
+ orientation: attributes.orientation,
162
+ activeTabIndex: attributes.activeTabIndex,
163
+ metadata: attributes.metadata,
164
+ };
165
+
166
+ return [ newAttributes, [ tabsMenuBlock, tabPanelsBlock ] ];
167
+ }
168
+
169
+ /**
170
+ * Check if block is using old structure (tab blocks directly as children).
171
+ *
172
+ * @param {Object} attributes Block attributes.
173
+ * @param {Array} innerBlocks Inner blocks array.
174
+ */
175
+ function v1IsEligible( attributes, innerBlocks ) {
176
+ // If there are any direct tab children (not wrapped in tab-panels), this is old structure
177
+ return innerBlocks.some( ( block ) => block.name === 'core/tab' );
178
+ }
179
+
180
+ const deprecated = [
181
+ {
182
+ attributes: v1Attributes,
183
+ supports: {
184
+ align: true,
185
+ color: {
186
+ text: false,
187
+ background: false,
188
+ },
189
+ html: false,
190
+ interactivity: true,
191
+ spacing: {
192
+ blockGap: [ 'horizontal', 'vertical' ],
193
+ margin: true,
194
+ padding: false,
195
+ },
196
+ typography: {
197
+ fontSize: true,
198
+ __experimentalFontFamily: true,
199
+ },
200
+ __experimentalBorder: {
201
+ radius: true,
202
+ __experimentalSkipSerialization: true,
203
+ __experimentalDefaultControls: {
204
+ radius: true,
205
+ },
206
+ },
207
+ },
208
+ isEligible: v1IsEligible,
209
+ migrate: v1Migrate,
210
+ save: v1Save,
211
+ },
212
+ ];
213
+
214
+ export default deprecated;
package/src/tabs/edit.js CHANGED
@@ -1,108 +1,148 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
1
  /**
7
2
  * WordPress dependencies
8
3
  */
4
+ import { __ } from '@wordpress/i18n';
9
5
  import {
10
6
  useBlockProps,
11
7
  useInnerBlocksProps,
12
- withColors,
8
+ BlockContextProvider,
9
+ store as blockEditorStore,
13
10
  } from '@wordpress/block-editor';
11
+ import { useSelect } from '@wordpress/data';
12
+ import { useMemo, useEffect } from '@wordpress/element';
14
13
 
15
14
  /**
16
15
  * Internal dependencies
17
16
  */
18
- import StyleEngine from './style-engine';
19
17
  import Controls from './controls';
20
18
 
21
- const TABS_TEMPLATE = [ [ 'core/tab', {} ] ];
22
-
23
- const DEFAULT_BLOCK = {
24
- name: 'core/tab',
25
- attributesToCopy: [ 'className', 'fontFamily', 'fontSize' ],
26
- };
19
+ const TABS_TEMPLATE = [
20
+ [
21
+ 'core/tabs-menu',
22
+ {
23
+ lock: {
24
+ remove: true,
25
+ },
26
+ },
27
+ ],
28
+ [
29
+ 'core/tab-panels',
30
+ {
31
+ lock: {
32
+ remove: true,
33
+ },
34
+ },
35
+ [
36
+ [
37
+ 'core/tab',
38
+ {
39
+ anchor: 'tab-1',
40
+ label: 'Tab 1',
41
+ },
42
+ [
43
+ [
44
+ 'core/paragraph',
45
+ {
46
+ placeholder: __( 'Type / to add a block to tab' ),
47
+ },
48
+ ],
49
+ ],
50
+ ],
51
+ ],
52
+ ],
53
+ ];
27
54
 
28
55
  function Edit( {
29
56
  clientId,
30
57
  attributes,
31
58
  setAttributes,
32
- tabInactiveColor,
33
- setTabInactiveColor,
34
- tabHoverColor,
35
- setTabHoverColor,
36
- tabActiveColor,
37
- setTabActiveColor,
38
- tabTextColor,
39
- setTabTextColor,
40
- tabActiveTextColor,
41
- setTabActiveTextColor,
42
- tabHoverTextColor,
43
- setTabHoverTextColor,
59
+ __unstableLayoutClassNames: layoutClassNames,
44
60
  } ) {
45
- const { style, orientation } = attributes;
61
+ const { anchor, activeTabIndex, editorActiveTabIndex } = attributes;
62
+
63
+ /**
64
+ * Initialize editorActiveTabIndex to activeTabIndex on mount.
65
+ * This ensures the ephemeral editor state starts at the persisted default.
66
+ */
67
+ useEffect( () => {
68
+ if ( editorActiveTabIndex === undefined ) {
69
+ setAttributes( { editorActiveTabIndex: activeTabIndex } );
70
+ }
71
+ }, [] ); // eslint-disable-line react-hooks/exhaustive-deps
72
+
73
+ /**
74
+ * Compute tabs list from innerblocks to provide via context.
75
+ * This traverses the tab-panels block to find all tab blocks
76
+ * and extracts their label and anchor for the tabs-menu to consume.
77
+ */
78
+ const tabsList = useSelect(
79
+ ( select ) => {
80
+ const { getBlocks } = select( blockEditorStore );
81
+ const innerBlocks = getBlocks( clientId );
82
+
83
+ // Find tab-panels block and extract tab data
84
+ const tabPanels = innerBlocks.find(
85
+ ( block ) => block.name === 'core/tab-panels'
86
+ );
87
+
88
+ if ( ! tabPanels ) {
89
+ return [];
90
+ }
91
+
92
+ return tabPanels.innerBlocks
93
+ .filter( ( block ) => block.name === 'core/tab' )
94
+ .map( ( tab, index ) => ( {
95
+ id: tab.attributes.anchor || `tab-${ index }`,
96
+ label: tab.attributes.label || '',
97
+ clientId: tab.clientId,
98
+ index,
99
+ } ) );
100
+ },
101
+ [ clientId ]
102
+ );
103
+
104
+ /**
105
+ * Memoize context value to prevent unnecessary re-renders.
106
+ */
107
+ const contextValue = useMemo(
108
+ () => ( {
109
+ 'core/tabs-list': tabsList,
110
+ 'core/tabs-id': anchor,
111
+ 'core/tabs-activeTabIndex': activeTabIndex,
112
+ 'core/tabs-editorActiveTabIndex': editorActiveTabIndex,
113
+ } ),
114
+ [ tabsList, anchor, activeTabIndex, editorActiveTabIndex ]
115
+ );
46
116
 
47
117
  /**
48
118
  * Block props for the tabs container.
49
119
  */
50
120
  const blockProps = useBlockProps( {
51
- className: clsx(
52
- 'vertical' === orientation ? 'is-vertical' : 'is-horizontal'
53
- ),
54
- style: {
55
- ...style,
56
- },
121
+ className: layoutClassNames,
57
122
  } );
58
123
 
59
124
  /**
60
- * Innerblocks props for the tabs list.
125
+ * Innerblocks props for the tabs container.
61
126
  */
62
127
  const innerBlockProps = useInnerBlocksProps( blockProps, {
63
- defaultBlock: DEFAULT_BLOCK,
64
- directInsert: true,
65
- __experimentalCaptureToolbars: true,
66
- clientId,
67
- orientation,
68
128
  template: TABS_TEMPLATE,
69
- renderAppender: false, // Appender is rendered by individual tab blocks.
129
+ templateLock: false,
130
+ renderAppender: false,
131
+ __experimentalCaptureToolbars: true,
70
132
  } );
71
133
 
72
134
  return (
73
- <>
135
+ <BlockContextProvider value={ contextValue }>
74
136
  <div { ...innerBlockProps }>
75
- { innerBlockProps.children }
76
- <StyleEngine attributes={ attributes } clientId={ clientId } />
77
137
  <Controls
78
- { ...{
79
- clientId,
80
- attributes,
81
- setAttributes,
82
- tabInactiveColor,
83
- setTabInactiveColor,
84
- tabHoverColor,
85
- setTabHoverColor,
86
- tabActiveColor,
87
- setTabActiveColor,
88
- tabTextColor,
89
- setTabTextColor,
90
- tabActiveTextColor,
91
- setTabActiveTextColor,
92
- tabHoverTextColor,
93
- setTabHoverTextColor,
94
- } }
138
+ clientId={ clientId }
139
+ attributes={ attributes }
140
+ setAttributes={ setAttributes }
95
141
  />
142
+ { innerBlockProps.children }
96
143
  </div>
97
- </>
144
+ </BlockContextProvider>
98
145
  );
99
146
  }
100
147
 
101
- export default withColors(
102
- 'tabInactiveColor',
103
- 'tabHoverColor',
104
- 'tabActiveColor',
105
- 'tabTextColor',
106
- 'tabActiveTextColor',
107
- 'tabHoverTextColor'
108
- )( Edit );
148
+ export default Edit;
package/src/tabs/index.js CHANGED
@@ -5,6 +5,7 @@ import initBlock from '../utils/init-block';
5
5
  import edit from './edit';
6
6
  import save from './save';
7
7
  import icon from './icon';
8
+ import deprecated from './deprecated';
8
9
 
9
10
  import metadata from './block.json';
10
11
 
@@ -16,6 +17,7 @@ export const settings = {
16
17
  icon,
17
18
  edit,
18
19
  save,
20
+ deprecated,
19
21
  };
20
22
 
21
23
  export const init = () => initBlock( { name, metadata, settings } );