@wordpress/block-editor 15.21.0 → 15.22.1-next.v.202606191442.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 (554) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/build/components/block-card/index.cjs +4 -5
  3. package/build/components/block-card/index.cjs.map +2 -2
  4. package/build/components/block-compare/index.cjs +2 -2
  5. package/build/components/block-compare/index.cjs.map +2 -2
  6. package/build/components/block-inspector/index.cjs +3 -4
  7. package/build/components/block-inspector/index.cjs.map +2 -2
  8. package/build/components/block-mover/mover-description.cjs +6 -6
  9. package/build/components/block-mover/mover-description.cjs.map +1 -1
  10. package/build/components/block-patterns-list/index.cjs +1 -1
  11. package/build/components/block-patterns-list/index.cjs.map +2 -2
  12. package/build/components/block-patterns-paging/index.cjs +4 -4
  13. package/build/components/block-patterns-paging/index.cjs.map +2 -2
  14. package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
  15. package/build/components/block-quick-navigation/index.cjs +7 -5
  16. package/build/components/block-quick-navigation/index.cjs.map +2 -2
  17. package/build/components/block-switcher/block-transformations-menu.cjs +16 -15
  18. package/build/components/block-switcher/block-transformations-menu.cjs.map +2 -2
  19. package/build/components/block-switcher/index.cjs +4 -4
  20. package/build/components/block-switcher/index.cjs.map +2 -2
  21. package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
  22. package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
  23. package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
  24. package/build/components/child-layout-control/index.cjs +51 -19
  25. package/build/components/child-layout-control/index.cjs.map +2 -2
  26. package/build/components/dimensions-tool/index.cjs +4 -5
  27. package/build/components/dimensions-tool/index.cjs.map +2 -2
  28. package/build/components/dimensions-tool/scale-tool.cjs +1 -1
  29. package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
  30. package/build/components/global-styles/advanced-panel.cjs +23 -15
  31. package/build/components/global-styles/advanced-panel.cjs.map +2 -2
  32. package/build/components/global-styles/background-panel.cjs +2 -2
  33. package/build/components/global-styles/background-panel.cjs.map +2 -2
  34. package/build/components/global-styles/border-panel.cjs +2 -0
  35. package/build/components/global-styles/border-panel.cjs.map +2 -2
  36. package/build/components/global-styles/dimensions-panel.cjs +2 -2
  37. package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
  38. package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
  39. package/build/components/grid/grid-item-resizer.cjs.map +1 -1
  40. package/build/components/grid/grid-visualizer.cjs.map +1 -1
  41. package/build/components/iframe/index.cjs +6 -3
  42. package/build/components/iframe/index.cjs.map +3 -3
  43. package/build/components/image-editor/use-transform-image.cjs.map +1 -1
  44. package/build/components/inner-blocks/use-inner-block-template-sync.cjs +3 -1
  45. package/build/components/inner-blocks/use-inner-block-template-sync.cjs.map +2 -2
  46. package/build/components/inserter/get-appender-label.cjs.map +1 -1
  47. package/build/components/inserter/hooks/use-patterns-state.cjs +1 -1
  48. package/build/components/inserter/hooks/use-patterns-state.cjs.map +2 -2
  49. package/build/components/inserter/index.cjs +179 -220
  50. package/build/components/inserter/index.cjs.map +3 -3
  51. package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
  52. package/build/components/inserter/search-items.cjs.map +1 -1
  53. package/build/components/inserter/search-results.cjs +1 -1
  54. package/build/components/inserter/search-results.cjs.map +2 -2
  55. package/build/components/inspector-controls/fill.cjs +1 -3
  56. package/build/components/inspector-controls/fill.cjs.map +2 -2
  57. package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
  58. package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
  59. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  60. package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
  61. package/build/components/line-height-control/index.cjs.map +1 -1
  62. package/build/components/link-control/index.cjs +1 -1
  63. package/build/components/link-control/index.cjs.map +1 -1
  64. package/build/components/link-control/normalize-url.cjs.map +1 -1
  65. package/build/components/list-view/block-select-button.cjs +10 -12
  66. package/build/components/list-view/block-select-button.cjs.map +2 -2
  67. package/build/components/list-view/block.cjs +2 -1
  68. package/build/components/list-view/block.cjs.map +2 -2
  69. package/build/components/list-view/utils.cjs.map +1 -1
  70. package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
  71. package/build/components/provider/index.cjs.map +1 -1
  72. package/build/components/provider/use-block-sync.cjs +11 -2
  73. package/build/components/provider/use-block-sync.cjs.map +2 -2
  74. package/build/components/rich-text/event-listeners/before-input-rules.cjs +5 -5
  75. package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +3 -3
  76. package/build/components/rich-text/event-listeners/delete.cjs +4 -4
  77. package/build/components/rich-text/event-listeners/delete.cjs.map +3 -3
  78. package/build/components/rich-text/event-listeners/enter.cjs +7 -2
  79. package/build/components/rich-text/event-listeners/enter.cjs.map +2 -2
  80. package/build/components/rich-text/event-listeners/input-events.cjs +4 -4
  81. package/build/components/rich-text/event-listeners/input-events.cjs.map +3 -3
  82. package/build/components/rich-text/event-listeners/input-rules.cjs +17 -4
  83. package/build/components/rich-text/event-listeners/input-rules.cjs.map +3 -3
  84. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs +4 -4
  85. package/build/components/rich-text/event-listeners/insert-replacement-text.cjs.map +3 -3
  86. package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
  87. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs +4 -4
  88. package/build/components/rich-text/event-listeners/remove-browser-shortcuts.cjs.map +3 -3
  89. package/build/components/rich-text/event-listeners/shortcuts.cjs +4 -4
  90. package/build/components/rich-text/event-listeners/shortcuts.cjs.map +3 -3
  91. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs +4 -4
  92. package/build/components/rich-text/event-listeners/undo-automatic-change.cjs.map +3 -3
  93. package/build/components/rich-text/index.cjs +1 -23
  94. package/build/components/rich-text/index.cjs.map +2 -2
  95. package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
  96. package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
  97. package/build/components/use-block-commands/index.cjs +5 -5
  98. package/build/components/use-block-commands/index.cjs.map +2 -2
  99. package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
  100. package/build/hooks/anchor.cjs +12 -16
  101. package/build/hooks/anchor.cjs.map +2 -2
  102. package/build/hooks/background.cjs.map +1 -1
  103. package/build/hooks/block-fields/index.cjs +13 -2
  104. package/build/hooks/block-fields/index.cjs.map +2 -2
  105. package/build/hooks/border.cjs +0 -3
  106. package/build/hooks/border.cjs.map +2 -2
  107. package/build/hooks/color.cjs +1 -4
  108. package/build/hooks/color.cjs.map +2 -2
  109. package/build/hooks/dimensions.cjs +13 -5
  110. package/build/hooks/dimensions.cjs.map +2 -2
  111. package/build/hooks/fit-text.cjs +11 -0
  112. package/build/hooks/fit-text.cjs.map +2 -2
  113. package/build/hooks/layout-child.cjs +27 -2
  114. package/build/hooks/layout-child.cjs.map +2 -2
  115. package/build/hooks/list-view.cjs +10 -7
  116. package/build/hooks/list-view.cjs.map +2 -2
  117. package/build/hooks/position.cjs +19 -22
  118. package/build/hooks/position.cjs.map +2 -2
  119. package/build/hooks/spacing-visualizer.cjs.map +1 -1
  120. package/build/hooks/state-utils.cjs.map +1 -1
  121. package/build/hooks/style.cjs +42 -2
  122. package/build/hooks/style.cjs.map +2 -2
  123. package/build/hooks/supports.cjs +0 -7
  124. package/build/hooks/supports.cjs.map +2 -2
  125. package/build/private-apis.cjs +4 -0
  126. package/build/private-apis.cjs.map +2 -2
  127. package/build/store/actions.cjs +7 -3
  128. package/build/store/actions.cjs.map +2 -2
  129. package/build/store/private-actions.cjs +1 -2
  130. package/build/store/private-actions.cjs.map +2 -2
  131. package/build/store/private-selectors.cjs +42 -2
  132. package/build/store/private-selectors.cjs.map +2 -2
  133. package/build/store/reducer.cjs +14 -6
  134. package/build/store/reducer.cjs.map +2 -2
  135. package/build/store/selectors.cjs +60 -41
  136. package/build/store/selectors.cjs.map +2 -2
  137. package/build/utils/dom.cjs.map +1 -1
  138. package/build/utils/selection.cjs +1 -1
  139. package/build-module/components/block-card/index.mjs +5 -6
  140. package/build-module/components/block-card/index.mjs.map +2 -2
  141. package/build-module/components/block-compare/index.mjs +1 -1
  142. package/build-module/components/block-compare/index.mjs.map +2 -2
  143. package/build-module/components/block-inspector/index.mjs +3 -5
  144. package/build-module/components/block-inspector/index.mjs.map +2 -2
  145. package/build-module/components/block-mover/mover-description.mjs +6 -6
  146. package/build-module/components/block-mover/mover-description.mjs.map +1 -1
  147. package/build-module/components/block-patterns-list/index.mjs +1 -1
  148. package/build-module/components/block-patterns-list/index.mjs.map +2 -2
  149. package/build-module/components/block-patterns-paging/index.mjs +4 -4
  150. package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
  151. package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
  152. package/build-module/components/block-quick-navigation/index.mjs +8 -6
  153. package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
  154. package/build-module/components/block-switcher/block-transformations-menu.mjs +16 -15
  155. package/build-module/components/block-switcher/block-transformations-menu.mjs.map +2 -2
  156. package/build-module/components/block-switcher/index.mjs +4 -4
  157. package/build-module/components/block-switcher/index.mjs.map +2 -2
  158. package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
  159. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
  160. package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
  161. package/build-module/components/child-layout-control/index.mjs +51 -19
  162. package/build-module/components/child-layout-control/index.mjs.map +2 -2
  163. package/build-module/components/dimensions-tool/index.mjs +4 -5
  164. package/build-module/components/dimensions-tool/index.mjs.map +2 -2
  165. package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
  166. package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
  167. package/build-module/components/global-styles/advanced-panel.mjs +23 -15
  168. package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
  169. package/build-module/components/global-styles/background-panel.mjs +3 -3
  170. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  171. package/build-module/components/global-styles/border-panel.mjs +2 -0
  172. package/build-module/components/global-styles/border-panel.mjs.map +2 -2
  173. package/build-module/components/global-styles/dimensions-panel.mjs +3 -4
  174. package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
  175. package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
  176. package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
  177. package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
  178. package/build-module/components/iframe/index.mjs +6 -3
  179. package/build-module/components/iframe/index.mjs.map +2 -2
  180. package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
  181. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs +3 -1
  182. package/build-module/components/inner-blocks/use-inner-block-template-sync.mjs.map +2 -2
  183. package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
  184. package/build-module/components/inserter/hooks/use-patterns-state.mjs +1 -1
  185. package/build-module/components/inserter/hooks/use-patterns-state.mjs.map +2 -2
  186. package/build-module/components/inserter/index.mjs +185 -222
  187. package/build-module/components/inserter/index.mjs.map +3 -3
  188. package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
  189. package/build-module/components/inserter/search-items.mjs.map +1 -1
  190. package/build-module/components/inserter/search-results.mjs +1 -1
  191. package/build-module/components/inserter/search-results.mjs.map +2 -2
  192. package/build-module/components/inspector-controls/fill.mjs +1 -3
  193. package/build-module/components/inspector-controls/fill.mjs.map +2 -2
  194. package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
  195. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
  196. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  197. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
  198. package/build-module/components/line-height-control/index.mjs.map +1 -1
  199. package/build-module/components/link-control/index.mjs +1 -1
  200. package/build-module/components/link-control/index.mjs.map +1 -1
  201. package/build-module/components/link-control/normalize-url.mjs.map +1 -1
  202. package/build-module/components/list-view/block-select-button.mjs +10 -12
  203. package/build-module/components/list-view/block-select-button.mjs.map +2 -2
  204. package/build-module/components/list-view/block.mjs +2 -1
  205. package/build-module/components/list-view/block.mjs.map +2 -2
  206. package/build-module/components/list-view/utils.mjs.map +1 -1
  207. package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
  208. package/build-module/components/provider/index.mjs.map +1 -1
  209. package/build-module/components/provider/use-block-sync.mjs +11 -2
  210. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  211. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +5 -5
  212. package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
  213. package/build-module/components/rich-text/event-listeners/delete.mjs +4 -4
  214. package/build-module/components/rich-text/event-listeners/delete.mjs.map +2 -2
  215. package/build-module/components/rich-text/event-listeners/enter.mjs +7 -2
  216. package/build-module/components/rich-text/event-listeners/enter.mjs.map +2 -2
  217. package/build-module/components/rich-text/event-listeners/input-events.mjs +4 -4
  218. package/build-module/components/rich-text/event-listeners/input-events.mjs.map +2 -2
  219. package/build-module/components/rich-text/event-listeners/input-rules.mjs +17 -4
  220. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  221. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs +4 -4
  222. package/build-module/components/rich-text/event-listeners/insert-replacement-text.mjs.map +2 -2
  223. package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
  224. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs +4 -4
  225. package/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.mjs.map +2 -2
  226. package/build-module/components/rich-text/event-listeners/shortcuts.mjs +4 -4
  227. package/build-module/components/rich-text/event-listeners/shortcuts.mjs.map +2 -2
  228. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs +4 -4
  229. package/build-module/components/rich-text/event-listeners/undo-automatic-change.mjs.map +2 -2
  230. package/build-module/components/rich-text/index.mjs +1 -23
  231. package/build-module/components/rich-text/index.mjs.map +2 -2
  232. package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
  233. package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
  234. package/build-module/components/use-block-commands/index.mjs +5 -5
  235. package/build-module/components/use-block-commands/index.mjs.map +2 -2
  236. package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
  237. package/build-module/hooks/anchor.mjs +12 -16
  238. package/build-module/hooks/anchor.mjs.map +2 -2
  239. package/build-module/hooks/background.mjs.map +1 -1
  240. package/build-module/hooks/block-fields/index.mjs +13 -2
  241. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  242. package/build-module/hooks/border.mjs +1 -4
  243. package/build-module/hooks/border.mjs.map +2 -2
  244. package/build-module/hooks/color.mjs +2 -5
  245. package/build-module/hooks/color.mjs.map +2 -2
  246. package/build-module/hooks/dimensions.mjs +13 -6
  247. package/build-module/hooks/dimensions.mjs.map +2 -2
  248. package/build-module/hooks/fit-text.mjs +11 -0
  249. package/build-module/hooks/fit-text.mjs.map +2 -2
  250. package/build-module/hooks/layout-child.mjs +27 -2
  251. package/build-module/hooks/layout-child.mjs.map +2 -2
  252. package/build-module/hooks/list-view.mjs +10 -7
  253. package/build-module/hooks/list-view.mjs.map +2 -2
  254. package/build-module/hooks/position.mjs +20 -23
  255. package/build-module/hooks/position.mjs.map +2 -2
  256. package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
  257. package/build-module/hooks/state-utils.mjs.map +1 -1
  258. package/build-module/hooks/style.mjs +44 -3
  259. package/build-module/hooks/style.mjs.map +2 -2
  260. package/build-module/hooks/supports.mjs +0 -7
  261. package/build-module/hooks/supports.mjs.map +2 -2
  262. package/build-module/private-apis.mjs +8 -0
  263. package/build-module/private-apis.mjs.map +2 -2
  264. package/build-module/store/actions.mjs +7 -3
  265. package/build-module/store/actions.mjs.map +2 -2
  266. package/build-module/store/private-actions.mjs +1 -2
  267. package/build-module/store/private-actions.mjs.map +2 -2
  268. package/build-module/store/private-selectors.mjs +39 -1
  269. package/build-module/store/private-selectors.mjs.map +2 -2
  270. package/build-module/store/reducer.mjs +14 -6
  271. package/build-module/store/reducer.mjs.map +2 -2
  272. package/build-module/store/selectors.mjs +62 -42
  273. package/build-module/store/selectors.mjs.map +2 -2
  274. package/build-module/utils/dom.mjs.map +1 -1
  275. package/build-module/utils/selection.mjs +1 -1
  276. package/build-style/content-rtl.css +12 -0
  277. package/build-style/content.css +12 -0
  278. package/build-style/style-rtl.css +26 -8
  279. package/build-style/style.css +26 -8
  280. package/package.json +54 -46
  281. package/src/components/block-breadcrumb/README.md +2 -2
  282. package/src/components/block-card/index.js +7 -13
  283. package/src/components/block-compare/README.md +6 -6
  284. package/src/components/block-compare/index.js +1 -3
  285. package/src/components/block-inspector/index.js +2 -10
  286. package/src/components/block-patterns-list/index.js +1 -2
  287. package/src/components/block-preview/README.md +1 -1
  288. package/src/components/block-quick-navigation/index.js +7 -7
  289. package/src/components/block-switcher/block-transformations-menu.js +16 -18
  290. package/src/components/block-switcher/index.js +4 -4
  291. package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
  292. package/src/components/block-types-list/README.md +0 -19
  293. package/src/components/child-layout-control/index.js +65 -20
  294. package/src/components/child-layout-control/test/index.js +64 -0
  295. package/src/components/dimensions-tool/index.js +4 -9
  296. package/src/components/dimensions-tool/scale-tool.js +1 -2
  297. package/src/components/dimensions-tool/test/index.js +89 -11
  298. package/src/components/global-styles/advanced-panel.js +5 -1
  299. package/src/components/global-styles/background-panel.js +3 -3
  300. package/src/components/global-styles/border-panel.js +2 -0
  301. package/src/components/global-styles/dimensions-panel.js +13 -15
  302. package/src/components/global-styles/shadow-panel-components.js +0 -1
  303. package/src/components/iframe/index.js +8 -3
  304. package/src/components/inner-blocks/use-inner-block-template-sync.js +3 -1
  305. package/src/components/inserter/hooks/use-patterns-state.js +1 -1
  306. package/src/components/inserter/index.js +257 -288
  307. package/src/components/inserter/media-tab/media-preview.js +0 -1
  308. package/src/components/inserter/search-results.js +1 -3
  309. package/src/components/inspector-controls/fill.js +6 -8
  310. package/src/components/inspector-controls-tabs/index.js +0 -1
  311. package/src/components/inspector-controls-tabs/styles-tab.js +5 -1
  312. package/src/components/justify-content-control/README.md +1 -1
  313. package/src/components/list-view/block-select-button.js +9 -14
  314. package/src/components/list-view/block.js +1 -0
  315. package/src/components/media-placeholder/README.md +1 -29
  316. package/src/components/media-upload/README.md +0 -19
  317. package/src/components/preset-input-control/custom-value-controls.js +0 -1
  318. package/src/components/provider/test/use-block-sync.js +40 -0
  319. package/src/components/provider/use-block-sync.js +12 -2
  320. package/src/components/rich-text/event-listeners/before-input-rules.js +5 -4
  321. package/src/components/rich-text/event-listeners/delete.js +9 -4
  322. package/src/components/rich-text/event-listeners/enter.js +9 -2
  323. package/src/components/rich-text/event-listeners/input-events.js +13 -4
  324. package/src/components/rich-text/event-listeners/input-rules.js +20 -4
  325. package/src/components/rich-text/event-listeners/insert-replacement-text.js +9 -4
  326. package/src/components/rich-text/event-listeners/remove-browser-shortcuts.js +9 -4
  327. package/src/components/rich-text/event-listeners/shortcuts.js +13 -4
  328. package/src/components/rich-text/event-listeners/undo-automatic-change.js +5 -4
  329. package/src/components/rich-text/index.js +1 -33
  330. package/src/components/unit-control/README.md +1 -1
  331. package/src/components/url-popover/README.md +1 -1
  332. package/src/components/use-block-commands/index.js +5 -5
  333. package/src/hooks/anchor.js +9 -17
  334. package/src/hooks/block-fields/index.js +27 -2
  335. package/src/hooks/border.js +1 -5
  336. package/src/hooks/color.js +1 -6
  337. package/src/hooks/dimensions.js +15 -8
  338. package/src/hooks/fit-text.js +16 -0
  339. package/src/hooks/layout-child.js +41 -2
  340. package/src/hooks/list-view.js +10 -11
  341. package/src/hooks/position.js +23 -27
  342. package/src/hooks/style.js +80 -2
  343. package/src/hooks/supports.js +0 -9
  344. package/src/hooks/test/dimensions.js +71 -0
  345. package/src/hooks/test/layout-child.js +165 -0
  346. package/src/hooks/test/style.js +126 -4
  347. package/src/private-apis.js +8 -0
  348. package/src/store/actions.js +13 -3
  349. package/src/store/private-actions.js +1 -4
  350. package/src/store/private-selectors.js +89 -0
  351. package/src/store/reducer.js +19 -7
  352. package/src/store/selectors.js +91 -53
  353. package/src/store/test/actions.js +21 -0
  354. package/src/store/test/private-selectors.js +138 -0
  355. package/src/store/test/reducer.js +46 -0
  356. package/src/store/test/selectors.js +77 -0
  357. package/build/components/media-upload-progress/constants.cjs +0 -46
  358. package/build/components/media-upload-progress/constants.cjs.map +0 -7
  359. package/build/components/rich-text/native/format-edit.cjs +0 -60
  360. package/build/components/rich-text/native/format-edit.cjs.map +0 -7
  361. package/build/components/rich-text/native/index.cjs +0 -28
  362. package/build/components/rich-text/native/index.cjs.map +0 -7
  363. package/build/components/rich-text/native/use-format-types.cjs +0 -139
  364. package/build/components/rich-text/native/use-format-types.cjs.map +0 -7
  365. package/build-module/components/media-upload-progress/constants.mjs +0 -16
  366. package/build-module/components/media-upload-progress/constants.mjs.map +0 -7
  367. package/build-module/components/rich-text/native/format-edit.mjs +0 -39
  368. package/build-module/components/rich-text/native/format-edit.mjs.map +0 -7
  369. package/build-module/components/rich-text/native/index.mjs +0 -7
  370. package/build-module/components/rich-text/native/index.mjs.map +0 -7
  371. package/build-module/components/rich-text/native/use-format-types.mjs +0 -114
  372. package/build-module/components/rich-text/native/use-format-types.mjs.map +0 -7
  373. package/src/components/audio-player/audio-url-parser.native.js +0 -20
  374. package/src/components/audio-player/index.native.js +0 -225
  375. package/src/components/audio-player/styles.native.scss +0 -114
  376. package/src/components/audio-player/test/audio-url-parser.native.js +0 -53
  377. package/src/components/block-alignment-control/test/index.native.js +0 -37
  378. package/src/components/block-alignment-control/ui.native.js +0 -86
  379. package/src/components/block-caption/README.md +0 -104
  380. package/src/components/block-caption/index.native.js +0 -89
  381. package/src/components/block-caption/styles.native.scss +0 -7
  382. package/src/components/block-controls/slot.native.js +0 -33
  383. package/src/components/block-draggable/draggable-chip.native.js +0 -49
  384. package/src/components/block-draggable/dropping-insertion-point.native.js +0 -181
  385. package/src/components/block-draggable/dropping-insertion-point.native.scss +0 -8
  386. package/src/components/block-draggable/index.native.js +0 -467
  387. package/src/components/block-draggable/style.native.scss +0 -19
  388. package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +0 -73
  389. package/src/components/block-draggable/test/helpers.native.js +0 -182
  390. package/src/components/block-draggable/test/index.native.js +0 -419
  391. package/src/components/block-draggable/use-scroll-when-dragging.native.js +0 -135
  392. package/src/components/block-edit/edit.native.js +0 -49
  393. package/src/components/block-edit/test/edit.native.js +0 -65
  394. package/src/components/block-heading-level-dropdown/index.native.js +0 -68
  395. package/src/components/block-icon/index.native.js +0 -47
  396. package/src/components/block-icon/style.native.scss +0 -7
  397. package/src/components/block-list/block-crash-boundary.native.js +0 -43
  398. package/src/components/block-list/block-crash-warning.native.js +0 -21
  399. package/src/components/block-list/block-invalid-warning.native.js +0 -70
  400. package/src/components/block-list/block-list-context.native.js +0 -172
  401. package/src/components/block-list/block-list-item-cell.native.js +0 -62
  402. package/src/components/block-list/block-list-item.native.js +0 -209
  403. package/src/components/block-list/block-list-item.native.scss +0 -16
  404. package/src/components/block-list/block-outline.native.js +0 -77
  405. package/src/components/block-list/block-selection-button.native.js +0 -100
  406. package/src/components/block-list/block-selection-button.native.scss +0 -34
  407. package/src/components/block-list/block.native.js +0 -716
  408. package/src/components/block-list/block.native.scss +0 -62
  409. package/src/components/block-list/grid-item.native.js +0 -58
  410. package/src/components/block-list/index.native.js +0 -437
  411. package/src/components/block-list/insertion-point.native.js +0 -36
  412. package/src/components/block-list/style.native.scss +0 -117
  413. package/src/components/block-list/test/block-invalid-warning.native.js +0 -62
  414. package/src/components/block-list/test/block-list-context.native.js +0 -243
  415. package/src/components/block-list/test/block-outline.native.js +0 -255
  416. package/src/components/block-list/test/fixtures/block-list-context.native.js +0 -79
  417. package/src/components/block-list/test/index.native.js +0 -205
  418. package/src/components/block-list/use-block-props/index.native.js +0 -10
  419. package/src/components/block-list/use-scroll-upon-insertion.native.js +0 -52
  420. package/src/components/block-list-appender/index.native.js +0 -70
  421. package/src/components/block-list-appender/style.native.scss +0 -8
  422. package/src/components/block-media-update-progress/README.md +0 -100
  423. package/src/components/block-media-update-progress/index.native.js +0 -299
  424. package/src/components/block-media-update-progress/styles.native.scss +0 -9
  425. package/src/components/block-media-update-progress/test/index.native.js +0 -543
  426. package/src/components/block-mover/index.native.js +0 -193
  427. package/src/components/block-mover/mover-description.native.js +0 -155
  428. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +0 -218
  429. package/src/components/block-mover/test/index.native.js +0 -186
  430. package/src/components/block-settings/button.native.js +0 -41
  431. package/src/components/block-settings/container.native.js +0 -91
  432. package/src/components/block-settings/container.native.scss +0 -4
  433. package/src/components/block-settings/index.native.js +0 -5
  434. package/src/components/block-styles/index.native.js +0 -94
  435. package/src/components/block-styles/preview.native.js +0 -109
  436. package/src/components/block-styles/style.native.scss +0 -64
  437. package/src/components/block-switcher/block-transformations-menu.native.js +0 -91
  438. package/src/components/block-toolbar/block-toolbar-menu.native.js +0 -477
  439. package/src/components/block-toolbar/index.native.js +0 -126
  440. package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +0 -125
  441. package/src/components/block-toolbar/test/block-toolbar-menu.native.js +0 -405
  442. package/src/components/block-toolbar/test/index.native.js +0 -36
  443. package/src/components/block-types-list/index.native.js +0 -175
  444. package/src/components/block-types-list/style.native.scss +0 -25
  445. package/src/components/block-variation-picker/index.native.js +0 -107
  446. package/src/components/block-variation-picker/style.native.scss +0 -32
  447. package/src/components/button-block-appender/index.native.js +0 -92
  448. package/src/components/button-block-appender/styles.native.scss +0 -43
  449. package/src/components/caption/README.md +0 -44
  450. package/src/components/caption/index.native.js +0 -61
  451. package/src/components/colors-gradients/panel-color-gradient-settings.native.js +0 -59
  452. package/src/components/contrast-checker/index.native.js +0 -113
  453. package/src/components/contrast-checker/style.native.scss +0 -26
  454. package/src/components/convert-to-group-buttons/index.native.js +0 -79
  455. package/src/components/default-block-appender/index.native.js +0 -113
  456. package/src/components/default-block-appender/style.native.scss +0 -18
  457. package/src/components/floating-toolbar/floatingToolbar.android.scss +0 -4
  458. package/src/components/floating-toolbar/floatingToolbar.ios.scss +0 -3
  459. package/src/components/floating-toolbar/index.native.js +0 -141
  460. package/src/components/floating-toolbar/styles.native.scss +0 -43
  461. package/src/components/font-sizes/index.native.js +0 -7
  462. package/src/components/global-styles/color-panel.native.js +0 -207
  463. package/src/components/global-styles/test/use-global-styles-context.native.js +0 -435
  464. package/src/components/global-styles/use-global-styles-context.native.js +0 -592
  465. package/src/components/gradients/index.native.js +0 -2
  466. package/src/components/image-link-destinations/index.native.js +0 -152
  467. package/src/components/image-link-destinations/style.native.scss +0 -16
  468. package/src/components/index.native.js +0 -108
  469. package/src/components/inner-blocks/constants.native.js +0 -5
  470. package/src/components/inner-blocks/index.native.js +0 -221
  471. package/src/components/inner-blocks/warning-max-depth-exceeded.native.js +0 -124
  472. package/src/components/inserter/block-types-tab.native.js +0 -76
  473. package/src/components/inserter/hooks/use-block-type-impressions.native.js +0 -47
  474. package/src/components/inserter/hooks/use-clipboard-block.native.js +0 -40
  475. package/src/components/inserter/index.native.js +0 -424
  476. package/src/components/inserter/menu.native.js +0 -237
  477. package/src/components/inserter/no-results.native.js +0 -49
  478. package/src/components/inserter/reusable-blocks-tab.native.js +0 -45
  479. package/src/components/inserter/search-results.native.js +0 -67
  480. package/src/components/inserter/style.native.scss +0 -83
  481. package/src/components/inserter/tabs.native.js +0 -152
  482. package/src/components/inserter/test/__snapshots__/index.native.js.snap +0 -117
  483. package/src/components/inserter/test/fixtures/index.native.js +0 -12
  484. package/src/components/inserter/test/index.native.js +0 -273
  485. package/src/components/inserter/test/reusable-blocks-tab.native.js +0 -62
  486. package/src/components/inserter/test/utils.native.js +0 -37
  487. package/src/components/inserter/utils.native.js +0 -46
  488. package/src/components/inserter-button/index.native.js +0 -108
  489. package/src/components/inserter-button/style.native.scss +0 -72
  490. package/src/components/inspector-controls/fill.native.js +0 -62
  491. package/src/components/inspector-controls/slot.native.js +0 -35
  492. package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +0 -31
  493. package/src/components/line-height-control/index.native.js +0 -28
  494. package/src/components/media-placeholder/index.native.js +0 -258
  495. package/src/components/media-placeholder/styles.native.scss +0 -108
  496. package/src/components/media-replace-flow/index.native.js +0 -12
  497. package/src/components/media-upload/constants.native.js +0 -14
  498. package/src/components/media-upload/index.native.js +0 -356
  499. package/src/components/media-upload/style.native.scss +0 -4
  500. package/src/components/media-upload/test/index.native.js +0 -172
  501. package/src/components/media-upload-progress/README.md +0 -100
  502. package/src/components/media-upload-progress/constants.js +0 -6
  503. package/src/components/media-upload-progress/index.native.js +0 -233
  504. package/src/components/media-upload-progress/styles.native.scss +0 -15
  505. package/src/components/media-upload-progress/test/index.native.js +0 -220
  506. package/src/components/plain-text/index.native.js +0 -164
  507. package/src/components/plain-text/style.native.scss +0 -10
  508. package/src/components/provider/index.native.js +0 -32
  509. package/src/components/rich-text/embed-handler-picker.native.js +0 -65
  510. package/src/components/rich-text/file-paste-handler.native.js +0 -3
  511. package/src/components/rich-text/format-toolbar/index.native.js +0 -21
  512. package/src/components/rich-text/format-toolbar-container.native.js +0 -16
  513. package/src/components/rich-text/index.native.js +0 -701
  514. package/src/components/rich-text/input-event.native.js +0 -10
  515. package/src/components/rich-text/native/format-edit.js +0 -44
  516. package/src/components/rich-text/native/get-format-colors.native.js +0 -47
  517. package/src/components/rich-text/native/index.js +0 -1
  518. package/src/components/rich-text/native/index.native.js +0 -1389
  519. package/src/components/rich-text/native/style.native.scss +0 -28
  520. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +0 -79
  521. package/src/components/rich-text/native/test/index.native.js +0 -345
  522. package/src/components/rich-text/native/test/performance/rich-text.native.js +0 -44
  523. package/src/components/rich-text/native/toolbar-button-with-options.native.js +0 -61
  524. package/src/components/rich-text/native/use-format-types.js +0 -146
  525. package/src/components/rich-text/remove-browser-shortcuts.native.js +0 -1
  526. package/src/components/rich-text/shortcut.native.js +0 -10
  527. package/src/components/ungroup-button/README.md +0 -23
  528. package/src/components/ungroup-button/index.native.js +0 -77
  529. package/src/components/unsupported-block-details/index.native.js +0 -187
  530. package/src/components/unsupported-block-details/style.native.scss +0 -56
  531. package/src/components/url-input/index.native.js +0 -33
  532. package/src/components/use-block-drop-zone/index.native.js +0 -207
  533. package/src/components/use-on-block-drop/index.native.js +0 -115
  534. package/src/components/use-unsupported-block-editor/index.native.js +0 -59
  535. package/src/components/video-player/gridicon-play.native.js +0 -13
  536. package/src/components/video-player/index.native.js +0 -133
  537. package/src/components/video-player/styles.native.scss +0 -29
  538. package/src/components/warning/index.native.js +0 -64
  539. package/src/components/warning/style.native.scss +0 -47
  540. package/src/hooks/align.native.js +0 -49
  541. package/src/hooks/custom-class-name.native.js +0 -70
  542. package/src/hooks/index.native.js +0 -36
  543. package/src/hooks/layout.native.js +0 -23
  544. package/src/hooks/test/__snapshots__/align.native.js.snap +0 -73
  545. package/src/hooks/test/__snapshots__/anchor.native.js.snap +0 -7
  546. package/src/hooks/test/align.native.js +0 -134
  547. package/src/hooks/test/anchor.native.js +0 -32
  548. package/src/hooks/test/use-editor-wrapper-styles.native.js +0 -282
  549. package/src/hooks/typography.native.js +0 -60
  550. package/src/hooks/use-editor-wrapper-styles.native.js +0 -250
  551. package/src/hooks/use-editor-wrapper-styles.native.scss +0 -12
  552. package/src/index.native.js +0 -6
  553. package/src/private-apis.native.js +0 -21
  554. package/src/store/defaults.native.js +0 -23
