@wordpress/block-library 8.6.0 → 8.8.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 (425) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/buttons/index.js +1 -0
  3. package/build/buttons/index.js.map +1 -1
  4. package/build/buttons/transforms.js +1 -0
  5. package/build/buttons/transforms.js.map +1 -1
  6. package/build/column/index.js +2 -1
  7. package/build/column/index.js.map +1 -1
  8. package/build/columns/edit.js +28 -8
  9. package/build/columns/edit.js.map +1 -1
  10. package/build/columns/index.js +6 -1
  11. package/build/columns/index.js.map +1 -1
  12. package/build/columns/utils.js +4 -9
  13. package/build/columns/utils.js.map +1 -1
  14. package/build/cover/edit/index.js +46 -50
  15. package/build/cover/edit/index.js.map +1 -1
  16. package/build/cover/edit/inspector-controls.js +2 -2
  17. package/build/cover/edit/inspector-controls.js.map +1 -1
  18. package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
  19. package/build/cover/edit/resizable-cover-popover.js.map +1 -0
  20. package/build/cover/index.js +12 -0
  21. package/build/cover/index.js.map +1 -1
  22. package/build/details/edit.js +67 -0
  23. package/build/details/edit.js.map +1 -0
  24. package/build/details/index.js +110 -0
  25. package/build/details/index.js.map +1 -0
  26. package/build/details/save.js +33 -0
  27. package/build/details/save.js.map +1 -0
  28. package/build/details-content/edit.js +34 -0
  29. package/build/details-content/edit.js.map +1 -0
  30. package/build/details-content/index.js +94 -0
  31. package/build/details-content/index.js.map +1 -0
  32. package/build/details-content/save.js +20 -0
  33. package/build/details-content/save.js.map +1 -0
  34. package/build/details-summary/edit.js +42 -0
  35. package/build/details-summary/edit.js.map +1 -0
  36. package/build/details-summary/index.js +97 -0
  37. package/build/details-summary/index.js.map +1 -0
  38. package/build/details-summary/save.js +24 -0
  39. package/build/details-summary/save.js.map +1 -0
  40. package/build/embed/deprecated.js +4 -1
  41. package/build/embed/deprecated.js.map +1 -1
  42. package/build/embed/embed-link-settings.native.js +1 -1
  43. package/build/embed/embed-link-settings.native.js.map +1 -1
  44. package/build/embed/embed-placeholder.js +1 -1
  45. package/build/embed/embed-placeholder.js.map +1 -1
  46. package/build/embed/index.js +4 -1
  47. package/build/embed/index.js.map +1 -1
  48. package/build/embed/transforms.js +4 -1
  49. package/build/embed/transforms.js.map +1 -1
  50. package/build/embed/util.js +4 -1
  51. package/build/embed/util.js.map +1 -1
  52. package/build/file/edit.native.js +0 -2
  53. package/build/file/edit.native.js.map +1 -1
  54. package/build/gallery/edit.js +8 -5
  55. package/build/gallery/edit.js.map +1 -1
  56. package/build/gallery/use-get-media.native.js +2 -1
  57. package/build/gallery/use-get-media.native.js.map +1 -1
  58. package/build/gallery/use-image-sizes.js +1 -1
  59. package/build/gallery/use-image-sizes.js.map +1 -1
  60. package/build/group/deprecated.js +4 -2
  61. package/build/group/deprecated.js.map +1 -1
  62. package/build/group/edit.js +22 -5
  63. package/build/group/edit.js.map +1 -1
  64. package/build/group/placeholder.js +11 -1
  65. package/build/group/placeholder.js.map +1 -1
  66. package/build/group/variations.js +23 -3
  67. package/build/group/variations.js.map +1 -1
  68. package/build/image/edit.js +1 -1
  69. package/build/image/edit.js.map +1 -1
  70. package/build/image/edit.native.js +1 -1
  71. package/build/image/edit.native.js.map +1 -1
  72. package/build/image/image.js +8 -6
  73. package/build/image/image.js.map +1 -1
  74. package/build/image/index.js +9 -2
  75. package/build/image/index.js.map +1 -1
  76. package/build/index.js +24 -6
  77. package/build/index.js.map +1 -1
  78. package/build/latest-posts/edit.js +1 -0
  79. package/build/latest-posts/edit.js.map +1 -1
  80. package/build/media-text/deprecated.js +228 -18
  81. package/build/media-text/deprecated.js.map +1 -1
  82. package/build/media-text/edit.js +3 -3
  83. package/build/media-text/edit.js.map +1 -1
  84. package/build/media-text/index.js +1 -1
  85. package/build/media-text/media-container.js +2 -6
  86. package/build/media-text/media-container.js.map +1 -1
  87. package/build/media-text/media-container.native.js +3 -3
  88. package/build/media-text/media-container.native.js.map +1 -1
  89. package/build/navigation/deprecated.js +8 -11
  90. package/build/navigation/deprecated.js.map +1 -1
  91. package/build/navigation/edit/index.js +1 -12
  92. package/build/navigation/edit/index.js.map +1 -1
  93. package/build/navigation/edit/inner-blocks.js +1 -4
  94. package/build/navigation/edit/inner-blocks.js.map +1 -1
  95. package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
  96. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  97. package/build/navigation/index.js +0 -1
  98. package/build/navigation/index.js.map +1 -1
  99. package/build/post-author/index.js +0 -1
  100. package/build/post-author/index.js.map +1 -1
  101. package/build/post-date/edit.js +2 -1
  102. package/build/post-date/edit.js.map +1 -1
  103. package/build/post-date/index.js +4 -1
  104. package/build/post-date/index.js.map +1 -1
  105. package/build/post-date/variations.js +28 -0
  106. package/build/post-date/variations.js.map +1 -0
  107. package/build/post-excerpt/edit.js +39 -10
  108. package/build/post-excerpt/edit.js.map +1 -1
  109. package/build/post-featured-image/dimension-controls.js +4 -3
  110. package/build/post-featured-image/dimension-controls.js.map +1 -1
  111. package/build/post-featured-image/edit.js +8 -22
  112. package/build/post-featured-image/edit.js.map +1 -1
  113. package/build/post-template/index.js +1 -1
  114. package/build/post-time-to-read/edit.js +1 -1
  115. package/build/post-time-to-read/edit.js.map +1 -1
  116. package/build/post-time-to-read/index.js +24 -1
  117. package/build/post-time-to-read/index.js.map +1 -1
  118. package/build/quote/index.js +1 -0
  119. package/build/quote/index.js.map +1 -1
  120. package/build/spacer/controls.js +25 -6
  121. package/build/spacer/controls.js.map +1 -1
  122. package/build/spacer/edit.js +27 -7
  123. package/build/spacer/edit.js.map +1 -1
  124. package/build/spacer/save.js +2 -2
  125. package/build/spacer/save.js.map +1 -1
  126. package/build/table/state.js +35 -35
  127. package/build/table/state.js.map +1 -1
  128. package/build/term-description/index.js +1 -2
  129. package/build/term-description/index.js.map +1 -1
  130. package/build/utils/clean-empty-object.js +5 -2
  131. package/build/utils/clean-empty-object.js.map +1 -1
  132. package/build-module/buttons/index.js +1 -0
  133. package/build-module/buttons/index.js.map +1 -1
  134. package/build-module/buttons/transforms.js +1 -0
  135. package/build-module/buttons/transforms.js.map +1 -1
  136. package/build-module/column/index.js +2 -1
  137. package/build-module/column/index.js.map +1 -1
  138. package/build-module/columns/edit.js +28 -8
  139. package/build-module/columns/edit.js.map +1 -1
  140. package/build-module/columns/index.js +6 -1
  141. package/build-module/columns/index.js.map +1 -1
  142. package/build-module/columns/utils.js +4 -8
  143. package/build-module/columns/utils.js.map +1 -1
  144. package/build-module/cover/edit/index.js +48 -52
  145. package/build-module/cover/edit/index.js.map +1 -1
  146. package/build-module/cover/edit/inspector-controls.js +2 -2
  147. package/build-module/cover/edit/inspector-controls.js.map +1 -1
  148. package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
  149. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
  150. package/build-module/cover/index.js +12 -0
  151. package/build-module/cover/index.js.map +1 -1
  152. package/build-module/details/edit.js +52 -0
  153. package/build-module/details/edit.js.map +1 -0
  154. package/build-module/details/index.js +91 -0
  155. package/build-module/details/index.js.map +1 -0
  156. package/build-module/details/save.js +20 -0
  157. package/build-module/details/save.js.map +1 -0
  158. package/build-module/details-content/edit.js +23 -0
  159. package/build-module/details-content/edit.js.map +1 -0
  160. package/build-module/details-content/index.js +76 -0
  161. package/build-module/details-content/index.js.map +1 -0
  162. package/build-module/details-content/save.js +11 -0
  163. package/build-module/details-content/save.js.map +1 -0
  164. package/build-module/details-summary/edit.js +30 -0
  165. package/build-module/details-summary/edit.js.map +1 -0
  166. package/build-module/details-summary/index.js +79 -0
  167. package/build-module/details-summary/index.js.map +1 -0
  168. package/build-module/details-summary/save.js +16 -0
  169. package/build-module/details-summary/save.js.map +1 -0
  170. package/build-module/embed/deprecated.js +4 -1
  171. package/build-module/embed/deprecated.js.map +1 -1
  172. package/build-module/embed/embed-link-settings.native.js +1 -1
  173. package/build-module/embed/embed-link-settings.native.js.map +1 -1
  174. package/build-module/embed/embed-placeholder.js +1 -1
  175. package/build-module/embed/embed-placeholder.js.map +1 -1
  176. package/build-module/embed/index.js +4 -1
  177. package/build-module/embed/index.js.map +1 -1
  178. package/build-module/embed/transforms.js +4 -1
  179. package/build-module/embed/transforms.js.map +1 -1
  180. package/build-module/embed/util.js +4 -1
  181. package/build-module/embed/util.js.map +1 -1
  182. package/build-module/file/edit.native.js +0 -2
  183. package/build-module/file/edit.native.js.map +1 -1
  184. package/build-module/gallery/edit.js +8 -5
  185. package/build-module/gallery/edit.js.map +1 -1
  186. package/build-module/gallery/use-get-media.native.js +2 -1
  187. package/build-module/gallery/use-get-media.native.js.map +1 -1
  188. package/build-module/gallery/use-image-sizes.js +1 -1
  189. package/build-module/gallery/use-image-sizes.js.map +1 -1
  190. package/build-module/group/deprecated.js +4 -2
  191. package/build-module/group/deprecated.js.map +1 -1
  192. package/build-module/group/edit.js +21 -5
  193. package/build-module/group/edit.js.map +1 -1
  194. package/build-module/group/placeholder.js +11 -1
  195. package/build-module/group/placeholder.js.map +1 -1
  196. package/build-module/group/variations.js +24 -1
  197. package/build-module/group/variations.js.map +1 -1
  198. package/build-module/image/edit.js +1 -1
  199. package/build-module/image/edit.js.map +1 -1
  200. package/build-module/image/edit.native.js +1 -1
  201. package/build-module/image/edit.native.js.map +1 -1
  202. package/build-module/image/image.js +8 -6
  203. package/build-module/image/image.js.map +1 -1
  204. package/build-module/image/index.js +9 -2
  205. package/build-module/image/index.js.map +1 -1
  206. package/build-module/index.js +21 -6
  207. package/build-module/index.js.map +1 -1
  208. package/build-module/latest-posts/edit.js +1 -0
  209. package/build-module/latest-posts/edit.js.map +1 -1
  210. package/build-module/media-text/deprecated.js +227 -18
  211. package/build-module/media-text/deprecated.js.map +1 -1
  212. package/build-module/media-text/edit.js +3 -3
  213. package/build-module/media-text/edit.js.map +1 -1
  214. package/build-module/media-text/index.js +1 -1
  215. package/build-module/media-text/media-container.js +1 -5
  216. package/build-module/media-text/media-container.js.map +1 -1
  217. package/build-module/media-text/media-container.native.js +1 -1
  218. package/build-module/media-text/media-container.native.js.map +1 -1
  219. package/build-module/navigation/deprecated.js +8 -10
  220. package/build-module/navigation/deprecated.js.map +1 -1
  221. package/build-module/navigation/edit/index.js +1 -12
  222. package/build-module/navigation/edit/index.js.map +1 -1
  223. package/build-module/navigation/edit/inner-blocks.js +1 -4
  224. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  225. package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
  226. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  227. package/build-module/navigation/index.js +0 -1
  228. package/build-module/navigation/index.js.map +1 -1
  229. package/build-module/post-author/index.js +0 -1
  230. package/build-module/post-author/index.js.map +1 -1
  231. package/build-module/post-date/edit.js +2 -1
  232. package/build-module/post-date/edit.js.map +1 -1
  233. package/build-module/post-date/index.js +3 -1
  234. package/build-module/post-date/index.js.map +1 -1
  235. package/build-module/post-date/variations.js +18 -0
  236. package/build-module/post-date/variations.js.map +1 -0
  237. package/build-module/post-excerpt/edit.js +38 -11
  238. package/build-module/post-excerpt/edit.js.map +1 -1
  239. package/build-module/post-featured-image/dimension-controls.js +4 -3
  240. package/build-module/post-featured-image/dimension-controls.js.map +1 -1
  241. package/build-module/post-featured-image/edit.js +8 -22
  242. package/build-module/post-featured-image/edit.js.map +1 -1
  243. package/build-module/post-template/index.js +1 -1
  244. package/build-module/post-time-to-read/edit.js +1 -1
  245. package/build-module/post-time-to-read/edit.js.map +1 -1
  246. package/build-module/post-time-to-read/index.js +24 -1
  247. package/build-module/post-time-to-read/index.js.map +1 -1
  248. package/build-module/quote/index.js +1 -0
  249. package/build-module/quote/index.js.map +1 -1
  250. package/build-module/spacer/controls.js +27 -9
  251. package/build-module/spacer/controls.js.map +1 -1
  252. package/build-module/spacer/edit.js +27 -8
  253. package/build-module/spacer/edit.js.map +1 -1
  254. package/build-module/spacer/save.js +3 -3
  255. package/build-module/spacer/save.js.map +1 -1
  256. package/build-module/table/state.js +35 -33
  257. package/build-module/table/state.js.map +1 -1
  258. package/build-module/term-description/index.js +1 -2
  259. package/build-module/term-description/index.js.map +1 -1
  260. package/build-module/utils/clean-empty-object.js +6 -3
  261. package/build-module/utils/clean-empty-object.js.map +1 -1
  262. package/build-style/categories/editor-rtl.css +5 -0
  263. package/build-style/categories/editor.css +5 -0
  264. package/build-style/categories/style-rtl.css +4 -0
  265. package/build-style/categories/style.css +4 -0
  266. package/build-style/columns/style-rtl.css +4 -1
  267. package/build-style/columns/style.css +4 -1
  268. package/build-style/common-rtl.css +1 -1
  269. package/build-style/common.css +1 -1
  270. package/build-style/cover/editor-rtl.css +11 -12
  271. package/build-style/cover/editor.css +11 -12
  272. package/build-style/cover/style-rtl.css +3 -2
  273. package/build-style/cover/style.css +3 -2
  274. package/build-style/details/style-rtl.css +91 -0
  275. package/build-style/details/style.css +91 -0
  276. package/build-style/details-summary/editor-rtl.css +91 -0
  277. package/build-style/details-summary/editor.css +91 -0
  278. package/build-style/details-summary/style-rtl.css +91 -0
  279. package/build-style/details-summary/style.css +91 -0
  280. package/build-style/editor-rtl.css +40 -48
  281. package/build-style/editor.css +40 -48
  282. package/build-style/file/style-rtl.css +4 -3
  283. package/build-style/file/style.css +4 -3
  284. package/build-style/navigation/style-rtl.css +2 -0
  285. package/build-style/navigation/style.css +2 -0
  286. package/build-style/post-excerpt/style-rtl.css +1 -1
  287. package/build-style/post-excerpt/style.css +1 -1
  288. package/build-style/post-featured-image/editor-rtl.css +1 -0
  289. package/build-style/post-featured-image/editor.css +1 -0
  290. package/build-style/post-template/style-rtl.css +1 -1
  291. package/build-style/post-template/style.css +1 -1
  292. package/build-style/post-time-to-read/style-rtl.css +91 -0
  293. package/build-style/post-time-to-read/style.css +91 -0
  294. package/build-style/pullquote/style-rtl.css +4 -1
  295. package/build-style/pullquote/style.css +4 -1
  296. package/build-style/search/style-rtl.css +8 -7
  297. package/build-style/search/style.css +8 -7
  298. package/build-style/shortcode/editor-rtl.css +15 -34
  299. package/build-style/shortcode/editor.css +15 -34
  300. package/build-style/spacer/editor-rtl.css +4 -2
  301. package/build-style/spacer/editor.css +4 -2
  302. package/build-style/style-rtl.css +44 -17
  303. package/build-style/style.css +44 -17
  304. package/package.json +31 -31
  305. package/src/buttons/block.json +1 -0
  306. package/src/categories/editor.scss +5 -0
  307. package/src/categories/style.scss +4 -0
  308. package/src/column/block.json +2 -1
  309. package/src/columns/block.json +6 -1
  310. package/src/columns/edit.js +35 -10
  311. package/src/columns/style.scss +5 -1
  312. package/src/columns/utils.js +8 -9
  313. package/src/comments/index.php +1 -0
  314. package/src/common.scss +1 -1
  315. package/src/cover/block.json +12 -0
  316. package/src/cover/edit/index.js +44 -37
  317. package/src/cover/edit/inspector-controls.js +4 -5
  318. package/src/cover/edit/resizable-cover-popover.js +82 -0
  319. package/src/cover/editor.scss +20 -13
  320. package/src/cover/index.php +9 -10
  321. package/src/cover/style.scss +2 -1
  322. package/src/cover/test/__snapshots__/transforms.native.js.snap +2 -2
  323. package/src/cover/test/edit.js +324 -0
  324. package/src/details/block.json +54 -0
  325. package/src/details/edit.js +59 -0
  326. package/src/details/index.js +35 -0
  327. package/src/details/save.js +15 -0
  328. package/src/details/style.scss +3 -0
  329. package/src/details-content/block.json +50 -0
  330. package/src/details-content/edit.js +29 -0
  331. package/src/details-content/index.js +23 -0
  332. package/src/details-content/save.js +12 -0
  333. package/src/details-summary/block.json +53 -0
  334. package/src/details-summary/edit.js +27 -0
  335. package/src/details-summary/editor.scss +3 -0
  336. package/src/details-summary/index.js +23 -0
  337. package/src/details-summary/save.js +13 -0
  338. package/src/details-summary/style.scss +3 -0
  339. package/src/editor.scss +1 -0
  340. package/src/embed/block.json +4 -1
  341. package/src/embed/embed-link-settings.native.js +1 -1
  342. package/src/embed/embed-placeholder.js +1 -1
  343. package/src/file/edit.native.js +0 -2
  344. package/src/file/style.scss +5 -2
  345. package/src/gallery/edit.js +5 -2
  346. package/src/gallery/test/use-get-media.native.js +24 -0
  347. package/src/gallery/use-get-media.native.js +1 -1
  348. package/src/gallery/use-image-sizes.js +1 -1
  349. package/src/group/deprecated.js +4 -2
  350. package/src/group/edit.js +27 -9
  351. package/src/group/placeholder.js +13 -1
  352. package/src/group/variations.js +14 -1
  353. package/src/home-link/index.php +2 -2
  354. package/src/image/block.json +9 -2
  355. package/src/image/edit.js +1 -1
  356. package/src/image/edit.native.js +1 -1
  357. package/src/image/image.js +15 -7
  358. package/src/image/index.php +7 -2
  359. package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
  360. package/src/index.js +13 -3
  361. package/src/latest-comments/style.scss +1 -1
  362. package/src/latest-posts/edit.js +3 -0
  363. package/src/media-text/block.json +1 -1
  364. package/src/media-text/deprecated.js +235 -3
  365. package/src/media-text/edit.js +7 -6
  366. package/src/media-text/media-container.js +1 -5
  367. package/src/media-text/media-container.native.js +1 -1
  368. package/src/media-text/test/__snapshots__/transforms.native.js.snap +4 -4
  369. package/src/navigation/block.json +0 -1
  370. package/src/navigation/deprecated.js +15 -19
  371. package/src/navigation/edit/index.js +0 -13
  372. package/src/navigation/edit/inner-blocks.js +0 -3
  373. package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
  374. package/src/navigation/index.php +0 -4
  375. package/src/navigation/style.scss +6 -4
  376. package/src/navigation-link/index.php +2 -1
  377. package/src/navigation-submenu/index.php +30 -76
  378. package/src/paragraph/test/edit.native.js +356 -1
  379. package/src/post-author/block.json +0 -1
  380. package/src/post-author/index.php +1 -1
  381. package/src/post-date/edit.js +4 -1
  382. package/src/post-date/index.js +2 -0
  383. package/src/post-date/variations.js +20 -0
  384. package/src/post-excerpt/edit.js +48 -16
  385. package/src/post-excerpt/index.php +3 -3
  386. package/src/post-excerpt/style.scss +2 -1
  387. package/src/post-featured-image/dimension-controls.js +7 -3
  388. package/src/post-featured-image/edit.js +8 -29
  389. package/src/post-featured-image/editor.scss +1 -0
  390. package/src/post-template/block.json +1 -1
  391. package/src/post-template/style.scss +1 -1
  392. package/src/post-time-to-read/block.json +24 -1
  393. package/src/post-time-to-read/edit.js +1 -1
  394. package/src/post-time-to-read/index.php +3 -3
  395. package/src/post-time-to-read/style.scss +4 -0
  396. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
  397. package/src/preformatted/test/edit.native.js +45 -2
  398. package/src/pullquote/style.scss +5 -1
  399. package/src/pullquote/test/edit.native.js +70 -0
  400. package/src/query-title/index.php +2 -5
  401. package/src/quote/block.json +1 -0
  402. package/src/quote/test/edit.native.js +92 -0
  403. package/src/search/index.php +1 -1
  404. package/src/search/style.scss +16 -12
  405. package/src/shortcode/editor.scss +26 -5
  406. package/src/spacer/controls.js +42 -17
  407. package/src/spacer/edit.js +41 -9
  408. package/src/spacer/editor.scss +2 -1
  409. package/src/spacer/save.js +3 -3
  410. package/src/style.scss +3 -0
  411. package/src/table/state.js +83 -66
  412. package/src/term-description/block.json +1 -2
  413. package/src/utils/clean-empty-object.js +4 -4
  414. package/src/verse/test/edit.native.js +33 -0
  415. package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
  416. package/tsconfig.tsbuildinfo +1 -1
  417. package/build/cover/edit/resizable-cover.js.map +0 -1
  418. package/build/media-text/media-container-icon.js +0 -27
  419. package/build/media-text/media-container-icon.js.map +0 -1
  420. package/build-module/cover/edit/resizable-cover.js.map +0 -1
  421. package/build-module/media-text/media-container-icon.js +0 -17
  422. package/build-module/media-text/media-container-icon.js.map +0 -1
  423. package/src/cover/edit/resizable-cover.js +0 -61
  424. package/src/cover/test/block-controls.js +0 -62
  425. package/src/media-text/media-container-icon.js +0 -12
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["__","InspectorControls","useSetting","PanelBody","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","useInstanceId","MIN_SPACER_SIZE","DimensionInput","label","onChange","isResizing","value","inputId","availableUnitSettings","undefined","filter","availableUnit","units","availableUnits","defaultValues","px","em","rem","vw","vh","handleOnChange","unprocessedValue","parsedQuantity","parsedUnit","computedValue","join","SpacerControls","setAttributes","orientation","height","width","nextWidth","nextHeight"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,iBAAT,EAA4BC,UAA5B,QAA8C,yBAA9C;AACA,SACCC,SADD,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,yBAAyB,IAAIC,WAH9B,EAICC,8CAA8C,IAAIC,gCAJnD,QAKO,uBALP;AAMA,SAASC,aAAT,QAA8B,oBAA9B;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,aAAhC;;AAEA,SAASC,cAAT,OAAuE;AAAA;;AAAA,MAA9C;AAAEC,IAAAA,KAAF;AAASC,IAAAA,QAAT;AAAmBC,IAAAA,UAAnB;AAA+BC,IAAAA,KAAK,GAAG;AAAvC,GAA8C;AACtE,QAAMC,OAAO,GAAGP,aAAa,CAAEH,WAAF,EAAe,2BAAf,CAA7B,CADsE,CAGtE;AACA;AACA;;AACA,QAAMW,qBAAqB,YAC1BhB,UAAU,CAAE,eAAF,CAAV,IAAiCiB,SADP,0CAAG,MAE3BC,MAF2B,CAEjBC,aAAF,IAAqBA,aAAa,KAAK,GAFpB,CAA9B;AAIA,QAAMC,KAAK,GAAGjB,cAAc,CAAE;AAC7BkB,IAAAA,cAAc,EAAEL,qBAAqB,IAAI,CACxC,IADwC,EAExC,IAFwC,EAGxC,KAHwC,EAIxC,IAJwC,EAKxC,IALwC,CADZ;AAQ7BM,IAAAA,aAAa,EAAE;AAAEC,MAAAA,EAAE,EAAE,GAAN;AAAWC,MAAAA,EAAE,EAAE,EAAf;AAAmBC,MAAAA,GAAG,EAAE,EAAxB;AAA4BC,MAAAA,EAAE,EAAE,EAAhC;AAAoCC,MAAAA,EAAE,EAAE;AAAxC;AARc,GAAF,CAA5B;;AAWA,QAAMC,cAAc,GAAKC,gBA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Aa,CAAE;AAAEE,MAAAA,MAAM,EAAEG;AAAV,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG3B;AANd,IAZF,CADD,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls, useSetting } from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { MIN_SPACER_SIZE } from './constants';\n\nfunction DimensionInput( { label, onChange, isResizing, value = '' } ) {\n\tconst inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );\n\n\t// In most contexts the spacer size cannot meaningfully be set to a\n\t// percentage, since this is relative to the parent container. This\n\t// unit is disabled from the UI.\n\tconst availableUnitSettings = (\n\t\tuseSetting( 'spacing.units' ) || undefined\n\t)?.filter( ( availableUnit ) => availableUnit !== '%' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnitSettings || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 100, em: 10, rem: 10, vw: 10, vh: 25 },\n\t} );\n\n\tconst handleOnChange = ( unprocessedValue ) => {\n\t\tonChange( unprocessedValue );\n\t};\n\n\t// Force the unit to update to `px` when the Spacer is being resized.\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( value );\n\tconst computedValue = [\n\t\tparsedQuantity,\n\t\tisResizing ? 'px' : parsedUnit,\n\t].join( '' );\n\n\treturn (\n\t\t<UnitControl\n\t\t\tlabel={ label }\n\t\t\tid={ inputId }\n\t\t\tisResetValueOnUnitChange\n\t\t\tmin={ MIN_SPACER_SIZE }\n\t\t\tonChange={ handleOnChange }\n\t\t\t__unstableInputWidth={ '80px' }\n\t\t\tvalue={ computedValue }\n\t\t\tunits={ units }\n\t\t/>\n\t);\n}\n\nexport default function SpacerControls( {\n\tsetAttributes,\n\torientation,\n\theight,\n\twidth,\n\tisResizing,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t{ orientation === 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: nextWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ orientation !== 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\t\tvalue={ height }\n\t\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\t\tsetAttributes( { height: nextHeight } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/spacer/controls.js"],"names":["__","InspectorControls","useSetting","__experimentalSpacingSizesControl","SpacingSizesControl","isValueSpacingPreset","BaseControl","PanelBody","__experimentalUseCustomUnits","useCustomUnits","__experimentalUnitControl","UnitControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","useInstanceId","View","MIN_SPACER_SIZE","DimensionInput","label","onChange","isResizing","value","inputId","spacingSizes","availableUnitSettings","undefined","filter","availableUnit","units","availableUnits","defaultValues","px","em","rem","vw","vh","handleOnChange","unprocessedValue","all","parsedQuantity","parsedUnit","computedValue","join","length","maxWidth","SpacerControls","setAttributes","orientation","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KANd;AAOC,IAAA,WAAW,EAAG;AAPf,IADD,CAhBF,CADD;AA+BA;;AAED,eAAe,SAASiB,cAAT,QAMX;AAAA,MANoC;AACvCC,IAAAA,aADuC;AAEvCC,IAAAA,WAFuC;AAGvCC,IAAAA,MAHuC;AAIvCC,IAAAA,KAJuC;AAKvC7B,IAAAA;AALuC,GAMpC;AACH,SACC,cAAC,iBAAD,QACC,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGpB,EAAE,CAAE,UAAF;AAArB,KACG+C,WAAW,KAAK,YAAhB,IACD,cAAC,cAAD;AACC,IAAA,KAAK,EAAG/C,EAAE,CAAE,OAAF,CADX;AAEC,IAAA,KAAK,EAAGiD,KAFT;AAGC,IAAA,QAAQ,EAAKC,SAAF,IACVJ,aAAa,CAAE;AAAEG,MAAAA,KAAK,EAAEC;AAAT,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG9B;AANd,IAFF,EAWG2B,WAAW,KAAK,YAAhB,IACD,cAAC,cAAD;AACC,IAAA,KAAK,EAAG/C,EAAE,CAAE,QAAF,CADX;AAEC,IAAA,KAAK,EAAGgD,MAFT;AAGC,IAAA,QAAQ,EAAKG,UAAF,IACVL,aAAa,CAAE;AAAEE,MAAAA,MAAM,EAAEG;AAAV,KAAF,CAJf;AAMC,IAAA,UAAU,EAAG/B;AANd,IAZF,CADD,CADD;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tInspectorControls,\n\tuseSetting,\n\t__experimentalSpacingSizesControl as SpacingSizesControl,\n\tisValueSpacingPreset,\n} from '@wordpress/block-editor';\nimport {\n\tBaseControl,\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport { MIN_SPACER_SIZE } from './constants';\n\nfunction DimensionInput( { label, onChange, isResizing, value = '' } ) {\n\tconst inputId = useInstanceId( UnitControl, 'block-spacer-height-input' );\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\t// In most contexts the spacer size cannot meaningfully be set to a\n\t// percentage, since this is relative to the parent container. This\n\t// unit is disabled from the UI.\n\tconst availableUnitSettings = (\n\t\tuseSetting( 'spacing.units' ) || undefined\n\t)?.filter( ( availableUnit ) => availableUnit !== '%' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: availableUnitSettings || [\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t\t'vh',\n\t\t],\n\t\tdefaultValues: { px: 100, em: 10, rem: 10, vw: 10, vh: 25 },\n\t} );\n\n\tconst handleOnChange = ( unprocessedValue ) => {\n\t\tonChange( unprocessedValue.all );\n\t};\n\n\t// Force the unit to update to `px` when the Spacer is being resized.\n\tconst [ parsedQuantity, parsedUnit ] =\n\t\tparseQuantityAndUnitFromRawValue( value );\n\tconst computedValue = isValueSpacingPreset( value )\n\t\t? value\n\t\t: [ parsedQuantity, isResizing ? 'px' : parsedUnit ].join( '' );\n\n\treturn (\n\t\t<>\n\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) && (\n\t\t\t\t<BaseControl label={ label } id={ inputId }>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tid={ inputId }\n\t\t\t\t\t\tisResetValueOnUnitChange\n\t\t\t\t\t\tmin={ MIN_SPACER_SIZE }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tstyle={ { maxWidth: 80 } }\n\t\t\t\t\t\tvalue={ computedValue }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t/>\n\t\t\t\t</BaseControl>\n\t\t\t) }\n\n\t\t\t{ spacingSizes?.length > 0 && (\n\t\t\t\t<View className=\"tools-panel-item-spacing\">\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ { all: computedValue } }\n\t\t\t\t\t\tonChange={ handleOnChange }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tsides={ [ 'all' ] }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ false }\n\t\t\t\t\t/>\n\t\t\t\t</View>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default function SpacerControls( {\n\tsetAttributes,\n\torientation,\n\theight,\n\twidth,\n\tisResizing,\n} ) {\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t{ orientation === 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\tvalue={ width }\n\t\t\t\t\t\tonChange={ ( nextWidth ) =>\n\t\t\t\t\t\t\tsetAttributes( { width: nextWidth } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ orientation !== 'horizontal' && (\n\t\t\t\t\t<DimensionInput\n\t\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\t\tvalue={ height }\n\t\t\t\t\t\tonChange={ ( nextHeight ) =>\n\t\t\t\t\t\t\tsetAttributes( { height: nextHeight } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n"]}
@@ -9,10 +9,11 @@ import classnames from 'classnames';
9
9
  * WordPress dependencies
