@wordpress/block-editor 9.7.0 → 9.8.1-next.957ca95e4c.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 (396) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-alignment-control/use-available-alignments.js +1 -1
  3. package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
  4. package/build/components/block-edit-visually-button/index.js +46 -0
  5. package/build/components/block-edit-visually-button/index.js.map +1 -0
  6. package/build/components/block-list/block-list-compact.native.js +73 -0
  7. package/build/components/block-list/block-list-compact.native.js.map +1 -0
  8. package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -1
  9. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  10. package/build/components/block-popover/inbetween.js +4 -2
  11. package/build/components/block-popover/inbetween.js.map +1 -1
  12. package/build/components/block-popover/index.js +11 -7
  13. package/build/components/block-popover/index.js.map +1 -1
  14. package/build/components/block-settings-menu/index.js +2 -6
  15. package/build/components/block-settings-menu/index.js.map +1 -1
  16. package/build/components/block-switcher/index.js +10 -16
  17. package/build/components/block-switcher/index.js.map +1 -1
  18. package/build/components/block-toolbar/index.js +5 -1
  19. package/build/components/block-toolbar/index.js.map +1 -1
  20. package/build/components/block-tools/selected-block-popover.js +10 -2
  21. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  22. package/build/components/block-tools/use-block-toolbar-popover-props.js +126 -0
  23. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
  24. package/build/components/border-radius-control/all-input-control.js +31 -3
  25. package/build/components/border-radius-control/all-input-control.js.map +1 -1
  26. package/build/components/border-radius-control/index.js +20 -6
  27. package/build/components/border-radius-control/index.js.map +1 -1
  28. package/build/components/border-radius-control/input-controls.js +21 -6
  29. package/build/components/border-radius-control/input-controls.js.map +1 -1
  30. package/build/components/border-radius-control/utils.js +13 -16
  31. package/build/components/border-radius-control/utils.js.map +1 -1
  32. package/build/components/colors/with-colors.js +17 -4
  33. package/build/components/colors/with-colors.js.map +1 -1
  34. package/build/components/colors-gradients/control.js +1 -0
  35. package/build/components/colors-gradients/control.js.map +1 -1
  36. package/build/components/copy-handler/index.js +6 -0
  37. package/build/components/copy-handler/index.js.map +1 -1
  38. package/build/components/date-format-picker/index.js +2 -7
  39. package/build/components/date-format-picker/index.js.map +1 -1
  40. package/build/components/duotone/components.js +5 -5
  41. package/build/components/duotone/components.js.map +1 -1
  42. package/build/components/font-family/index.js +1 -1
  43. package/build/components/font-family/index.js.map +1 -1
  44. package/build/components/font-sizes/with-font-sizes.js +17 -4
  45. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  46. package/build/components/index.js +9 -0
  47. package/build/components/index.js.map +1 -1
  48. package/build/components/inner-blocks/index.native.js +6 -2
  49. package/build/components/inner-blocks/index.native.js.map +1 -1
  50. package/build/components/inserter/search-items.js +22 -4
  51. package/build/components/inserter/search-items.js.map +1 -1
  52. package/build/components/link-control/link-preview.js +0 -1
  53. package/build/components/link-control/link-preview.js.map +1 -1
  54. package/build/components/list-view/block-select-button.js +5 -2
  55. package/build/components/list-view/block-select-button.js.map +1 -1
  56. package/build/components/list-view/use-block-selection.js +1 -7
  57. package/build/components/list-view/use-block-selection.js.map +1 -1
  58. package/build/components/rich-text/index.js +10 -0
  59. package/build/components/rich-text/index.js.map +1 -1
  60. package/build/components/rich-text/use-enter.js +0 -4
  61. package/build/components/rich-text/use-enter.js.map +1 -1
  62. package/build/components/rich-text/use-format-types.js +8 -11
  63. package/build/components/rich-text/use-format-types.js.map +1 -1
  64. package/build/components/spacing-sizes-control/all-input-control.js +53 -0
  65. package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
  66. package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
  67. package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
  68. package/build/components/spacing-sizes-control/index.js +100 -0
  69. package/build/components/spacing-sizes-control/index.js.map +1 -0
  70. package/build/components/spacing-sizes-control/input-controls.js +52 -0
  71. package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
  72. package/build/components/spacing-sizes-control/linked-button.js +38 -0
  73. package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
  74. package/build/components/spacing-sizes-control/spacing-input-control.js +213 -0
  75. package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
  76. package/build/components/spacing-sizes-control/utils.js +233 -0
  77. package/build/components/spacing-sizes-control/utils.js.map +1 -0
  78. package/build/components/text-decoration-control/index.js +28 -17
  79. package/build/components/text-decoration-control/index.js.map +1 -1
  80. package/build/components/text-transform-control/index.js +21 -14
  81. package/build/components/text-transform-control/index.js.map +1 -1
  82. package/build/components/url-input/index.js +1 -1
  83. package/build/components/url-input/index.js.map +1 -1
  84. package/build/components/writing-flow/index.js +2 -0
  85. package/build/components/writing-flow/index.js.map +1 -1
  86. package/build/components/writing-flow/use-multi-selection.js +4 -2
  87. package/build/components/writing-flow/use-multi-selection.js.map +1 -1
  88. package/build/components/writing-flow/use-select-all.js +7 -10
  89. package/build/components/writing-flow/use-select-all.js.map +1 -1
  90. package/build/components/writing-flow/use-selection-observer.js +10 -2
  91. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  92. package/build/hooks/align.js +3 -1
  93. package/build/hooks/align.js.map +1 -1
  94. package/build/hooks/anchor.js +3 -7
  95. package/build/hooks/anchor.js.map +1 -1
  96. package/build/hooks/border-radius.js +2 -7
  97. package/build/hooks/border-radius.js.map +1 -1
  98. package/build/hooks/border.js +2 -2
  99. package/build/hooks/border.js.map +1 -1
  100. package/build/hooks/color.js +4 -1
  101. package/build/hooks/color.js.map +1 -1
  102. package/build/hooks/dimensions.js +15 -0
  103. package/build/hooks/dimensions.js.map +1 -1
  104. package/build/hooks/duotone.js +4 -4
  105. package/build/hooks/duotone.js.map +1 -1
  106. package/build/hooks/font-appearance.js +2 -1
  107. package/build/hooks/font-appearance.js.map +1 -1
  108. package/build/hooks/font-family.js +3 -1
  109. package/build/hooks/font-family.js.map +1 -1
  110. package/build/hooks/font-size.js +3 -1
  111. package/build/hooks/font-size.js.map +1 -1
  112. package/build/hooks/gap.js +25 -6
  113. package/build/hooks/gap.js.map +1 -1
  114. package/build/hooks/generated-class-name.js +1 -7
  115. package/build/hooks/generated-class-name.js.map +1 -1
  116. package/build/hooks/layout.js +23 -13
  117. package/build/hooks/layout.js.map +1 -1
  118. package/build/hooks/letter-spacing.js +2 -1
  119. package/build/hooks/letter-spacing.js.map +1 -1
  120. package/build/hooks/line-height.js +2 -1
  121. package/build/hooks/line-height.js.map +1 -1
  122. package/build/hooks/lock.js +3 -7
  123. package/build/hooks/lock.js.map +1 -1
  124. package/build/hooks/margin.js +28 -12
  125. package/build/hooks/margin.js.map +1 -1
  126. package/build/hooks/padding.js +19 -8
  127. package/build/hooks/padding.js.map +1 -1
  128. package/build/hooks/style.js +4 -50
  129. package/build/hooks/style.js.map +1 -1
  130. package/build/hooks/text-decoration.js +2 -1
  131. package/build/hooks/text-decoration.js.map +1 -1
  132. package/build/hooks/text-transform.js +2 -1
  133. package/build/hooks/text-transform.js.map +1 -1
  134. package/build/layouts/constrained.js +225 -0
  135. package/build/layouts/constrained.js.map +1 -0
  136. package/build/layouts/flex.js +1 -1
  137. package/build/layouts/flex.js.map +1 -1
  138. package/build/layouts/flow.js +18 -152
  139. package/build/layouts/flow.js.map +1 -1
  140. package/build/layouts/index.js +3 -1
  141. package/build/layouts/index.js.map +1 -1
  142. package/build/layouts/utils.js +43 -0
  143. package/build/layouts/utils.js.map +1 -1
  144. package/build/store/actions.js +25 -3
  145. package/build/store/actions.js.map +1 -1
  146. package/build/store/selectors.js +4 -6
  147. package/build/store/selectors.js.map +1 -1
  148. package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
  149. package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
  150. package/build-module/components/block-edit-visually-button/index.js +35 -0
  151. package/build-module/components/block-edit-visually-button/index.js.map +1 -0
  152. package/build-module/components/block-list/block-list-compact.native.js +58 -0
  153. package/build-module/components/block-list/block-list-compact.native.js.map +1 -0
  154. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -1
  155. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  156. package/build-module/components/block-popover/inbetween.js +4 -2
  157. package/build-module/components/block-popover/inbetween.js.map +1 -1
  158. package/build-module/components/block-popover/index.js +9 -7
  159. package/build-module/components/block-popover/index.js.map +1 -1
  160. package/build-module/components/block-settings-menu/index.js +3 -6
  161. package/build-module/components/block-settings-menu/index.js.map +1 -1
  162. package/build-module/components/block-switcher/index.js +10 -16
  163. package/build-module/components/block-switcher/index.js.map +1 -1
  164. package/build-module/components/block-toolbar/index.js +4 -1
  165. package/build-module/components/block-toolbar/index.js.map +1 -1
  166. package/build-module/components/block-tools/selected-block-popover.js +8 -2
  167. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  168. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +114 -0
  169. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
  170. package/build-module/components/border-radius-control/all-input-control.js +32 -4
  171. package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
  172. package/build-module/components/border-radius-control/index.js +20 -6
  173. package/build-module/components/border-radius-control/index.js.map +1 -1
  174. package/build-module/components/border-radius-control/input-controls.js +22 -7
  175. package/build-module/components/border-radius-control/input-controls.js.map +1 -1
  176. package/build-module/components/border-radius-control/utils.js +13 -16
  177. package/build-module/components/border-radius-control/utils.js.map +1 -1
  178. package/build-module/components/colors/with-colors.js +16 -3
  179. package/build-module/components/colors/with-colors.js.map +1 -1
  180. package/build-module/components/colors-gradients/control.js +1 -0
  181. package/build-module/components/colors-gradients/control.js.map +1 -1
  182. package/build-module/components/copy-handler/index.js +7 -1
  183. package/build-module/components/copy-handler/index.js.map +1 -1
  184. package/build-module/components/date-format-picker/index.js +2 -6
  185. package/build-module/components/date-format-picker/index.js.map +1 -1
  186. package/build-module/components/duotone/components.js +5 -5
  187. package/build-module/components/duotone/components.js.map +1 -1
  188. package/build-module/components/font-family/index.js +1 -1
  189. package/build-module/components/font-family/index.js.map +1 -1
  190. package/build-module/components/font-sizes/with-font-sizes.js +16 -3
  191. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  192. package/build-module/components/index.js +1 -0
  193. package/build-module/components/index.js.map +1 -1
  194. package/build-module/components/inner-blocks/index.native.js +5 -2
  195. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  196. package/build-module/components/inserter/search-items.js +19 -5
  197. package/build-module/components/inserter/search-items.js.map +1 -1
  198. package/build-module/components/link-control/link-preview.js +0 -1
  199. package/build-module/components/link-control/link-preview.js.map +1 -1
  200. package/build-module/components/list-view/block-select-button.js +5 -2
  201. package/build-module/components/list-view/block-select-button.js.map +1 -1
  202. package/build-module/components/list-view/use-block-selection.js +1 -6
  203. package/build-module/components/list-view/use-block-selection.js.map +1 -1
  204. package/build-module/components/rich-text/index.js +10 -0
  205. package/build-module/components/rich-text/index.js.map +1 -1
  206. package/build-module/components/rich-text/use-enter.js +0 -4
  207. package/build-module/components/rich-text/use-enter.js.map +1 -1
  208. package/build-module/components/rich-text/use-format-types.js +8 -10
  209. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  210. package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
  211. package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
  212. package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
  213. package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
  214. package/build-module/components/spacing-sizes-control/index.js +83 -0
  215. package/build-module/components/spacing-sizes-control/index.js.map +1 -0
  216. package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
  217. package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
  218. package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
  219. package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
  220. package/build-module/components/spacing-sizes-control/spacing-input-control.js +197 -0
  221. package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
  222. package/build-module/components/spacing-sizes-control/utils.js +203 -0
  223. package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
  224. package/build-module/components/text-decoration-control/index.js +25 -18
  225. package/build-module/components/text-decoration-control/index.js.map +1 -1
  226. package/build-module/components/text-transform-control/index.js +19 -15
  227. package/build-module/components/text-transform-control/index.js.map +1 -1
  228. package/build-module/components/url-input/index.js +1 -1
  229. package/build-module/components/url-input/index.js.map +1 -1
  230. package/build-module/components/writing-flow/index.js +2 -0
  231. package/build-module/components/writing-flow/index.js.map +1 -1
  232. package/build-module/components/writing-flow/use-multi-selection.js +4 -2
  233. package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
  234. package/build-module/components/writing-flow/use-select-all.js +7 -10
  235. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  236. package/build-module/components/writing-flow/use-selection-observer.js +10 -2
  237. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  238. package/build-module/hooks/align.js +4 -2
  239. package/build-module/hooks/align.js.map +1 -1
  240. package/build-module/hooks/anchor.js +3 -6
  241. package/build-module/hooks/anchor.js.map +1 -1
  242. package/build-module/hooks/border-radius.js +2 -7
  243. package/build-module/hooks/border-radius.js.map +1 -1
  244. package/build-module/hooks/border.js +2 -2
  245. package/build-module/hooks/border.js.map +1 -1
  246. package/build-module/hooks/color.js +4 -1
  247. package/build-module/hooks/color.js.map +1 -1
  248. package/build-module/hooks/dimensions.js +13 -0
  249. package/build-module/hooks/dimensions.js.map +1 -1
  250. package/build-module/hooks/duotone.js +4 -4
  251. package/build-module/hooks/duotone.js.map +1 -1
  252. package/build-module/hooks/font-appearance.js +2 -1
  253. package/build-module/hooks/font-appearance.js.map +1 -1
  254. package/build-module/hooks/font-family.js +3 -1
  255. package/build-module/hooks/font-family.js.map +1 -1
  256. package/build-module/hooks/font-size.js +3 -1
  257. package/build-module/hooks/font-size.js.map +1 -1
  258. package/build-module/hooks/gap.js +21 -4
  259. package/build-module/hooks/gap.js.map +1 -1
  260. package/build-module/hooks/generated-class-name.js +1 -6
  261. package/build-module/hooks/generated-class-name.js.map +1 -1
  262. package/build-module/hooks/layout.js +24 -14
  263. package/build-module/hooks/layout.js.map +1 -1
  264. package/build-module/hooks/letter-spacing.js +2 -1
  265. package/build-module/hooks/letter-spacing.js.map +1 -1
  266. package/build-module/hooks/line-height.js +2 -1
  267. package/build-module/hooks/line-height.js.map +1 -1
  268. package/build-module/hooks/lock.js +3 -6
  269. package/build-module/hooks/lock.js.map +1 -1
  270. package/build-module/hooks/margin.js +26 -12
  271. package/build-module/hooks/margin.js.map +1 -1
  272. package/build-module/hooks/padding.js +17 -8
  273. package/build-module/hooks/padding.js.map +1 -1
  274. package/build-module/hooks/style.js +7 -53
  275. package/build-module/hooks/style.js.map +1 -1
  276. package/build-module/hooks/text-decoration.js +2 -1
  277. package/build-module/hooks/text-decoration.js.map +1 -1
  278. package/build-module/hooks/text-transform.js +2 -1
  279. package/build-module/hooks/text-transform.js.map +1 -1
  280. package/build-module/layouts/constrained.js +207 -0
  281. package/build-module/layouts/constrained.js.map +1 -0
  282. package/build-module/layouts/flex.js +1 -1
  283. package/build-module/layouts/flex.js.map +1 -1
  284. package/build-module/layouts/flow.js +20 -147
  285. package/build-module/layouts/flow.js.map +1 -1
  286. package/build-module/layouts/index.js +2 -1
  287. package/build-module/layouts/index.js.map +1 -1
  288. package/build-module/layouts/utils.js +40 -0
  289. package/build-module/layouts/utils.js.map +1 -1
  290. package/build-module/store/actions.js +25 -3
  291. package/build-module/store/actions.js.map +1 -1
  292. package/build-module/store/selectors.js +5 -7
  293. package/build-module/store/selectors.js.map +1 -1
  294. package/build-style/style-rtl.css +157 -61
  295. package/build-style/style.css +157 -61
  296. package/package.json +30 -28
  297. package/src/components/block-alignment-control/use-available-alignments.js +1 -1
  298. package/src/components/block-edit-visually-button/index.js +39 -0
  299. package/src/components/block-list/block-list-compact.native.js +62 -0
  300. package/src/components/block-list/style.scss +29 -6
  301. package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -1
  302. package/src/components/block-popover/inbetween.js +4 -1
  303. package/src/components/block-popover/index.js +22 -15
  304. package/src/components/block-settings-menu/index.js +11 -15
  305. package/src/components/block-switcher/index.js +9 -13
  306. package/src/components/block-switcher/test/index.js +2 -2
  307. package/src/components/block-toolbar/index.js +2 -0
  308. package/src/components/block-tools/selected-block-popover.js +7 -0
  309. package/src/components/block-tools/use-block-toolbar-popover-props.js +123 -0
  310. package/src/components/border-radius-control/all-input-control.js +41 -4
  311. package/src/components/border-radius-control/index.js +25 -5
  312. package/src/components/border-radius-control/input-controls.js +40 -13
  313. package/src/components/border-radius-control/test/utils.js +22 -60
  314. package/src/components/border-radius-control/utils.js +12 -16
  315. package/src/components/button-block-appender/style.scss +23 -0
  316. package/src/components/colors/with-colors.js +11 -1
  317. package/src/components/colors-gradients/control.js +1 -0
  318. package/src/components/copy-handler/index.js +18 -0
  319. package/src/components/date-format-picker/index.js +12 -14
  320. package/src/components/date-format-picker/style.scss +0 -4
  321. package/src/components/duotone/components.js +5 -5
  322. package/src/components/duotone-control/style.scss +0 -4
  323. package/src/components/font-appearance-control/style.scss +0 -2
  324. package/src/components/font-family/index.js +1 -1
  325. package/src/components/font-sizes/with-font-sizes.js +11 -1
  326. package/src/components/index.js +1 -0
  327. package/src/components/inner-blocks/index.native.js +5 -1
  328. package/src/components/inserter/search-items.js +17 -5
  329. package/src/components/link-control/link-preview.js +0 -1
  330. package/src/components/link-control/test/index.js +540 -893
  331. package/src/components/list-view/block-select-button.js +7 -2
  332. package/src/components/list-view/style.scss +11 -4
  333. package/src/components/list-view/use-block-selection.js +2 -8
  334. package/src/components/media-replace-flow/style.scss +1 -0
  335. package/src/components/rich-text/index.js +9 -0
  336. package/src/components/rich-text/use-enter.js +0 -3
  337. package/src/components/rich-text/use-format-types.js +6 -6
  338. package/src/components/spacing-sizes-control/all-input-control.js +40 -0
  339. package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
  340. package/src/components/spacing-sizes-control/index.js +91 -0
  341. package/src/components/spacing-sizes-control/input-controls.js +46 -0
  342. package/src/components/spacing-sizes-control/linked-button.js +25 -0
  343. package/src/components/spacing-sizes-control/spacing-input-control.js +285 -0
  344. package/src/components/spacing-sizes-control/style.scss +122 -0
  345. package/src/components/spacing-sizes-control/test/utils.js +182 -0
  346. package/src/components/spacing-sizes-control/utils.js +222 -0
  347. package/src/components/text-decoration-control/index.js +41 -30
  348. package/src/components/text-decoration-control/stories/index.js +37 -0
  349. package/src/components/text-transform-control/index.js +27 -27
  350. package/src/components/text-transform-control/stories/index.js +37 -0
  351. package/src/components/url-input/index.js +1 -1
  352. package/src/components/url-input/style.scss +2 -2
  353. package/src/components/url-popover/style.scss +0 -3
  354. package/src/components/writing-flow/index.js +2 -0
  355. package/src/components/writing-flow/use-multi-selection.js +4 -1
  356. package/src/components/writing-flow/use-select-all.js +10 -13
  357. package/src/components/writing-flow/use-selection-observer.js +10 -2
  358. package/src/hooks/align.js +2 -2
  359. package/src/hooks/anchor.js +1 -6
  360. package/src/hooks/border-radius.js +2 -6
  361. package/src/hooks/border.js +2 -2
  362. package/src/hooks/color.js +13 -3
  363. package/src/hooks/dimensions.js +14 -0
  364. package/src/hooks/duotone.js +4 -4
  365. package/src/hooks/font-appearance.js +1 -0
  366. package/src/hooks/font-family.js +2 -0
  367. package/src/hooks/font-size.js +2 -0
  368. package/src/hooks/gap.js +42 -19
  369. package/src/hooks/generated-class-name.js +6 -9
  370. package/src/hooks/layout.js +47 -16
  371. package/src/hooks/letter-spacing.js +1 -0
  372. package/src/hooks/line-height.js +1 -0
  373. package/src/hooks/lock.js +1 -6
  374. package/src/hooks/margin.js +49 -17
  375. package/src/hooks/padding.js +41 -14
  376. package/src/hooks/style.js +5 -56
  377. package/src/hooks/test/gap.js +16 -0
  378. package/src/hooks/text-decoration.js +1 -0
  379. package/src/hooks/text-transform.js +1 -0
  380. package/src/hooks/typography.scss +0 -7
  381. package/src/layouts/constrained.js +220 -0
  382. package/src/layouts/flex.js +1 -1
  383. package/src/layouts/flow.js +17 -173
  384. package/src/layouts/index.js +2 -1
  385. package/src/layouts/test/constrained.js +21 -0
  386. package/src/layouts/utils.js +34 -0
  387. package/src/store/actions.js +32 -4
  388. package/src/store/selectors.js +5 -4
  389. package/src/style.scss +1 -2
  390. package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
  391. package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
  392. package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
  393. package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
  394. package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
  395. package/src/components/text-decoration-control/style.scss +0 -18
  396. package/src/components/text-transform-control/style.scss +0 -18
