@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
@@ -0,0 +1,103 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ BlockControls,
6
+ store as blockEditorStore,
7
+ } from '@wordpress/block-editor';
8
+ import { ToolbarGroup, ToolbarButton } from '@wordpress/components';
9
+ import { __ } from '@wordpress/i18n';
10
+ import { useDispatch, useSelect } from '@wordpress/data';
11
+
12
+ /**
13
+ * "Remove Tab" button in the block toolbar for the tab block.
14
+ * Removes the currently active tab from the tab-panels block.
15
+ *
16
+ * @param {Object} props
17
+ * @param {string} props.tabsClientId The client ID of the parent tabs block.
18
+ * @return {JSX.Element} The toolbar control element.
19
+ */
20
+ export default function RemoveTabToolbarControl( { tabsClientId } ) {
21
+ const {
22
+ removeBlock,
23
+ updateBlockAttributes,
24
+ selectBlock,
25
+ __unstableMarkNextChangeAsNotPersistent,
26
+ } = useDispatch( blockEditorStore );
27
+
28
+ // Find the tab-panels block, active tab, and tab count within the tabs block
29
+ const { activeTabClientId, tabCount, editorActiveTabIndex } = useSelect(
30
+ ( select ) => {
31
+ if ( ! tabsClientId ) {
32
+ return {
33
+ activeTabClientId: null,
34
+ tabCount: 0,
35
+ editorActiveTabIndex: 0,
36
+ };
37
+ }
38
+ const { getBlocks, getBlockAttributes } =
39
+ select( blockEditorStore );
40
+ const tabsAttributes = getBlockAttributes( tabsClientId );
41
+ const activeIndex =
42
+ tabsAttributes?.editorActiveTabIndex ??
43
+ tabsAttributes?.activeTabIndex ??
44
+ 0;
45
+ const innerBlocks = getBlocks( tabsClientId );
46
+ const tabPanels = innerBlocks.find(
47
+ ( block ) => block.name === 'core/tab-panels'
48
+ );
49
+ const tabs = tabPanels?.innerBlocks || [];
50
+ const activeTab = tabs[ activeIndex ];
51
+ return {
52
+ activeTabClientId: activeTab?.clientId || null,
53
+ tabCount: tabs.length,
54
+ editorActiveTabIndex: activeIndex,
55
+ };
56
+ },
57
+ [ tabsClientId ]
58
+ );
59
+
60
+ const removeTab = () => {
61
+ if ( ! activeTabClientId || tabCount <= 1 ) {
62
+ return;
63
+ }
64
+
65
+ // Calculate new active index after removal
66
+ const newActiveIndex =
67
+ editorActiveTabIndex >= tabCount - 1
68
+ ? tabCount - 2 // If removing last tab, select the previous one
69
+ : editorActiveTabIndex; // Otherwise keep the same index (next tab shifts into position)
70
+
71
+ // Update the active tab index before removing
72
+ __unstableMarkNextChangeAsNotPersistent();
73
+ updateBlockAttributes( tabsClientId, {
74
+ editorActiveTabIndex: newActiveIndex,
75
+ } );
76
+
77
+ // Remove the tab
78
+ removeBlock( activeTabClientId, false );
79
+
80
+ // Select the tabs block after removal
81
+ if ( tabsClientId ) {
82
+ selectBlock( tabsClientId );
83
+ }
84
+ };
85
+
86
+ // Don't show the button if there's only one tab or no active tab
87
+ const isDisabled = tabCount <= 1 || ! activeTabClientId;
88
+
89
+ return (
90
+ <BlockControls group="other">
91
+ <ToolbarGroup>
92
+ <ToolbarButton
93
+ className="components-toolbar__control"
94
+ label={ __( 'Remove the current tab' ) }
95
+ onClick={ removeTab }
96
+ showTooltip
97
+ text={ __( 'Remove Tab' ) }
98
+ disabled={ isDisabled }
99
+ />
100
+ </ToolbarGroup>
101
+ </BlockControls>
102
+ );
103
+ }
package/src/tab/save.js CHANGED
@@ -3,14 +3,12 @@
3
3
  */