10
10
  */
11
11
 
12
- import { useBlockProps } from '@wordpress/block-editor';
12
+ import { useBlockProps, getSpacingPresetCssVar, store as blockEditorStore } from '@wordpress/block-editor';
13
13
  import { ResizableBox } from '@wordpress/components';
14
14
  import { useState, useEffect } from '@wordpress/element';
15
15
  import { View } from '@wordpress/primitives';
16
+ import { useSelect } from '@wordpress/data';
16
17
  /**
17
18
  * Internal dependencies
18
19
  */
@@ -79,11 +80,24 @@ const SpacerEdit = _ref2 => {
79
80
  isSelected,
80
81
  setAttributes,
81
82
  toggleSelection,
82
- context
83
+ context,
84
+ __unstableParentLayout: parentLayout,
85
+ className
83
86
  } = _ref2;
87
+ const disableCustomSpacingSizes = useSelect(select => {
88
+ const editorSettings = select(blockEditorStore).getSettings();
89
+ return editorSettings === null || editorSettings === void 0 ? void 0 : editorSettings.disableCustomSpacingSizes;
90
+ });
84
91
  const {
85
92
  orientation
86
93
  } = context;
94
+ const {
95
+ orientation: parentOrientation,
96
+ type
97
+ } = parentLayout || {}; // If the spacer is inside a flex container, it should either inherit the orientation
98
+ // of the parent or use the flex default orientation.
99
+
100
+ const inheritedOrientation = !parentOrientation && type === 'flex' ? 'horizontal' : parentOrientation || orientation;
87
101
  const {
88
102
  height,
89
103
  width
@@ -113,8 +127,10 @@ const SpacerEdit = _ref2 => {
113
127
  };
114
128
 
115
129
  const style = {
116
- height: orientation === 'horizontal' ? 24 : temporaryHeight || height || undefined,
117
- width: orientation === 'horizontal' ? temporaryWidth || width || undefined : undefined
130
+ height: inheritedOrientation === 'horizontal' ? 24 : temporaryHeight || getSpacingPresetCssVar(height) || undefined,
131
+ width: inheritedOrientation === 'horizontal' ? temporaryWidth || getSpacingPresetCssVar(width) || undefined : undefined,
132
+ // In vertical flex containers, the spacer shrinks to nothing without a minimum width.
133
+ minWidth: inheritedOrientation === 'vertical' && type === 'flex' ? 48 : undefined
118
134
  };
119
135
 
120
136
  const resizableBoxWithOrientation = blockOrientation => {
@@ -164,7 +180,7 @@ const SpacerEdit = _ref2 => {
164
180
  };
165
181
 
166
182
  useEffect(() => {
167
- if (orientation === 'horizontal' && !width) {
183
+ if (inheritedOrientation === 'horizontal' && !width) {
168
184
  setAttributes({
169
185
  height: '0px',
170
186
  width: '72px'
@@ -172,12 +188,15 @@ const SpacerEdit = _ref2 => {
172
188
  }
173
189
  }, []);
174
190
  return createElement(Fragment, null, createElement(View, useBlockProps({
175
- style
176
- }), resizableBoxWithOrientation(orientation)), createElement(SpacerControls, {
191
+ style,
192
+ className: classnames(className, {
193
+ 'custom-sizes-disabled': disableCustomSpacingSizes
194
+ })
195
+ }), resizableBoxWithOrientation(inheritedOrientation)), createElement(SpacerControls, {
177
196
  setAttributes: setAttributes,
178
197
  height: temporaryHeight || height,
179
198
  width: temporaryWidth || width,
180
- orientation: orientation,
199
+ orientation: inheritedOrientation,
181
200
  isResizing: isResizing
182
201
  }));
183
202
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["classnames","useBlockProps","ResizableBox","useState","useEffect","View","SpacerControls","MIN_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","axis","position","isVisible","SpacerEdit","attributes","setAttributes","toggleSelection","context","height","width","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","style","undefined","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,IAAT,QAAqB,uBAArB;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,YAA3B;AACA,SAASC,eAAT,QAAgC,aAAhC;;AAEA,MAAMC,eAAe,GAAG,QASjB;AAAA,MATmB;AACzBC,IAAAA,WADyB;AAEzBC,IAAAA,aAFyB;AAGzBC,IAAAA,QAHyB;AAIzBC,IAAAA,YAJ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AAQRC,QAAAA,OAAO,EAAE;AARD,OAFV;AAYC,MAAA,WAAW,EAAGR,gBAZf;AAaC,MAAA,aAAa,EAAGpC,aAbjB;AAcC,MAAA,QAAQ,EAAG0B,kBAdZ;AAeC,MAAA,YAAY,EAAGG,0BAfhB;AAgBC,MAAA,UAAU,EAAG1B,UAhBd;AAiBC,MAAA,UAAU,EAAGC,UAjBd;AAkBC,MAAA,aAAa,EAAGC;AAlBjB,MADD,CADD;AAwBA,GAlDD;;AAoDAX,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKK,WAAW,KAAK,YAAhB,IAAgC,CAAEyB,KAAvC,EAA+C;AAC9CJ,MAAAA,aAAa,CAAE;AACdG,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE;AAFO,OAAF,CAAb;AAIA;AACD,GAPQ,EAON,EAPM,CAAT;AASA,SACC,8BACC,cAAC,IAAD,EAAWjC,aAAa,CAAE;AAAE0C,IAAAA;AAAF,GAAF,CAAxB,EACGE,2BAA2B,CAAEpC,WAAF,CAD9B,CADD,EAIC,cAAC,cAAD;AACC,IAAA,aAAa,EAAGqB,aADjB;AAEC,IAAA,MAAM,EAAGK,eAAe,IAAIF,MAF7B;AAGC,IAAA,KAAK,EAAGI,cAAc,IAAIH,KAH3B;AAIC,IAAA,WAAW,EAAGzB,WAJf;AAKC,IAAA,UAAU,EAAGK;AALd,IAJD,CADD;AAcA,CApHD;;AAsHA,eAAec,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\nimport { MIN_SPACER_SIZE } from './constants';\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getCurrentSize( elt );\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\ttoggleSelection,\n\tcontext,\n} ) => {\n\tconst { orientation } = context;\n\tconst { height, width } = attributes;\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst onResizeStart = () => toggleSelection( false );\n\tconst onResizeStop = () => toggleSelection( true );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst style = {\n\t\theight:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: temporaryHeight || height || undefined,\n\t\twidth:\n\t\t\torientation === 'horizontal'\n\t\t\t\t? temporaryWidth || width || undefined\n\t\t\t\t: undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminHeight={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( orientation === 'horizontal' && ! width ) {\n\t\t\tsetAttributes( {\n\t\t\t\theight: '0px',\n\t\t\t\twidth: '72px',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View { ...useBlockProps( { style } ) }>\n\t\t\t\t{ resizableBoxWithOrientation( orientation ) }\n\t\t\t</View>\n\t\t\t<SpacerControls\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\torientation={ orientation }\n\t\t\t\tisResizing={ isResizing }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default SpacerEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/spacer/edit.js"],"names":["classnames","useBlockProps","getSpacingPresetCssVar","store","blockEditorStore","ResizableBox","useState","useEffect","View","useSelect","SpacerControls","MIN_SPACER_SIZE","ResizableSpacer","orientation","onResizeStart","onResize","onResizeStop","isSelected","isResizing","setIsResizing","props","getCurrentSize","elt","clientWidth","clientHeight","getNextVal","_event","_direction","nextVal","axis","position","isVisible","SpacerEdit","attributes","setAttributes","toggleSelection","context","__unstableParentLayout","parentLayout","className","disableCustomSpacingSizes","select","editorSettings","getSettings","parentOrientation","type","inheritedOrientation","height","width","temporaryHeight","setTemporaryHeight","temporaryWidth","setTemporaryWidth","handleOnVerticalResizeStop","newHeight","handleOnHorizontalResizeStop","newWidth","style","undefined","minWidth","resizableBoxWithOrientation","blockOrientation","top","right","bottom","left","topRight","bottomRight","bottomLeft","topLeft"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,sBAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,YAA3B;AACA,SAASC,eAAT,QAAgC,aAAhC;;AAEA,MAAMC,eAAe,GAAG,QASjB;AAAA,MATmB;AACzBC,IAAAA,WADyB;AAEzBC,IAAAA,aAFyB;AAGzBC,IAAAA,QAHyB;AAIzBC,IAAAA,YAJyB;AAKzBC,IAAAA,UALyB;AAMzBC,IAAAA,UANyB;AAOzBC,IAAAA,aAPyB;AAQzB,OAAGC;AARsB,GASnB;;AACN,QAAMC,cAAc,GAAKC,GAAF,IAAW;AACjC,WAAOT,WAAW,KAAK,YAAhB,GACJS,GAAG,CAACC,WADA,GAEJD,GAAG,CAACE,YAFP;AAGA,GAJD;;AAMA,QAAMC,UAAU,GAAKH,GAAF,IAAW;AAC7B,WAAQ,GAAGD,cAAc,CAAEC,GAAF,CAAS,IAAlC;AACA,GAFD;;AAIA,SACC,cAAC,YAAD;AACC,IAAA,SAAS,EAAGtB,UAAU,CAAE,wCAAF,EAA4C;AACjE,2BAAqBa,WAAW,KAAK,YAD4B;AAEjE,qBAAeK,UAFkD;AAGjE,qBAAeD;AAHkD,KAA5C,CADvB;AAMC,IAAA,aAAa,EAA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RC,QAAAA,IAAI,EAAE,KAJE;AAKRC,QAAAA,QAAQ,EAAE,KALF;AAMRC,QAAAA,WAAW,EAAE,KANL;AAORC,QAAAA,UAAU,EAAE,KAPJ;AAQRC,QAAAA,OAAO,EAAE;AARD,OAFV;AAYC,MAAA,WAAW,EAAGR,gBAZf;AAaC,MAAA,aAAa,EAAG/C,aAbjB;AAcC,MAAA,QAAQ,EAAGoC,kBAdZ;AAeC,MAAA,YAAY,EAAGG,0BAfhB;AAgBC,MAAA,UAAU,EAAGpC,UAhBd;AAiBC,MAAA,UAAU,EAAGC,UAjBd;AAkBC,MAAA,aAAa,EAAGC;AAlBjB,MADD,CADD;AAwBA,GAlDD;;AAoDAZ,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKuC,oBAAoB,KAAK,YAAzB,IAAyC,CAAEE,KAAhD,EAAwD;AACvDd,MAAAA,aAAa,CAAE;AACda,QAAAA,MAAM,EAAE,KADM;AAEdC,QAAAA,KAAK,EAAE;AAFO,OAAF,CAAb;AAIA;AACD,GAPQ,EAON,EAPM,CAAT;AASA,SACC,8BACC,cAAC,IAAD,EACM/C,aAAa,CAAE;AACnBwD,IAAAA,KADmB;AAEnBlB,IAAAA,SAAS,EAAEvC,UAAU,CAAEuC,SAAF,EAAa;AACjC,+BAAyBC;AADQ,KAAb;AAFF,GAAF,CADnB,EAQGoB,2BAA2B,CAAEd,oBAAF,CAR9B,CADD,EAWC,cAAC,cAAD;AACC,IAAA,aAAa,EAAGZ,aADjB;AAEC,IAAA,MAAM,EAAGe,eAAe,IAAIF,MAF7B;AAGC,IAAA,KAAK,EAAGI,cAAc,IAAIH,KAH3B;AAIC,IAAA,WAAW,EAAGF,oBAJf;AAKC,IAAA,UAAU,EAAG5B;AALd,IAXD,CADD;AAqBA,CA/ID;;AAiJA,eAAec,UAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseBlockProps,\n\tgetSpacingPresetCssVar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport { View } from '@wordpress/primitives';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport SpacerControls from './controls';\nimport { MIN_SPACER_SIZE } from './constants';\n\nconst ResizableSpacer = ( {\n\torientation,\n\tonResizeStart,\n\tonResize,\n\tonResizeStop,\n\tisSelected,\n\tisResizing,\n\tsetIsResizing,\n\t...props\n} ) => {\n\tconst getCurrentSize = ( elt ) => {\n\t\treturn orientation === 'horizontal'\n\t\t\t? elt.clientWidth\n\t\t\t: elt.clientHeight;\n\t};\n\n\tconst getNextVal = ( elt ) => {\n\t\treturn `${ getCurrentSize( elt ) }px`;\n\t};\n\n\treturn (\n\t\t<ResizableBox\n\t\t\tclassName={ classnames( 'block-library-spacer__resize-container', {\n\t\t\t\t'resize-horizontal': orientation === 'horizontal',\n\t\t\t\t'is-resizing': isResizing,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t} ) }\n\t\t\tonResizeStart={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getNextVal( elt );\n\t\t\t\tonResizeStart( nextVal );\n\t\t\t\tonResize( nextVal );\n\t\t\t} }\n\t\t\tonResize={ ( _event, _direction, elt ) => {\n\t\t\t\tonResize( getNextVal( elt ) );\n\t\t\t\tif ( ! isResizing ) {\n\t\t\t\t\tsetIsResizing( true );\n\t\t\t\t}\n\t\t\t} }\n\t\t\tonResizeStop={ ( _event, _direction, elt ) => {\n\t\t\t\tconst nextVal = getCurrentSize( elt );\n\t\t\t\tonResizeStop( `${ nextVal }px` );\n\t\t\t\tsetIsResizing( false );\n\t\t\t} }\n\t\t\t__experimentalShowTooltip={ true }\n\t\t\t__experimentalTooltipProps={ {\n\t\t\t\taxis: orientation === 'horizontal' ? 'x' : 'y',\n\t\t\t\tposition: 'corner',\n\t\t\t\tisVisible: isResizing,\n\t\t\t} }\n\t\t\tshowHandle={ isSelected }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n};\n\nconst SpacerEdit = ( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\ttoggleSelection,\n\tcontext,\n\t__unstableParentLayout: parentLayout,\n\tclassName,\n} ) => {\n\tconst disableCustomSpacingSizes = useSelect( ( select ) => {\n\t\tconst editorSettings = select( blockEditorStore ).getSettings();\n\t\treturn editorSettings?.disableCustomSpacingSizes;\n\t} );\n\tconst { orientation } = context;\n\tconst { orientation: parentOrientation, type } = parentLayout || {};\n\t// If the spacer is inside a flex container, it should either inherit the orientation\n\t// of the parent or use the flex default orientation.\n\tconst inheritedOrientation =\n\t\t! parentOrientation && type === 'flex'\n\t\t\t? 'horizontal'\n\t\t\t: parentOrientation || orientation;\n\tconst { height, width } = attributes;\n\n\tconst [ isResizing, setIsResizing ] = useState( false );\n\tconst [ temporaryHeight, setTemporaryHeight ] = useState( null );\n\tconst [ temporaryWidth, setTemporaryWidth ] = useState( null );\n\n\tconst onResizeStart = () => toggleSelection( false );\n\tconst onResizeStop = () => toggleSelection( true );\n\n\tconst handleOnVerticalResizeStop = ( newHeight ) => {\n\t\tonResizeStop();\n\n\t\tsetAttributes( { height: newHeight } );\n\t\tsetTemporaryHeight( null );\n\t};\n\n\tconst handleOnHorizontalResizeStop = ( newWidth ) => {\n\t\tonResizeStop();\n\t\tsetAttributes( { width: newWidth } );\n\t\tsetTemporaryWidth( null );\n\t};\n\n\tconst style = {\n\t\theight:\n\t\t\tinheritedOrientation === 'horizontal'\n\t\t\t\t? 24\n\t\t\t\t: temporaryHeight ||\n\t\t\t\t getSpacingPresetCssVar( height ) ||\n\t\t\t\t undefined,\n\t\twidth:\n\t\t\tinheritedOrientation === 'horizontal'\n\t\t\t\t? temporaryWidth || getSpacingPresetCssVar( width ) || undefined\n\t\t\t\t: undefined,\n\t\t// In vertical flex containers, the spacer shrinks to nothing without a minimum width.\n\t\tminWidth:\n\t\t\tinheritedOrientation === 'vertical' && type === 'flex'\n\t\t\t\t? 48\n\t\t\t\t: undefined,\n\t};\n\n\tconst resizableBoxWithOrientation = ( blockOrientation ) => {\n\t\tif ( blockOrientation === 'horizontal' ) {\n\t\t\treturn (\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminWidth={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: true,\n\t\t\t\t\t\tbottom: false,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryWidth }\n\t\t\t\t\tonResizeStop={ handleOnHorizontalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ResizableSpacer\n\t\t\t\t\tminHeight={ MIN_SPACER_SIZE }\n\t\t\t\t\tenable={ {\n\t\t\t\t\t\ttop: false,\n\t\t\t\t\t\tright: false,\n\t\t\t\t\t\tbottom: true,\n\t\t\t\t\t\tleft: false,\n\t\t\t\t\t\ttopRight: false,\n\t\t\t\t\t\tbottomRight: false,\n\t\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\t\ttopLeft: false,\n\t\t\t\t\t} }\n\t\t\t\t\torientation={ blockOrientation }\n\t\t\t\t\tonResizeStart={ onResizeStart }\n\t\t\t\t\tonResize={ setTemporaryHeight }\n\t\t\t\t\tonResizeStop={ handleOnVerticalResizeStop }\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\tisResizing={ isResizing }\n\t\t\t\t\tsetIsResizing={ setIsResizing }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( inheritedOrientation === 'horizontal' && ! width ) {\n\t\t\tsetAttributes( {\n\t\t\t\theight: '0px',\n\t\t\t\twidth: '72px',\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<View\n\t\t\t\t{ ...useBlockProps( {\n\t\t\t\t\tstyle,\n\t\t\t\t\tclassName: classnames( className, {\n\t\t\t\t\t\t'custom-sizes-disabled': disableCustomSpacingSizes,\n\t\t\t\t\t} ),\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ resizableBoxWithOrientation( inheritedOrientation ) }\n\t\t\t</View>\n\t\t\t<SpacerControls\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\theight={ temporaryHeight || height }\n\t\t\t\twidth={ temporaryWidth || width }\n\t\t\t\torientation={ inheritedOrientation }\n\t\t\t\tisResizing={ isResizing }\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default SpacerEdit;\n"]}
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * WordPress dependencies
5
5
  */
6
- import { useBlockProps } from '@wordpress/block-editor';
6
+ import { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';
7
7
  export default function save(_ref) {
8
8
  let {
9
9
  attributes: {
@@ -13,8 +13,8 @@ export default function save(_ref) {
13
13
  } = _ref;
14
14
  return createElement("div", useBlockProps.save({
15
15
  style: {
16
- height,
17
- width
16
+ height: getSpacingPresetCssVar(height),
17
+ width: getSpacingPresetCssVar(width)
18
18
  },
19
19
  'aria-hidden': true
20
20
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/spacer/save.js"],"names":["useBlockProps","save","attributes","height","width","style"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,yBAA9B;AAEA,eAAe,SAASC,IAAT,OAAmD;AAAA,MAApC;AAAEC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AAAd,GAAoC;AACjE,SACC,qBACMJ,aAAa,CAACC,IAAd,CAAoB;AACxBI,IAAAA,KAAK,EAAE;AACNF,MAAAA,MADM;AAENC,MAAAA;AAFM,KADiB;AAKxB,mBAAe;AALS,GAApB,CADN,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\n\nexport default function save( { attributes: { height, width } } ) {\n\treturn (\n\t\t<div\n\t\t\t{ ...useBlockProps.save( {\n\t\t\t\tstyle: {\n\t\t\t\t\theight,\n\t\t\t\t\twidth,\n\t\t\t\t},\n\t\t\t\t'aria-hidden': true,\n\t\t\t} ) }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/spacer/save.js"],"names":["useBlockProps","getSpacingPresetCssVar","save","attributes","height","width","style"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,sBAAxB,QAAsD,yBAAtD;AAEA,eAAe,SAASC,IAAT,OAAmD;AAAA,MAApC;AAAEC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA;AAAV;AAAd,GAAoC;AACjE,SACC,qBACML,aAAa,CAACE,IAAd,CAAoB;AACxBI,IAAAA,KAAK,EAAE;AACNF,MAAAA,MAAM,EAAEH,sBAAsB,CAAEG,MAAF,CADxB;AAENC,MAAAA,KAAK,EAAEJ,sBAAsB,CAAEI,KAAF;AAFvB,KADiB;AAKxB,mBAAe;AALS,GAApB,CADN,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, getSpacingPresetCssVar } from '@wordpress/block-editor';\n\nexport default function save( { attributes: { height, width } } ) {\n\treturn (\n\t\t<div\n\t\t\t{ ...useBlockProps.save( {\n\t\t\t\tstyle: {\n\t\t\t\t\theight: getSpacingPresetCssVar( height ),\n\t\t\t\t\twidth: getSpacingPresetCssVar( width ),\n\t\t\t\t},\n\t\t\t\t'aria-hidden': true,\n\t\t\t} ) }\n\t\t/>\n\t);\n}\n"]}
@@ -1,7 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { mapValues } from 'lodash';
5
1
  const INHERITED_COLUMN_ATTRIBUTES = ['align'];
6
2
  /**
7
3
  * Creates a table state.
@@ -95,12 +91,14 @@ export function updateSelectedCell(state, selection, updateCell) {
95
91
  sectionName: selectionSectionName,
96
92
  rowIndex: selectionRowIndex
97
93
  } = selection;
98
- return mapValues(tableSections, (section, sectionName) => {
94
+ return Object.fromEntries(Object.entries(tableSections).map(_ref3 => {
95
+ let [sectionName, section] = _ref3;
96
+
99
97
  if (selectionSectionName && selectionSectionName !== sectionName) {
100
- return section;
98
+ return [sectionName, section];
101
99
  }
102
100
 
103
- return section.map((row, rowIndex) => {
101
+ return [sectionName, section.map((row, rowIndex) => {
104
102
  if (selectionRowIndex && selectionRowIndex !== rowIndex) {
105
103
  return row;
106
104
  }
@@ -120,8 +118,8 @@ export function updateSelectedCell(state, selection, updateCell) {
120
118
  return updateCell(cellAttributes);
121
119
  })
122
120
  };
123
- });
124
- });
121
+ })];
122
+ }));
125
123
  }
126
124
  /**
127
125
  * Returns whether the cell at `cellLocation` is included in the selection `selection`.
@@ -157,14 +155,14 @@ export function isCellSelected(cellLocation, selection) {
157
155
  * @return {Object} New table state.
158
156
  */
159
157
 
160
- export function insertRow(state, _ref3) {
158
+ export function insertRow(state, _ref4) {
161
159
  var _firstRow$cells;
162
160
 
163
161
  let {
164
162
  sectionName,
165
163
  rowIndex,
166
164
  columnCount
167
- } = _ref3;
165
+ } = _ref4;
168
166
  const firstRow = getFirstRow(state);
169
167
  const cellCount = columnCount === undefined ? firstRow === null || firstRow === void 0 ? void 0 : (_firstRow$cells = firstRow.cells) === null || _firstRow$cells === void 0 ? void 0 : _firstRow$cells.length : columnCount; // Bail early if the function cannot determine how many cells to add.
170
168
 
@@ -180,8 +178,8 @@ export function insertRow(state, _ref3) {
180
178
  var _firstRow$cells$index, _firstRow$cells2;
181
179
 
182
180
  const firstCellInColumn = (_firstRow$cells$index = firstRow === null || firstRow === void 0 ? void 0 : (_firstRow$cells2 = firstRow.cells) === null || _firstRow$cells2 === void 0 ? void 0 : _firstRow$cells2[index]) !== null && _firstRow$cells$index !== void 0 ? _firstRow$cells$index : {};
183
- const inheritedAttributes = Object.fromEntries(Object.entries(firstCellInColumn).filter(_ref4 => {
184
- let [key] = _ref4;
181
+ const inheritedAttributes = Object.fromEntries(Object.entries(firstCellInColumn).filter(_ref5 => {
182
+ let [key] = _ref5;
185
183
  return INHERITED_COLUMN_ATTRIBUTES.includes(key);
186
184
  }));
187
185
  return { ...inheritedAttributes,
@@ -203,11 +201,11 @@ export function insertRow(state, _ref3) {
203
201
  * @return {Object} New table state.
204
202
  */
205
203
 
206
- export function deleteRow(state, _ref5) {
204
+ export function deleteRow(state, _ref6) {
207
205
  let {
208
206
  sectionName,
209
207
  rowIndex
210
- } = _ref5;
208
+ } = _ref6;
211
209
  return {
212
210
  [sectionName]: state[sectionName].filter((row, index) => index !== rowIndex)
213
211
  };
@@ -222,21 +220,23 @@ export function deleteRow(state, _ref5) {
222
220
  * @return {Object} New table state.
223
221
  */
224
222
 
225
- export function insertColumn(state, _ref6) {
223
+ export function insertColumn(state, _ref7) {
226
224
  let {
227
225
  columnIndex
228
- } = _ref6;
229
- const tableSections = Object.fromEntries(Object.entries(state).filter(_ref7 => {
230
- let [key] = _ref7;
226
+ } = _ref7;
227
+ const tableSections = Object.fromEntries(Object.entries(state).filter(_ref8 => {
228
+ let [key] = _ref8;
231
229
  return ['head', 'body', 'foot'].includes(key);
232
230
  }));
233
- return mapValues(tableSections, (section, sectionName) => {
231
+ return Object.fromEntries(Object.entries(tableSections).map(_ref9 => {
232
+ let [sectionName, section] = _ref9;
233
+
234
234
  // Bail early if the table section is empty.
235
235
  if (isEmptyTableSection(section)) {
236
- return section;
236
+ return [sectionName, section];
237
237
  }
238
238
 
239
- return section.map(row => {
239
+ return [sectionName, section.map(row => {
240
240
  // Bail early if the row is empty or it's an attempt to insert past
241
241
  // the last possible index of the array.
242
242
  if (isEmptyRow(row) || row.cells.length < columnIndex) {
@@ -249,8 +249,8 @@ export function insertColumn(state, _ref6) {
249
249
  tag: sectionName === 'head' ? 'th' : 'td'
250
250
  }, ...row.cells.slice(columnIndex)]
251
251
  };
252
- });
253
- });
252
+ })];
253
+ }));
254
254
  }
255
255
  /**
256
256
  * Deletes a column from the table state.
@@ -262,24 +262,26 @@ export function insertColumn(state, _ref6) {
262
262
  * @return {Object} New table state.
263
263
  */
264
264
 
265
- export function deleteColumn(state, _ref8) {
265
+ export function deleteColumn(state, _ref10) {
266
266
  let {
267
267
  columnIndex
268
- } = _ref8;
269
- const tableSections = Object.fromEntries(Object.entries(state).filter(_ref9 => {
270
- let [key] = _ref9;
268
+ } = _ref10;
269
+ const tableSections = Object.fromEntries(Object.entries(state).filter(_ref11 => {
270
+ let [key] = _ref11;
271
271
  return ['head', 'body', 'foot'].includes(key);
272
272
  }));
273
- return mapValues(tableSections, section => {
273
+ return Object.fromEntries(Object.entries(tableSections).map(_ref12 => {
274
+ let [sectionName, section] = _ref12;
275
+
274
276
  // Bail early if the table section is empty.
275
277
  if (isEmptyTableSection(section)) {
276
- return section;
278
+ return [sectionName, section];
277
279
  }
278
280
 
279
- return section.map(row => ({
281
+ return [sectionName, section.map(row => ({
280
282
  cells: row.cells.length >= columnIndex ? row.cells.filter((cell, index) => index !== columnIndex) : row.cells
281
- })).filter(row => row.cells.length);
282
- });
283
+ })).filter(row => row.cells.length)];
284
+ }));
283
285
  }
284
286
  /**
285
287
  * Toggles the existence of a section.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["mapValues","INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","Array","from","length","map","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","Object","fromEntries","entries","filter","key","includes","selectionSectionName","selectionRowIndex","section","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","_","index","firstCellInColumn","inheritedAttributes","deleteRow","insertColumn","isEmptyRow","deleteColumn","cell","toggleSection","every"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA,MAAMC,2BAA2B,GAAG,CAAE,OAAF,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACxD,SAAO;AACNC,IAAAA,IAAI,EAAEC,KAAK,CAACC,IAAN,CAAY;AAAEC,MAAAA,MAAM,EAAEL;AAAV,KAAZ,EAAmCM,GAAnC,CAAwC,OAAQ;AACrDC,MAAAA,KAAK,EAAEJ,KAAK,CAACC,IAAN,CAAY;AAAEC,QAAAA,MAAM,EAAEJ;AAAV,OAAZ,EAAsCK,GAAtC,CAA2C,OAAQ;AACzDE,QAAAA,OAAO,EAAE,EADgD;AAEzDC,QAAAA,GAAG,EAAE;AAFoD,OAAR,CAA3C;AAD8C,KAAR,CAAxC;AADA,GAAP;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AACpC,MAAK,CAAEC,mBAAmB,CAAED,KAAK,CAACE,IAAR,CAA1B,EAA2C;AAC1C,WAAOF,KAAK,CAACE,IAAN,CAAY,CAAZ,CAAP;AACA;;AACD,MAAK,CAAED,mBAAmB,CAAED,KAAK,CAACT,IAAR,CAA1B,EAA2C;AAC1C,WAAOS,KAAK,CAACT,IAAN,CAAY,CAAZ,CAAP;AACA;;AACD,MAAK,CAAEU,mBAAmB,CAAED,KAAK,CAACG,IAAR,CAA1B,EAA2C;AAC1C,WAAOH,KAA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D;AACpD,WAAO;AAAE,OAAEA,WAAF,GAAiB;AAAnB,KAAP;AACA,GAJkD,CAMnD;;;AACA,QAAMjB,WAAW,2CAAGU,KAAK,CAACT,IAAT,gEAAG,YAAc,CAAd,CAAH,uEAAG,aAAmBK,KAAtB,uDAAG,mBAA0BF,MAA7B,yEAAuC,CAAxD,CAPmD,CASnD;;AACA,SAAOiC,SAAS,CAAE3B,KAAF,EAAS;AAAEO,IAAAA,WAAF;AAAeC,IAAAA,QAAQ,EAAE,CAAzB;AAA4BlB,IAAAA;AAA5B,GAAT,CAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,mBAAT,CAA8BqB,OAA9B,EAAwC;AAC9C,SAAO,CAAEA,OAAF,IAAa,CAAEA,OAAO,CAAC5B,MAAvB,IAAiC4B,OAAO,CAACoB,KAAR,CAAeJ,UAAf,CAAxC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASA,UAAT,CAAqBf,GAArB,EAA2B;AACjC,SAAO,EAAIA,GAAG,CAAC3B,KAAJ,IAAa2B,GAAG,CAAC3B,KAAJ,CAAUF,MAA3B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { mapValues } from 'lodash';\n\nconst INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\tif ( selectionSectionName && selectionSectionName !== sectionName ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row, rowIndex ) => {\n\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: row.cells.map( ( cellAttributes, columnIndex ) => {\n\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\trowIndex,\n\t\t\t\t\t};\n\n\t\t\t\t\tif ( ! isCellSelected( cellLocation, selection ) ) {\n\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t} ),\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn mapValues( tableSections, ( section, sectionName ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section.map( ( row ) => {\n\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t// the last possible index of the array.\n\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\treturn row;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcells: [\n\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t{\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t},\n\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t],\n\t\t\t};\n\t\t} );\n\t} );\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn mapValues( tableSections, ( section ) => {\n\t\t// Bail early if the table section is empty.\n\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\treturn section;\n\t\t}\n\n\t\treturn section\n\t\t\t.map( ( row ) => ( {\n\t\t\t\tcells:\n\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: row.cells,\n\t\t\t} ) )\n\t\t\t.filter( ( row ) => row.cells.length );\n\t} );\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/table/state.js"],"names":["INHERITED_COLUMN_ATTRIBUTES","createTable","rowCount","columnCount","body","Array","from","length","map","cells","content","tag","getFirstRow","state","isEmptyTableSection","head","foot","getCellAttribute","cellLocation","attributeName","sectionName","rowIndex","columnIndex","updateSelectedCell","selection","updateCell","tableSections","Object","fromEntries","entries","filter","key","includes","selectionSectionName","selectionRowIndex","section","row","cellAttributes","isCellSelected","type","insertRow","firstRow","cellCount","undefined","slice","_","index","firstCellInColumn","inheritedAttributes","deleteRow","insertColumn","isEmptyRow","deleteColumn","cell","toggleSection","every"],"mappings":"AAAA,MAAMA,2BAA2B,GAAG,CAAE,OAAF,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,OAAkD;AAAA,MAA5B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA4B;AACxD,SAAO;AACNC,IAAAA,IAAI,EAAEC,KAAK,CAACC,IAAN,CAAY;AAAEC,MAAAA,MAAM,EAAEL;AAAV,KAAZ,EAAmCM,GAAnC,CAAwC,OAAQ;AACrDC,MAAAA,KAAK,EAAEJ,KAAK,CAACC,IAAN,CAAY;AAAEC,QAAAA,MAAM,EAAEJ;AAAV,OAAZ,EAAsCK,GAAtC,CAA2C,OAAQ;AACzDE,QAAAA,OAAO,EAAE,EADgD;AAEzDC,QAAAA,GAAG,EAAE;AAFoD,OAAR,CAA3C;AAD8C,KAAR,CAAxC;AADA,GAAP;AAQA;AAED;AACA;AACA;AACA;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AF,IAAa,CAAEA,OAAO,CAAC5B,MAAvB,IAAiC4B,OAAO,CAACoB,KAAR,CAAeJ,UAAf,CAAxC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASA,UAAT,CAAqBf,GAArB,EAA2B;AACjC,SAAO,EAAIA,GAAG,CAAC3B,KAAJ,IAAa2B,GAAG,CAAC3B,KAAJ,CAAUF,MAA3B,CAAP;AACA","sourcesContent":["const INHERITED_COLUMN_ATTRIBUTES = [ 'align' ];\n\n/**\n * Creates a table state.\n *\n * @param {Object} options\n * @param {number} options.rowCount Row count for the table to create.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function createTable( { rowCount, columnCount } ) {\n\treturn {\n\t\tbody: Array.from( { length: rowCount } ).map( () => ( {\n\t\t\tcells: Array.from( { length: columnCount } ).map( () => ( {\n\t\t\t\tcontent: '',\n\t\t\t\ttag: 'td',\n\t\t\t} ) ),\n\t\t} ) ),\n\t};\n}\n\n/**\n * Returns the first row in the table.\n *\n * @param {Object} state Current table state.\n *\n * @return {Object | undefined} The first table row.\n */\nexport function getFirstRow( state ) {\n\tif ( ! isEmptyTableSection( state.head ) ) {\n\t\treturn state.head[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.body ) ) {\n\t\treturn state.body[ 0 ];\n\t}\n\tif ( ! isEmptyTableSection( state.foot ) ) {\n\t\treturn state.foot[ 0 ];\n\t}\n}\n\n/**\n * Gets an attribute for a cell.\n *\n * @param {Object} state Current table state.\n * @param {Object} cellLocation The location of the cell\n * @param {string} attributeName The name of the attribute to get the value of.\n *\n * @return {*} The attribute value.\n */\nexport function getCellAttribute( state, cellLocation, attributeName ) {\n\tconst { sectionName, rowIndex, columnIndex } = cellLocation;\n\treturn state[ sectionName ]?.[ rowIndex ]?.cells?.[ columnIndex ]?.[\n\t\tattributeName\n\t];\n}\n\n/**\n * Returns updated cell attributes after applying the `updateCell` function to the selection.\n *\n * @param {Object} state The block attributes.\n * @param {Object} selection The selection of cells to update.\n * @param {Function} updateCell A function to update the selected cell attributes.\n *\n * @return {Object} New table state including the updated cells.\n */\nexport function updateSelectedCell( state, selection, updateCell ) {\n\tif ( ! selection ) {\n\t\treturn state;\n\t}\n\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\tconst { sectionName: selectionSectionName, rowIndex: selectionRowIndex } =\n\t\tselection;\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\tif (\n\t\t\t\tselectionSectionName &&\n\t\t\t\tselectionSectionName !== sectionName\n\t\t\t) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row, rowIndex ) => {\n\t\t\t\t\tif ( selectionRowIndex && selectionRowIndex !== rowIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: row.cells.map(\n\t\t\t\t\t\t\t( cellAttributes, columnIndex ) => {\n\t\t\t\t\t\t\t\tconst cellLocation = {\n\t\t\t\t\t\t\t\t\tsectionName,\n\t\t\t\t\t\t\t\t\tcolumnIndex,\n\t\t\t\t\t\t\t\t\trowIndex,\n\t\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! isCellSelected( cellLocation, selection )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\treturn cellAttributes;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn updateCell( cellAttributes );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Returns whether the cell at `cellLocation` is included in the selection `selection`.\n *\n * @param {Object} cellLocation An object containing cell location properties.\n * @param {Object} selection An object containing selection properties.\n *\n * @return {boolean} True if the cell is selected, false otherwise.\n */\nexport function isCellSelected( cellLocation, selection ) {\n\tif ( ! cellLocation || ! selection ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection.type ) {\n\t\tcase 'column':\n\t\t\treturn (\n\t\t\t\tselection.type === 'column' &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex\n\t\t\t);\n\t\tcase 'cell':\n\t\t\treturn (\n\t\t\t\tselection.type === 'cell' &&\n\t\t\t\tcellLocation.sectionName === selection.sectionName &&\n\t\t\t\tcellLocation.columnIndex === selection.columnIndex &&\n\t\t\t\tcellLocation.rowIndex === selection.rowIndex\n\t\t\t);\n\t}\n}\n\n/**\n * Inserts a row in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to insert the row.\n * @param {number} options.rowIndex Row index at which to insert the row.\n * @param {number} options.columnCount Column count for the table to create.\n *\n * @return {Object} New table state.\n */\nexport function insertRow( state, { sectionName, rowIndex, columnCount } ) {\n\tconst firstRow = getFirstRow( state );\n\tconst cellCount =\n\t\tcolumnCount === undefined ? firstRow?.cells?.length : columnCount;\n\n\t// Bail early if the function cannot determine how many cells to add.\n\tif ( ! cellCount ) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\t[ sectionName ]: [\n\t\t\t...state[ sectionName ].slice( 0, rowIndex ),\n\t\t\t{\n\t\t\t\tcells: Array.from( { length: cellCount } ).map(\n\t\t\t\t\t( _, index ) => {\n\t\t\t\t\t\tconst firstCellInColumn =\n\t\t\t\t\t\t\tfirstRow?.cells?.[ index ] ?? {};\n\n\t\t\t\t\t\tconst inheritedAttributes = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( firstCellInColumn ).filter(\n\t\t\t\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\t\t\t\tINHERITED_COLUMN_ATTRIBUTES.includes( key )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...inheritedAttributes,\n\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t},\n\t\t\t...state[ sectionName ].slice( rowIndex ),\n\t\t],\n\t};\n}\n\n/**\n * Deletes a row from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {string} options.sectionName Section in which to delete the row.\n * @param {number} options.rowIndex Row index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteRow( state, { sectionName, rowIndex } ) {\n\treturn {\n\t\t[ sectionName ]: state[ sectionName ].filter(\n\t\t\t( row, index ) => index !== rowIndex\n\t\t),\n\t};\n}\n\n/**\n * Inserts a column in the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index at which to insert the column.\n *\n * @return {Object} New table state.\n */\nexport function insertColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection.map( ( row ) => {\n\t\t\t\t\t// Bail early if the row is empty or it's an attempt to insert past\n\t\t\t\t\t// the last possible index of the array.\n\t\t\t\t\tif ( isEmptyRow( row ) || row.cells.length < columnIndex ) {\n\t\t\t\t\t\treturn row;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcells: [\n\t\t\t\t\t\t\t...row.cells.slice( 0, columnIndex ),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t\t\t\ttag: sectionName === 'head' ? 'th' : 'td',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t...row.cells.slice( columnIndex ),\n\t\t\t\t\t\t],\n\t\t\t\t\t};\n\t\t\t\t} ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Deletes a column from the table state.\n *\n * @param {Object} state Current table state.\n * @param {Object} options\n * @param {number} options.columnIndex Column index to delete.\n *\n * @return {Object} New table state.\n */\nexport function deleteColumn( state, { columnIndex } ) {\n\tconst tableSections = Object.fromEntries(\n\t\tObject.entries( state ).filter( ( [ key ] ) =>\n\t\t\t[ 'head', 'body', 'foot' ].includes( key )\n\t\t)\n\t);\n\n\treturn Object.fromEntries(\n\t\tObject.entries( tableSections ).map( ( [ sectionName, section ] ) => {\n\t\t\t// Bail early if the table section is empty.\n\t\t\tif ( isEmptyTableSection( section ) ) {\n\t\t\t\treturn [ sectionName, section ];\n\t\t\t}\n\n\t\t\treturn [\n\t\t\t\tsectionName,\n\t\t\t\tsection\n\t\t\t\t\t.map( ( row ) => ( {\n\t\t\t\t\t\tcells:\n\t\t\t\t\t\t\trow.cells.length >= columnIndex\n\t\t\t\t\t\t\t\t? row.cells.filter(\n\t\t\t\t\t\t\t\t\t\t( cell, index ) => index !== columnIndex\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: row.cells,\n\t\t\t\t\t} ) )\n\t\t\t\t\t.filter( ( row ) => row.cells.length ),\n\t\t\t];\n\t\t} )\n\t);\n}\n\n/**\n * Toggles the existence of a section.\n *\n * @param {Object} state Current table state.\n * @param {string} sectionName Name of the section to toggle.\n *\n * @return {Object} New table state.\n */\nexport function toggleSection( state, sectionName ) {\n\t// Section exists, replace it with an empty row to remove it.\n\tif ( ! isEmptyTableSection( state[ sectionName ] ) ) {\n\t\treturn { [ sectionName ]: [] };\n\t}\n\n\t// Get the length of the first row of the body to use when creating the header.\n\tconst columnCount = state.body?.[ 0 ]?.cells?.length ?? 1;\n\n\t// Section doesn't exist, insert an empty row to create the section.\n\treturn insertRow( state, { sectionName, rowIndex: 0, columnCount } );\n}\n\n/**\n * Determines whether a table section is empty.\n *\n * @param {Object} section Table section state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyTableSection( section ) {\n\treturn ! section || ! section.length || section.every( isEmptyRow );\n}\n\n/**\n * Determines whether a table row is empty.\n *\n * @param {Object} row Table row state.\n *\n * @return {boolean} True if the table section is empty, false otherwise.\n */\nexport function isEmptyRow( row ) {\n\treturn ! ( row.cells && row.cells.length );\n}\n"]}
@@ -48,8 +48,7 @@ const metadata = {
48
48
  fontSize: true
49
49
  }
50
50
  }
51
- },
52
- editorStyle: "wp-block-term-description-editor"
51
+ }
53
52
  };
54
53
  import edit from './edit';
55
54
  const {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/term-description/index.js"],"names":["termDescription","icon","initBlock","edit","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAA5B,QAAwC,kBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBE,EAAAA;AAFuB,CAAjB;AAKP,OAAO,MAAMI,IAAI,GAAG,MAAML,SAAS,CAAE;AAAEE,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/term-description/index.js"],"names":["termDescription","icon","initBlock","edit","name","metadata","settings","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,IAAIC,IAA5B,QAAwC,kBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBL,EAAAA,IADuB;AAEvBE,EAAAA;AAFuB,CAAjB;AAKP,OAAO,MAAMI,IAAI,GAAG,MAAML,SAAS,CAAE;AAAEE,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { termDescription as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { isEmpty, mapValues } from 'lodash';
4
+ import { isEmpty } from 'lodash';
5
5
  /**
6
6
  * Removed empty nodes from nested objects.
7
7
  *
@@ -14,8 +14,11 @@ const cleanEmptyObject = object => {
14
14
  return object;
15
15
  }
16
16
 
17
- const cleanedNestedObjects = Object.fromEntries(Object.entries(mapValues(object, cleanEmptyObject)).filter(_ref => {
18
- let [, value] = _ref;
17
+ const cleanedNestedObjects = Object.fromEntries(Object.entries(object).map(_ref => {
18
+ let [key, value] = _ref;
19
+ return [key, cleanEmptyObject(value)];
20
+ }).filter(_ref2 => {
21
+ let [, value] = _ref2;
19
22
  return Boolean(value);
20
23
  }));
21
24
  return isEmpty(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/utils/clean-empty-object.js"],"names":["isEmpty","mapValues","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","filter","value","Boolean","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,SAAlB,QAAmC,QAAnC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AACtC,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CAACE,OAAP,CAAgBR,SAAS,CAAEE,MAAF,EAAUD,gBAAV,CAAzB,EAAwDQ,MAAxD,CACC;AAAA,QAAE,GAAIC,KAAJ,CAAF;AAAA,WAAmBC,OAAO,CAAED,KAAF,CAA1B;AAAA,GADD,CAD4B,CAA7B;AAKA,SAAOX,OAAO,CAAEM,oBAAF,CAAP,GAAkCO,SAAlC,GAA8CP,oBAArD;AACA,CAdD;;AAgBA,eAAeJ,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty, mapValues } from 'lodash';\n\n/**\n * Removed empty nodes from nested objects.\n *\n * @param {Object} object\n * @return {Object} Object cleaned from empty nodes.\n */\nconst cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( mapValues( object, cleanEmptyObject ) ).filter(\n\t\t\t( [ , value ] ) => Boolean( value )\n\t\t)\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport default cleanEmptyObject;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/utils/clean-empty-object.js"],"names":["isEmpty","cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","map","key","value","filter","Boolean","undefined"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAKC,MAAF,IAAc;AACtC,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CAACE,OAAP,CAAgBN,MAAhB,EACEO,GADF,CACO;AAAA,QAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF;AAAA,WAAsB,CAAED,GAAF,EAAOT,gBAAgB,CAAEU,KAAF,CAAvB,CAAtB;AAAA,GADP,EAEEC,MAFF,CAEU;AAAA,QAAE,GAAID,KAAJ,CAAF;AAAA,WAAmBE,OAAO,CAAEF,KAAF,CAA1B;AAAA,GAFV,CAD4B,CAA7B;AAKA,SAAOX,OAAO,CAAEK,oBAAF,CAAP,GAAkCS,SAAlC,GAA8CT,oBAArD;AACA,CAdD;;AAgBA,eAAeJ,gBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * Removed empty nodes from nested objects.\n *\n * @param {Object} object\n * @return {Object} Object cleaned from empty nodes.\n */\nconst cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( object )\n\t\t\t.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )\n\t\t\t.filter( ( [ , value ] ) => Boolean( value ) )\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport default cleanEmptyObject;\n"]}
@@ -91,4 +91,9 @@
91
91
  }
92
92
  .wp-block-categories ul ul {
93
93
  margin-top: 6px;
94
+ }
95
+
96
+ /* Center alignment for classic themes. */
97
+ [data-align=center] .wp-block-categories {
98
+ text-align: center;
94
99
  }
@@ -91,4 +91,9 @@
91
91
  }
92
92
  .wp-block-categories ul ul {
93
93
  margin-top: 6px;
94
+ }
95
+
96
+ /* Center alignment for classic themes. */
97
+ [data-align=center] .wp-block-categories {
98
+ text-align: center;
94
99
  }
@@ -88,10 +88,14 @@
88
88
  */
89
89
  .wp-block-categories {
90
90
  box-sizing: border-box;
91
+ /* Only apply the text align on dropdowns, not lists. */
91
92
  }
92
93
  .wp-block-categories.alignleft {
93
94
  margin-right: 2em;
94
95
  }
95
96
  .wp-block-categories.alignright {
96
97
  margin-left: 2em;
98
+ }
99
+ .wp-block-categories.wp-block-categories-dropdown.aligncenter {
100
+ text-align: center;
97
101
  }
@@ -88,6 +88,7 @@
88
88
  */
89
89
  .wp-block-categories {
90
90
  box-sizing: border-box;
91
+ /* Only apply the text align on dropdowns, not lists. */
91
92
  }
92
93
  .wp-block-categories.alignleft {
93
94
  /*rtl:ignore*/
@@ -96,4 +97,7 @@
96
97
  .wp-block-categories.alignright {
97
98
  /*rtl:ignore*/
98
99
  margin-left: 2em;
100
+ }
101
+ .wp-block-categories.wp-block-categories-dropdown.aligncenter {
102
+ text-align: center;
99
103
  }
@@ -88,7 +88,6 @@
88
88
  */
89
89
  .wp-block-columns {
90
90
  display: flex;
91
- margin-bottom: 1.75em;
92
91
  box-sizing: border-box;
93
92
  flex-wrap: wrap !important;
94
93
  align-items: initial !important;
@@ -135,6 +134,10 @@
135
134
  flex-grow: 0;
136
135
  }
137
136
 
137
+ :where(.wp-block-columns) {
138
+ margin-bottom: 1.75em;
139
+ }
140
+
138
141
  :where(.wp-block-columns.has-background) {
139
142
  padding: 1.25em 2.375em;
140
143
  }
@@ -88,7 +88,6 @@
88
88
  */
89
89
  .wp-block-columns {
90
90
  display: flex;
91
- margin-bottom: 1.75em;
92
91
  box-sizing: border-box;
93
92
  flex-wrap: wrap !important;
94
93
  align-items: initial !important;
@@ -135,6 +134,10 @@
135
134
  flex-grow: 0;
136
135
  }
137
136
 
137
+ :where(.wp-block-columns) {
138
+ margin-bottom: 1.75em;
139
+ }
140
+
138
141
  :where(.wp-block-columns.has-background) {
139
142
  padding: 1.25em 2.375em;
140
143
  }
@@ -300,7 +300,7 @@ html :where(img[class*="wp-image-"]) {
300
300
  /**
301
301
  * Reset user agent styles for figure element margins.
302
302
  */
303
- figure {
303
+ :where(figure) {
304
304
  margin: 0 0 1em 0;
305
305
  }
306
306
 
@@ -302,7 +302,7 @@ html :where(img[class*="wp-image-"]) {
302
302
  /**
303
303
  * Reset user agent styles for figure element margins.
304
304
  */
305
- figure {
305
+ :where(figure) {
306
306
  margin: 0 0 1em 0;
307
307
  }
308
308