@wordpress/block-editor 14.10.1 → 14.12.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 (295) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/build/components/background-image-control/index.js +0 -1
  3. package/build/components/background-image-control/index.js.map +1 -1
  4. package/build/components/block-actions/index.js +0 -3
  5. package/build/components/block-actions/index.js.map +1 -1
  6. package/build/components/block-inspector/index.js +6 -11
  7. package/build/components/block-inspector/index.js.map +1 -1
  8. package/build/components/block-list/use-block-props/use-focus-handler.js +1 -1
  9. package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  10. package/build/components/block-rename/modal.js +36 -11
  11. package/build/components/block-rename/modal.js.map +1 -1
  12. package/build/components/block-rename/rename-control.js +2 -43
  13. package/build/components/block-rename/rename-control.js.map +1 -1
  14. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
  15. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  16. package/build/components/block-styles/preview.native.js +1 -1
  17. package/build/components/block-styles/preview.native.js.map +1 -1
  18. package/build/components/block-switcher/block-transformations-menu.js +7 -7
  19. package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
  20. package/build/components/block-switcher/block-variation-transformations.js +2 -2
  21. package/build/components/block-switcher/block-variation-transformations.js.map +1 -1
  22. package/build/components/block-switcher/index.js +1 -1
  23. package/build/components/block-switcher/index.js.map +1 -1
  24. package/build/components/block-switcher/use-transformed-patterns.js +1 -1
  25. package/build/components/block-switcher/use-transformed-patterns.js.map +1 -1
  26. package/build/components/block-toolbar/index.native.js +2 -2
  27. package/build/components/block-toolbar/index.native.js.map +1 -1
  28. package/build/components/date-format-picker/index.js +1 -1
  29. package/build/components/date-format-picker/index.js.map +1 -1
  30. package/build/components/global-styles/filters-panel.js +2 -2
  31. package/build/components/global-styles/filters-panel.js.map +1 -1
  32. package/build/components/global-styles/image-settings-panel.js +2 -2
  33. package/build/components/global-styles/image-settings-panel.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +3 -3
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/grid/grid-visualizer.js +11 -19
  37. package/build/components/grid/grid-visualizer.js.map +1 -1
  38. package/build/components/grid/utils.js +6 -4
  39. package/build/components/grid/utils.js.map +1 -1
  40. package/build/components/iframe/get-compatibility-styles.js +1 -1
  41. package/build/components/iframe/get-compatibility-styles.js.map +1 -1
  42. package/build/components/iframe/index.js +1 -1
  43. package/build/components/iframe/index.js.map +1 -1
  44. package/build/components/image-size-control/index.js +2 -1
  45. package/build/components/image-size-control/index.js.map +1 -1
  46. package/build/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  47. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  48. package/build/components/inserter/menu.js +13 -2
  49. package/build/components/inserter/menu.js.map +1 -1
  50. package/build/components/inserter/reusable-blocks-tab.native.js +1 -1
  51. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  52. package/build/components/inspector-controls-tabs/position-controls-panel.js +49 -21
  53. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  54. package/build/components/line-height-control/index.native.js +1 -1
  55. package/build/components/line-height-control/index.native.js.map +1 -1
  56. package/build/components/link-control/index.js +1 -1
  57. package/build/components/link-control/index.js.map +1 -1
  58. package/build/components/link-control/use-search-handler.js +1 -1
  59. package/build/components/link-control/use-search-handler.js.map +1 -1
  60. package/build/components/list-view/block-select-button.js +5 -2
  61. package/build/components/list-view/block-select-button.js.map +1 -1
  62. package/build/components/media-placeholder/index.js +1 -0
  63. package/build/components/media-placeholder/index.js.map +1 -1
  64. package/build/components/observe-typing/index.js +1 -1
  65. package/build/components/observe-typing/index.js.map +1 -1
  66. package/build/components/provider/index.js +0 -2
  67. package/build/components/provider/index.js.map +1 -1
  68. package/build/components/provider/use-block-sync.js +2 -2
  69. package/build/components/provider/use-block-sync.js.map +1 -1
  70. package/build/components/rich-text/event-listeners/input-rules.js +3 -3
  71. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  72. package/build/components/rich-text/native/use-format-types.js +1 -1
  73. package/build/components/rich-text/native/use-format-types.js.map +1 -1
  74. package/build/components/rich-text/use-format-types.js +1 -1
  75. package/build/components/rich-text/use-format-types.js.map +1 -1
  76. package/build/components/spacing-sizes-control/index.js +44 -2
  77. package/build/components/spacing-sizes-control/index.js.map +1 -1
  78. package/build/components/spacing-sizes-control/linked-button.js +6 -9
  79. package/build/components/spacing-sizes-control/linked-button.js.map +1 -1
  80. package/build/components/spacing-sizes-control/utils.js +0 -108
  81. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  82. package/build/components/tabbed-sidebar/index.js +39 -0
  83. package/build/components/tabbed-sidebar/index.js.map +1 -1
  84. package/build/components/typewriter/index.js +1 -1
  85. package/build/components/typewriter/index.js.map +1 -1
  86. package/build/components/url-popover/image-url-input-ui.js +3 -3
  87. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  88. package/build/components/use-block-commands/index.js +1 -1
  89. package/build/components/use-block-commands/index.js.map +1 -1
  90. package/build/components/use-moving-animation/index.js +1 -1
  91. package/build/components/use-moving-animation/index.js.map +1 -1
  92. package/build/hooks/contrast-checker.js +41 -22
  93. package/build/hooks/contrast-checker.js.map +1 -1
  94. package/build/hooks/custom-class-name.js +2 -1
  95. package/build/hooks/custom-class-name.js.map +1 -1
  96. package/build/store/actions.js +1 -1
  97. package/build/store/actions.js.map +1 -1
  98. package/build/store/selectors.js +18 -7
  99. package/build/store/selectors.js.map +1 -1
  100. package/build/utils/transform-styles/index.js +1 -1
  101. package/build/utils/transform-styles/index.js.map +1 -1
  102. package/build/utils/use-notify-copy.js +19 -11
  103. package/build/utils/use-notify-copy.js.map +1 -1
  104. package/build-module/components/background-image-control/index.js +0 -1
  105. package/build-module/components/background-image-control/index.js.map +1 -1
  106. package/build-module/components/block-actions/index.js +0 -3
  107. package/build-module/components/block-actions/index.js.map +1 -1
  108. package/build-module/components/block-inspector/index.js +6 -11
  109. package/build-module/components/block-inspector/index.js.map +1 -1
  110. package/build-module/components/block-list/use-block-props/use-focus-handler.js +1 -1
  111. package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
  112. package/build-module/components/block-rename/modal.js +36 -11
  113. package/build-module/components/block-rename/modal.js.map +1 -1
  114. package/build-module/components/block-rename/rename-control.js +2 -43
  115. package/build-module/components/block-rename/rename-control.js.map +1 -1
  116. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
  117. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  118. package/build-module/components/block-styles/preview.native.js +1 -1
  119. package/build-module/components/block-styles/preview.native.js.map +1 -1
  120. package/build-module/components/block-switcher/block-transformations-menu.js +7 -7
  121. package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
  122. package/build-module/components/block-switcher/block-variation-transformations.js +2 -2
  123. package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -1
  124. package/build-module/components/block-switcher/index.js +1 -1
  125. package/build-module/components/block-switcher/index.js.map +1 -1
  126. package/build-module/components/block-switcher/use-transformed-patterns.js +1 -1
  127. package/build-module/components/block-switcher/use-transformed-patterns.js.map +1 -1
  128. package/build-module/components/block-toolbar/index.native.js +2 -2
  129. package/build-module/components/block-toolbar/index.native.js.map +1 -1
  130. package/build-module/components/date-format-picker/index.js +1 -1
  131. package/build-module/components/date-format-picker/index.js.map +1 -1
  132. package/build-module/components/global-styles/filters-panel.js +2 -2
  133. package/build-module/components/global-styles/filters-panel.js.map +1 -1
  134. package/build-module/components/global-styles/image-settings-panel.js +2 -2
  135. package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
  136. package/build-module/components/global-styles/use-global-styles-output.js +3 -3
  137. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  138. package/build-module/components/grid/grid-visualizer.js +11 -19
  139. package/build-module/components/grid/grid-visualizer.js.map +1 -1
  140. package/build-module/components/grid/utils.js +6 -4
  141. package/build-module/components/grid/utils.js.map +1 -1
  142. package/build-module/components/iframe/get-compatibility-styles.js +1 -1
  143. package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
  144. package/build-module/components/iframe/index.js +1 -1
  145. package/build-module/components/iframe/index.js.map +1 -1
  146. package/build-module/components/image-size-control/index.js +3 -2
  147. package/build-module/components/image-size-control/index.js.map +1 -1
  148. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  149. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
  150. package/build-module/components/inserter/menu.js +13 -2
  151. package/build-module/components/inserter/menu.js.map +1 -1
  152. package/build-module/components/inserter/reusable-blocks-tab.native.js +1 -1
  153. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  154. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +51 -23
  155. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  156. package/build-module/components/line-height-control/index.native.js +1 -1
  157. package/build-module/components/line-height-control/index.native.js.map +1 -1
  158. package/build-module/components/link-control/index.js +1 -1
  159. package/build-module/components/link-control/index.js.map +1 -1
  160. package/build-module/components/link-control/use-search-handler.js +1 -1
  161. package/build-module/components/link-control/use-search-handler.js.map +1 -1
  162. package/build-module/components/list-view/block-select-button.js +6 -3
  163. package/build-module/components/list-view/block-select-button.js.map +1 -1
  164. package/build-module/components/media-placeholder/index.js +1 -0
  165. package/build-module/components/media-placeholder/index.js.map +1 -1
  166. package/build-module/components/observe-typing/index.js +1 -1
  167. package/build-module/components/observe-typing/index.js.map +1 -1
  168. package/build-module/components/provider/index.js +0 -1
  169. package/build-module/components/provider/index.js.map +1 -1
  170. package/build-module/components/provider/use-block-sync.js +2 -2
  171. package/build-module/components/provider/use-block-sync.js.map +1 -1
  172. package/build-module/components/rich-text/event-listeners/input-rules.js +3 -3
  173. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  174. package/build-module/components/rich-text/native/use-format-types.js +1 -1
  175. package/build-module/components/rich-text/native/use-format-types.js.map +1 -1
  176. package/build-module/components/rich-text/use-format-types.js +1 -1
  177. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  178. package/build-module/components/spacing-sizes-control/index.js +45 -1
  179. package/build-module/components/spacing-sizes-control/index.js.map +1 -1
  180. package/build-module/components/spacing-sizes-control/linked-button.js +7 -10
  181. package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -1
  182. package/build-module/components/spacing-sizes-control/utils.js +0 -104
  183. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  184. package/build-module/components/tabbed-sidebar/index.js +39 -0
  185. package/build-module/components/tabbed-sidebar/index.js.map +1 -1
  186. package/build-module/components/typewriter/index.js +1 -1
  187. package/build-module/components/typewriter/index.js.map +1 -1
  188. package/build-module/components/url-popover/image-url-input-ui.js +3 -3
  189. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  190. package/build-module/components/use-block-commands/index.js +1 -1
  191. package/build-module/components/use-block-commands/index.js.map +1 -1
  192. package/build-module/components/use-moving-animation/index.js +1 -1
  193. package/build-module/components/use-moving-animation/index.js.map +1 -1
  194. package/build-module/hooks/contrast-checker.js +42 -23
  195. package/build-module/hooks/contrast-checker.js.map +1 -1
  196. package/build-module/hooks/custom-class-name.js +2 -1
  197. package/build-module/hooks/custom-class-name.js.map +1 -1
  198. package/build-module/store/actions.js +1 -1
  199. package/build-module/store/actions.js.map +1 -1
  200. package/build-module/store/selectors.js +18 -7
  201. package/build-module/store/selectors.js.map +1 -1
  202. package/build-module/utils/transform-styles/index.js +1 -1
  203. package/build-module/utils/transform-styles/index.js.map +1 -1
  204. package/build-module/utils/use-notify-copy.js +19 -11
  205. package/build-module/utils/use-notify-copy.js.map +1 -1
  206. package/build-style/content-rtl.css +0 -9
  207. package/build-style/content.css +0 -9
  208. package/build-style/style-rtl.css +19 -21
  209. package/build-style/style.css +19 -21
  210. package/package.json +34 -33
  211. package/src/components/background-image-control/index.js +0 -1
  212. package/src/components/block-actions/index.js +0 -3
  213. package/src/components/block-icon/content.scss +1 -1
  214. package/src/components/{block-card → block-icon}/stories/index.story.js +16 -26
  215. package/src/components/block-icon/style.scss +1 -1
  216. package/src/components/block-inspector/index.js +7 -10
  217. package/src/components/block-list/use-block-props/use-focus-handler.js +1 -1
  218. package/src/components/block-preview/style.scss +1 -1
  219. package/src/components/block-rename/modal.js +40 -12
  220. package/src/components/block-rename/rename-control.js +1 -53
  221. package/src/components/block-settings-menu/block-settings-dropdown.js +16 -2
  222. package/src/components/block-styles/preview.native.js +1 -1
  223. package/src/components/block-switcher/block-transformations-menu.js +9 -9
  224. package/src/components/block-switcher/block-variation-transformations.js +2 -2
  225. package/src/components/block-switcher/index.js +1 -1
  226. package/src/components/block-switcher/use-transformed-patterns.js +1 -1
  227. package/src/components/block-toolbar/index.native.js +2 -2
  228. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  229. package/src/components/colors-gradients/style.scss +1 -0
  230. package/src/components/colors-gradients/test/control.js +2 -2
  231. package/src/components/date-format-picker/index.js +1 -1
  232. package/src/components/duotone-control/style.scss +2 -2
  233. package/src/components/global-styles/filters-panel.js +4 -2
  234. package/src/components/global-styles/image-settings-panel.js +2 -2
  235. package/src/components/global-styles/test/typography-utils.js +1 -1
  236. package/src/components/global-styles/use-global-styles-output.js +3 -3
  237. package/src/components/grid/grid-visualizer.js +10 -21
  238. package/src/components/grid/style.scss +1 -0
  239. package/src/components/grid/utils.js +6 -4
  240. package/src/components/iframe/get-compatibility-styles.js +1 -1
  241. package/src/components/iframe/index.js +1 -1
  242. package/src/components/image-size-control/index.js +6 -2
  243. package/src/components/inner-blocks/README.md +1 -1
  244. package/src/components/inserter/block-patterns-tab/patterns-filter.js +1 -1
  245. package/src/components/inserter/menu.js +11 -9
  246. package/src/components/inserter/reusable-blocks-tab.native.js +1 -1
  247. package/src/components/inspector-controls-tabs/position-controls-panel.js +62 -27
  248. package/src/components/line-height-control/index.native.js +1 -1
  249. package/src/components/link-control/README.md +2 -2
  250. package/src/components/link-control/index.js +1 -1
  251. package/src/components/link-control/test/index.js +3 -3
  252. package/src/components/link-control/use-search-handler.js +1 -1
  253. package/src/components/list-view/README.md +1 -1
  254. package/src/components/list-view/block-select-button.js +5 -5
  255. package/src/components/list-view/style.scss +3 -7
  256. package/src/components/media-placeholder/content.scss +0 -8
  257. package/src/components/media-placeholder/index.js +1 -0
  258. package/src/components/media-placeholder/style.scss +7 -0
  259. package/src/components/observe-typing/index.js +1 -1
  260. package/src/components/provider/index.js +0 -1
  261. package/src/components/provider/use-block-sync.js +2 -2
  262. package/src/components/resolution-tool/stories/index.story.js +52 -2
  263. package/src/components/rich-text/README.md +1 -1
  264. package/src/components/rich-text/event-listeners/input-rules.js +3 -3
  265. package/src/components/rich-text/native/use-format-types.js +1 -1
  266. package/src/components/rich-text/use-format-types.js +1 -1
  267. package/src/components/spacing-sizes-control/README.md +93 -0
  268. package/src/components/spacing-sizes-control/index.js +44 -1
  269. package/src/components/spacing-sizes-control/linked-button.js +8 -10
  270. package/src/components/spacing-sizes-control/test/utils.js +0 -151
  271. package/src/components/spacing-sizes-control/utils.js +0 -106
  272. package/src/components/tabbed-sidebar/README.md +24 -13
  273. package/src/components/tabbed-sidebar/index.js +38 -0
  274. package/src/components/tabbed-sidebar/stories/index.story.js +104 -0
  275. package/src/components/typewriter/index.js +1 -1
  276. package/src/components/unit-control/README.md +1 -1
  277. package/src/components/unit-control/stories/index.story.js +124 -0
  278. package/src/components/url-popover/image-url-input-ui.js +3 -3
  279. package/src/components/use-block-commands/index.js +1 -1
  280. package/src/components/use-moving-animation/index.js +1 -1
  281. package/src/components/use-settings/README.md +1 -1
  282. package/src/components/warning/content.scss +1 -1
  283. package/src/components/writing-flow/test/index.js +1 -1
  284. package/src/hooks/color.scss +0 -7
  285. package/src/hooks/contrast-checker.js +64 -30
  286. package/src/hooks/custom-class-name.js +2 -1
  287. package/src/store/actions.js +1 -1
  288. package/src/store/selectors.js +20 -12
  289. package/src/store/test/private-selectors.js +1 -1
  290. package/src/store/test/selectors.js +3 -3
  291. package/src/style.scss +1 -0
  292. package/src/utils/test/sorting.js +1 -1
  293. package/src/utils/transform-styles/index.js +1 -1
  294. package/src/utils/use-notify-copy.js +51 -43
  295. package/tsconfig.json +1 -0