4
4
  import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
5
 
6
- export default function Save( { attributes } ) {
6
+ export default function save( { attributes } ) {
7
7
  const { anchor } = attributes;
8
8
 
9
9
  const tabPanelId = anchor;
10
10
 
11
- // eslint-disable-next-line react-compiler/react-compiler
12
11
  const blockProps = useBlockProps.save();
13
- // eslint-disable-next-line react-compiler/react-compiler
14
12
  const innerBlocksProps = useInnerBlocksProps.save( blockProps );
15
13
 
16
14
  return <section { ...innerBlocksProps } id={ tabPanelId } />;
@@ -4,6 +4,13 @@
4
4
  flex-grow: 1;
5
5
  box-sizing: border-box;
6
6
 
7
+ & > *:first-child {
8
+ margin-top: 0;
9
+ }
10
+ & > *:last-child {
11
+ margin-bottom: 0;
12
+ }
13
+
7
14
  &[hidden],
8
15
  &:empty {
9
16
  display: none !important;
@@ -13,7 +20,7 @@
13
20
  }
14
21
  }
15
22
 
16
- .wp-block-tab.wp-block section.has-background,
23
+ .wp-block-tab.wp-block.has-background,
17
24
  .wp-block-tab:not(.wp-block).has-background {
18
25
  padding: var(--wp--preset--spacing--30);
19
26
  }
@@ -0,0 +1,70 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "__experimental": true,
4
+ "apiVersion": 3,
5
+ "name": "core/tab-panels",
6
+ "title": "Tab Panels",
7
+ "description": "Container for tab panel content in a tabbed interface.",
8
+ "version": "1.0.0",
9
+ "category": "design",
10
+ "textdomain": "default",
11
+ "parent": [
12
+ "core/tabs"
13
+ ],
14
+ "allowedBlocks": [
15
+ "core/tab"
16
+ ],
17
+ "attributes": {},
18
+ "supports": {
19
+ "anchor": false,
20
+ "html": false,
21
+ "reusable": false,
22
+ "lock": false,
23
+ "dimensions": {
24
+ "aspectRatio": false,
25
+ "height": false,
26
+ "minHeight": false,
27
+ "width": false
28
+ },
29
+ "color": {
30
+ "background": true,
31
+ "text": true,
32
+ "heading": true,
33
+ "link": true,
34
+ "__experimentalDefaultControls": {
35
+ "background": true,
36
+ "text": true
37
+ }
38
+ },
39
+ "spacing": {
40
+ "blockGap": false,
41
+ "padding": true,
42
+ "margin": true
43
+ },
44
+ "typography": {
45
+ "fontSize": true,
46
+ "__experimentalFontFamily": true
47
+ },
48
+ "layout": {
49
+ "default": {
50
+ "type": "flex",
51
+ "flexWrap": "nowrap",
52
+ "justifyContent": "stretch",
53
+ "orientation": "vertical"
54
+ },
55
+ "allowSwitching": false,
56
+ "allowVerticalAlignment": false,
57
+ "allowOrientation": false,
58
+ "allowJustification": true,
59
+ "allowSizingOnChildren": false
60
+ },
61
+ "__experimentalBorder": {
62
+ "radius": true,
63
+ "color": true,
64
+ "width": true,
65
+ "style": true
66
+ }
67
+ },
68
+ "editorScript": "file:./index.js",
69
+ "style": "file:./style-index.css"
70
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ useBlockProps,
6
+ useInnerBlocksProps,
7
+ store as blockEditorStore,
8
+ } from '@wordpress/block-editor';
9
+ import { useSelect } from '@wordpress/data';
10
+
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+ import AddTabToolbarControl from '../tab/add-tab-toolbar-control';
15
+ import RemoveTabToolbarControl from '../tab/remove-tab-toolbar-control';
16
+
17
+ const TAB_PANELS_TEMPLATE = [ [ 'core/tab', {} ] ];
18
+
19
+ export default function Edit( { clientId } ) {
20
+ const blockProps = useBlockProps();
21
+
22
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
23
+ template: TAB_PANELS_TEMPLATE,
24
+ templateLock: false,
25
+ renderAppender: false, // Appender handled by individual tab blocks
26
+ } );
27
+
28
+ // Get the parent tabs block clientId
29
+ const tabsClientId = useSelect(
30
+ ( select ) => {
31
+ const { getBlockRootClientId } = select( blockEditorStore );
32
+ return getBlockRootClientId( clientId );
33
+ },
34
+ [ clientId ]
35
+ );
36
+
37
+ return (
38
+ <>
39
+ <AddTabToolbarControl tabsClientId={ tabsClientId } />
40
+ <RemoveTabToolbarControl tabsClientId={ tabsClientId } />
41
+ <div { ...innerBlocksProps } />
42
+ </>
43
+ );
44
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { SVG, Path } from '@wordpress/primitives';
5
+
6
+ export default (
7
+ <SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
8
+ <Path d="M4 4H20V20H4V4ZM5.5 5.5V18.5H18.5V5.5H5.5Z" />
9
+ </SVG>
10
+ );
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import initBlock from '../utils/init-block';
5
+ import edit from './edit';
6
+ import save from './save';
7
+ import icon from './icon';
8
+
9
+ import metadata from './block.json';
10
+
11
+ const { name } = metadata;
12
+
13
+ export { metadata, name };
14
+
15
+ export const settings = {
16
+ icon,
17
+ edit,
18
+ save,
19
+ };
20
+
21
+ export const init = () => initBlock( { name, metadata, settings } );
@@ -0,0 +1,11 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
5
+
6
+ export default function save() {
7
+ const blockProps = useBlockProps.save();
8
+ const innerBlocksProps = useInnerBlocksProps.save( blockProps );
9
+
10
+ return <div { ...innerBlocksProps } />;
11
+ }
@@ -0,0 +1,4 @@
1
+ .wp-block-tab-panels {
2
+ flex-grow: 1;
3
+ min-width: 0;
4
+ }
@@ -8,97 +8,53 @@
8
8
  "version": "1.0.0",