@@ -0,0 +1,122 @@
1
+ .tools-panel-item-spacing {
2
+ display: grid;
3
+ grid-template-columns: auto 1fr auto;
4
+ grid-row-gap: $grid-unit-05;
5
+ }
6
+
7
+ .component-spacing-sizes-control {
8
+ box-sizing: border-box;
9
+ padding-bottom: 12px;
10
+ width: 100%;
11
+ display: contents;
12
+
13
+ legend {
14
+ padding: 0;
15
+ grid-column: 1 / 1;
16
+ grid-row: 1 / 1;
17
+ align-self: center;
18
+ }
19
+
20
+ .components-spacing-sizes-control__side-labels {
21
+ grid-column: 1 / 1;
22
+ min-height: 30px;
23
+ justify-content: left;
24
+ }
25
+
26
+ .components-spacing-sizes-control__hint-single {
27
+ margin-top: 0;
28
+ margin-left: 0;
29
+ }
30
+
31
+ .components-spacing-sizes-control__hint-single,
32
+ .components-spacing-sizes-control__hint-all {
33
+ color: $gray-700;
34
+ font-size: 12px;
35
+ }
36
+
37
+ .components-spacing-sizes-control__hint-all {
38
+ grid-column: 2 / 2;
39
+ justify-self: left;
40
+ grid-row: 1 / 1;
41
+ align-self: center;
42
+ margin-left: $grid-unit-05;
43
+ }
44
+
45
+ .components-spacing-sizes-control__custom-toggle-all {
46
+ grid-column: 2 / 2;
47
+ grid-row: 1 / 1;
48
+ justify-self: end;
49
+ margin-right: $grid-unit-05;
50
+ padding: 0;
51
+ }
52
+
53
+ .components-spacing-sizes-control__custom-toggle-single {
54
+ grid-column: 3 / 3;
55
+ justify-self: end;
56
+ }
57
+
58
+ .components-spacing-sizes-control__custom-toggle-all,
59
+ .components-spacing-sizes-control__custom-toggle-single {
60
+ &.is-small.has-icon {
61
+ padding: 0;
62
+ min-width: $icon-size;
63
+ }
64
+ }
65
+
66
+ .component-spacing-sizes-control__linked-button {
67
+ grid-column: 3 / 3;
68
+ grid-row: 1 / 1;
69
+ justify-self: end;
70
+ }
71
+
72
+ .components-spacing-sizes-control__custom-value-range {
73
+ grid-column: span 2;
74
+ margin-left: $grid-unit-10;
75
+ padding-right: $grid-unit-10;
76
+ height: 30px;
77
+ }
78
+
79
+ .components-spacing-sizes-control__custom-value-input {
80
+ width: 124px;
81
+ }
82
+
83
+ .components-spacing-sizes-control__range-control {
84
+ grid-column: span 3;
85
+ padding-right: $grid-unit-10;
86
+ height: 30px;
87
+ }
88
+
89
+ .components-range-control__wrapper {
90
+ margin-bottom: 0;
91
+ }
92
+
93
+ .components-range-control__mark {
94
+ height: $grid-unit-05;
95
+ width: 3px;
96
+ background-color: #fff;
97
+ z-index: 1;
98
+ }
99
+
100
+ .components-range-control__marks {
101
+ margin-top: 17px;
102
+
103
+ :first-child {
104
+ display: none;
105
+ }
106
+ }
107
+
108
+ [class*="ThumbWrapper-thumbColor"] {
109
+ z-index: 3;
110
+ }
111
+
112
+ .components-spacing-sizes-control__side-label {
113
+ margin-right: $grid-unit-05;
114
+ grid-column: 1 / 1;
115
+ justify-self: left;
116
+ font-size: 12px;
117
+ }
118
+
119
+ .components-spacing-sizes-control__custom-select-control {
120
+ grid-column: span 3;
121
+ }
122
+ }
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import {
5
+ isValueSpacingPreset,
6
+ getCustomValueFromPreset,
7
+ getPresetValueFromCustomValue,
8
+ getSpacingPresetCssVar,
9
+ getSpacingPresetSlug,
10
+ getSliderValueFromPreset,
11
+ getAllRawValue,
12
+ isValuesMixed,
13
+ isValuesDefined,
14
+ } from '../utils';
15
+
16
+ describe( 'isValueSpacingPreset', () => {
17
+ it( 'should return true if value is string in spacing presets var format', () => {
18
+ expect( isValueSpacingPreset( 'var:preset|spacing|20' ) ).toBe( true );
19
+ } );
20
+ it( 'should return false if value is not a string in spacing presets var format', () => {
21
+ expect( isValueSpacingPreset( '30px' ) ).toBe( false );
22
+ } );
23
+ } );
24
+
25
+ describe( 'getCustomValueFromPreset', () => {
26
+ const spacingSizes = [ { name: 'Small', slug: 20, size: '8px' } ];
27
+ it( 'should return original value if not a string in spacing presets var format', () => {
28
+ expect( getCustomValueFromPreset( '20px', spacingSizes ) ).toBe(
29
+ '20px'
30
+ );
31
+ } );
32
+ it( 'should return value from matching spacingSizes array entry if string in spacing presets var format', () => {
33
+ expect(
34
+ getCustomValueFromPreset( 'var:preset|spacing|20', spacingSizes )
35
+ ).toBe( '8px' );
36
+ } );
37
+ it( 'should return undefined if no matching preset in spacingSizes array', () => {
38
+ expect(
39
+ getCustomValueFromPreset( 'var:preset|spacing|30', spacingSizes )
40
+ ).toBe( undefined );
41
+ } );
42
+ } );
43
+
44
+ describe( 'getPresetValueFromCustomValue', () => {
45
+ const spacingSizes = [ { name: 'Small', slug: 20, size: '8px' } ];
46
+ it( 'should return original value if a string in spacing presets var format', () => {
47
+ expect(
48
+ getPresetValueFromCustomValue(
49
+ 'var:preset|spacing|80',
50
+ spacingSizes
51
+ )
52
+ ).toBe( 'var:preset|spacing|80' );
53
+ } );
54
+ it( 'should return value constructed from matching spacingSizes array entry if value matches sizes', () => {
55
+ expect( getPresetValueFromCustomValue( '8px', spacingSizes ) ).toBe(
56
+ 'var:preset|spacing|20'
57
+ );
58
+ } );
59
+ it( 'should return values as-is if no matching preset in spacingSizes array', () => {
60
+ expect(
61
+ getPresetValueFromCustomValue( '1.125rem', spacingSizes )
62
+ ).toBe( '1.125rem' );
63
+ } );
64
+ } );
65
+
66
+ describe( 'getSpacingPresetCssVar', () => {
67
+ it( 'should return original value if not a string in spacing presets var format', () => {
68
+ expect( getSpacingPresetCssVar( '20px' ) ).toBe( '20px' );
69
+ } );
70
+ it( 'should return a string in spacing presets css var format with slug from provided value', () => {
71
+ expect( getSpacingPresetCssVar( 'var:preset|spacing|20' ) ).toBe(
72
+ 'var(--wp--preset--spacing--20)'
73
+ );
74
+ } );
75
+ } );
76
+
77
+ describe( 'getSpacingPresetSlug', () => {
78
+ it( 'should return original value if 0 or default', () => {
79
+ expect( getSpacingPresetSlug( '0' ) ).toBe( '0' );
80
+ expect( getSpacingPresetSlug( 'default' ) ).toBe( 'default' );
81
+ } );
82
+ it( 'should return the int value of the slug portion of a valid preset var', () => {
83
+ expect( getSpacingPresetSlug( 'var:preset|spacing|20' ) ).toBe( '20' );
84
+ } );
85
+ } );
86
+
87
+ describe( 'getSliderValueFromPreset', () => {
88
+ const spacingSizes = [
89
+ { name: 'Small', slug: 20, size: '8px' },
90
+ { name: 'Large', slug: 30, size: '24px' },
91
+ ];
92
+ it( 'should return NaN if no matching preset found - NaN makes range control go to start', () => {
93
+ expect( getSliderValueFromPreset( '10px', spacingSizes ) ).toBe( NaN );
94
+ } );
95
+ it( 'should return the int value of the slug portion of a valid preset var', () => {
96
+ expect(
97
+ getSliderValueFromPreset( 'var:preset|spacing|30', spacingSizes )
98
+ ).toBe( 1 );
99
+ } );
100
+ } );
101
+
102
+ describe( 'getAllRawValue', () => {
103
+ const customValues = {
104
+ top: '5px',
105
+ bottom: '5px',
106
+ left: '6px',
107
+ right: '2px',
108
+ };
109
+ it( 'should return the most common custom value from the values object', () => {
110
+ expect( getAllRawValue( customValues ) ).toBe( '5px' );
111
+ } );
112
+ const presetValues = {
113
+ top: 'var:preset|spacing|30',
114
+ bottom: 'var:preset|spacing|20',
115
+ left: 'var:preset|spacing|10',
116
+ right: 'var:preset|spacing|30',
117
+ };
118
+ it( 'should return the most common preset value from the values object', () => {
119
+ expect( getAllRawValue( presetValues ) ).toBe(
120
+ 'var:preset|spacing|30'
121
+ );
122
+ } );
123
+ } );
124
+
125
+ describe( 'isValuesMixed', () => {
126
+ const unmixedValues = {
127
+ top: '5px',
128
+ bottom: '5px',
129
+ left: '5px',
130
+ right: '5px',
131
+ };
132
+ it( 'should return false if all values are the same', () => {
133
+ expect( isValuesMixed( unmixedValues ) ).toBe( false );
134
+ } );
135
+ const mixedValues = {
136
+ top: 'var:preset|spacing|30',
137
+ bottom: 'var:preset|spacing|20',
138
+ left: 'var:preset|spacing|10',
139
+ right: 'var:preset|spacing|30',
140
+ };
141
+ it( 'should return true if all the values are not the same', () => {
142
+ expect( isValuesMixed( mixedValues ) ).toBe( true );
143
+ } );
144
+ const singleValue = {
145
+ top: 'var:preset|spacing|30',
146
+ };
147
+ it( 'should return true if only one side set', () => {
148
+ expect( isValuesMixed( singleValue ) ).toBe( true );
149
+ } );
150
+ const incompleteValues = {
151
+ top: 'var:preset|spacing|30',
152
+ bottom: 'var:preset|spacing|30',
153
+ left: 'var:preset|spacing|30',
154
+ };
155
+ it( 'should return true if all sides not set', () => {
156
+ expect( isValuesMixed( incompleteValues ) ).toBe( true );
157
+ } );
158
+ } );
159
+
160
+ describe( 'isValuesDefined', () => {
161
+ const undefinedValues = {
162
+ top: undefined,
163
+ bottom: undefined,
164
+ left: undefined,
165
+ right: undefined,
166
+ };
167
+ it( 'should return false if values are not defined', () => {
168
+ expect( isValuesDefined( undefinedValues ) ).toBe( false );
169
+ } );
170
+ it( 'should return false if values is passed in as null', () => {
171
+ expect( isValuesDefined( null ) ).toBe( false );
172
+ } );
173
+ const definedValues = {
174
+ top: 'var:preset|spacing|30',
175
+ bottom: 'var:preset|spacing|20',
176
+ left: 'var:preset|spacing|10',
177
+ right: 'var:preset|spacing|30',
178
+ };
179
+ it( 'should return true if all the values are not the same', () => {
180
+ expect( isValuesDefined( definedValues ) ).toBe( true );
181
+ } );
182
+ } );
@@ -0,0 +1,222 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { isEmpty } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { __ } from '@wordpress/i18n';
10
+
11
+ /**
12
+ * Checks is given value is a spacing preset.
13
+ *
14
+ * @param {string} value Value to check
15
+ *
16
+ * @return {boolean} Return true if value is string in format var:preset|spacing|.
17
+ */
18
+ export function isValueSpacingPreset( value ) {
19
+ if ( ! value?.includes ) {
20
+ return false;
21
+ }
22
+ return value === '0' || value.includes( 'var:preset|spacing|' );
23
+ }
24
+
25
+ /**
26
+ * Converts a spacing preset into a custom value.
27
+ *
28
+ * @param {string} value Value to convert
29
+ * @param {Array} spacingSizes Array of the current spacing preset objects
30
+ *
31
+ * @return {string} Mapping of the spacing preset to its equivalent custom value.
32
+ */
33
+ export function getCustomValueFromPreset( value, spacingSizes ) {
34
+ if ( ! isValueSpacingPreset( value ) ) {
35
+ return value;
36
+ }
37
+
38
+ const slug = getSpacingPresetSlug( value );
39
+ const spacingSize = spacingSizes.find(
40
+ ( size ) => String( size.slug ) === slug
41
+ );
42
+
43
+ return spacingSize?.size;
44
+ }
45
+
46
+ /**
47
+ * Converts a custom value to preset value if one can be found.
48
+ *
49
+ * Returns value as-is if no match is found.
50
+ *
51
+ * @param {string} value Value to convert
52
+ * @param {Array} spacingSizes Array of the current spacing preset objects
53
+ *
54
+ * @return {string} The preset value if it can be found.
55
+ */
56
+ export function getPresetValueFromCustomValue( value, spacingSizes ) {
57
+ // Return value as-is if it is already a preset;
58
+ if ( isValueSpacingPreset( value ) ) {
59
+ return value;
60
+ }
61
+
62
+ const spacingMatch = spacingSizes.find(
63
+ ( size ) => String( size.size ) === String( value )
64
+ );
65
+
66
+ if ( spacingMatch?.slug ) {
67
+ return `var:preset|spacing|${ spacingMatch.slug }`;
68
+ }
69
+
70
+ return value;
71
+ }
72
+
73
+ /**
74
+ * Converts a spacing preset into a custom value.
75
+ *
76
+ * @param {string} value Value to convert.
77
+ *
78
+ * @return {string} CSS var string for given spacing preset value.
79
+ */
80
+ export function getSpacingPresetCssVar( value ) {
81
+ if ( ! value ) {
82
+ return;
83
+ }
84
+
85
+ const slug = value.match( /var:preset\|spacing\|(.+)/ );
86
+
87
+ if ( ! slug ) {
88
+ return value;
89
+ }
90
+
91
+ return `var(--wp--preset--spacing--${ slug[ 1 ] })`;
92
+ }
93
+
94
+ /**
95
+ * Returns the slug section of the given spacing preset string.
96
+ *
97
+ * @param {string} value Value to extract slug from.
98
+ *
99
+ * @return {number} The int value of the slug from given spacing preset.
100
+ */
101
+ export function getSpacingPresetSlug( value ) {
102
+ if ( ! value ) {
103
+ return;
104
+ }
105
+
106
+ if ( value === '0' || value === 'default' ) {
107
+ return value;
108
+ }
109
+
110
+ const slug = value.match( /var:preset\|spacing\|(.+)/ );
111
+
112
+ return slug ? slug[ 1 ] : undefined;
113
+ }
114
+
115
+ /**
116
+ * Converts spacing preset value into a Range component value .
117
+ *
118
+ * @param {string} presetValue Value to convert to Range value.
119
+ * @param {Array} spacingSizes Array of current spacing preset value objects.
120
+ *
121
+ * @return {number} The int value for use in Range control.
122
+ */
123
+ export function getSliderValueFromPreset( presetValue, spacingSizes ) {
124
+ if ( presetValue === undefined ) {
125
+ return 0;
126
+ }
127
+ const slug =
128
+ parseFloat( presetValue, 10 ) === 0
129
+ ? '0'
130
+ : getSpacingPresetSlug( presetValue );
131
+ const sliderValue = spacingSizes.findIndex( ( spacingSize ) => {
132
+ return String( spacingSize.slug ) === slug;
133
+ } );
134
+
135
+ // Returning NaN rather than undefined as undefined makes range control thumb sit in center
136
+ return sliderValue !== -1 ? sliderValue : NaN;
137
+ }
138
+
139
+ export const LABELS = {
140
+ all: __( 'All sides' ),
141
+ top: __( 'Top' ),
142
+ bottom: __( 'Bottom' ),
143
+ left: __( 'Left' ),
144
+ right: __( 'Right' ),
145
+ mixed: __( 'Mixed' ),
146
+ vertical: __( 'Vertical' ),
147
+ horizontal: __( 'Horizontal' ),
148
+ };
149
+
150
+ export const DEFAULT_VALUES = {
151
+ top: undefined,
152
+ right: undefined,
153
+ bottom: undefined,
154
+ left: undefined,
155
+ };
156
+
157
+ export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
158
+
159
+ /**
160
+ * Gets an items with the most occurrence within an array
161
+ * https://stackoverflow.com/a/20762713
162
+ *
163
+ * @param {Array<any>} arr Array of items to check.
164
+ * @return {any} The item with the most occurrences.
165
+ */
166
+ function mode( arr ) {
167
+ return arr
168
+ .sort(
169
+ ( a, b ) =>
170
+ arr.filter( ( v ) => v === a ).length -
171
+ arr.filter( ( v ) => v === b ).length
172
+ )
173
+ .pop();
174
+ }
175
+
176
+ /**
177
+ * Gets the 'all' input value from values data.
178
+ *
179
+ * @param {Object} values Box spacing values
180
+ *
181
+ * @return {string} The most common value from all sides of box.
182
+ */
183
+ export function getAllRawValue( values = {} ) {
184
+ return mode( Object.values( values ) );
185
+ }
186
+
187
+ /**
188
+ * Checks to determine if values are mixed.
189
+ *
190
+ * @param {Object} values Box values.
191
+ * @param {Array} sides Sides that values relate to.
192
+ *
193
+ * @return {boolean} Whether values are mixed.
194
+ */
195
+ export function isValuesMixed( values = {}, sides = ALL_SIDES ) {
196
+ return (
197
+ ( Object.values( values ).length >= 1 &&
198
+ Object.values( values ).length < sides.length ) ||
199
+ new Set( Object.values( values ) ).size > 1
200
+ );
201
+ }
202
+
203
+ /**
204
+ * Checks to determine if values are defined.
205
+ *
206
+ * @param {Object} values Box values.
207
+ *
208
+ * @return {boolean} Whether values are defined.
209
+ */
210
+ export function isValuesDefined( values ) {
211
+ if ( values === undefined || values === null ) {
212
+ return false;
213
+ }
214
+ return ! isEmpty(
215
+ Object.values( values ).filter(
216
+ // Switching units when input is empty causes values only
217
+ // containing units. This gives false positive on mixed values
218
+ // unless filtered.
219
+ ( value ) => !! value && /\d/.test( value )
220
+ )
221
+ );
222
+ }
@@ -1,7 +1,15 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
4
- import { BaseControl, Button } from '@wordpress/components';
9
+ import {
10
+ __experimentalToggleGroupControl as ToggleGroupControl,
11
+ __experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
12
+ } from '@wordpress/components';
5
13
  import { formatStrikethrough, formatUnderline } from '@wordpress/icons';