@@ -14,6 +14,7 @@ import { store as blockEditorStore } from "../store/index.mjs";
14
14
  import { useBlockElement } from "../components/block-list/use-block-props/use-block-refs.mjs";
15
15
  import InspectorControls from "../components/inspector-controls/index.mjs";
16
16
  import FitTextSizeWarning from "../components/fit-text-size-warning/index.mjs";
17
+ import { unlock } from "../lock-unlock.mjs";
17
18
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
18
19
  var EMPTY_OBJECT = {};
19
20
  var MIN_FONT_SIZE_FOR_WARNING = 12;
@@ -157,9 +158,19 @@ function FitTextControl({
157
158
  fontSize,
158
159
  style
159
160
  }) {
161
+ const hasSelectedStyleState = useSelect(
162
+ (select) => {
163
+ const { hasSelectedStyleState: hasSelectedBlockStyleState } = unlock(select(blockEditorStore));
164
+ return hasSelectedBlockStyleState(clientId);
165
+ },
166
+ [clientId]
167
+ );
160
168
  if (!hasBlockSupport(name, FIT_TEXT_SUPPORT_KEY)) {
161
169
  return null;
162
170
  }
171
+ if (hasSelectedStyleState) {
172
+ return null;
173
+ }
163
174
  return /* @__PURE__ */ jsx(
164
175
  ToolsPanelItem,
165
176
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/fit-text.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useEffect, useCallback, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\nconst EMPTY_OBJECT = {};\nconst MIN_FONT_SIZE_FOR_WARNING = 12;\n\n/**\n * Internal dependencies\n */\nimport { optimizeFitText } from '../utils/fit-text-utils';\nimport { store as blockEditorStore } from '../store';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport InspectorControls from '../components/inspector-controls';\nimport FitTextSizeWarning from '../components/fit-text-size-warning';\n\nexport const FIT_TEXT_SUPPORT_KEY = 'typography.fitText';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fitText` attribute.\n *\n * @param {Object} settings Original block settings.\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition.\n\tif ( settings.attributes?.fitText ) {\n\t\treturn settings;\n\t}\n\n\t// Add fitText attribute.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tfitText: {\n\t\t\t\ttype: 'boolean',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Custom hook to handle fit text functionality in the editor.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.fitText Fit text attribute.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n */\nfunction useFitText( { fitText, name, clientId } ) {\n\tconst [ fontSize, setFontSize ] = useState( null );\n\tconst hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\tconst blockElement = useBlockElement( clientId );\n\n\t// Monitor block attribute changes, parent changes, and block mode.\n\t// Any attribute or parent change may change the available space.\n\t// Block mode is needed to disable fit text when in HTML editing mode.\n\tconst { blockAttributes, parentId, blockMode } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId || ! hasFitTextSupport || ! fitText ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\t\t\tconst _blockMode =\n\t\t\t\tselect( blockEditorStore ).getBlockMode( clientId );\n\t\t\tif ( _blockMode === 'html' ) {\n\t\t\t\treturn { blockMode: _blockMode };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tblockAttributes:\n\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ),\n\t\t\t\tparentId:\n\t\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId ),\n\t\t\t\tblockMode: _blockMode,\n\t\t\t};\n\t\t},\n\t\t[ clientId, hasFitTextSupport, fitText ]\n\t);\n\n\tconst applyFitText = useCallback( () => {\n\t\tif ( ! blockElement || ! hasFitTextSupport || ! fitText ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create style element with unique ID\n\t\tconst styleId = `fit-text-${ clientId }`;\n\t\tlet styleElement = blockElement.ownerDocument.getElementById( styleId );\n\t\tif ( ! styleElement ) {\n\t\t\tstyleElement = blockElement.ownerDocument.createElement( 'style' );\n\t\t\tstyleElement.id = styleId;\n\t\t\tblockElement.ownerDocument.head.appendChild( styleElement );\n\t\t}\n\n\t\tconst blockSelector = `#block-${ clientId }`;\n\n\t\tconst applyFontSizeStyle = ( size ) => {\n\t\t\tif ( size === 0 ) {\n\t\t\t\tstyleElement.textContent = '';\n\t\t\t} else {\n\t\t\t\tstyleElement.textContent = `${ blockSelector } { font-size: ${ size }px !important; }`;\n\t\t\t}\n\t\t};\n\n\t\tconst optimalSize = optimizeFitText( blockElement, applyFontSizeStyle );\n\t\tsetFontSize( optimalSize );\n\t}, [ blockElement, clientId, hasFitTextSupport, fitText ] );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! fitText ||\n\t\t\t! blockElement ||\n\t\t\t! clientId ||\n\t\t\t! hasFitTextSupport ||\n\t\t\tblockMode === 'html'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Store current element value for cleanup\n\t\tconst currentElement = blockElement;\n\t\tconst previousVisibility = currentElement.style.visibility;\n\n\t\t// Store IDs for cleanup\n\t\tlet hideFrameId = null;\n\t\tlet calculateFrameId = null;\n\t\tlet showTimeoutId = null;\n\n\t\t// We are hiding the element doing the calculation of fit text\n\t\t// and then showing it again to avoid the user noticing a flash of potentially\n\t\t// big fitText while the binary search is happening.\n\t\thideFrameId = window.requestAnimationFrame( () => {\n\t\t\tcurrentElement.style.visibility = 'hidden';\n\t\t\t// Wait for browser to render the hidden state\n\t\t\tcalculateFrameId = window.requestAnimationFrame( () => {\n\t\t\t\tapplyFitText();\n\n\t\t\t\t// Using a timeout instead of requestAnimationFrame, because\n\t\t\t\t// with requestAnimationFrame a flash of very high size\n\t\t\t\t// can still occur although rare.\n\t\t\t\tshowTimeoutId = setTimeout( () => {\n\t\t\t\t\tcurrentElement.style.visibility = previousVisibility;\n\t\t\t\t}, 10 );\n\t\t\t} );\n\t\t} );\n\n\t\t// Watch for size changes\n\t\tlet resizeObserver;\n\t\tif ( window.ResizeObserver && currentElement.parentElement ) {\n\t\t\tresizeObserver = new window.ResizeObserver( applyFitText );\n\t\t\tresizeObserver.observe( currentElement.parentElement );\n\t\t\tresizeObserver.observe( currentElement );\n\t\t}\n\n\t\t// Cleanup function\n\t\treturn () => {\n\t\t\t// Cancel pending async operations\n\t\t\tif ( hideFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( hideFrameId );\n\t\t\t}\n\t\t\tif ( calculateFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( calculateFrameId );\n\t\t\t}\n\t\t\tif ( showTimeoutId !== null ) {\n\t\t\t\tclearTimeout( showTimeoutId );\n\t\t\t}\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\n\t\t\tconst styleId = `fit-text-${ clientId }`;\n\t\t\tconst styleElement =\n\t\t\t\tcurrentElement.ownerDocument.getElementById( styleId );\n\t\t\tif ( styleElement ) {\n\t\t\t\tstyleElement.remove();\n\t\t\t}\n\t\t};\n\t}, [\n\t\tfitText,\n\t\tclientId,\n\t\tparentId,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\t// Trigger fit text recalculation when content changes\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfitText &&\n\t\t\tblockElement &&\n\t\t\thasFitTextSupport &&\n\t\t\tblockMode !== 'html'\n\t\t) {\n\t\t\t// Wait for next frame to ensure DOM has updated after content changes\n\t\t\tconst frameId = window.requestAnimationFrame( () => {\n\t\t\t\tif ( blockElement ) {\n\t\t\t\t\tapplyFitText();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn () => window.cancelAnimationFrame( frameId );\n\t\t}\n\t}, [\n\t\tblockAttributes,\n\t\tfitText,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\treturn { fontSize };\n}\n\n/**\n * Fit text control component for the typography panel.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.fontSize Font size slug.\n * @param {Object} props.style Block style object.\n */\nexport function FitTextControl( {\n\tclientId,\n\tfitText = false,\n\tsetAttributes,\n\tname,\n\tfontSize,\n\tstyle,\n} ) {\n\tif ( ! hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => fitText }\n\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\tonDeselect={ () => setAttributes( { fitText: undefined } ) }\n\t\t\tresetAllFilter={ () => ( { fitText: undefined } ) }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\t\tchecked={ fitText }\n\t\t\t\tonChange={ () => {\n\t\t\t\t\tconst newFitText = ! fitText || undefined;\n\t\t\t\t\tconst updates = { fitText: newFitText };\n\n\t\t\t\t\t// When enabling fit text, clear font size if it has a value\n\t\t\t\t\tif ( newFitText ) {\n\t\t\t\t\t\tif ( fontSize ) {\n\t\t\t\t\t\t\tupdates.fontSize = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( style?.typography?.fontSize ) {\n\t\t\t\t\t\t\tupdates.style = {\n\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t\t...style?.typography,\n\t\t\t\t\t\t\t\t\tfontSize: undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tsetAttributes( updates );\n\t\t\t\t} }\n\t\t\t\thelp={\n\t\t\t\t\tfitText\n\t\t\t\t\t\t? __( 'Text will resize to fit its container.' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'The text will resize to fit its container, resetting other font size settings.'\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n\n/**\n * Override props applied to the block element on save.\n *\n * @param {Object} props Additional props applied to the block element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tconst { fitText } = attributes;\n\n\tif ( ! fitText ) {\n\t\treturn props;\n\t}\n\n\t// Add CSS class for frontend detection and styling\n\tconst className = props.className\n\t\t? `${ props.className } has-fit-text`\n\t\t: 'has-fit-text';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\n/**\n * Override props applied to the block element in the editor.\n *\n * @param {Object} props Component props including block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction useBlockProps( { name, fitText } ) {\n\tif ( fitText && hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn {\n\t\t\tclassName: 'has-fit-text',\n\t\t};\n\t}\n\treturn {};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fit-text/addAttribute',\n\taddAttributes\n);\n\nconst hasFitTextSupport = ( blockNameOrType ) => {\n\treturn hasBlockSupport( blockNameOrType, FIT_TEXT_SUPPORT_KEY );\n};\n\n/**\n * Component that handles the fit text font size and displays a warning\n * if the fit text font size is below a minimum threshold.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n * @param {boolean} props.isSelected Whether the block is selected.\n * @return {Element|null} Warning component or null.\n */\nfunction FitTextFontSize( { fitText, name, clientId, isSelected } ) {\n\tconst { fontSize } = useFitText( { fitText, name, clientId } );\n\tif ( isSelected && fontSize && fontSize < MIN_FONT_SIZE_FOR_WARNING ) {\n\t\treturn (\n\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t<FitTextSizeWarning />\n\t\t\t</InspectorControls>\n\t\t);\n\t}\n\treturn null;\n}\n\n/*\n * Fit-text requires that layout calculations be done even when a block is not\n * currently selected. Therefore, the regular hooking approach using an\n * exported `edit` method is not enough, and we must use this HoC with the\n * `editor.BlockEdit` filter.\n */\nconst addFitTextControl = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn function AddFitTextControl( props ) {\n\t\tconst { name, attributes, clientId, isSelected, setAttributes } = props;\n\t\tconst { fitText } = attributes;\n\t\tconst supportsFitText = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\t\tif ( ! supportsFitText ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t\t<FitTextControl\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tfontSize={ attributes.fontSize }\n\t\t\t\t\t\tstyle={ attributes.style }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t\t{ fitText && (\n\t\t\t\t\t<FitTextFontSize\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n}, 'addFitTextControl' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/fit-text/add-fit-text-control',\n\taddFitTextControl\n);\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'fitText', 'fontSize', 'style' ],\n\thasSupport: hasFitTextSupport,\n\tedit: () => null,\n};\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,WAAW,aAAa,gBAAgB;AACjD,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,gCAAgC;AAAA,OAC1B;AACP,SAAS,kCAAkC;AAQ3C,SAAS,uBAAuB;AAChC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,OAAO,wBAAwB;AA6O5B,SAoIA,UApIA,KAoIA,YApIA;AAvPH,IAAM,eAAe,CAAC;AACtB,IAAM,4BAA4B;AAW3B,IAAM,uBAAuB;AASpC,SAAS,cAAe,UAAW;AAClC,MAAK,CAAE,gBAAiB,UAAU,oBAAqB,GAAI;AAC1D,WAAO;AAAA,EACR;AAGA,MAAK,SAAS,YAAY,SAAU;AACnC,WAAO;AAAA,EACR;AAGA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAG,SAAS;AAAA,MACZ,SAAS;AAAA,QACR,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;AAUA,SAAS,WAAY,EAAE,SAAS,MAAM,SAAS,GAAI;AAClD,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,IAAK;AACjD,QAAMA,qBAAoB,gBAAiB,MAAM,oBAAqB;AACtE,QAAM,eAAe,gBAAiB,QAAS;AAK/C,QAAM,EAAE,iBAAiB,UAAU,UAAU,IAAI;AAAA,IAChD,CAAE,WAAY;AACb,UAAK,CAAE,YAAY,CAAEA,sBAAqB,CAAE,SAAU;AACrD,eAAO;AAAA,MACR;AACA,YAAM,aACL,OAAQ,gBAAiB,EAAE,aAAc,QAAS;AACnD,UAAK,eA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\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useEffect, useCallback, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\nconst EMPTY_OBJECT = {};\nconst MIN_FONT_SIZE_FOR_WARNING = 12;\n\n/**\n * Internal dependencies\n */\nimport { optimizeFitText } from '../utils/fit-text-utils';\nimport { store as blockEditorStore } from '../store';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport InspectorControls from '../components/inspector-controls';\nimport FitTextSizeWarning from '../components/fit-text-size-warning';\nimport { unlock } from '../lock-unlock';\n\nexport const FIT_TEXT_SUPPORT_KEY = 'typography.fitText';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fitText` attribute.\n *\n * @param {Object} settings Original block settings.\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition.\n\tif ( settings.attributes?.fitText ) {\n\t\treturn settings;\n\t}\n\n\t// Add fitText attribute.\n\treturn {\n\t\t...settings,\n\t\tattributes: {\n\t\t\t...settings.attributes,\n\t\t\tfitText: {\n\t\t\t\ttype: 'boolean',\n\t\t\t},\n\t\t},\n\t};\n}\n\n/**\n * Custom hook to handle fit text functionality in the editor.\n *\n * @param {Object} props Component props.\n * @param {?boolean} props.fitText Fit text attribute.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n */\nfunction useFitText( { fitText, name, clientId } ) {\n\tconst [ fontSize, setFontSize ] = useState( null );\n\tconst hasFitTextSupport = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\tconst blockElement = useBlockElement( clientId );\n\n\t// Monitor block attribute changes, parent changes, and block mode.\n\t// Any attribute or parent change may change the available space.\n\t// Block mode is needed to disable fit text when in HTML editing mode.\n\tconst { blockAttributes, parentId, blockMode } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId || ! hasFitTextSupport || ! fitText ) {\n\t\t\t\treturn EMPTY_OBJECT;\n\t\t\t}\n\t\t\tconst _blockMode =\n\t\t\t\tselect( blockEditorStore ).getBlockMode( clientId );\n\t\t\tif ( _blockMode === 'html' ) {\n\t\t\t\treturn { blockMode: _blockMode };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tblockAttributes:\n\t\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId ),\n\t\t\t\tparentId:\n\t\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId ),\n\t\t\t\tblockMode: _blockMode,\n\t\t\t};\n\t\t},\n\t\t[ clientId, hasFitTextSupport, fitText ]\n\t);\n\n\tconst applyFitText = useCallback( () => {\n\t\tif ( ! blockElement || ! hasFitTextSupport || ! fitText ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Get or create style element with unique ID\n\t\tconst styleId = `fit-text-${ clientId }`;\n\t\tlet styleElement = blockElement.ownerDocument.getElementById( styleId );\n\t\tif ( ! styleElement ) {\n\t\t\tstyleElement = blockElement.ownerDocument.createElement( 'style' );\n\t\t\tstyleElement.id = styleId;\n\t\t\tblockElement.ownerDocument.head.appendChild( styleElement );\n\t\t}\n\n\t\tconst blockSelector = `#block-${ clientId }`;\n\n\t\tconst applyFontSizeStyle = ( size ) => {\n\t\t\tif ( size === 0 ) {\n\t\t\t\tstyleElement.textContent = '';\n\t\t\t} else {\n\t\t\t\tstyleElement.textContent = `${ blockSelector } { font-size: ${ size }px !important; }`;\n\t\t\t}\n\t\t};\n\n\t\tconst optimalSize = optimizeFitText( blockElement, applyFontSizeStyle );\n\t\tsetFontSize( optimalSize );\n\t}, [ blockElement, clientId, hasFitTextSupport, fitText ] );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! fitText ||\n\t\t\t! blockElement ||\n\t\t\t! clientId ||\n\t\t\t! hasFitTextSupport ||\n\t\t\tblockMode === 'html'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Store current element value for cleanup\n\t\tconst currentElement = blockElement;\n\t\tconst previousVisibility = currentElement.style.visibility;\n\n\t\t// Store IDs for cleanup\n\t\tlet hideFrameId = null;\n\t\tlet calculateFrameId = null;\n\t\tlet showTimeoutId = null;\n\n\t\t// We are hiding the element doing the calculation of fit text\n\t\t// and then showing it again to avoid the user noticing a flash of potentially\n\t\t// big fitText while the binary search is happening.\n\t\thideFrameId = window.requestAnimationFrame( () => {\n\t\t\tcurrentElement.style.visibility = 'hidden';\n\t\t\t// Wait for browser to render the hidden state\n\t\t\tcalculateFrameId = window.requestAnimationFrame( () => {\n\t\t\t\tapplyFitText();\n\n\t\t\t\t// Using a timeout instead of requestAnimationFrame, because\n\t\t\t\t// with requestAnimationFrame a flash of very high size\n\t\t\t\t// can still occur although rare.\n\t\t\t\tshowTimeoutId = setTimeout( () => {\n\t\t\t\t\tcurrentElement.style.visibility = previousVisibility;\n\t\t\t\t}, 10 );\n\t\t\t} );\n\t\t} );\n\n\t\t// Watch for size changes\n\t\tlet resizeObserver;\n\t\tif ( window.ResizeObserver && currentElement.parentElement ) {\n\t\t\tresizeObserver = new window.ResizeObserver( applyFitText );\n\t\t\tresizeObserver.observe( currentElement.parentElement );\n\t\t\tresizeObserver.observe( currentElement );\n\t\t}\n\n\t\t// Cleanup function\n\t\treturn () => {\n\t\t\t// Cancel pending async operations\n\t\t\tif ( hideFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( hideFrameId );\n\t\t\t}\n\t\t\tif ( calculateFrameId !== null ) {\n\t\t\t\twindow.cancelAnimationFrame( calculateFrameId );\n\t\t\t}\n\t\t\tif ( showTimeoutId !== null ) {\n\t\t\t\tclearTimeout( showTimeoutId );\n\t\t\t}\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\n\t\t\tconst styleId = `fit-text-${ clientId }`;\n\t\t\tconst styleElement =\n\t\t\t\tcurrentElement.ownerDocument.getElementById( styleId );\n\t\t\tif ( styleElement ) {\n\t\t\t\tstyleElement.remove();\n\t\t\t}\n\t\t};\n\t}, [\n\t\tfitText,\n\t\tclientId,\n\t\tparentId,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\t// Trigger fit text recalculation when content changes\n\tuseEffect( () => {\n\t\tif (\n\t\t\tfitText &&\n\t\t\tblockElement &&\n\t\t\thasFitTextSupport &&\n\t\t\tblockMode !== 'html'\n\t\t) {\n\t\t\t// Wait for next frame to ensure DOM has updated after content changes\n\t\t\tconst frameId = window.requestAnimationFrame( () => {\n\t\t\t\tif ( blockElement ) {\n\t\t\t\t\tapplyFitText();\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\treturn () => window.cancelAnimationFrame( frameId );\n\t\t}\n\t}, [\n\t\tblockAttributes,\n\t\tfitText,\n\t\tapplyFitText,\n\t\tblockElement,\n\t\thasFitTextSupport,\n\t\tblockMode,\n\t] );\n\n\treturn { fontSize };\n}\n\n/**\n * Fit text control component for the typography panel.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.fontSize Font size slug.\n * @param {Object} props.style Block style object.\n */\nexport function FitTextControl( {\n\tclientId,\n\tfitText = false,\n\tsetAttributes,\n\tname,\n\tfontSize,\n\tstyle,\n} ) {\n\tconst hasSelectedStyleState = useSelect(\n\t\t( select ) => {\n\t\t\tconst { hasSelectedStyleState: hasSelectedBlockStyleState } =\n\t\t\t\tunlock( select( blockEditorStore ) );\n\n\t\t\treturn hasSelectedBlockStyleState( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn null;\n\t}\n\n\tif ( hasSelectedStyleState ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\thasValue={ () => fitText }\n\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\tonDeselect={ () => setAttributes( { fitText: undefined } ) }\n\t\t\tresetAllFilter={ () => ( { fitText: undefined } ) }\n\t\t\tpanelId={ clientId }\n\t\t>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Fit text' ) }\n\t\t\t\tchecked={ fitText }\n\t\t\t\tonChange={ () => {\n\t\t\t\t\tconst newFitText = ! fitText || undefined;\n\t\t\t\t\tconst updates = { fitText: newFitText };\n\n\t\t\t\t\t// When enabling fit text, clear font size if it has a value\n\t\t\t\t\tif ( newFitText ) {\n\t\t\t\t\t\tif ( fontSize ) {\n\t\t\t\t\t\t\tupdates.fontSize = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( style?.typography?.fontSize ) {\n\t\t\t\t\t\t\tupdates.style = {\n\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t\t...style?.typography,\n\t\t\t\t\t\t\t\t\tfontSize: undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tsetAttributes( updates );\n\t\t\t\t} }\n\t\t\t\thelp={\n\t\t\t\t\tfitText\n\t\t\t\t\t\t? __( 'Text will resize to fit its container.' )\n\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t'The text will resize to fit its container, resetting other font size settings.'\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t/>\n\t\t</ToolsPanelItem>\n\t);\n}\n\n/**\n * Override props applied to the block element on save.\n *\n * @param {Object} props Additional props applied to the block element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tconst { fitText } = attributes;\n\n\tif ( ! fitText ) {\n\t\treturn props;\n\t}\n\n\t// Add CSS class for frontend detection and styling\n\tconst className = props.className\n\t\t? `${ props.className } has-fit-text`\n\t\t: 'has-fit-text';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\n/**\n * Override props applied to the block element in the editor.\n *\n * @param {Object} props Component props including block attributes.\n * @param {string} props.name Block name.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @return {Object} Filtered props applied to the block element.\n */\nfunction useBlockProps( { name, fitText } ) {\n\tif ( fitText && hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY ) ) {\n\t\treturn {\n\t\t\tclassName: 'has-fit-text',\n\t\t};\n\t}\n\treturn {};\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fit-text/addAttribute',\n\taddAttributes\n);\n\nconst hasFitTextSupport = ( blockNameOrType ) => {\n\treturn hasBlockSupport( blockNameOrType, FIT_TEXT_SUPPORT_KEY );\n};\n\n/**\n * Component that handles the fit text font size and displays a warning\n * if the fit text font size is below a minimum threshold.\n *\n * @param {Object} props Component props.\n * @param {boolean} props.fitText Whether fit text is enabled.\n * @param {string} props.name Block name.\n * @param {string} props.clientId Block client ID.\n * @param {boolean} props.isSelected Whether the block is selected.\n * @return {Element|null} Warning component or null.\n */\nfunction FitTextFontSize( { fitText, name, clientId, isSelected } ) {\n\tconst { fontSize } = useFitText( { fitText, name, clientId } );\n\tif ( isSelected && fontSize && fontSize < MIN_FONT_SIZE_FOR_WARNING ) {\n\t\treturn (\n\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t<FitTextSizeWarning />\n\t\t\t</InspectorControls>\n\t\t);\n\t}\n\treturn null;\n}\n\n/*\n * Fit-text requires that layout calculations be done even when a block is not\n * currently selected. Therefore, the regular hooking approach using an\n * exported `edit` method is not enough, and we must use this HoC with the\n * `editor.BlockEdit` filter.\n */\nconst addFitTextControl = createHigherOrderComponent( ( BlockEdit ) => {\n\treturn function AddFitTextControl( props ) {\n\t\tconst { name, attributes, clientId, isSelected, setAttributes } = props;\n\t\tconst { fitText } = attributes;\n\t\tconst supportsFitText = hasBlockSupport( name, FIT_TEXT_SUPPORT_KEY );\n\t\tif ( ! supportsFitText ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t<InspectorControls group=\"typography\">\n\t\t\t\t\t<FitTextControl\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tfontSize={ attributes.fontSize }\n\t\t\t\t\t\tstyle={ attributes.style }\n\t\t\t\t\t/>\n\t\t\t\t</InspectorControls>\n\t\t\t\t{ fitText && (\n\t\t\t\t\t<FitTextFontSize\n\t\t\t\t\t\tfitText={ fitText }\n\t\t\t\t\t\tname={ name }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n}, 'addFitTextControl' );\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/fit-text/add-fit-text-control',\n\taddFitTextControl\n);\n\nexport default {\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'fitText', 'fontSize', 'style' ],\n\thasSupport: hasFitTextSupport,\n\tedit: () => null,\n};\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,WAAW,aAAa,gBAAgB;AACjD,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,gCA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TS = {
19
19
  mobile: "@media (width <= 480px)",
20
20
  tablet: "@media (480px < width <= 782px)"
21
21
  };
22
+ var FLEX_CHILD_LAYOUT_VALUES = {
23
+ fit: "fit",
24
+ grow: "fill",
25
+ max: "fixed",
26
+ fixed: "fixedNoShrink"
27
+ };
28
+ var FLEX_SIZE_VALUES = [
29
+ FLEX_CHILD_LAYOUT_VALUES.max,
30
+ FLEX_CHILD_LAYOUT_VALUES.fixed
31
+ ];
32
+ function isFlexSizeValue(value) {
33
+ return FLEX_SIZE_VALUES.includes(value);
34
+ }
22
35
  function serializeRule({ selector, declarations }) {
23
36
  return `${selector} {
24
37
  ${Object.entries(declarations).map(([property, value]) => `${property}: ${value}`).join("; ")};
@@ -45,14 +58,26 @@ function getChildLayoutStyleRules({
45
58
  columnSpan,
46
59
  rowSpan
47
60
  } = effectiveLayout;
61
+ const baseSelfStretch = layout.selfStretch;
48
62
  const { columnCount, minimumColumnWidth } = parentLayout;
49
63
  const rules = [];
50
64
  const declarations = {};
51
65
  if (!hasViewportOverrides || hasViewportOverride("selfStretch") || hasViewportOverride("flexSize")) {
52
- if (selfStretch === "fixed" && flexSize) {
66
+ if (hasViewportOverrides && (selfStretch === FLEX_CHILD_LAYOUT_VALUES.fit || selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow) && isFlexSizeValue(baseSelfStretch) && layout.flexSize) {
67
+ declarations["flex-basis"] = "unset";
68
+ if (baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed) {
69
+ declarations["flex-shrink"] = "unset";
70
+ }
71
+ }
72
+ if (isFlexSizeValue(selfStretch) && flexSize) {
53
73
  declarations["flex-basis"] = flexSize;
74
+ if (selfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed) {
75
+ declarations["flex-shrink"] = "0";
76
+ } else if (hasViewportOverrides && baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed) {
77
+ declarations["flex-shrink"] = "unset";
78
+ }
54
79
  declarations["box-sizing"] = "border-box";
55
- } else if (selfStretch === "fill") {
80
+ } else if (selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow) {
56
81
  declarations["flex-grow"] = "1";
57
82
  }
58
83
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/layout-child.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useStyleOverride } from './utils';\nimport { useLayout } from '../components/block-list/layout';\nimport {\n\tGridVisualizer,\n\tGridItemResizer,\n\tGridItemMovers,\n} from '../components/grid';\nimport useBlockVisibility from '../components/block-visibility/use-block-visibility';\nimport { deviceTypeKey } from '../store/private-keys';\nimport { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';\n\n// Used for generating the instance ID\nconst LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};\n// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS.\nconst RESPONSIVE_BREAKPOINTS = {\n\tmobile: '@media (width <= 480px)',\n\ttablet: '@media (480px < width <= 782px)',\n};\n\nfunction serializeRule( { selector, declarations } ) {\n\treturn `${ selector } {\n\t\t${ Object.entries( declarations )\n\t\t\t.map( ( [ property, value ] ) => `${ property }: ${ value }` )\n\t\t\t.join( '; ' ) };\n\t}`;\n}\n\nexport function getChildLayoutStyleRules( {\n\tselector,\n\tlayout = {},\n\tviewportOverrides,\n\tparentLayout = {},\n\tincludeContainerQuery = true,\n} ) {\n\tconst hasViewportOverrides = viewportOverrides !== undefined;\n\tconst effectiveLayout = hasViewportOverrides\n\t\t? {\n\t\t\t\t...layout,\n\t\t\t\t...viewportOverrides,\n\t\t }\n\t\t: layout;\n\tconst hasViewportOverride = ( key ) =>\n\t\tObject.hasOwn( viewportOverrides || {}, key );\n\tconst {\n\t\tselfStretch,\n\t\tflexSize,\n\t\tcolumnStart,\n\t\trowStart,\n\t\tcolumnSpan,\n\t\trowSpan,\n\t} = effectiveLayout;\n\tconst { columnCount, minimumColumnWidth } = parentLayout;\n\tconst rules = [];\n\n\tconst declarations = {};\n\tif (\n\t\t! hasViewportOverrides ||\n\t\thasViewportOverride( 'selfStretch' ) ||\n\t\thasViewportOverride( 'flexSize' )\n\t) {\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tdeclarations[ 'flex-basis' ] = flexSize;\n\t\t\tdeclarations[ 'box-sizing' ] = 'border-box';\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tdeclarations[ 'flex-grow' ] = '1';\n\t\t}\n\t}\n\n\tif (\n\t\t! hasViewportOverrides ||\n\t\thasViewportOverride( 'columnStart' ) ||\n\t\thasViewportOverride( 'columnSpan' )\n\t) {\n\t\tif ( columnStart && columnSpan ) {\n\t\t\tdeclarations[\n\t\t\t\t'grid-column'\n\t\t\t] = `${ columnStart } / span ${ columnSpan }`;\n\t\t} else if ( columnStart ) {\n\t\t\tdeclarations[ 'grid-column' ] = `${ columnStart }`;\n\t\t} else if ( columnSpan ) {\n\t\t\tdeclarations[ 'grid-column' ] = `span ${ columnSpan }`;\n\t\t}\n\t}\n\n\tif (\n\t\t! hasViewportOverrides ||\n\t\thasViewportOverride( 'rowStart' ) ||\n\t\thasViewportOverride( 'rowSpan' )\n\t) {\n\t\tif ( rowStart && rowSpan ) {\n\t\t\tdeclarations[ 'grid-row' ] = `${ rowStart } / span ${ rowSpan }`;\n\t\t} else if ( rowStart ) {\n\t\t\tdeclarations[ 'grid-row' ] = `${ rowStart }`;\n\t\t} else if ( rowSpan ) {\n\t\t\tdeclarations[ 'grid-row' ] = `span ${ rowSpan }`;\n\t\t}\n\t}\n\n\tif ( Object.keys( declarations ).length ) {\n\t\trules.push( { selector, declarations } );\n\t}\n\n\tif ( includeContainerQuery && ! hasViewportOverrides ) {\n\t\t/**\n\t\t * If minimumColumnWidth is set on the parent, or if no\n\t\t * columnCount is set, the grid is responsive so a\n\t\t * container query is needed for the span to resize.\n\t\t */\n\t\tif (\n\t\t\t( columnSpan || columnStart ) &&\n\t\t\t( minimumColumnWidth || ! columnCount )\n\t\t) {\n\t\t\tlet parentColumnValue = parseFloat( minimumColumnWidth );\n\t\t\t/**\n\t\t\t * 12rem is the default minimumColumnWidth value.\n\t\t\t * If parentColumnValue is not a number, default to 12.\n\t\t\t */\n\t\t\tif ( isNaN( parentColumnValue ) ) {\n\t\t\t\tparentColumnValue = 12;\n\t\t\t}\n\n\t\t\tlet parentColumnUnit = minimumColumnWidth?.replace(\n\t\t\t\tparentColumnValue,\n\t\t\t\t''\n\t\t\t);\n\t\t\t/**\n\t\t\t * Check that parent column unit is either 'px', 'rem' or 'em'.\n\t\t\t * If not, default to 'rem'.\n\t\t\t */\n\t\t\tif ( ! [ 'px', 'rem', 'em' ].includes( parentColumnUnit ) ) {\n\t\t\t\tparentColumnUnit = 'rem';\n\t\t\t}\n\n\t\t\tlet numColsToBreakAt = 2;\n\n\t\t\tif ( columnSpan && columnStart ) {\n\t\t\t\tnumColsToBreakAt = columnSpan + columnStart - 1;\n\t\t\t} else if ( columnSpan ) {\n\t\t\t\tnumColsToBreakAt = columnSpan;\n\t\t\t} else {\n\t\t\t\tnumColsToBreakAt = columnStart;\n\t\t\t}\n\n\t\t\tconst defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5;\n\t\t\tconst containerQueryValue =\n\t\t\t\tnumColsToBreakAt * parentColumnValue +\n\t\t\t\t( numColsToBreakAt - 1 ) * defaultGapValue;\n\t\t\t// For blocks that only span one column, we want to remove any rowStart values as\n\t\t\t// the container reduces in size, so that blocks are still arranged in markup order.\n\t\t\tconst minimumContainerQueryValue =\n\t\t\t\tparentColumnValue * 2 + defaultGapValue - 1;\n\t\t\t// If a span is set we want to preserve it as long as possible, otherwise we just reset the value.\n\t\t\tconst gridColumnValue =\n\t\t\t\tcolumnSpan && columnSpan > 1 ? '1/-1' : 'auto';\n\n\t\t\trules.push( {\n\t\t\t\trulesGroup: `@container (max-width: ${ Math.max(\n\t\t\t\t\tcontainerQueryValue,\n\t\t\t\t\tminimumContainerQueryValue\n\t\t\t\t) }${ parentColumnUnit })`,\n\t\t\t\tselector,\n\t\t\t\tdeclarations: {\n\t\t\t\t\t'grid-column': gridColumnValue,\n\t\t\t\t\t'grid-row': 'auto',\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}\n\n\treturn rules;\n}\n\nexport function getChildLayoutStyles( {\n\tselector,\n\tlayout = {},\n\tparentLayout = {},\n\tincludeContainerQuery = true,\n} ) {\n\treturn getChildLayoutStyleRules( {\n\t\tselector,\n\t\tlayout,\n\t\tparentLayout,\n\t\tincludeContainerQuery,\n\t} )\n\t\t.map( ( rule ) => {\n\t\t\tconst serializedRule = serializeRule( rule );\n\t\t\treturn rule.rulesGroup\n\t\t\t\t? `${ rule.rulesGroup } {\n\t\t\t\t${ serializedRule }\n\t\t\t}`\n\t\t\t\t: serializedRule;\n\t\t} )\n\t\t.join( '' );\n}\n\nexport function getResponsiveChildLayoutStyles( {\n\tstyle = {},\n\tselector,\n\tparentLayout = {},\n} ) {\n\tconst baseLayout = style?.layout ?? {};\n\n\treturn Object.entries( RESPONSIVE_BREAKPOINTS )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportLayout = style?.[ viewport ]?.layout;\n\t\t\tif ( ! viewportLayout || ! Object.keys( viewportLayout ).length ) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst viewportRules = getChildLayoutStyleRules( {\n\t\t\t\tselector,\n\t\t\t\tlayout: baseLayout,\n\t\t\t\tviewportOverrides: viewportLayout,\n\t\t\t\tparentLayout,\n\t\t\t\tincludeContainerQuery: false,\n\t\t\t} );\n\t\t\tconst css = viewportRules.map( serializeRule ).join( '' );\n\n\t\t\treturn css ? `${ mediaQuery }{${ css }}` : '';\n\t\t} )\n\t\t.filter( Boolean )\n\t\t.join( '' );\n}\n\nfunction useBlockPropsChildLayoutStyles( { style } ) {\n\tconst shouldRenderChildLayoutStyles = useSelect( ( select ) => {\n\t\treturn ! select( blockEditorStore ).getSettings().disableLayoutStyles;\n\t} );\n\tconst layout = style?.layout ?? {};\n\tconst { columnStart, rowStart, columnSpan, rowSpan } = layout;\n\tconst parentLayout = useLayout() || {};\n\tconst id = useInstanceId( LAYOUT_CHILD_BLOCK_PROPS_REFERENCE );\n\tconst selector = `.wp-container-content-${ id }`;\n\n\t// Check that the grid layout attributes are of the correct type, so that we don't accidentally\n\t// write code that stores a string attribute instead of a number.\n\tif ( process.env.NODE_ENV === 'development' ) {\n\t\tif ( columnStart && typeof columnStart !== 'number' ) {\n\t\t\tthrow new Error( 'columnStart must be a number' );\n\t\t}\n\t\tif ( rowStart && typeof rowStart !== 'number' ) {\n\t\t\tthrow new Error( 'rowStart must be a number' );\n\t\t}\n\t\tif ( columnSpan && typeof columnSpan !== 'number' ) {\n\t\t\tthrow new Error( 'columnSpan must be a number' );\n\t\t}\n\t\tif ( rowSpan && typeof rowSpan !== 'number' ) {\n\t\t\tthrow new Error( 'rowSpan must be a number' );\n\t\t}\n\t}\n\n\tlet css = '';\n\tif ( shouldRenderChildLayoutStyles ) {\n\t\tcss = [\n\t\t\tgetChildLayoutStyles( {\n\t\t\t\tselector,\n\t\t\t\tlayout,\n\t\t\t\tparentLayout,\n\t\t\t} ),\n\t\t\tgetResponsiveChildLayoutStyles( {\n\t\t\t\tstyle,\n\t\t\t\tselector,\n\t\t\t\tparentLayout,\n\t\t\t} ),\n\t\t].join( '' );\n\t}\n\n\tuseStyleOverride( { css } );\n\n\t// Only attach a container class if there is generated CSS to be attached.\n\tif ( ! css ) {\n\t\treturn;\n\t}\n\n\t// Attach a `wp-container-content` id-based classname.\n\treturn { className: `wp-container-content-${ id }` };\n}\n\nfunction ChildLayoutControlsPure( { clientId, style, setAttributes } ) {\n\tconst parentLayout = useLayout() || {};\n\tconst {\n\t\ttype: parentLayoutType = 'default',\n\t\tallowSizingOnChildren = false,\n\t\tisManualPlacement,\n\t} = parentLayout;\n\n\tif ( parentLayoutType !== 'grid' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<GridTools\n\t\t\tclientId={ clientId }\n\t\t\tstyle={ style }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tallowSizingOnChildren={ allowSizingOnChildren }\n\t\t\tisManualPlacement={ isManualPlacement }\n\t\t\tparentLayout={ parentLayout }\n\t\t/>\n\t);\n}\n\nfunction GridTools( {\n\tclientId,\n\tstyle,\n\tsetAttributes,\n\tallowSizingOnChildren,\n\tisManualPlacement,\n\tparentLayout,\n} ) {\n\tconst {\n\t\trootClientId,\n\t\tisVisible,\n\t\tparentBlockVisibility,\n\t\tblockBlockVisibility,\n\t\tdeviceType,\n\t\tisChildBlockAGrid,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId( clientId );\n\n\t\t\tif (\n\t\t\t\tgetTemplateLock( _rootClientId ) ||\n\t\t\t\tgetBlockEditingMode( _rootClientId ) !== 'default'\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\tisVisible: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst parentAttributes = getBlockAttributes( _rootClientId );\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\tconst settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible: true,\n\t\t\t\tparentBlockVisibility:\n\t\t\t\t\tparentAttributes?.metadata?.blockVisibility,\n\t\t\t\tblockBlockVisibility:\n\t\t\t\t\tblockAttributes?.metadata?.blockVisibility,\n\t\t\t\tdeviceType:\n\t\t\t\t\tsettings?.[ deviceTypeKey ]?.toLowerCase() ||\n\t\t\t\t\tBLOCK_VISIBILITY_VIEWPORTS.desktop.key,\n\t\t\t\t// Check if the selected child block is itself a grid.\n\t\t\t\tisChildBlockAGrid: blockAttributes?.layout?.type === 'grid',\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { isBlockCurrentlyHidden: isParentBlockCurrentlyHidden } =\n\t\tuseBlockVisibility( {\n\t\t\tblockVisibility: parentBlockVisibility,\n\t\t\tdeviceType,\n\t\t} );\n\n\tconst { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } =\n\t\tuseBlockVisibility( {\n\t\t\tblockVisibility: blockBlockVisibility,\n\t\t\tdeviceType,\n\t\t} );\n\n\t// Use useState() instead of useRef() so that GridItemResizer updates when ref is set.\n\tconst [ resizerBounds, setResizerBounds ] = useState();\n\n\tconst childGridClientId = isChildBlockAGrid ? clientId : undefined;\n\n\tif ( ! isVisible || isParentBlockCurrentlyHidden ) {\n\t\treturn null;\n\t}\n\n\tconst showResizer = allowSizingOnChildren && ! isBlockItselfCurrentlyHidden;\n\n\tfunction updateLayout( layout ) {\n\t\tsetAttributes( {\n\t\t\tstyle: {\n\t\t\t\t...style,\n\t\t\t\tlayout: {\n\t\t\t\t\t...style?.layout,\n\t\t\t\t\t...layout,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<GridVisualizer\n\t\t\t\tclientId={ rootClientId }\n\t\t\t\tcontentRef={ setResizerBounds }\n\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\tchildGridClientId={ childGridClientId }\n\t\t\t/>\n\t\t\t{ showResizer && (\n\t\t\t\t<GridItemResizer\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t// Don't allow resizing beyond the grid visualizer.\n\t\t\t\t\tbounds={ resizerBounds }\n\t\t\t\t\tonChange={ updateLayout }\n\t\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isManualPlacement &&\n\t\t\t\twindow.__experimentalEnableGridInteractivity && (\n\t\t\t\t\t<GridItemMovers\n\t\t\t\t\t\tlayout={ style?.layout }\n\t\t\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\t\t\tonChange={ updateLayout }\n\t\t\t\t\t\tgridClientId={ rootClientId }\n\t\t\t\t\t\tblockClientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tuseBlockProps: useBlockPropsChildLayoutStyles,\n\tedit: ChildLayoutControlsPure,\n\tattributeKeys: [ 'style' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],
5
- "mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAKzB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,wBAAwB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AA0RzC,SAyGA,UAzGA,KAyGA,YAzGA;AAvRF,IAAM,qCAAqC,CAAC;AAE5C,IAAM,yBAAyB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AACT;AAEA,SAAS,cAAe,EAAE,UAAU,aAAa,GAAI;AACpD,SAAO,GAAI,QAAS;AAAA,IAChB,OAAO,QAAS,YAAa,EAC9B,IAAK,CAAE,CAAE,UAAU,KAAM,MAAO,GAAI,QAAS,KAAM,KAAM,EAAG,EAC5D,KAAM,IAAK,CAAE;AAAA;AAEjB;AAEO,SAAS,yBAA0B;AAAA,EACzC;AAAA,EACA,SAAS,CAAC;AAAA,EACV;AAAA,EACA,eAAe,CAAC;AAAA,EAChB,wBAAwB;AACzB,GAAI;AACH,QAAM,uBAAuB,sBAAsB;AACnD,QAAM,kBAAkB,uBACrB;AAAA,IAC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QAAS,OAAO;AAAA,QAChB;AAAA,QACA,UAAW;AAAA,QACX,cAAe;AAAA,QACf,eAAgB;AAAA;AAAA,IACjB;AAAA,KAEH;AAEF;AAEA,IAAO,uBAAQ;AAAA,EACd,eAAe;AAAA,EACf,MAAM;AAAA,EACN,eAAe,CAAE,OAAQ;AAAA,EACzB,aAAa;AACZ,WAAO;AAAA,EACR;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useStyleOverride } from './utils';\nimport { useLayout } from '../components/block-list/layout';\nimport {\n\tGridVisualizer,\n\tGridItemResizer,\n\tGridItemMovers,\n} from '../components/grid';\nimport useBlockVisibility from '../components/block-visibility/use-block-visibility';\nimport { deviceTypeKey } from '../store/private-keys';\nimport { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';\n\n// Used for generating the instance ID\nconst LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};\n// Keep in sync with WP_Theme_JSON_Gutenberg::RESPONSIVE_BREAKPOINTS.\nconst RESPONSIVE_BREAKPOINTS = {\n\tmobile: '@media (width <= 480px)',\n\ttablet: '@media (480px < width <= 782px)',\n};\n\n// These are the serialized `selfStretch` values. `max` used to be called\n// \"Fixed\" in the UI, but was renamed and replaced by `fixedNoShrink`.\nconst FLEX_CHILD_LAYOUT_VALUES = {\n\tfit: 'fit',\n\tgrow: 'fill',\n\tmax: 'fixed',\n\tfixed: 'fixedNoShrink',\n};\n\nconst FLEX_SIZE_VALUES = [\n\tFLEX_CHILD_LAYOUT_VALUES.max,\n\tFLEX_CHILD_LAYOUT_VALUES.fixed,\n];\n\nfunction isFlexSizeValue( value ) {\n\treturn FLEX_SIZE_VALUES.includes( value );\n}\n\nfunction serializeRule( { selector, declarations } ) {\n\treturn `${ selector } {\n\t\t${ Object.entries( declarations )\n\t\t\t.map( ( [ property, value ] ) => `${ property }: ${ value }` )\n\t\t\t.join( '; ' ) };\n\t}`;\n}\n\nexport function getChildLayoutStyleRules( {\n\tselector,\n\tlayout = {},\n\tviewportOverrides,\n\tparentLayout = {},\n\tincludeContainerQuery = true,\n} ) {\n\tconst hasViewportOverrides = viewportOverrides !== undefined;\n\tconst effectiveLayout = hasViewportOverrides\n\t\t? {\n\t\t\t\t...layout,\n\t\t\t\t...viewportOverrides,\n\t\t }\n\t\t: layout;\n\tconst hasViewportOverride = ( key ) =>\n\t\tObject.hasOwn( viewportOverrides || {}, key );\n\tconst {\n\t\tselfStretch,\n\t\tflexSize,\n\t\tcolumnStart,\n\t\trowStart,\n\t\tcolumnSpan,\n\t\trowSpan,\n\t} = effectiveLayout;\n\tconst baseSelfStretch = layout.selfStretch;\n\tconst { columnCount, minimumColumnWidth } = parentLayout;\n\tconst rules = [];\n\n\tconst declarations = {};\n\tif (\n\t\t! hasViewportOverrides ||\n\t\thasViewportOverride( 'selfStretch' ) ||\n\t\thasViewportOverride( 'flexSize' )\n\t) {\n\t\tif (\n\t\t\thasViewportOverrides &&\n\t\t\t( selfStretch === FLEX_CHILD_LAYOUT_VALUES.fit ||\n\t\t\t\tselfStretch === FLEX_CHILD_LAYOUT_VALUES.grow ) &&\n\t\t\tisFlexSizeValue( baseSelfStretch ) &&\n\t\t\tlayout.flexSize\n\t\t) {\n\t\t\tdeclarations[ 'flex-basis' ] = 'unset';\n\t\t\tif ( baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed ) {\n\t\t\t\tdeclarations[ 'flex-shrink' ] = 'unset';\n\t\t\t}\n\t\t}\n\t\tif ( isFlexSizeValue( selfStretch ) && flexSize ) {\n\t\t\tdeclarations[ 'flex-basis' ] = flexSize;\n\t\t\tif ( selfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed ) {\n\t\t\t\tdeclarations[ 'flex-shrink' ] = '0';\n\t\t\t} else if (\n\t\t\t\thasViewportOverrides &&\n\t\t\t\tbaseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed\n\t\t\t) {\n\t\t\t\tdeclarations[ 'flex-shrink' ] = 'unset';\n\t\t\t}\n\t\t\tdeclarations[ 'box-sizing' ] = 'border-box';\n\t\t} else if ( selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow ) {\n\t\t\tdeclarations[ 'flex-grow' ] = '1';\n\t\t}\n\t}\n\n\tif (\n\t\t! hasViewportOverrides ||\n\t\thasViewportOverride( 'columnStart' ) ||\n\t\thasViewportOverride( 'columnSpan' )\n\t) {\n\t\tif ( columnStart && columnSpan ) {\n\t\t\tdeclarations[\n\t\t\t\t'grid-column'\n\t\t\t] = `${ columnStart } / span ${ columnSpan }`;\n\t\t} else if ( columnStart ) {\n\t\t\tdeclarations[ 'grid-column' ] = `${ columnStart }`;\n\t\t} else if ( columnSpan ) {\n\t\t\tdeclarations[ 'grid-column' ] = `span ${ columnSpan }`;\n\t\t}\n\t}\n\n\tif (\n\t\t! hasViewportOverrides ||\n\t\thasViewportOverride( 'rowStart' ) ||\n\t\thasViewportOverride( 'rowSpan' )\n\t) {\n\t\tif ( rowStart && rowSpan ) {\n\t\t\tdeclarations[ 'grid-row' ] = `${ rowStart } / span ${ rowSpan }`;\n\t\t} else if ( rowStart ) {\n\t\t\tdeclarations[ 'grid-row' ] = `${ rowStart }`;\n\t\t} else if ( rowSpan ) {\n\t\t\tdeclarations[ 'grid-row' ] = `span ${ rowSpan }`;\n\t\t}\n\t}\n\n\tif ( Object.keys( declarations ).length ) {\n\t\trules.push( { selector, declarations } );\n\t}\n\n\tif ( includeContainerQuery && ! hasViewportOverrides ) {\n\t\t/**\n\t\t * If minimumColumnWidth is set on the parent, or if no\n\t\t * columnCount is set, the grid is responsive so a\n\t\t * container query is needed for the span to resize.\n\t\t */\n\t\tif (\n\t\t\t( columnSpan || columnStart ) &&\n\t\t\t( minimumColumnWidth || ! columnCount )\n\t\t) {\n\t\t\tlet parentColumnValue = parseFloat( minimumColumnWidth );\n\t\t\t/**\n\t\t\t * 12rem is the default minimumColumnWidth value.\n\t\t\t * If parentColumnValue is not a number, default to 12.\n\t\t\t */\n\t\t\tif ( isNaN( parentColumnValue ) ) {\n\t\t\t\tparentColumnValue = 12;\n\t\t\t}\n\n\t\t\tlet parentColumnUnit = minimumColumnWidth?.replace(\n\t\t\t\tparentColumnValue,\n\t\t\t\t''\n\t\t\t);\n\t\t\t/**\n\t\t\t * Check that parent column unit is either 'px', 'rem' or 'em'.\n\t\t\t * If not, default to 'rem'.\n\t\t\t */\n\t\t\tif ( ! [ 'px', 'rem', 'em' ].includes( parentColumnUnit ) ) {\n\t\t\t\tparentColumnUnit = 'rem';\n\t\t\t}\n\n\t\t\tlet numColsToBreakAt = 2;\n\n\t\t\tif ( columnSpan && columnStart ) {\n\t\t\t\tnumColsToBreakAt = columnSpan + columnStart - 1;\n\t\t\t} else if ( columnSpan ) {\n\t\t\t\tnumColsToBreakAt = columnSpan;\n\t\t\t} else {\n\t\t\t\tnumColsToBreakAt = columnStart;\n\t\t\t}\n\n\t\t\tconst defaultGapValue = parentColumnUnit === 'px' ? 24 : 1.5;\n\t\t\tconst containerQueryValue =\n\t\t\t\tnumColsToBreakAt * parentColumnValue +\n\t\t\t\t( numColsToBreakAt - 1 ) * defaultGapValue;\n\t\t\t// For blocks that only span one column, we want to remove any rowStart values as\n\t\t\t// the container reduces in size, so that blocks are still arranged in markup order.\n\t\t\tconst minimumContainerQueryValue =\n\t\t\t\tparentColumnValue * 2 + defaultGapValue - 1;\n\t\t\t// If a span is set we want to preserve it as long as possible, otherwise we just reset the value.\n\t\t\tconst gridColumnValue =\n\t\t\t\tcolumnSpan && columnSpan > 1 ? '1/-1' : 'auto';\n\n\t\t\trules.push( {\n\t\t\t\trulesGroup: `@container (max-width: ${ Math.max(\n\t\t\t\t\tcontainerQueryValue,\n\t\t\t\t\tminimumContainerQueryValue\n\t\t\t\t) }${ parentColumnUnit })`,\n\t\t\t\tselector,\n\t\t\t\tdeclarations: {\n\t\t\t\t\t'grid-column': gridColumnValue,\n\t\t\t\t\t'grid-row': 'auto',\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}\n\n\treturn rules;\n}\n\nexport function getChildLayoutStyles( {\n\tselector,\n\tlayout = {},\n\tparentLayout = {},\n\tincludeContainerQuery = true,\n} ) {\n\treturn getChildLayoutStyleRules( {\n\t\tselector,\n\t\tlayout,\n\t\tparentLayout,\n\t\tincludeContainerQuery,\n\t} )\n\t\t.map( ( rule ) => {\n\t\t\tconst serializedRule = serializeRule( rule );\n\t\t\treturn rule.rulesGroup\n\t\t\t\t? `${ rule.rulesGroup } {\n\t\t\t\t${ serializedRule }\n\t\t\t}`\n\t\t\t\t: serializedRule;\n\t\t} )\n\t\t.join( '' );\n}\n\nexport function getResponsiveChildLayoutStyles( {\n\tstyle = {},\n\tselector,\n\tparentLayout = {},\n} ) {\n\tconst baseLayout = style?.layout ?? {};\n\n\treturn Object.entries( RESPONSIVE_BREAKPOINTS )\n\t\t.map( ( [ viewport, mediaQuery ] ) => {\n\t\t\tconst viewportLayout = style?.[ viewport ]?.layout;\n\t\t\tif ( ! viewportLayout || ! Object.keys( viewportLayout ).length ) {\n\t\t\t\treturn '';\n\t\t\t}\n\n\t\t\tconst viewportRules = getChildLayoutStyleRules( {\n\t\t\t\tselector,\n\t\t\t\tlayout: baseLayout,\n\t\t\t\tviewportOverrides: viewportLayout,\n\t\t\t\tparentLayout,\n\t\t\t\tincludeContainerQuery: false,\n\t\t\t} );\n\t\t\tconst css = viewportRules.map( serializeRule ).join( '' );\n\n\t\t\treturn css ? `${ mediaQuery }{${ css }}` : '';\n\t\t} )\n\t\t.filter( Boolean )\n\t\t.join( '' );\n}\n\nfunction useBlockPropsChildLayoutStyles( { style } ) {\n\tconst shouldRenderChildLayoutStyles = useSelect( ( select ) => {\n\t\treturn ! select( blockEditorStore ).getSettings().disableLayoutStyles;\n\t} );\n\tconst layout = style?.layout ?? {};\n\tconst { columnStart, rowStart, columnSpan, rowSpan } = layout;\n\tconst parentLayout = useLayout() || {};\n\tconst id = useInstanceId( LAYOUT_CHILD_BLOCK_PROPS_REFERENCE );\n\tconst selector = `.wp-container-content-${ id }`;\n\n\t// Check that the grid layout attributes are of the correct type, so that we don't accidentally\n\t// write code that stores a string attribute instead of a number.\n\tif ( process.env.NODE_ENV === 'development' ) {\n\t\tif ( columnStart && typeof columnStart !== 'number' ) {\n\t\t\tthrow new Error( 'columnStart must be a number' );\n\t\t}\n\t\tif ( rowStart && typeof rowStart !== 'number' ) {\n\t\t\tthrow new Error( 'rowStart must be a number' );\n\t\t}\n\t\tif ( columnSpan && typeof columnSpan !== 'number' ) {\n\t\t\tthrow new Error( 'columnSpan must be a number' );\n\t\t}\n\t\tif ( rowSpan && typeof rowSpan !== 'number' ) {\n\t\t\tthrow new Error( 'rowSpan must be a number' );\n\t\t}\n\t}\n\n\tlet css = '';\n\tif ( shouldRenderChildLayoutStyles ) {\n\t\tcss = [\n\t\t\tgetChildLayoutStyles( {\n\t\t\t\tselector,\n\t\t\t\tlayout,\n\t\t\t\tparentLayout,\n\t\t\t} ),\n\t\t\tgetResponsiveChildLayoutStyles( {\n\t\t\t\tstyle,\n\t\t\t\tselector,\n\t\t\t\tparentLayout,\n\t\t\t} ),\n\t\t].join( '' );\n\t}\n\n\tuseStyleOverride( { css } );\n\n\t// Only attach a container class if there is generated CSS to be attached.\n\tif ( ! css ) {\n\t\treturn;\n\t}\n\n\t// Attach a `wp-container-content` id-based classname.\n\treturn { className: `wp-container-content-${ id }` };\n}\n\nfunction ChildLayoutControlsPure( { clientId, style, setAttributes } ) {\n\tconst parentLayout = useLayout() || {};\n\tconst {\n\t\ttype: parentLayoutType = 'default',\n\t\tallowSizingOnChildren = false,\n\t\tisManualPlacement,\n\t} = parentLayout;\n\n\tif ( parentLayoutType !== 'grid' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<GridTools\n\t\t\tclientId={ clientId }\n\t\t\tstyle={ style }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tallowSizingOnChildren={ allowSizingOnChildren }\n\t\t\tisManualPlacement={ isManualPlacement }\n\t\t\tparentLayout={ parentLayout }\n\t\t/>\n\t);\n}\n\nfunction GridTools( {\n\tclientId,\n\tstyle,\n\tsetAttributes,\n\tallowSizingOnChildren,\n\tisManualPlacement,\n\tparentLayout,\n} ) {\n\tconst {\n\t\trootClientId,\n\t\tisVisible,\n\t\tparentBlockVisibility,\n\t\tblockBlockVisibility,\n\t\tdeviceType,\n\t\tisChildBlockAGrid,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId( clientId );\n\n\t\t\tif (\n\t\t\t\tgetTemplateLock( _rootClientId ) ||\n\t\t\t\tgetBlockEditingMode( _rootClientId ) !== 'default'\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: _rootClientId,\n\t\t\t\t\tisVisible: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst parentAttributes = getBlockAttributes( _rootClientId );\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\tconst settings = getSettings();\n\n\t\t\treturn {\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible: true,\n\t\t\t\tparentBlockVisibility:\n\t\t\t\t\tparentAttributes?.metadata?.blockVisibility,\n\t\t\t\tblockBlockVisibility:\n\t\t\t\t\tblockAttributes?.metadata?.blockVisibility,\n\t\t\t\tdeviceType:\n\t\t\t\t\tsettings?.[ deviceTypeKey ]?.toLowerCase() ||\n\t\t\t\t\tBLOCK_VISIBILITY_VIEWPORTS.desktop.key,\n\t\t\t\t// Check if the selected child block is itself a grid.\n\t\t\t\tisChildBlockAGrid: blockAttributes?.layout?.type === 'grid',\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { isBlockCurrentlyHidden: isParentBlockCurrentlyHidden } =\n\t\tuseBlockVisibility( {\n\t\t\tblockVisibility: parentBlockVisibility,\n\t\t\tdeviceType,\n\t\t} );\n\n\tconst { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } =\n\t\tuseBlockVisibility( {\n\t\t\tblockVisibility: blockBlockVisibility,\n\t\t\tdeviceType,\n\t\t} );\n\n\t// Use useState() instead of useRef() so that GridItemResizer updates when ref is set.\n\tconst [ resizerBounds, setResizerBounds ] = useState();\n\n\tconst childGridClientId = isChildBlockAGrid ? clientId : undefined;\n\n\tif ( ! isVisible || isParentBlockCurrentlyHidden ) {\n\t\treturn null;\n\t}\n\n\tconst showResizer = allowSizingOnChildren && ! isBlockItselfCurrentlyHidden;\n\n\tfunction updateLayout( layout ) {\n\t\tsetAttributes( {\n\t\t\tstyle: {\n\t\t\t\t...style,\n\t\t\t\tlayout: {\n\t\t\t\t\t...style?.layout,\n\t\t\t\t\t...layout,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<GridVisualizer\n\t\t\t\tclientId={ rootClientId }\n\t\t\t\tcontentRef={ setResizerBounds }\n\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\tchildGridClientId={ childGridClientId }\n\t\t\t/>\n\t\t\t{ showResizer && (\n\t\t\t\t<GridItemResizer\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t// Don't allow resizing beyond the grid visualizer.\n\t\t\t\t\tbounds={ resizerBounds }\n\t\t\t\t\tonChange={ updateLayout }\n\t\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isManualPlacement &&\n\t\t\t\twindow.__experimentalEnableGridInteractivity && (\n\t\t\t\t\t<GridItemMovers\n\t\t\t\t\t\tlayout={ style?.layout }\n\t\t\t\t\t\tparentLayout={ parentLayout }\n\t\t\t\t\t\tonChange={ updateLayout }\n\t\t\t\t\t\tgridClientId={ rootClientId }\n\t\t\t\t\t\tblockClientId={ clientId }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tuseBlockProps: useBlockPropsChildLayoutStyles,\n\tedit: ChildLayoutControlsPure,\n\tattributeKeys: [ 'style' ],\n\thasSupport() {\n\t\treturn true;\n\t},\n};\n"],
5
+ "mappings": ";AAGA,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,gBAAgB;AAKzB,SAAS,SAAS,wBAAwB;AAC1C,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,wBAAwB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAiUzC,SAyGA,UAzGA,KAyGA,YAzGA;AA9TF,IAAM,qCAAqC,CAAC;AAE5C,IAAM,yBAAyB;AAAA,EAC9B,QAAQ;AAAA,EACR,QAAQ;AACT;AAIA,IAAM,2BAA2B;AAAA,EAChC,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AACR;AAEA,IAAM,mBAAmB;AAAA,EACxB,yBAAyB;AAAA,EACzB,yBAAyB;AAC1B;AAEA,SAAS,gBAAiB,OAAQ;AACjC,SAAO,iBAAiB,SAAU,KAAM;AACzC;AAEA,SAAS,cAAe,EAAE,UAAU,aAAa,GAAI;AACpD,SAAO,GAAI,QAAS;AAAA,IAChB,OAAO,QAAS,YAAa,EAC9B,IAAK,CAAE,CAAE,UAAU,KAAM,MAAO,GAAI,QAAS,KAAM,KAAM,EAAG,EAC5D,KAAM,IAAK,CAAE;AAAA;AAEjB;AAEO,SAAS,yBAA0B;AAAA,EACzC;AAAA,EACA,SAAS,CAAC;AAAA,EACV;AAAA,EACA,eAAe,CAAC;AAAA,EAChB,wBAAwB;AACzB,GAAI;AACH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AS,aAAc,QAAS;AAC/B,kBAAe;AAAA,MACd,OAAO;AAAA,QACN,GAAG;AAAA,QACH,QAAQ;AAAA,UACP,GAAG,OAAO;AAAA,UACV,GAAG;AAAA,QACJ;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH;AAEA,SACC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,UAAW;AAAA,QACX,YAAa;AAAA,QACb;AAAA,QACA;AAAA;AAAA,IACD;AAAA,IACE,eACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QAEA,QAAS;AAAA,QACT,UAAW;AAAA,QACX;AAAA;AAAA,IACD;AAAA,IAEC,qBACD,OAAO,yCACN;AAAA,MAAC;AAAA;AAAA,QACA,QAAS,OAAO;AAAA,QAChB;AAAA,QACA,UAAW;AAAA,QACX,cAAe;AAAA,QACf,eAAgB;AAAA;AAAA,IACjB;AAAA,KAEH;AAEF;AAEA,IAAO,uBAAQ;AAAA,EACd,eAAe;AAAA,EACf,MAAM;AAAA,EACN,eAAe,CAAE,OAAQ;AAAA,EACzB,aAAa;AACZ,WAAO;AAAA,EACR;AACD;",
6
6
  "names": []
7
7
  }
@@ -21,16 +21,19 @@ function ListViewPanel({ clientId, name }) {
21
21
  const { openListViewContentPanel } = unlock(
22
22
  useDispatch(blockEditorStore)
23
23
  );
24
- const isEnabled = hasListViewSupport(name);
25
- const { hasChildren, isNestedListView } = useSelect(
24
+ const { isEnabled, hasChildren, isNestedListView } = useSelect(
26
25
  (select) => {
27
- const { getBlockCount, getBlockParents, getBlockName } = select(blockEditorStore);
26
+ const {
27
+ getBlockCount,
28
+ getBlockParents,
29
+ shouldRenderBlockListView
30
+ } = unlock(select(blockEditorStore));
28
31
  const parents = getBlockParents(clientId, false);
29
- const _isNestedListView = parents.find((parentId) => {
30
- const parentName = getBlockName(parentId);
31
- return parentName === "core/navigation" || hasBlockSupport(parentName, "listView");
32
- });
32
+ const _isNestedListView = parents.find(
33
+ (parentId) => shouldRenderBlockListView(parentId)
34
+ );
33
35
  return {
36
+ isEnabled: shouldRenderBlockListView(clientId),
34
37
  hasChildren: !!getBlockCount(clientId),
35
38
  isNestedListView: _isNestedListView
36
39
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/list-view.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { hasBlockSupport, getBlockType } from '@wordpress/blocks';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { PrivateListView } from '../components/list-view';\nimport InspectorControls from '../components/inspector-controls/fill';\nimport { PrivateBlockContext } from '../components/block-list/private-block-context';\nimport useListViewPanelState from '../components/use-list-view-panel-state';\n\nimport { unlock } from '../lock-unlock';\n\nexport const LIST_VIEW_SUPPORT_KEY = 'listView';\n\n/**\n * Check if the block has list view support.\n *\n * @param {string|Object} nameOrType Block name or block type object.\n * @return {boolean} Whether the block has list view support.\n */\nexport function hasListViewSupport( nameOrType ) {\n\treturn hasBlockSupport( nameOrType, LIST_VIEW_SUPPORT_KEY );\n}\n\n/**\n * Inspector controls panel for list view.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n * @param {string} props.name Block name.\n * @return {Element|null} List view inspector controls or null.\n */\nexport function ListViewPanel( { clientId, name } ) {\n\tconst { isSelectionWithinCurrentSection } =\n\t\tuseContext( PrivateBlockContext );\n\n\tconst { isOpened, expandRevision, handleToggle } =\n\t\tuseListViewPanelState( clientId );\n\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { openListViewContentPanel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst isEnabled = hasListViewSupport( name );\n\tconst { hasChildren, isNestedListView } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockCount, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\t// Avoid showing List Views for both parent and child blocks that have support.\n\t\t\t// In this situation the parent will show the child in its list already.\n\t\t\t// Search parents to see if there's one that also has support, and if so skip rendering.\n\t\t\t// This matches closely the logic in the `BlockCard` component.\n\t\t\tconst parents = getBlockParents( clientId, false );\n\t\t\tconst _isNestedListView = parents.find( ( parentId ) => {\n\t\t\t\tconst parentName = getBlockName( parentId );\n\t\t\t\treturn (\n\t\t\t\t\tparentName === 'core/navigation' ||\n\t\t\t\t\thasBlockSupport( parentName, 'listView' )\n\t\t\t\t);\n\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tisNestedListView: _isNestedListView,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockType = getBlockType( name );\n\tconst title = blockType?.title || name;\n\n\tif ( ! isEnabled || isNestedListView ) {\n\t\treturn null;\n\t}\n\n\tconst showBlockTitle = isSelectionWithinCurrentSection;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ showBlockTitle ? title : undefined }\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ handleToggle }\n\t\t\t>\n\t\t\t\t{ ! hasChildren && (\n\t\t\t\t\t<p className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t{ __( 'No items yet.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<PrivateListView\n\t\t\t\t\tkey={ `${ clientId }-${ expandRevision }` }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\tisExpanded\n\t\t\t\t\tdescription={ title }\n\t\t\t\t\tshowAppender\n\t\t\t\t\tonSelect={ openListViewContentPanel }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Export block support definition.\n */\nexport default {\n\tedit: ListViewPanel,\n\thasSupport: hasListViewSupport,\n\tattribut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B;AAEvB,SACC,oBAAC,qBAAkB,OAAM,QACxB;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ,iBAAiB,QAAQ;AAAA,MACjC,QAAS;AAAA,MACT,UAAW;AAAA,MAET;AAAA,SAAE,eACH,oBAAC,OAAE,WAAU,2CACV,aAAI,eAAgB,GACvB;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YAEA,cAAe;AAAA,YACf,YAAU;AAAA,YACV,aAAc;AAAA,YACd,cAAY;AAAA,YACZ,UAAW;AAAA;AAAA,UALL,GAAI,QAAS,IAAK,cAAe;AAAA,QAMxC;AAAA;AAAA;AAAA,EACD,GACD;AAEF;AAKA,IAAO,oBAAQ;AAAA,EACd,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,eAAe,CAAC;AAAA,EAChB,wBAAwB;AACzB;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { hasBlockSupport, getBlockType } from '@wordpress/blocks';\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { PrivateListView } from '../components/list-view';\nimport InspectorControls from '../components/inspector-controls/fill';\nimport { PrivateBlockContext } from '../components/block-list/private-block-context';\nimport useListViewPanelState from '../components/use-list-view-panel-state';\n\nimport { unlock } from '../lock-unlock';\n\nexport const LIST_VIEW_SUPPORT_KEY = 'listView';\n\n/**\n * Check if the block has list view support.\n *\n * @param {string|Object} nameOrType Block name or block type object.\n * @return {boolean} Whether the block has list view support.\n */\nexport function hasListViewSupport( nameOrType ) {\n\treturn hasBlockSupport( nameOrType, LIST_VIEW_SUPPORT_KEY );\n}\n\n/**\n * Inspector controls panel for list view.\n *\n * @param {Object} props Component props.\n * @param {string} props.clientId Block client ID.\n * @param {string} props.name Block name.\n * @return {Element|null} List view inspector controls or null.\n */\nexport function ListViewPanel( { clientId, name } ) {\n\tconst { isSelectionWithinCurrentSection } =\n\t\tuseContext( PrivateBlockContext );\n\n\tconst { isOpened, expandRevision, handleToggle } =\n\t\tuseListViewPanelState( clientId );\n\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { openListViewContentPanel } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\n\tconst { isEnabled, hasChildren, isNestedListView } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockParents,\n\t\t\t\tshouldRenderBlockListView,\n\t\t\t} = unlock( select( blockEditorStore ) );\n\n\t\t\t// Avoid showing List Views for both parent and child blocks that have support.\n\t\t\t// In this situation the parent will show the child in its list already.\n\t\t\t// Search parents to see if there's one that also has support, and if so skip rendering.\n\t\t\t// This matches closely the logic in the `BlockCard` component.\n\t\t\tconst parents = getBlockParents( clientId, false );\n\t\t\tconst _isNestedListView = parents.find( ( parentId ) =>\n\t\t\t\tshouldRenderBlockListView( parentId )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tisEnabled: shouldRenderBlockListView( clientId ),\n\t\t\t\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tisNestedListView: _isNestedListView,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockType = getBlockType( name );\n\tconst title = blockType?.title || name;\n\n\tif ( ! isEnabled || isNestedListView ) {\n\t\treturn null;\n\t}\n\n\tconst showBlockTitle = isSelectionWithinCurrentSection;\n\n\treturn (\n\t\t<InspectorControls group=\"list\">\n\t\t\t<PanelBody\n\t\t\t\ttitle={ showBlockTitle ? title : undefined }\n\t\t\t\topened={ isOpened }\n\t\t\t\tonToggle={ handleToggle }\n\t\t\t>\n\t\t\t\t{ ! hasChildren && (\n\t\t\t\t\t<p className=\"block-editor-block-inspector__no-blocks\">\n\t\t\t\t\t\t{ __( 'No items yet.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t<PrivateListView\n\t\t\t\t\tkey={ `${ clientId }-${ expandRevision }` }\n\t\t\t\t\trootClientId={ clientId }\n\t\t\t\t\tisExpanded\n\t\t\t\t\tdescription={ title }\n\t\t\t\t\tshowAppender\n\t\t\t\t\tonSelect={ openListViewContentPanel }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Export block support definition.\n */\nexport default {\n\tedit: ListViewPanel,\n\thasSupport: hasListViewSupport,\n\tattributeKeys: [],\n\tsupportsPatternEditing: true,\n};\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,aAAa,iBAAiB;AACvC,SAAS,iBAAiB,oBAAoB;AAC9C,SAAS,kBAAkB;AAK3B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,uBAAuB;AAChC,OAAO,uBAAuB;AAC9B,SAAS,2BAA2B;AACpC,OAAO,2BAA2B;AAElC,SAAS,cAAc;AAuEpB,SAME,KANF;AArEI,IAAM,wBAAwB;AAQ9B,SAAS,mBAAoB,YAAa;AAChD,SAAO,gBAAiB,YAAY,qBAAsB;AAC3D;AAUO,SAAS,cAAe,EAAE,UAAU,KAAK,GAAI;AACnD,QAAM,EAAE,gCAAgC,IACvC,WAAY,mBAAoB;AAEjC,QAAM,EAAE,UAAU,gBAAgB,aAAa,IAC9C,sBAAuB,QAAS;AAGjC,QAAM,EAAE,yBAAyB,IAAI;AAAA,IACpC,YAAa,gBAAiB;AAAA,EAC/B;AAEA,QAAM,EAAE,WAAW,aAAa,iBAAiB,IAAI;AAAA,IACpD,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,OAAQ,gBAAiB,CAAE;AAMvC,YAAM,UAAU,gBAAiB,UAAU,KAAM;AACjD,YAAM,oBAAoB,QAAQ;AAAA,QAAM,CAAE,aACzC,0BAA2B,QAAS;AAAA,MACrC;AAEA,aAAO;AAAA,QACN,WAAW,0BAA2B,QAAS;AAAA,QAC/C,aAAa,CAAC,CAAE,cAAe,QAAS;AAAA,QACxC,kBAAkB;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,YAAY,aAAc,IAAK;AACrC,QAAM,QAAQ,WAAW,SAAS;AAElC,MAAK,CAAE,aAAa,kBAAmB;AACtC,WAAO;AAAA,EACR;AAEA,QAAM,iBAAiB;AAEvB,SACC,oBAAC,qBAAkB,OAAM,QACxB;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ,iBAAiB,QAAQ;AAAA,MACjC,QAAS;AAAA,MACT,UAAW;AAAA,MAET;AAAA,SAAE,eACH,oBAAC,OAAE,WAAU,2CACV,aAAI,eAAgB,GACvB;AAAA,QAED;AAAA,UAAC;AAAA;AAAA,YAEA,cAAe;AAAA,YACf,YAAU;AAAA,YACV,aAAc;AAAA,YACd,cAAY;AAAA,YACZ,UAAW;AAAA;AAAA,UALL,GAAI,QAAS,IAAK,cAAe;AAAA,QAMxC;AAAA;AAAA;AAAA,EACD,GACD;AAEF;AAKA,IAAO,oBAAQ;AAAA,EACd,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,eAAe,CAAC;AAAA,EAChB,wBAAwB;AACzB;",
6
6
  "names": []
7
7
  }
@@ -5,7 +5,7 @@ import { getBlockSupport, hasBlockSupport } from "@wordpress/blocks";
5
5
  import { BaseControl, CustomSelectControl } from "@wordpress/components";
6
6
  import { useInstanceId } from "@wordpress/compose";
7
7
  import { useSelect } from "@wordpress/data";
8
- import { useMemo, Platform } from "@wordpress/element";
8
+ import { useMemo } from "@wordpress/element";
9
9
  import { useSettings } from "../components/use-settings/index.mjs";
10
10
  import InspectorControls from "../components/inspector-controls/index.mjs";
11
11
  import useBlockDisplayInformation from "../components/use-block-display-information/index.mjs";
@@ -146,28 +146,25 @@ function PositionPanelPure({
146
146
  });
147
147
  };
148
148
  const selectedOption = value ? options.find((option) => option.value === value) || DEFAULT_OPTION : DEFAULT_OPTION;
149
- return Platform.select({
150
- web: options.length > 1 ? /* @__PURE__ */ jsx(InspectorControls, { group: "position", children: /* @__PURE__ */ jsx(BaseControl, { help: stickyHelpText, children: /* @__PURE__ */ jsx(
151
- CustomSelectControl,
152
- {
153
- __next40pxDefaultSize: true,
154
- label: __("Position"),
155
- hideLabelFromVision: true,
156
- describedBy: sprintf(
157
- // translators: %s: Currently selected position.
158
- __("Currently selected position: %s"),
159
- selectedOption.name
160
- ),
161
- options,
162
- value: selectedOption,
163
- onChange: ({ selectedItem }) => {
164
- onChangeType(selectedItem.value);
165
- },
166
- size: "__unstable-large"
167
- }
168
- ) }) }) : null,
169
- native: null
170
- });
149
+ return options.length > 1 ? /* @__PURE__ */ jsx(InspectorControls, { group: "position", children: /* @__PURE__ */ jsx(BaseControl, { help: stickyHelpText, children: /* @__PURE__ */ jsx(
150
+ CustomSelectControl,
151
+ {
152
+ __next40pxDefaultSize: true,
153
+ label: __("Position"),
154
+ hideLabelFromVision: true,
155
+ describedBy: sprintf(
156
+ // translators: %s: Currently selected position.
157
+ __("Currently selected position: %s"),
158
+ selectedOption.name
159
+ ),
160
+ options,
161
+ value: selectedOption,
162
+ onChange: ({ selectedItem }) => {
163
+ onChangeType(selectedItem.value);
164
+ },
165
+ size: "__unstable-large"
166
+ }
167
+ ) }) }) : null;
171
168
  }
172
169
  var position_default = {
173
170
  edit: function Edit(props) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/position.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { BaseControl, CustomSelectControl } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\thint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\thint: __( 'The block will not move when the page is scrolled.' ),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl help={ stickyHelpText }>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\n// Used for generating the instance ID\nconst POSITION_BLOCK_PROPS_REFERENCE = {};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( POSITION_BLOCK_PROPS_REFERENCE );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = clsx( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,aAAa,2BAA2B;AACjD,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,SAAS,SAAS,gBAAgB;AAKlC,SAAS,mBA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aAAa,MAAO;AAClC,uBAAc,aAAa,KAAM;AAAA,QAClC;AAAA,QACA,MAAK;AAAA;AAAA,IACN,GACD,GACD,IACG;AAAA,IACL,QAAQ;AAAA,EACT,CAAE;AACH;AAEA,IAAO,mBAAQ;AAAA,EACd,MAAM,SAAS,KAAM,OAAQ;AAC5B,UAAM,qBAAqB,sBAAuB,KAAM;AACxD,QAAK,oBAAqB;AACzB,aAAO;AAAA,IACR;AACA,WAAO,oBAAC,qBAAoB,GAAG,OAAQ;AAAA,EACxC;AAAA,EACA;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,WAAY,MAAO;AAClB,WAAO,gBAAiB,MAAM,oBAAqB;AAAA,EACpD;AACD;AAGA,IAAM,iCAAiC,CAAC;AAExC,SAAS,cAAe,EAAE,MAAM,MAAM,GAAI;AACzC,QAAM,0BAA0B;AAAA,IAC/B;AAAA,IACA;AAAA,EACD;AACA,QAAM,qBAAqB,sBAAuB,EAAE,KAAK,CAAE;AAC3D,QAAM,sBAAsB,2BAA2B,CAAE;AAEzD,QAAM,KAAK,cAAe,8BAA+B;AAGzD,QAAM,mBAAmB,iBAAkB,EAAG,iBAAkB,EAAG;AAGnE,MAAI;AACJ,MAAK,qBAAsB;AAC1B,UACC,eAAgB;AAAA,MACf,UAAU;AAAA,MACV;AAAA,IACD,CAAE,KAAK;AAAA,EACT;AAGA,QAAM,YAAY,KAAM;AAAA,IACvB,CAAE,gBAAiB,EAAG,EAAG,GAAG,uBAAuB,CAAC,CAAE;AAAA;AAAA,IACtD,CAAE,eAAgB,OAAO,UAAU,IAAK,EAAG,GAC1C,uBAAuB,CAAC,CAAE,OAAO,CAAC,CAAE,OAAO,UAAU;AAAA,EACvD,CAAE;AAEF,mBAAkB,EAAE,IAAI,CAAE;AAE1B,SAAO,EAAE,UAAU;AACpB;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { BaseControl, CustomSelectControl } from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\thint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\thint: __( 'The block will not move when the page is scrolled.' ),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn options.length > 1 ? (\n\t\t<InspectorControls group=\"position\">\n\t\t\t<BaseControl help={ stickyHelpText }>\n\t\t\t\t<CustomSelectControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t) }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t</BaseControl>\n\t\t</InspectorControls>\n\t) : null;\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\n// Used for generating the instance ID\nconst POSITION_BLOCK_PROPS_REFERENCE = {};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( POSITION_BLOCK_PROPS_REFERENCE );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = clsx( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,IAAI,IAAI,eAAe;AAChC,SAAS,iBAAiB,uBAAuB;AACjD,SAAS,aAAa,2BAA2B;AACjD,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B,S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Aa,MAAO;AAClC,qBAAc,aAAa,KAAM;AAAA,MAClC;AAAA,MACA,MAAK;AAAA;AAAA,EACN,GACD,GACD,IACG;AACL;AAEA,IAAO,mBAAQ;AAAA,EACd,MAAM,SAAS,KAAM,OAAQ;AAC5B,UAAM,qBAAqB,sBAAuB,KAAM;AACxD,QAAK,oBAAqB;AACzB,aAAO;AAAA,IACR;AACA,WAAO,oBAAC,qBAAoB,GAAG,OAAQ;AAAA,EACxC;AAAA,EACA;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,WAAY,MAAO;AAClB,WAAO,gBAAiB,MAAM,oBAAqB;AAAA,EACpD;AACD;AAGA,IAAM,iCAAiC,CAAC;AAExC,SAAS,cAAe,EAAE,MAAM,MAAM,GAAI;AACzC,QAAM,0BAA0B;AAAA,IAC/B;AAAA,IACA;AAAA,EACD;AACA,QAAM,qBAAqB,sBAAuB,EAAE,KAAK,CAAE;AAC3D,QAAM,sBAAsB,2BAA2B,CAAE;AAEzD,QAAM,KAAK,cAAe,8BAA+B;AAGzD,QAAM,mBAAmB,iBAAkB,EAAG,iBAAkB,EAAG;AAGnE,MAAI;AACJ,MAAK,qBAAsB;AAC1B,UACC,eAAgB;AAAA,MACf,UAAU;AAAA,MACV;AAAA,IACD,CAAE,KAAK;AAAA,EACT;AAGA,QAAM,YAAY,KAAM;AAAA,IACvB,CAAE,gBAAiB,EAAG,EAAG,GAAG,uBAAuB,CAAC,CAAE;AAAA;AAAA,IACtD,CAAE,eAAgB,OAAO,UAAU,IAAK,EAAG,GAC1C,uBAAuB,CAAC,CAAE,OAAO,CAAC,CAAE,OAAO,UAAU;AAAA,EACvD,CAAE;AAEF,mBAAkB,EAAE,IAAI,CAAE;AAE1B,SAAO,EAAE,UAAU;AACpB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/spacing-visualizer.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect, useReducer } from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport BlockPopoverCover from '../components/block-popover/cover';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst [ style, updateStyle ] = useReducer( () =>\n\t\tcomputeStyle( blockElement )\n\t);\n\n\t// Force style computation when forceShow becomes true (e.g., when hovering control)\n\t// to ensure visualizer displays correct dimensions on first render.\n\tuseEffect( () => {\n\t\tif ( blockElement && forceShow ) {\n\t\t\tupdateStyle();\n\t\t}\n\t}, [ blockElement, forceShow ] );\n\n\t// It's not sufficient to read the block's computed style when `value` changes because\n\t// the effect would run before the block\u2019s style has updated. Thus observing mutations\n\t// to the block\u2019s attributes is used to trigger updates to the visualizer\u2019s styles.\n\tuseEffect( () => {\n\t\tif ( ! blockElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( updateStyle );\n\t\tobserver.observe( blockElement, {\n\t\t\tattributes: true,\n\t\t\tattributeFilter: [ 'style', 'class' ],\n\t\t} );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ blockElement ] );\n\n\tconst previousValueRef = useRef( value );\n\tconst [ isActive, setIsActive ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( isShallowEqual( value, previousValueRef.current ) || forceShow ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsActive( true );\n\t\tpreviousValueRef.current = value;\n\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetIsActive( false );\n\t\t}, 400 );\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimeout( timeout );\n\t\t};\n\t}, [ value, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t>\n\t\t\t<div className=\"block-editor__spacing-visualizer\" style={ style } />\n\t\t</BlockPopoverCover>\n\t);\n}\n\nfunction getComputedCSS( element, property ) {\n\treturn element.ownerDocument.defaultView\n\t\t.getComputedStyle( element )\n\t\t.getPropertyValue( property );\n}\n\nexport function MarginVisualizer( { clientId, value, forceShow } ) {\n\treturn (\n\t\t<SpacingVisualizer\n\t\t\tclientId={ clientId }\n\t\t\tvalue={ value?.spacing?.margin }\n\t\t\tcomputeStyle={ ( blockElement ) => {\n\t\t\t\tconst top = getComputedCSS( blockElement, 'margin-top' );\n\t\t\t\tconst right = getComputedCSS( blockElement, 'margin-right' );\n\t\t\t\tconst bottom = getComputedCSS( blockElement, 'margin-bottom' );\n\t\t\t\tconst left = getComputedCSS( blockElement, 'margin-left' );\n\t\t\t\treturn {\n\t\t\t\t\tborderTopWidth: top,\n\t\t\t\t\tborderRightWidth: right,\n\t\t\t\t\tborderBottomWidth: bottom,\n\t\t\t\t\tborderLeftWidth: left,\n\t\t\t\t\ttop: top ? `-${ top }` : 0,\n\t\t\t\t\tright: right ? `-${ right }` : 0,\n\t\t\t\t\tbottom: bottom ? `-${ bottom }` : 0,\n\t\t\t\t\tleft: left ? `-${ left }` : 0,\n\t\t\t\t};\n\t\t\t} }\n\t\t\tforceShow={ forceShow }\n\t\t/>\n\t);\n}\n\nexport function PaddingVisualizer( { clientId, value, forceShow } ) {\n\treturn (\n\t\t<SpacingVisualizer\n\t\t\tclientId={ clientId }\n\t\t\tvalue={ value?.spacing?.padding }\n\t\t\tcomputeStyle={ ( blockElement ) => ( {\n\t\t\t\tborderTopWidth: getComputedCSS( blockElement, 'padding-top' ),\n\t\t\t\tborderRightWidth: getComputedCSS(\n\t\t\t\t\tblockElement,\n\t\t\t\t\t'padding-right'\n\t\t\t\t),\n\t\t\t\tborderBottomWidth: getComputedCSS(\n\t\t\t\t\tblockElement,\n\t\t\t\t\t'padding-bottom'\n\t\t\t\t),\n\t\t\t\tborderLeftWidth: getComputedCSS( blockElement, 'padding-left' ),\n\t\t\t} ) }\n\t\t\tforceShow={ forceShow }\n\t\t/>\n\t);\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect, useReducer } from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport BlockPopoverCover from '../components/block-popover/cover';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst [ style, updateStyle ] = useReducer( () =>\n\t\tcomputeStyle( blockElement )\n\t);\n\n\t// Force style computation when forceShow becomes true (e.g., when hovering control)\n\t// to ensure visualizer displays correct dimensions on first render.\n\tuseEffect( () => {\n\t\tif ( blockElement && forceShow ) {\n\t\t\tupdateStyle();\n\t\t}\n\t}, [ blockElement, forceShow ] );\n\n\t// It's not sufficient to read the block's computed style when `value` changes because\n\t// the effect would run before the block’s style has updated. Thus observing mutations\n\t// to the block’s attributes is used to trigger updates to the visualizer’s styles.\n\tuseEffect( () => {\n\t\tif ( ! blockElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( updateStyle );\n\t\tobserver.observe( blockElement, {\n\t\t\tattributes: true,\n\t\t\tattributeFilter: [ 'style', 'class' ],\n\t\t} );\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ blockElement ] );\n\n\tconst previousValueRef = useRef( value );\n\tconst [ isActive, setIsActive ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( isShallowEqual( value, previousValueRef.current ) || forceShow ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsActive( true );\n\t\tpreviousValueRef.current = value;\n\n\t\tconst timeout = setTimeout( () => {\n\t\t\tsetIsActive( false );\n\t\t}, 400 );\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimeout( timeout );\n\t\t};\n\t}, [ value, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t>\n\t\t\t<div className=\"block-editor__spacing-visualizer\" style={ style } />\n\t\t</BlockPopoverCover>\n\t);\n}\n\nfunction getComputedCSS( element, property ) {\n\treturn element.ownerDocument.defaultView\n\t\t.getComputedStyle( element )\n\t\t.getPropertyValue( property );\n}\n\nexport function MarginVisualizer( { clientId, value, forceShow } ) {\n\treturn (\n\t\t<SpacingVisualizer\n\t\t\tclientId={ clientId }\n\t\t\tvalue={ value?.spacing?.margin }\n\t\t\tcomputeStyle={ ( blockElement ) => {\n\t\t\t\tconst top = getComputedCSS( blockElement, 'margin-top' );\n\t\t\t\tconst right = getComputedCSS( blockElement, 'margin-right' );\n\t\t\t\tconst bottom = getComputedCSS( blockElement, 'margin-bottom' );\n\t\t\t\tconst left = getComputedCSS( blockElement, 'margin-left' );\n\t\t\t\treturn {\n\t\t\t\t\tborderTopWidth: top,\n\t\t\t\t\tborderRightWidth: right,\n\t\t\t\t\tborderBottomWidth: bottom,\n\t\t\t\t\tborderLeftWidth: left,\n\t\t\t\t\ttop: top ? `-${ top }` : 0,\n\t\t\t\t\tright: right ? `-${ right }` : 0,\n\t\t\t\t\tbottom: bottom ? `-${ bottom }` : 0,\n\t\t\t\t\tleft: left ? `-${ left }` : 0,\n\t\t\t\t};\n\t\t\t} }\n\t\t\tforceShow={ forceShow }\n\t\t/>\n\t);\n}\n\nexport function PaddingVisualizer( { clientId, value, forceShow } ) {\n\treturn (\n\t\t<SpacingVisualizer\n\t\t\tclientId={ clientId }\n\t\t\tvalue={ value?.spacing?.padding }\n\t\t\tcomputeStyle={ ( blockElement ) => ( {\n\t\t\t\tborderTopWidth: getComputedCSS( blockElement, 'padding-top' ),\n\t\t\t\tborderRightWidth: getComputedCSS(\n\t\t\t\t\tblockElement,\n\t\t\t\t\t'padding-right'\n\t\t\t\t),\n\t\t\t\tborderBottomWidth: getComputedCSS(\n\t\t\t\t\tblockElement,\n\t\t\t\t\t'padding-bottom'\n\t\t\t\t),\n\t\t\t\tborderLeftWidth: getComputedCSS( blockElement, 'padding-left' ),\n\t\t\t} ) }\n\t\t\tforceShow={ forceShow }\n\t\t/>\n\t);\n}\n"],
5
5
  "mappings": ";AAGA,SAAS,UAAU,QAAQ,WAAW,kBAAkB;AACxD,SAAS,sBAAsB;AAK/B,OAAO,uBAAuB;AAC9B,SAAS,uBAAuB;AA+D7B;AA7DH,SAAS,kBAAmB,EAAE,UAAU,OAAO,cAAc,UAAU,GAAI;AAC1E,QAAM,eAAe,gBAAiB,QAAS;AAC/C,QAAM,CAAE,OAAO,WAAY,IAAI;AAAA,IAAY,MAC1C,aAAc,YAAa;AAAA,EAC5B;AAIA,YAAW,MAAM;AAChB,QAAK,gBAAgB,WAAY;AAChC,kBAAY;AAAA,IACb;AAAA,EACD,GAAG,CAAE,cAAc,SAAU,CAAE;AAK/B,YAAW,MAAM;AAChB,QAAK,CAAE,cAAe;AACrB;AAAA,IACD;AACA,UAAM,WAAW,IAAI,OAAO,iBAAkB,WAAY;AAC1D,aAAS,QAAS,cAAc;AAAA,MAC/B,YAAY;AAAA,MACZ,iBAAiB,CAAE,SAAS,OAAQ;AAAA,IACrC,CAAE;AACF,WAAO,MAAM;AACZ,eAAS,WAAW;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,YAAa,CAAE;AAEpB,QAAM,mBAAmB,OAAQ,KAAM;AACvC,QAAM,CAAE,UAAU,WAAY,IAAI,SAAU,KAAM;AAElD,YAAW,MAAM;AAChB,QAAK,eAAgB,OAAO,iBAAiB,OAAQ,KAAK,WAAY;AACrE;AAAA,IACD;AAEA,gBAAa,IAAK;AAClB,qBAAiB,UAAU;AAE3B,UAAM,UAAU,WAAY,MAAM;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oB;AAAA,QACpC,gBAAgB,eAAgB,cAAc,aAAc;AAAA,QAC5D,kBAAkB;AAAA,UACjB;AAAA,UACA;AAAA,QACD;AAAA,QACA,mBAAmB;AAAA,UAClB;AAAA,UACA;AAAA,QACD;AAAA,QACA,iBAAiB,eAAgB,cAAc,cAAe;AAAA,MAC/D;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/state-utils.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { splitSelectorList } from '@wordpress/global-styles-engine';\n\n/**\n * Given a block's `selectors.root` value, returns the part of the selector\n * that is relative to the block wrapper \u2014 i.e., everything after the first\n * compound selector segment.\n *\n * Examples:\n * \".wp-block-button .wp-block-button__link\" \u2192 \".wp-block-button__link\"\n * \".wp-block-foo > .inner\" \u2192 \"> .inner\"\n * \".wp-block-foo\" \u2192 null (no descendant)\n *\n * @param {string} rootSelector The block's `selectors.root` value.\n * @return {string|null} Relative selector, or null if rootSelector targets the wrapper itself.\n */\nexport function getRelativeRootSelector( rootSelector ) {\n\t// Match everything after the first compound selector (up to the first\n\t// whitespace or combinator character).\n\t// Require at least one combinator character (space, >, +, ~) between the\n\t// first compound selector and the rest. Without this anchor, a greedy\n\t// quantifier would backtrack into the first token and produce false matches.\n\tconst match = rootSelector.trim().match( /^[^ >+~]+[ >+~](.*)$/ );\n\tif ( ! match ) {\n\t\treturn null;\n\t}\n\tconst rest = match[ 1 ].trim();\n\treturn rest || null;\n}\n\n/**\n * Builds a scoped selector from a block selector and optional suffix.\n *\n * If the block selector targets a descendant, the descendant portion is scoped\n * under the provided base selector. Otherwise the base selector itself is used.\n *\n * @param {string} baseSelector The block-instance scoping selector.\n * @param {string} blockSelector The block or feature selector from block metadata.\n * @param {string} suffix Optional selector suffix, e.g. \":hover\".\n * @return {string} The scoped CSS selector.\n */\nexport function buildScopedBlockSelector(\n\tbaseSelector,\n\tblockSelector,\n\tsuffix = ''\n) {\n\tif ( typeof blockSelector !== 'string' || ! blockSelector ) {\n\t\treturn splitSelectorList( baseSelector )\n\t\t\t.map( ( selector ) => `${ selector.trim() }${ suffix }` )\n\t\t\t.join( ', ' );\n\t}\n\n\tconst baseSelectors = splitSelectorList( baseSelector ).filter(\n\t\t( selector ) => selector.trim()\n\t);\n\tconst selectors = splitSelectorList( blockSelector ).filter( ( selector ) =>\n\t\tselector.trim()\n\t);\n\n\tif ( ! selectors.length ) {\n\t\treturn baseSelectors\n\t\t\t.map( ( selector ) => `${ selector.trim() }${ suffix }` )\n\t\t\t.join( ', ' );\n\t}\n\n\treturn selectors\n\t\t.map( ( selector ) => {\n\t\t\tselector = selector.trim();\n\n\t\t\t/*\n\t\t\t * Replace only the leading block selector part (e.g. class name,\n\t\t\t * attribute selector, ID, or tag name) with the block instance selector.\n\t\t\t * Preserve anything after that prefix, including modifier classes on the\n\t\t\t * same element and combinators without spaces.\n\t\t\t */\n\t\t\tconst match = selector.match( /^([.#]?[-_a-zA-Z0-9]+|\\[[^\\]]+\\])/ );\n\t\t\tif ( match ) {\n\t\t\t\treturn baseSelectors\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( base ) =>\n\t\t\t\t\t\t\t`${ base.trim() }${ selector.slice(\n\t\t\t\t\t\t\t\tmatch[ 0 ].length\n\t\t\t\t\t\t\t) }${ suffix }`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ', ' );\n\t\t\t}\n\n\t\t\treturn baseSelectors\n\t\t\t\t.map( ( base ) => `${ base.trim() }${ suffix }` )\n\t\t\t\t.join( ', ' );\n\t\t} )\n\t\t.join( ', ' );\n}\n\n/**\n * Builds the scoped selector for root block style state styles.\n *\n * Uses the block's `selectors.root` to determine which element should receive\n * root-level state styles. If `selectors.root` describes a descendant element\n * (e.g. `.wp-block-button .wp-block-button__link`), the relative portion is\n * scoped under `baseSelector`. If no descendant is present, falls back to the\n * base selector.\n *\n * @param {string} baseSelector The block-instance scoping class selector.\n * @param {string} name The block name, used to look up selectors.\n * @return {string} The fully-scoped CSS selector for root state styles.\n */\nexport function buildRootStyleStateSelector( baseSelector, name ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector( baseSelector, rootSelector );\n}\n\n/**\n * Builds the scoped CSS selector for a block state (e.g. :hover, :focus).\n *\n * Uses the block's `selectors.root` to determine which element the state\n * pseudo-class should apply to. If `selectors.root` describes a descendant\n * element (e.g. \".wp-block-button .wp-block-button__link\"), the relative\n * portion (\".wp-block-button__link\") is scoped under `baseSelector`. If no\n * descendant is present, falls back to appending the state to `baseSelector`.\n *\n * @param {string} baseSelector The block-instance scoping class selector.\n * @param {string} name The block name, used to look up selectors.\n * @param {string} state The pseudo-class string, e.g. \":hover\".\n * @return {string} The fully-scoped CSS selector for this state.\n */\nexport function buildPseudoStyleStateSelector( baseSelector, name, state ) {\n\treturn `${ buildRootStyleStateSelector( baseSelector, name ) }${ state }`;\n}\n\nexport function buildStateSelector( baseSelector, name, state ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector( baseSelector, rootSelector, state );\n}\n\n/**\n * Builds the CSS selector used to preview a state on the editor canvas,\n * scoped to a specific block instance via its `data-block` attribute.\n *\n * For blocks whose `selectors.root` targets a descendant element\n * (e.g. \".wp-block-button .wp-block-button__link\"), the selector targets\n * that descendant inside the block wrapper. Otherwise it targets the wrapper\n * itself.\n *\n * @param {string} clientId The block's clientId.\n * @param {string} name The block name, used to look up selectors.\n * @return {string} CSS selector scoped to this block instance.\n */\nexport function buildCanvasStateSelector( clientId, name ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector(\n\t\t`[data-block=\"${ clientId }\"]`,\n\t\trootSelector\n\t);\n}\n"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockType } from '@wordpress/blocks';\nimport { splitSelectorList } from '@wordpress/global-styles-engine';\n\n/**\n * Given a block's `selectors.root` value, returns the part of the selector\n * that is relative to the block wrapper i.e., everything after the first\n * compound selector segment.\n *\n * Examples:\n * \".wp-block-button .wp-block-button__link\" \".wp-block-button__link\"\n * \".wp-block-foo > .inner\" \"> .inner\"\n * \".wp-block-foo\" null (no descendant)\n *\n * @param {string} rootSelector The block's `selectors.root` value.\n * @return {string|null} Relative selector, or null if rootSelector targets the wrapper itself.\n */\nexport function getRelativeRootSelector( rootSelector ) {\n\t// Match everything after the first compound selector (up to the first\n\t// whitespace or combinator character).\n\t// Require at least one combinator character (space, >, +, ~) between the\n\t// first compound selector and the rest. Without this anchor, a greedy\n\t// quantifier would backtrack into the first token and produce false matches.\n\tconst match = rootSelector.trim().match( /^[^ >+~]+[ >+~](.*)$/ );\n\tif ( ! match ) {\n\t\treturn null;\n\t}\n\tconst rest = match[ 1 ].trim();\n\treturn rest || null;\n}\n\n/**\n * Builds a scoped selector from a block selector and optional suffix.\n *\n * If the block selector targets a descendant, the descendant portion is scoped\n * under the provided base selector. Otherwise the base selector itself is used.\n *\n * @param {string} baseSelector The block-instance scoping selector.\n * @param {string} blockSelector The block or feature selector from block metadata.\n * @param {string} suffix Optional selector suffix, e.g. \":hover\".\n * @return {string} The scoped CSS selector.\n */\nexport function buildScopedBlockSelector(\n\tbaseSelector,\n\tblockSelector,\n\tsuffix = ''\n) {\n\tif ( typeof blockSelector !== 'string' || ! blockSelector ) {\n\t\treturn splitSelectorList( baseSelector )\n\t\t\t.map( ( selector ) => `${ selector.trim() }${ suffix }` )\n\t\t\t.join( ', ' );\n\t}\n\n\tconst baseSelectors = splitSelectorList( baseSelector ).filter(\n\t\t( selector ) => selector.trim()\n\t);\n\tconst selectors = splitSelectorList( blockSelector ).filter( ( selector ) =>\n\t\tselector.trim()\n\t);\n\n\tif ( ! selectors.length ) {\n\t\treturn baseSelectors\n\t\t\t.map( ( selector ) => `${ selector.trim() }${ suffix }` )\n\t\t\t.join( ', ' );\n\t}\n\n\treturn selectors\n\t\t.map( ( selector ) => {\n\t\t\tselector = selector.trim();\n\n\t\t\t/*\n\t\t\t * Replace only the leading block selector part (e.g. class name,\n\t\t\t * attribute selector, ID, or tag name) with the block instance selector.\n\t\t\t * Preserve anything after that prefix, including modifier classes on the\n\t\t\t * same element and combinators without spaces.\n\t\t\t */\n\t\t\tconst match = selector.match( /^([.#]?[-_a-zA-Z0-9]+|\\[[^\\]]+\\])/ );\n\t\t\tif ( match ) {\n\t\t\t\treturn baseSelectors\n\t\t\t\t\t.map(\n\t\t\t\t\t\t( base ) =>\n\t\t\t\t\t\t\t`${ base.trim() }${ selector.slice(\n\t\t\t\t\t\t\t\tmatch[ 0 ].length\n\t\t\t\t\t\t\t) }${ suffix }`\n\t\t\t\t\t)\n\t\t\t\t\t.join( ', ' );\n\t\t\t}\n\n\t\t\treturn baseSelectors\n\t\t\t\t.map( ( base ) => `${ base.trim() }${ suffix }` )\n\t\t\t\t.join( ', ' );\n\t\t} )\n\t\t.join( ', ' );\n}\n\n/**\n * Builds the scoped selector for root block style state styles.\n *\n * Uses the block's `selectors.root` to determine which element should receive\n * root-level state styles. If `selectors.root` describes a descendant element\n * (e.g. `.wp-block-button .wp-block-button__link`), the relative portion is\n * scoped under `baseSelector`. If no descendant is present, falls back to the\n * base selector.\n *\n * @param {string} baseSelector The block-instance scoping class selector.\n * @param {string} name The block name, used to look up selectors.\n * @return {string} The fully-scoped CSS selector for root state styles.\n */\nexport function buildRootStyleStateSelector( baseSelector, name ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector( baseSelector, rootSelector );\n}\n\n/**\n * Builds the scoped CSS selector for a block state (e.g. :hover, :focus).\n *\n * Uses the block's `selectors.root` to determine which element the state\n * pseudo-class should apply to. If `selectors.root` describes a descendant\n * element (e.g. \".wp-block-button .wp-block-button__link\"), the relative\n * portion (\".wp-block-button__link\") is scoped under `baseSelector`. If no\n * descendant is present, falls back to appending the state to `baseSelector`.\n *\n * @param {string} baseSelector The block-instance scoping class selector.\n * @param {string} name The block name, used to look up selectors.\n * @param {string} state The pseudo-class string, e.g. \":hover\".\n * @return {string} The fully-scoped CSS selector for this state.\n */\nexport function buildPseudoStyleStateSelector( baseSelector, name, state ) {\n\treturn `${ buildRootStyleStateSelector( baseSelector, name ) }${ state }`;\n}\n\nexport function buildStateSelector( baseSelector, name, state ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector( baseSelector, rootSelector, state );\n}\n\n/**\n * Builds the CSS selector used to preview a state on the editor canvas,\n * scoped to a specific block instance via its `data-block` attribute.\n *\n * For blocks whose `selectors.root` targets a descendant element\n * (e.g. \".wp-block-button .wp-block-button__link\"), the selector targets\n * that descendant inside the block wrapper. Otherwise it targets the wrapper\n * itself.\n *\n * @param {string} clientId The block's clientId.\n * @param {string} name The block name, used to look up selectors.\n * @return {string} CSS selector scoped to this block instance.\n */\nexport function buildCanvasStateSelector( clientId, name ) {\n\tconst rootSelector = getBlockType( name )?.selectors?.root;\n\treturn buildScopedBlockSelector(\n\t\t`[data-block=\"${ clientId }\"]`,\n\t\trootSelector\n\t);\n}\n"],
5
5
  "mappings": ";AAGA,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAe3B,SAAS,wBAAyB,cAAe;AAMvD,QAAM,QAAQ,aAAa,KAAK,EAAE,MAAO,sBAAuB;AAChE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AACA,QAAM,OAAO,MAAO,CAAE,EAAE,KAAK;AAC7B,SAAO,QAAQ;AAChB;AAaO,SAAS,yBACf,cACA,eACA,SAAS,IACR;AACD,MAAK,OAAO,kBAAkB,YAAY,CAAE,eAAgB;AAC3D,WAAO,kBAAmB,YAAa,EACrC,IAAK,CAAE,aAAc,GAAI,SAAS,KAAK,CAAE,GAAI,MAAO,EAAG,EACvD,KAAM,IAAK;AAAA,EACd;AAEA,QAAM,gBAAgB,kBAAmB,YAAa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