@@ -3,20 +3,15 @@
3
3
  */
4
4
  import {
5
5
  ALL_SIDES,
6
- getAllRawValue,
7
6
  getCustomValueFromPreset,
8
7
  getInitialView,
9
8
  getPresetValueFromCustomValue,
10
9
  getSliderValueFromPreset,
11
10
  getSpacingPresetCssVar,
12
11
  getSpacingPresetSlug,
13
- getSupportedMenuItems,
14
12
  hasAxisSupport,
15
13
  hasBalancedSidesSupport,
16
- isValuesDefined,
17
- isValuesMixed,
18
14
  isValueSpacingPreset,
19
- LABELS,
20
15
  VIEWS,
21
16
  } from '../utils';
22
17
 
@@ -114,88 +109,6 @@ describe( 'getSliderValueFromPreset', () => {
114
109
  } );
115
110
  } );
116
111
 
117
- describe( 'getAllRawValue', () => {
118
- const customValues = {
119
- top: '5px',
120
- bottom: '5px',
121
- left: '6px',
122
- right: '2px',
123
- };
124
- it( 'should return the most common custom value from the values object', () => {
125
- expect( getAllRawValue( customValues ) ).toBe( '5px' );
126
- } );
127
- const presetValues = {
128
- top: 'var:preset|spacing|30',
129
- bottom: 'var:preset|spacing|20',
130
- left: 'var:preset|spacing|10',
131
- right: 'var:preset|spacing|30',
132
- };
133
- it( 'should return the most common preset value from the values object', () => {
134
- expect( getAllRawValue( presetValues ) ).toBe(
135
- 'var:preset|spacing|30'
136
- );
137
- } );
138
- } );
139
-
140
- describe( 'isValuesMixed', () => {
141
- const unmixedValues = {
142
- top: '5px',
143
- bottom: '5px',
144
- left: '5px',
145
- right: '5px',
146
- };
147
- it( 'should return false if all values are the same', () => {
148
- expect( isValuesMixed( unmixedValues ) ).toBe( false );
149
- } );
150
- const mixedValues = {
151
- top: 'var:preset|spacing|30',
152
- bottom: 'var:preset|spacing|20',
153
- left: 'var:preset|spacing|10',
154
- right: 'var:preset|spacing|30',
155
- };
156
- it( 'should return true if all the values are not the same', () => {
157
- expect( isValuesMixed( mixedValues ) ).toBe( true );
158
- } );
159
- const singleValue = {
160
- top: 'var:preset|spacing|30',
161
- };
162
- it( 'should return true if only one side set', () => {
163
- expect( isValuesMixed( singleValue ) ).toBe( true );
164
- } );
165
- const incompleteValues = {
166
- top: 'var:preset|spacing|30',
167
- bottom: 'var:preset|spacing|30',
168
- left: 'var:preset|spacing|30',
169
- };
170
- it( 'should return true if all sides not set', () => {
171
- expect( isValuesMixed( incompleteValues ) ).toBe( true );
172
- } );
173
- } );
174
-
175
- describe( 'isValuesDefined', () => {
176
- const undefinedValues = {
177
- top: undefined,
178
- bottom: undefined,
179
- left: undefined,
180
- right: undefined,
181
- };
182
- it( 'should return false if values are not defined', () => {
183
- expect( isValuesDefined( undefinedValues ) ).toBe( false );
184
- } );
185
- it( 'should return false if values is passed in as null', () => {
186
- expect( isValuesDefined( null ) ).toBe( false );
187
- } );
188
- const definedValues = {
189
- top: 'var:preset|spacing|30',
190
- bottom: 'var:preset|spacing|20',
191
- left: 'var:preset|spacing|10',
192
- right: 'var:preset|spacing|30',
193
- };
194
- it( 'should return true if all the values are not the same', () => {
195
- expect( isValuesDefined( definedValues ) ).toBe( true );
196
- } );
197
- } );
198
-
199
112
  describe( 'hasAxisSupport', () => {
200
113
  it( 'should return true for horizontal support if it is in sides', () => {
201
114
  expect( hasAxisSupport( [ 'horizontal' ], 'horizontal' ) ).toBe( true );
@@ -228,70 +141,6 @@ describe( 'hasAxisSupport', () => {
228
141
  } );
229
142
  } );
230
143
 
231
- describe( 'getSupportedMenuItems', () => {
232
- it( 'returns no items when sides are not configured', () => {
233
- expect( getSupportedMenuItems( [] ) ).toEqual( {} );
234
- expect( getSupportedMenuItems() ).toEqual( {} );
235
- } );
236
-
237
- const sideConfigs = [
238
- [ LABELS.axial, [ 'horizontal', 'vertical' ] ],
239
- [ LABELS.axial, [ 'top', 'right', 'bottom', 'left' ] ],
240
- [ LABELS.horizontal, [ 'horizontal' ] ],
241
- [ LABELS.horizontal, [ 'left', 'right' ] ],
242
- [ LABELS.vertical, [ 'vertical' ] ],
243
- [ LABELS.vertical, [ 'top', 'bottom' ] ],
244
- [ LABELS.horizontal, [ 'horizontal' ] ],
245
- ];
246
-
247
- test.each( sideConfigs )(
248
- 'should include %s axial menu with %s sides',
249
- ( label, sides ) => {
250
- expect( getSupportedMenuItems( sides ) ).toHaveProperty(
251
- 'axial.label',
252
- label
253
- );
254
- }
255
- );
256
-
257
- it( 'returns no axial item when not not supported', () => {
258
- expect( getSupportedMenuItems( [ 'left', 'top' ] ) ).not.toHaveProperty(
259
- 'axial'
260
- );
261
- } );
262
-
263
- it( 'should include the correct individual side options', () => {
264
- expect( getSupportedMenuItems( [ 'top' ] ) ).toHaveProperty(
265
- 'top.label',
266
- LABELS.top
267
- );
268
- expect( getSupportedMenuItems( [ 'right' ] ) ).toHaveProperty(
269
- 'right.label',
270
- LABELS.right
271
- );
272
- expect( getSupportedMenuItems( [ 'bottom' ] ) ).toHaveProperty(
273
- 'bottom.label',
274
- LABELS.bottom
275
- );
276
- expect( getSupportedMenuItems( [ 'left' ] ) ).toHaveProperty(
277
- 'left.label',
278
- LABELS.left
279
- );
280
- } );
281
- it( 'should include the custom option only when applicable', () => {
282
- expect( getSupportedMenuItems( [ 'top', 'left' ] ) ).toHaveProperty(
283
- 'custom.label',
284
- LABELS.custom
285
- );
286
- expect( getSupportedMenuItems( [ 'top' ] ) ).not.toHaveProperty(
287
- 'custom'
288
- );
289
- expect(
290
- getSupportedMenuItems( [ 'horizontal', 'vertical' ] )
291
- ).not.toHaveProperty( 'custom.label' );
292
- } );
293
- } );
294
-
295
144
  describe( 'hasBalancedSidesSupport', () => {
296
145
  it( 'should determine balanced sides', () => {
297
146
  expect( hasBalancedSidesSupport( ALL_SIDES ) ).toBe( true );
@@ -184,64 +184,6 @@ export function getSliderValueFromPreset( presetValue, spacingSizes ) {
184
184
  return sliderValue !== -1 ? sliderValue : NaN;
185
185
  }
186
186
 
187
- /**
188
- * Gets an items with the most occurrence within an array
189
- * https://stackoverflow.com/a/20762713
190
- *
191
- * @param {Array<any>} arr Array of items to check.
192
- * @return {any} The item with the most occurrences.
193
- */
194
- function mode( arr ) {
195
- return arr
196
- .sort(
197
- ( a, b ) =>
198
- arr.filter( ( v ) => v === a ).length -
199
- arr.filter( ( v ) => v === b ).length
200
- )
201
- .pop();
202
- }
203
-
204
- /**
205
- * Gets the 'all' input value from values data.
206
- *
207
- * @param {Object} values Box spacing values
208
- *
209
- * @return {string} The most common value from all sides of box.
210
- */
211
- export function getAllRawValue( values = {} ) {
212
- return mode( Object.values( values ) );
213
- }
214
-
215
- /**
216
- * Checks to determine if values are mixed.
217
- *
218
- * @param {Object} values Box values.
219
- * @param {Array} sides Sides that values relate to.
220
- *
221
- * @return {boolean} Whether values are mixed.
222
- */
223
- export function isValuesMixed( values = {}, sides = ALL_SIDES ) {
224
- return (
225
- ( Object.values( values ).length >= 1 &&
226
- Object.values( values ).length < sides.length ) ||
227
- new Set( Object.values( values ) ).size > 1
228
- );
229
- }
230
-
231
- /**
232
- * Checks to determine if values are defined.
233
- *
234
- * @param {Object} values Box values.
235
- *
236
- * @return {boolean} Whether values are defined.
237
- */
238
- export function isValuesDefined( values ) {
239
- if ( values === undefined || values === null ) {
240
- return false;
241
- }
242
- return Object.values( values ).filter( ( value ) => !! value ).length > 0;
243
- }
244
-
245
187
  /**
246
188
  * Determines whether a particular axis has support. If no axis is
247
189
  * specified, this function checks if either axis is supported.
@@ -275,54 +217,6 @@ export function hasAxisSupport( sides, axis ) {
275
217
  return hasHorizontalSupport || hasVerticalSupport;
276
218
  }
277
219
 
278
- /**
279
- * Determines which menu options should be included in the SidePicker.
280
- *
281
- * @param {Array} sides Supported sides.
282
- *
283
- * @return {Object} Menu options with each option containing label & icon.
284
- */
285
- export function getSupportedMenuItems( sides ) {
286
- if ( ! sides || ! sides.length ) {
287
- return {};
288
- }
289
-
290
- const menuItems = {};
291
-
292
- // Determine the primary "side" menu options.
293
- const hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );
294
- const hasVerticalSupport = hasAxisSupport( sides, 'vertical' );
295
-
296
- if ( hasHorizontalSupport && hasVerticalSupport ) {
297
- menuItems.axial = { label: LABELS.axial, icon: ICONS.axial };
298
- } else if ( hasHorizontalSupport ) {
299
- menuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };
300
- } else if ( hasVerticalSupport ) {
301
- menuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };
302
- }
303
-
304
- // Track whether we have any individual sides so we can omit the custom
305
- // option if required.
306
- let numberOfIndividualSides = 0;
307
-
308
- ALL_SIDES.forEach( ( side ) => {
309
- if ( sides.includes( side ) ) {
310
- numberOfIndividualSides += 1;
311
- menuItems[ side ] = {
312
- label: LABELS[ side ],
313
- icon: ICONS[ side ],
314
- };
315
- }
316
- } );
317
-
318
- // Add custom item if there are enough sides to warrant a separated view.
319
- if ( numberOfIndividualSides > 1 ) {
320
- menuItems.custom = { label: LABELS.custom, icon: ICONS.custom };
321
- }
322
-
323
- return menuItems;
324
- }
325
-
326
220
  /**
327
221
  * Checks if the supported sides are balanced for each axis.
328
222
  * - Horizontal - both left and right sides are supported.
@@ -1,21 +1,19 @@
1
- # Tabbed Panel
1
+ # TabbedSidebar
2
2
 
3
- The `TabbedPanel` component is used to create the secondary panels in the editor.
3
+ The `TabbedSidebar` component is used to create secondary panels in the editor with tabbed navigation.
4
4
 
5
5
  ## Development guidelines
6
6
 
7
- This acts as a wrapper for the `Tabs` component, but adding conventions that can be shared between all secondary panels, for example:
7
+ This acts as a wrapper for the `Tabs` component, adding conventions that can be shared between all secondary panels, including:
8
8
 
9
9
  - A close button
10
10
  - Tabs that fill the panel
11
- - Custom scollbars
11
+ - Custom scrollbars
12
12
 
13
13
  ### Usage
14
14
 
15
- Renders a block alignment toolbar with alignments options.
16
-
17
15
  ```jsx
18
- import { TabbedSidebar } from '@wordpress/components';
16
+ import { TabbedSidebar } from '@wordpress/block-editor';
19
17
 
20
18
  const MyTabbedSidebar = () => (
21
19
  <TabbedSidebar
@@ -23,7 +21,7 @@ const MyTabbedSidebar = () => (
23
21
  {
24
22
  name: 'slug-1',
25
23
  title: _x( 'Title 1', 'context' ),
26
- panel: <PanelContents>,
24
+ panel: <PanelContents />,
27
25
  panelRef: useRef('an-optional-ref'),
28
26
  },
29
27
  {
@@ -35,6 +33,8 @@ const MyTabbedSidebar = () => (
35
33
  onClose={ onClickCloseButton }
36
34
  onSelect={ onSelectTab }
37
35
  defaultTabId="slug-1"
36
+ selectedTab="slug-1"
37
+ closeButtonLabel="Close sidebar"
38
38
  ref={ tabsRef }
39
39
  />
40
40
  );
@@ -47,30 +47,41 @@ const MyTabbedSidebar = () => (
47
47
  - **Type:** `String`
48
48
  - **Default:** `undefined`
49
49
 
50
- This is passed to the `Tabs` component so it can handle the tab to select by default when it component renders.
50
+ The ID of the tab to be selected by default when the component renders.
51
51
 
52
52
  ### `onClose`
53
53
 
54
54
  - **Type:** `Function`
55
55
 
56
- The function that is called when the close button is clicked.
56
+ Function called when the close button is clicked.
57
57
 
58
58
  ### `onSelect`
59
59
 
60
60
  - **Type:** `Function`
61
61
 
62
- This is passed to the `Tabs` component - it will be called when a tab has been selected. It is passed the selected tab's ID as an argument.
62
+ Function called when a tab is selected. Receives the selected tab's ID as an argument.
63
63
 
64
64
  ### `selectedTab`
65
65
 
66
66
  - **Type:** `String`
67
67
  - **Default:** `undefined`
68
68
 
69
- This is passed to the `Tabs` component - it will display this tab as selected.
69
+ The ID of the currently selected tab.
70
70
 
71
71
  ### `tabs`
72
72
 
73
73
  - **Type:** `Array`
74
74
  - **Default:** `undefined`
75
75
 
76
- An array of tabs which will be rendered as `TabList` and `TabPanel` components.
76
+ Array of tab objects. Each tab should have:
77
+
78
+ - `name` (string): Unique identifier for the tab
79
+ - `title` (string): Display title for the tab
80
+ - `panel` (React.Node): Content to display in the tab panel
81
+ - `panelRef` (React.Ref, optional): Reference to the tab panel element
82
+
83
+ #### `closeButtonLabel`
84
+
85
+ - **Type:** `String`
86
+
87
+ Accessibility label for the close button.
@@ -15,6 +15,44 @@ import { unlock } from '../../lock-unlock';
15
15
 
16
16
  const { Tabs } = unlock( componentsPrivateApis );
17
17
 
18
+ /**
19
+ * A component that creates a tabbed sidebar with a close button.
20
+ *
21
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/tabbed-sidebar/README.md
22
+ *
23
+ * @example
24
+ * ```jsx
25
+ * function MyTabbedSidebar() {
26
+ * return (
27
+ * <TabbedSidebar
28
+ * tabs={ [
29
+ * {
30
+ * name: 'tab1',
31
+ * title: 'Settings',
32
+ * panel: <PanelContents />,
33
+ * }
34
+ * ] }
35
+ * onClose={ () => {} }
36
+ * onSelect={ () => {} }
37
+ * defaultTabId="tab1"
38
+ * selectedTab="tab1"
39
+ * closeButtonLabel="Close sidebar"
40
+ * />
41
+ * );
42
+ * }
43
+ * ```
44
+ *
45
+ * @param {Object} props Component props.
46
+ * @param {string} [props.defaultTabId] The ID of the tab to be selected by default when the component renders.
47
+ * @param {Function} props.onClose Function called when the close button is clicked.
48
+ * @param {Function} props.onSelect Function called when a tab is selected. Receives the selected tab's ID as an argument.
49
+ * @param {string} props.selectedTab The ID of the currently selected tab.
50
+ * @param {Array} props.tabs Array of tab objects. Each tab should have: name (string), title (string),
51
+ * panel (React.Node), and optionally panelRef (React.Ref).
52
+ * @param {string} props.closeButtonLabel Accessibility label for the close button.
53
+ * @param {Object} ref Forward ref to the tabs list element.
54
+ * @return {Element} The tabbed sidebar component.
55
+ */
18
56
  function TabbedSidebar(
19
57
  { defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel },
20
58
  ref
@@ -0,0 +1,104 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import TabbedSidebar from '../';
10
+
11
+ const meta = {
12
+ title: 'BlockEditor/TabbedSidebar',
13
+ component: TabbedSidebar,
14
+ tags: [ 'status-private' ],
15
+ parameters: {
16
+ docs: {
17
+ canvas: { sourceState: 'shown' },
18
+ description: {
19
+ component:
20
+ 'A component that creates a tabbed sidebar with a close button.',
21
+ },
22
+ },
23
+ },
24
+ argTypes: {
25
+ defaultTabId: {
26
+ control: { type: null },
27
+ table: {
28
+ type: { summary: 'string' },
29
+ },
30
+ description:
31
+ 'The ID of the tab to be selected by default when the component renders.',
32
+ },
33
+ onClose: {
34
+ action: 'onClose',
35
+ control: { type: null },
36
+ table: {
37
+ type: { summary: 'function' },
38
+ },
39
+ description: 'Function called when the close button is clicked.',
40
+ },
41
+ onSelect: {
42
+ action: 'onSelect',
43
+ control: { type: null },
44
+ table: {
45
+ type: { summary: 'function' },
46
+ },
47
+ description:
48
+ "Function called when a tab is selected. Receives the selected tab's ID as an argument.",
49
+ },
50
+ selectedTab: {
51
+ control: { type: null },
52
+ table: {
53
+ type: { summary: 'string' },
54
+ },
55
+ description: 'The ID of the currently selected tab.',
56
+ },
57
+ tabs: {
58
+ control: { type: 'array' },
59
+ table: {
60
+ type: { summary: 'array' },
61
+ },
62
+ description:
63
+ 'Array of tab objects. Each tab should have: name (string), title (string), panel (React.Node), and optionally panelRef (React.Ref).',
64
+ },
65
+ closeButtonLabel: {
66
+ control: { type: 'text' },
67
+ table: {
68
+ type: { summary: 'string' },
69
+ },
70
+ description: 'Accessibility label for the close button.',
71
+ },
72
+ },
73
+ };
74
+
75
+ export default meta;
76
+
77
+ const DEMO_TABS = [
78
+ { name: 'tab1', title: 'Settings' },
79
+ { name: 'tab2', title: 'Styles' },
80
+ { name: 'tab3', title: 'Advanced' },
81
+ ];
82
+
83
+ export const Default = {
84
+ render: function Template( { onSelect, onClose, ...args } ) {
85
+ const [ selectedTab, setSelectedTab ] = useState();
86
+
87
+ return (
88
+ <TabbedSidebar
89
+ { ...args }
90
+ selectedTab={ selectedTab }
91
+ onSelect={ ( ...changeArgs ) => {
92
+ onSelect( ...changeArgs );
93
+ setSelectedTab( ...changeArgs );
94
+ } }
95
+ onClose={ onClose }
96
+ />
97
+ );
98
+ },
99
+ args: {
100
+ tabs: DEMO_TABS,
101
+ defaultTabId: 'tab1',
102
+ closeButtonLabel: 'Close Sidebar',
103
+ },
104
+ };
@@ -193,7 +193,7 @@ export function useTypewriter() {
193
193
  }
194
194
 
195
195
  /**
196
- * Checks if the current situation is elegible for scroll:
196
+ * Checks if the current situation is eligible for scroll:
197
197
  * - There should be one and only one block selected.
198
198
  * - The component must contain the selection.
199
199
  * - The active element must be contenteditable.
@@ -34,7 +34,7 @@ const Example = () => {
34
34
 
35
35
  ### Props
36
36
 
37
- #### disabledUnits
37
+ #### disableUnits
38
38
 
39
39
  If true, the unit `<select>` is hidden.
40
40
 
@@ -0,0 +1,124 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import UnitControl from '../';
10
+
11
+ const meta = {
12
+ title: 'BlockEditor/UnitControl',
13
+ component: UnitControl,
14
+ parameters: {
15
+ docs: {
16
+ canvas: { sourceState: 'shown' },
17
+ description: {
18
+ component:
19
+ 'UnitControl allows the user to set a numeric quantity as well as a unit.',
20
+ },
21
+ },
22
+ },
23
+ argTypes: {
24
+ onChange: {
25
+ action: 'onChange',
26
+ description: 'Callback function when the value changes.',
27
+ table: {
28
+ type: { summary: 'function' },
29
+ },
30
+ },
31
+ onUnitChange: {
32
+ action: 'onUnitChange',
33
+ description: 'Callback function when the unit changes.',
34
+ table: {
35
+ type: { summary: 'function' },
36
+ },
37
+ },
38
+ labelPosition: {
39
+ control: 'radio',
40
+ options: [ 'top', 'side', 'bottom', 'edge' ],
41
+ description: 'The position of the label.',
42
+ table: {
43
+ type: { summary: 'string' },
44
+ },
45
+ },
46
+ label: {
47
+ control: 'text',
48
+ description: 'The label for the control.',
49
+ table: {
50
+ type: { summary: 'string' },
51
+ },
52
+ },
53
+ value: {
54
+ control: { type: null },
55
+ description: 'The value of the control.',
56
+ table: {
57
+ type: { summary: 'string' },
58
+ },
59
+ },
60
+ size: {
61
+ control: 'radio',
62
+ options: [ 'default', 'small' ],
63
+ description: 'The size of the control.',
64
+ table: {
65
+ type: { summary: 'string' },
66
+ defaultValue: { summary: 'default' },
67
+ },
68
+ },
69
+ disabled: {
70
+ control: 'boolean',
71
+ description: 'Whether the control is disabled.',
72
+ table: {
73
+ type: { summary: 'boolean' },
74
+ defaultValue: { summary: false },
75
+ },
76
+ },
77
+ disableUnits: {
78
+ control: 'boolean',
79
+ description: 'If true, the unit select is hidden.',
80
+ table: {
81
+ type: { summary: 'boolean' },
82
+ defaultValue: { summary: false },
83
+ },
84
+ },
85
+ isPressEnterToChange: {
86
+ control: 'boolean',
87
+ description:
88
+ 'If true, the ENTER key press is required to trigger onChange. Change is also triggered on blur.',
89
+ table: {
90
+ type: { summary: 'boolean' },
91
+ defaultValue: { summary: false },
92
+ },
93
+ },
94
+ isUnitSelectTabbable: {
95
+ control: 'boolean',
96
+ description: 'Determines if the unit select is tabbable.',
97
+ table: {
98
+ type: { summary: 'boolean' },
99
+ defaultValue: { summary: true },
100
+ },
101
+ },
102
+ },
103
+ };
104
+
105
+ export default meta;
106
+
107
+ export const Default = {
108
+ render: function Template( { onChange, ...args } ) {
109
+ const [ value, setValue ] = useState();
110
+ return (
111
+ <UnitControl
112
+ { ...args }
113
+ value={ value }
114
+ onChange={ ( ...changeArgs ) => {
115
+ onChange( ...changeArgs );
116
+ setValue( ...changeArgs );
117
+ } }
118
+ />
119
+ );
120
+ },
121
+ args: {
122
+ label: 'Label',
123
+ },
124
+ };