6
14
  import { __ } from '@wordpress/i18n';
7
15
 
@@ -21,38 +29,41 @@ const TEXT_DECORATIONS = [
21
29
  /**
22
30
  * Control to facilitate text decoration selections.
23
31
  *
24
- * @param {Object} props Component props.
25
- * @param {string} props.value Currently selected text decoration.
26
- * @param {Function} props.onChange Handles change in text decoration selection.
32
+ * @param {Object} props Component props.
33
+ * @param {string} props.value Currently selected text decoration.
34
+ * @param {Function} props.onChange Handles change in text decoration selection.
35
+ * @param {string} [props.className] Additional class name to apply.
27
36
  *
28
37
  * @return {WPElement} Text decoration control.
29
38
  */
30
- export default function TextDecorationControl( { value, onChange } ) {
39
+ export default function TextDecorationControl( {
40
+ value,
41
+ onChange,
42
+ className,
43
+ ...props
44
+ } ) {
31
45
  return (
32
- <fieldset className="block-editor-text-decoration-control">
33
- <BaseControl.VisualLabel as="legend">
34
- { __( 'Decoration' ) }
35
- </BaseControl.VisualLabel>
36
- <div className="block-editor-text-decoration-control__buttons">
37
- { TEXT_DECORATIONS.map( ( textDecoration ) => {
38
- return (
39
- <Button
40
- key={ textDecoration.value }
41
- icon={ textDecoration.icon }
42
- isSmall
43
- isPressed={ textDecoration.value === value }
44
- onClick={ () =>
45
- onChange(
46
- textDecoration.value === value
47
- ? undefined
48
- : textDecoration.value
49
- )
50
- }
51
- aria-label={ textDecoration.name }
52
- />
53
- );
54
- } ) }
55
- </div>
56
- </fieldset>
46
+ <ToggleGroupControl
47
+ { ...props }
48
+ className={ classnames(
49
+ 'block-editor-text-decoration-control',
50
+ className
51
+ ) }
52
+ __experimentalIsIconGroup
53
+ label={ __( 'Decoration' ) }
54
+ value={ value }
55
+ onChange={ onChange }
56
+ >
57
+ { TEXT_DECORATIONS.map( ( textDecoration ) => {
58
+ return (
59
+ <ToggleGroupControlOptionIcon
60
+ key={ textDecoration.value }
61
+ value={ textDecoration.value }
62
+ icon={ textDecoration.icon }
63
+ label={ textDecoration.name }
64
+ />
65
+ );
66
+ } ) }
67
+ </ToggleGroupControl>
57
68
  );
58
69
  }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import TextDecorationControl from '../';
10
+
11
+ export default {
12
+ title: 'BlockEditor/TextDecorationControl',
13
+ component: TextDecorationControl,
14
+ argTypes: {
15
+ onChange: { action: 'onChange' },
16
+ size: {
17
+ options: [ 'default', '__unstable-large' ],
18
+ control: { type: 'radio' },
19
+ },
20
+ },
21
+ };
22
+
23
+ const Template = ( { onChange, ...args } ) => {
24
+ const [ value, setValue ] = useState();
25
+ return (
26
+ <TextDecorationControl
27
+ { ...args }
28
+ onChange={ ( ...changeArgs ) => {
29
+ onChange( ...changeArgs );
30
+ setValue( ...changeArgs );
31
+ } }
32
+ value={ value }
33
+ />
34
+ );
35
+ };
36
+
37
+ export const Default = Template.bind( {} );