9
9
  "category": "design",
10
10
  "textdomain": "default",
11
- "allowedBlocks": [ "core/tab" ],
11
+ "allowedBlocks": [
12
+ "core/tabs-menu",
13
+ "core/tab-panels"
14
+ ],
12
15
  "attributes": {
13
- "tabsId": {
14
- "type": "string",
15
- "default": ""
16
- },
17
- "orientation": {
18
- "type": "string",
19
- "default": "horizontal",
20
- "enum": [ "horizontal", "vertical" ]
21
- },
22
16
  "activeTabIndex": {
23
17
  "type": "number",
24
18
  "default": 0
25
19
  },
26
- "tabInactiveColor": {
27
- "type": "string"
28
- },
29
- "customTabInactiveColor": {
30
- "type": "string"
31
- },
32
- "tabHoverColor": {
33
- "type": "string"
34
- },
35
- "customTabHoverColor": {
36
- "type": "string"
37
- },
38
- "tabActiveColor": {
39
- "type": "string"
40
- },
41
- "customTabActiveColor": {
42
- "type": "string"
43
- },
44
- "tabTextColor": {
45
- "type": "string"
46
- },
47
- "customTabTextColor": {
48
- "type": "string"
49
- },
50
- "tabActiveTextColor": {
51
- "type": "string"
52
- },
53
- "customTabActiveTextColor": {
54
- "type": "string"
55
- },
56
- "tabHoverTextColor": {
57
- "type": "string"
58
- },
59
- "customTabHoverTextColor": {
60
- "type": "string"
20
+ "editorActiveTabIndex": {
21
+ "type": "number",
22
+ "role": "local"
61
23
  }
62
24
  },
63
- "styles": [
64
- {
65
- "name": "tab",
66
- "label": "Tabs",
67
- "isDefault": true
68
- },
69
- {
70
- "name": "links",
71
- "label": "Links"
72
- },
73
- {
74
- "name": "button",
75
- "label": "Button"
76
- }
77
- ],
78
25
  "supports": {
79
26
  "align": true,
27
+ "anchor": true,
80
28
  "color": {
81
29
  "text": false,
82
30
  "background": false
83
31
  },
32
+ "layout": {
33
+ "default": {
34
+ "type": "flex",
35
+ "flexWrap": "nowrap",
36
+ "justifyContent": "stretch",
37
+ "verticalAlignment": "stretch",
38
+ "orientation": "vertical"
39
+ },
40
+ "allowSwitching": false,
41
+ "allowVerticalAlignment": true,
42
+ "allowJustification": true,
43
+ "allowOrientation": true,
44
+ "allowSizingOnChildren": true
45
+ },
84
46
  "html": false,
85
47
  "interactivity": true,
86
48
  "spacing": {
87
- "blockGap": [ "horizontal", "vertical" ],
49
+ "blockGap": true,
88
50
  "margin": true,
89
- "padding": false
51
+ "padding": true
90
52
  },
91
53
  "typography": {
92
54
  "fontSize": true,
93
55
  "__experimentalFontFamily": true
94
56
  },
95
- "__experimentalBorder": {
96
- "radius": true,
97
- "__experimentalSkipSerialization": true,
98
- "__experimentalDefaultControls": {
99
- "radius": true
100
- }
101
- }
57
+ "renaming": true
102
58
  },
103
59
  "example": {
104
60
  "attributes": {
@@ -106,42 +62,57 @@
106
62
  },
107
63
  "innerBlocks": [
108
64
  {
109
- "name": "core/tab",
110
- "attributes": {
111
- "label": "Tab 1"
112
- },
65
+ "name": "core/tabs-menu",
66
+ "attributes": {},
67
+ "innerBlocks": [
68
+ {
69
+ "name": "core/tabs-menu-item",
70
+ "attributes": {}
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "name": "core/tab-panels",
76
+ "attributes": {},
113
77
  "innerBlocks": [
114
78
  {
115
- "name": "core/paragraph",
79
+ "name": "core/tab",
116
80
  "attributes": {
117
- "content": "Pariatur commodo sint mollit. Veniam Lorem labore voluptate fugiat. Ad nulla est labore cillum cillum qui nostrud do incididunt eiusmod. Aliqua aliqua sunt consequat consequat in duis deserunt."
81
+ "label": "Tab 1"
82
+ },
83
+ "innerBlocks": [
84
+ {
85
+ "name": "core/paragraph",
86
+ "attributes": {
87
+ "content": "Pariatur commodo sint mollit. Veniam Lorem labore voluptate fugiat. Ad nulla est labore cillum cillum qui nostrud do incididunt eiusmod."
88
+ }
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ "name": "core/tab",
94
+ "attributes": {
95
+ "label": "Tab 2"
118
96
  }
119
97
  },
120
98
  {
121
- "name": "core/paragraph",
99
+ "name": "core/tab",
122
100
  "attributes": {
123
- "content": "Adipisicing ullamco nisi in eu laborum adipisicing aliquip aliqua. Fugiat labore officia consequat nisi veniam velit commodo cillum enim duis quis ad."
101
+ "label": "Tab 3"
124
102
  }
125
103
  }
126
104
  ]
127
- },
128
- {
129
- "name": "core/tab",
130
- "attributes": {
131
- "label": "Tab 2"
132
- }
133
- },
134
- {
135
- "name": "core/tab",
136
- "attributes": {
137
- "label": "Tab 3"
138
- }
139
105
  }
140
106
  ]
141
107
  },
142
108
  "providesContext": {
143
- "core/tabs-id": "tabsId"
109
+ "core/tabs-activeTabIndex": "activeTabIndex",
110
+ "core/tabs-editorActiveTabIndex": "editorActiveTabIndex"
144
111
  },
112
+ "usesContext": [
113
+ "core/tabs-list",
114
+ "core/tabs-id"
115
+ ],
145
116
  "editorScript": "file:./index.js",
146
117
  "editorStyle": "file:./index.css",
147
118
  "style": "file:./style-index.css",