@wordpress/block-editor 11.2.0 → 11.3.1

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 (675) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +28 -4
  3. package/build/components/alignment-control/ui.js +1 -1
  4. package/build/components/alignment-control/ui.js.map +1 -1
  5. package/build/components/autocomplete/index.js +2 -7
  6. package/build/components/autocomplete/index.js.map +1 -1
  7. package/build/components/block-actions/index.js +7 -2
  8. package/build/components/block-actions/index.js.map +1 -1
  9. package/build/components/block-alignment-matrix-control/index.js +2 -2
  10. package/build/components/block-alignment-matrix-control/index.js.map +1 -1
  11. package/build/components/block-card/index.js +2 -4
  12. package/build/components/block-card/index.js.map +1 -1
  13. package/build/components/block-edit/index.js +8 -0
  14. package/build/components/block-edit/index.js.map +1 -1
  15. package/build/components/block-inspector/index.js +15 -14
  16. package/build/components/block-inspector/index.js.map +1 -1
  17. package/build/components/block-list/use-in-between-inserter.js +5 -0
  18. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  19. package/build/components/block-lock/modal.js +0 -1
  20. package/build/components/block-lock/modal.js.map +1 -1
  21. package/build/components/block-mover/mover-description.js +2 -2
  22. package/build/components/block-mover/mover-description.js.map +1 -1
  23. package/build/components/block-navigation/dropdown.js +3 -1
  24. package/build/components/block-navigation/dropdown.js.map +1 -1
  25. package/build/components/block-pattern-setup/index.js +1 -1
  26. package/build/components/block-pattern-setup/index.js.map +1 -1
  27. package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
  28. package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  29. package/build/components/block-patterns-list/index.js +31 -3
  30. package/build/components/block-patterns-list/index.js.map +1 -1
  31. package/build/components/block-preview/auto.js +9 -11
  32. package/build/components/block-preview/auto.js.map +1 -1
  33. package/build/components/block-preview/index.js +32 -8
  34. package/build/components/block-preview/index.js.map +1 -1
  35. package/build/components/block-selection-clearer/index.js +1 -1
  36. package/build/components/block-selection-clearer/index.js.map +1 -1
  37. package/build/components/block-settings/container.native.js +7 -33
  38. package/build/components/block-settings/container.native.js.map +1 -1
  39. package/build/components/block-settings-menu/block-settings-dropdown.js +12 -6
  40. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  41. package/build/components/block-settings-menu-controls/index.js +2 -8
  42. package/build/components/block-settings-menu-controls/index.js.map +1 -1
  43. package/build/components/block-switcher/utils.js +1 -1
  44. package/build/components/block-switcher/utils.js.map +1 -1
  45. package/build/components/block-tools/selected-block-popover.js +55 -47
  46. package/build/components/block-tools/selected-block-popover.js.map +1 -1
  47. package/build/components/block-vertical-alignment-control/icons.js +15 -1
  48. package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
  49. package/build/components/block-vertical-alignment-control/ui.js +9 -4
  50. package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
  51. package/build/components/color-style-selector/index.js +3 -1
  52. package/build/components/color-style-selector/index.js.map +1 -1
  53. package/build/components/date-format-picker/index.js +3 -4
  54. package/build/components/date-format-picker/index.js.map +1 -1
  55. package/build/components/font-family/index.js +1 -7
  56. package/build/components/font-family/index.js.map +1 -1
  57. package/build/components/font-sizes/fluid-utils.js +1 -1
  58. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  59. package/build/components/font-sizes/utils.js +1 -1
  60. package/build/components/font-sizes/utils.js.map +1 -1
  61. package/build/components/global-styles/context.js +22 -0
  62. package/build/components/global-styles/context.js.map +1 -0
  63. package/build/components/global-styles/hooks.js +142 -0
  64. package/build/components/global-styles/hooks.js.map +1 -0
  65. package/build/components/global-styles/index.js +42 -0
  66. package/build/components/global-styles/index.js.map +1 -0
  67. package/build/components/global-styles/typography-utils.js +92 -0
  68. package/build/components/global-styles/typography-utils.js.map +1 -0
  69. package/build/components/global-styles/use-global-styles-output.js +974 -0
  70. package/build/components/global-styles/use-global-styles-output.js.map +1 -0
  71. package/build/components/global-styles/utils.js +340 -0
  72. package/build/components/global-styles/utils.js.map +1 -0
  73. package/build/components/height-control/index.js +13 -1
  74. package/build/components/height-control/index.js.map +1 -1
  75. package/build/components/iframe/index.js +5 -3
  76. package/build/components/iframe/index.js.map +1 -1
  77. package/build/components/image-editor/constants.js +1 -1
  78. package/build/components/image-editor/constants.js.map +1 -1
  79. package/build/components/image-editor/context.js +1 -2
  80. package/build/components/image-editor/context.js.map +1 -1
  81. package/build/components/image-editor/cropper.js +3 -1
  82. package/build/components/image-editor/cropper.js.map +1 -1
  83. package/build/components/image-editor/index.js +13 -9
  84. package/build/components/image-editor/index.js.map +1 -1
  85. package/build/components/image-editor/use-transform-image.js +11 -35
  86. package/build/components/image-editor/use-transform-image.js.map +1 -1
  87. package/build/components/image-size-control/index.js +1 -7
  88. package/build/components/image-size-control/index.js.map +1 -1
  89. package/build/components/index.js +8 -24
  90. package/build/components/index.js.map +1 -1
  91. package/build/components/inner-blocks/index.js +22 -32
  92. package/build/components/inner-blocks/index.js.map +1 -1
  93. package/build/components/inner-blocks/index.native.js +8 -23
  94. package/build/components/inner-blocks/index.native.js.map +1 -1
  95. package/build/components/inner-blocks/use-block-context.js +53 -0
  96. package/build/components/inner-blocks/use-block-context.js.map +1 -0
  97. package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
  98. package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  99. package/build/components/inserter/block-patterns-tab.js +9 -2
  100. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  101. package/build/components/inserter/block-types-tab.js +2 -2
  102. package/build/components/inserter/block-types-tab.js.map +1 -1
  103. package/build/components/inserter/hooks/use-patterns-state.js +1 -7
  104. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  105. package/build/components/inserter/index.js +5 -4
  106. package/build/components/inserter/index.js.map +1 -1
  107. package/build/components/inserter/media-tab/hooks.js +142 -56
  108. package/build/components/inserter/media-tab/hooks.js.map +1 -1
  109. package/build/components/inserter/media-tab/media-list.js +74 -21
  110. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  111. package/build/components/inserter/media-tab/media-panel.js +11 -13
  112. package/build/components/inserter/media-tab/media-panel.js.map +1 -1
  113. package/build/components/inserter/media-tab/media-tab.js +6 -3
  114. package/build/components/inserter/media-tab/media-tab.js.map +1 -1
  115. package/build/components/inserter/media-tab/utils.js +26 -15
  116. package/build/components/inserter/media-tab/utils.js.map +1 -1
  117. package/build/components/inserter/menu.js +4 -0
  118. package/build/components/inserter/menu.js.map +1 -1
  119. package/build/components/inserter/preview-panel.js +5 -3
  120. package/build/components/inserter/preview-panel.js.map +1 -1
  121. package/build/components/inserter/search-results.js +2 -7
  122. package/build/components/inserter/search-results.js.map +1 -1
  123. package/build/components/inserter-list-item/index.js +1 -9
  124. package/build/components/inserter-list-item/index.js.map +1 -1
  125. package/build/components/inspector-controls/fill.js +15 -2
  126. package/build/components/inspector-controls/fill.js.map +1 -1
  127. package/build/components/inspector-controls/fill.native.js +14 -1
  128. package/build/components/inspector-controls/fill.native.js.map +1 -1
  129. package/build/components/inspector-controls/groups.js +4 -0
  130. package/build/components/inspector-controls/groups.js.map +1 -1
  131. package/build/components/inspector-controls/index.js +2 -2
  132. package/build/components/inspector-controls/index.js.map +1 -1
  133. package/build/components/inspector-controls/slot.js +14 -1
  134. package/build/components/inspector-controls/slot.js.map +1 -1
  135. package/build/components/inspector-controls/slot.native.js +14 -1
  136. package/build/components/inspector-controls/slot.native.js.map +1 -1
  137. package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  138. package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  139. package/build/components/inspector-controls-tabs/index.js +2 -2
  140. package/build/components/inspector-controls-tabs/index.js.map +1 -1
  141. package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  142. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  143. package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
  144. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  145. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
  146. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  147. package/build/components/justify-content-control/ui.js +8 -1
  148. package/build/components/justify-content-control/ui.js.map +1 -1
  149. package/build/components/link-control/index.js +45 -17
  150. package/build/components/link-control/index.js.map +1 -1
  151. package/build/components/list-view/block.js +1 -1
  152. package/build/components/list-view/block.js.map +1 -1
  153. package/build/components/list-view/use-list-view-drop-zone.js +1 -1
  154. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  155. package/build/components/media-upload/index.native.js +4 -1
  156. package/build/components/media-upload/index.native.js.map +1 -1
  157. package/build/components/off-canvas-editor/appender.js +50 -3
  158. package/build/components/off-canvas-editor/appender.js.map +1 -1
  159. package/build/components/off-canvas-editor/block-contents.js +3 -1
  160. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  161. package/build/components/off-canvas-editor/block-select-button.js +10 -4
  162. package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
  163. package/build/components/off-canvas-editor/block.js +6 -27
  164. package/build/components/off-canvas-editor/block.js.map +1 -1
  165. package/build/components/off-canvas-editor/branch.js +25 -10
  166. package/build/components/off-canvas-editor/branch.js.map +1 -1
  167. package/build/components/off-canvas-editor/index.js +27 -20
  168. package/build/components/off-canvas-editor/index.js.map +1 -1
  169. package/build/components/off-canvas-editor/link-ui.js +2 -2
  170. package/build/components/off-canvas-editor/link-ui.js.map +1 -1
  171. package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  172. package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  173. package/build/components/provider/index.js +21 -9
  174. package/build/components/provider/index.js.map +1 -1
  175. package/build/components/provider/index.native.js +5 -6
  176. package/build/components/provider/index.native.js.map +1 -1
  177. package/build/components/rich-text/use-before-input-rules.js +11 -3
  178. package/build/components/rich-text/use-before-input-rules.js.map +1 -1
  179. package/build/components/rich-text/utils.js +1 -1
  180. package/build/components/rich-text/utils.js.map +1 -1
  181. package/build/components/spacing-sizes-control/utils.js +2 -8
  182. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  183. package/build/components/tool-selector/index.js +3 -1
  184. package/build/components/tool-selector/index.js.map +1 -1
  185. package/build/components/url-popover/image-url-input-ui.js +7 -8
  186. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  187. package/build/components/use-block-display-information/index.js +1 -1
  188. package/build/components/use-block-display-information/index.js.map +1 -1
  189. package/build/experiments.js +45 -0
  190. package/build/experiments.js.map +1 -0
  191. package/build/experiments.native.js +40 -0
  192. package/build/experiments.native.js.map +1 -0
  193. package/build/hooks/anchor.js +2 -1
  194. package/build/hooks/anchor.js.map +1 -1
  195. package/build/hooks/border.js +1 -1
  196. package/build/hooks/border.js.map +1 -1
  197. package/build/hooks/child-layout.js +5 -1
  198. package/build/hooks/child-layout.js.map +1 -1
  199. package/build/hooks/color-panel.js +1 -1
  200. package/build/hooks/color-panel.js.map +1 -1
  201. package/build/hooks/color.js +3 -3
  202. package/build/hooks/color.js.map +1 -1
  203. package/build/hooks/custom-class-name.js +2 -1
  204. package/build/hooks/custom-class-name.js.map +1 -1
  205. package/build/hooks/dimensions.js +7 -5
  206. package/build/hooks/dimensions.js.map +1 -1
  207. package/build/hooks/margin.js +1 -0
  208. package/build/hooks/margin.js.map +1 -1
  209. package/build/hooks/padding.js +1 -0
  210. package/build/hooks/padding.js.map +1 -1
  211. package/build/hooks/position.js +39 -17
  212. package/build/hooks/position.js.map +1 -1
  213. package/build/hooks/typography.js +1 -1
  214. package/build/hooks/typography.js.map +1 -1
  215. package/build/hooks/use-color-props.js +3 -3
  216. package/build/hooks/use-color-props.js.map +1 -1
  217. package/build/hooks/utils.js +69 -3
  218. package/build/hooks/utils.js.map +1 -1
  219. package/build/index.js +10 -1
  220. package/build/index.js.map +1 -1
  221. package/build/layouts/constrained.js +3 -0
  222. package/build/layouts/constrained.js.map +1 -1
  223. package/build/layouts/flex.js +59 -9
  224. package/build/layouts/flex.js.map +1 -1
  225. package/build/layouts/flow.js +0 -18
  226. package/build/layouts/flow.js.map +1 -1
  227. package/build/store/actions.js +3 -30
  228. package/build/store/actions.js.map +1 -1
  229. package/build/store/defaults.js +5 -2
  230. package/build/store/defaults.js.map +1 -1
  231. package/build/store/index.js +11 -2
  232. package/build/store/index.js.map +1 -1
  233. package/build/store/private-actions.js +78 -0
  234. package/build/store/private-actions.js.map +1 -0
  235. package/build/store/private-selectors.js +32 -0
  236. package/build/store/private-selectors.js.map +1 -0
  237. package/build/store/reducer.js +1 -1
  238. package/build/store/reducer.js.map +1 -1
  239. package/build/store/selectors.js +60 -48
  240. package/build/store/selectors.js.map +1 -1
  241. package/build/utils/block-variation-transforms.js +1 -1
  242. package/build/utils/block-variation-transforms.js.map +1 -1
  243. package/build/utils/parse-css-unit-to-px.js +1 -1
  244. package/build/utils/parse-css-unit-to-px.js.map +1 -1
  245. package/build/utils/transform-styles/index.js +1 -7
  246. package/build/utils/transform-styles/index.js.map +1 -1
  247. package/build-module/components/alignment-control/ui.js +1 -1
  248. package/build-module/components/alignment-control/ui.js.map +1 -1
  249. package/build-module/components/autocomplete/index.js +2 -6
  250. package/build-module/components/autocomplete/index.js.map +1 -1
  251. package/build-module/components/block-actions/index.js +7 -2
  252. package/build-module/components/block-actions/index.js.map +1 -1
  253. package/build-module/components/block-alignment-matrix-control/index.js +2 -2
  254. package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
  255. package/build-module/components/block-card/index.js +2 -4
  256. package/build-module/components/block-card/index.js.map +1 -1
  257. package/build-module/components/block-edit/index.js +7 -0
  258. package/build-module/components/block-edit/index.js.map +1 -1
  259. package/build-module/components/block-inspector/index.js +15 -14
  260. package/build-module/components/block-inspector/index.js.map +1 -1
  261. package/build-module/components/block-list/use-in-between-inserter.js +5 -0
  262. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  263. package/build-module/components/block-lock/modal.js +0 -1
  264. package/build-module/components/block-lock/modal.js.map +1 -1
  265. package/build-module/components/block-mover/mover-description.js +2 -2
  266. package/build-module/components/block-mover/mover-description.js.map +1 -1
  267. package/build-module/components/block-navigation/dropdown.js +3 -1
  268. package/build-module/components/block-navigation/dropdown.js.map +1 -1
  269. package/build-module/components/block-pattern-setup/index.js +1 -1
  270. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  271. package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
  272. package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
  273. package/build-module/components/block-patterns-list/index.js +32 -3
  274. package/build-module/components/block-patterns-list/index.js.map +1 -1
  275. package/build-module/components/block-preview/auto.js +9 -11
  276. package/build-module/components/block-preview/auto.js.map +1 -1
  277. package/build-module/components/block-preview/index.js +31 -8
  278. package/build-module/components/block-preview/index.js.map +1 -1
  279. package/build-module/components/block-selection-clearer/index.js +1 -1
  280. package/build-module/components/block-selection-clearer/index.js.map +1 -1
  281. package/build-module/components/block-settings/container.native.js +6 -30
  282. package/build-module/components/block-settings/container.native.js.map +1 -1
  283. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -6
  284. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  285. package/build-module/components/block-settings-menu-controls/index.js +2 -7
  286. package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
  287. package/build-module/components/block-switcher/utils.js +1 -1
  288. package/build-module/components/block-switcher/utils.js.map +1 -1
  289. package/build-module/components/block-tools/selected-block-popover.js +55 -48
  290. package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
  291. package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
  292. package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
  293. package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
  294. package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
  295. package/build-module/components/color-style-selector/index.js +3 -1
  296. package/build-module/components/color-style-selector/index.js.map +1 -1
  297. package/build-module/components/date-format-picker/index.js +4 -5
  298. package/build-module/components/date-format-picker/index.js.map +1 -1
  299. package/build-module/components/font-family/index.js +1 -6
  300. package/build-module/components/font-family/index.js.map +1 -1
  301. package/build-module/components/font-sizes/fluid-utils.js +1 -1
  302. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  303. package/build-module/components/font-sizes/utils.js +1 -1
  304. package/build-module/components/font-sizes/utils.js.map +1 -1
  305. package/build-module/components/global-styles/context.js +12 -0
  306. package/build-module/components/global-styles/context.js.map +1 -0
  307. package/build-module/components/global-styles/hooks.js +121 -0
  308. package/build-module/components/global-styles/hooks.js.map +1 -0
  309. package/build-module/components/global-styles/index.js +4 -0
  310. package/build-module/components/global-styles/index.js.map +1 -0
  311. package/build-module/components/global-styles/typography-utils.js +84 -0
  312. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  313. package/build-module/components/global-styles/use-global-styles-output.js +930 -0
  314. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
  315. package/build-module/components/global-styles/utils.js +321 -0
  316. package/build-module/components/global-styles/utils.js.map +1 -0
  317. package/build-module/components/height-control/index.js +14 -1
  318. package/build-module/components/height-control/index.js.map +1 -1
  319. package/build-module/components/iframe/index.js +6 -4
  320. package/build-module/components/iframe/index.js.map +1 -1
  321. package/build-module/components/image-editor/constants.js +1 -1
  322. package/build-module/components/image-editor/constants.js.map +1 -1
  323. package/build-module/components/image-editor/context.js +1 -2
  324. package/build-module/components/image-editor/context.js.map +1 -1
  325. package/build-module/components/image-editor/cropper.js +3 -1
  326. package/build-module/components/image-editor/cropper.js.map +1 -1
  327. package/build-module/components/image-editor/index.js +13 -3
  328. package/build-module/components/image-editor/index.js.map +1 -1
  329. package/build-module/components/image-editor/use-transform-image.js +12 -37
  330. package/build-module/components/image-editor/use-transform-image.js.map +1 -1
  331. package/build-module/components/image-size-control/index.js +1 -6
  332. package/build-module/components/image-size-control/index.js.map +1 -1
  333. package/build-module/components/index.js +2 -3
  334. package/build-module/components/index.js.map +1 -1
  335. package/build-module/components/inner-blocks/index.js +21 -32
  336. package/build-module/components/inner-blocks/index.js.map +1 -1
  337. package/build-module/components/inner-blocks/index.native.js +9 -22
  338. package/build-module/components/inner-blocks/index.native.js.map +1 -1
  339. package/build-module/components/inner-blocks/use-block-context.js +43 -0
  340. package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
  341. package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
  342. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
  343. package/build-module/components/inserter/block-patterns-tab.js +9 -2
  344. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  345. package/build-module/components/inserter/block-types-tab.js +3 -3
  346. package/build-module/components/inserter/block-types-tab.js.map +1 -1
  347. package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
  348. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  349. package/build-module/components/inserter/index.js +5 -4
  350. package/build-module/components/inserter/index.js.map +1 -1
  351. package/build-module/components/inserter/media-tab/hooks.js +145 -56
  352. package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
  353. package/build-module/components/inserter/media-tab/media-list.js +74 -24
  354. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  355. package/build-module/components/inserter/media-tab/media-panel.js +14 -14
  356. package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
  357. package/build-module/components/inserter/media-tab/media-tab.js +7 -4
  358. package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
  359. package/build-module/components/inserter/media-tab/utils.js +27 -15
  360. package/build-module/components/inserter/media-tab/utils.js.map +1 -1
  361. package/build-module/components/inserter/menu.js +4 -0
  362. package/build-module/components/inserter/menu.js.map +1 -1
  363. package/build-module/components/inserter/preview-panel.js +5 -3
  364. package/build-module/components/inserter/preview-panel.js.map +1 -1
  365. package/build-module/components/inserter/search-results.js +2 -6
  366. package/build-module/components/inserter/search-results.js.map +1 -1
  367. package/build-module/components/inserter-list-item/index.js +1 -9
  368. package/build-module/components/inserter-list-item/index.js.map +1 -1
  369. package/build-module/components/inspector-controls/fill.js +14 -2
  370. package/build-module/components/inspector-controls/fill.js.map +1 -1
  371. package/build-module/components/inspector-controls/fill.native.js +13 -1
  372. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  373. package/build-module/components/inspector-controls/groups.js +4 -0
  374. package/build-module/components/inspector-controls/groups.js.map +1 -1
  375. package/build-module/components/inspector-controls/index.js +2 -2
  376. package/build-module/components/inspector-controls/index.js.map +1 -1
  377. package/build-module/components/inspector-controls/slot.js +13 -1
  378. package/build-module/components/inspector-controls/slot.js.map +1 -1
  379. package/build-module/components/inspector-controls/slot.native.js +13 -1
  380. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  381. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  382. package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
  383. package/build-module/components/inspector-controls-tabs/index.js +2 -2
  384. package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
  385. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  386. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
  387. package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
  388. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  389. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +17 -12
  390. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  391. package/build-module/components/justify-content-control/ui.js +9 -2
  392. package/build-module/components/justify-content-control/ui.js.map +1 -1
  393. package/build-module/components/link-control/index.js +45 -16
  394. package/build-module/components/link-control/index.js.map +1 -1
  395. package/build-module/components/list-view/block.js +1 -1
  396. package/build-module/components/list-view/block.js.map +1 -1
  397. package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
  398. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  399. package/build-module/components/media-upload/index.native.js +4 -1
  400. package/build-module/components/media-upload/index.native.js.map +1 -1
  401. package/build-module/components/off-canvas-editor/appender.js +47 -4
  402. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  403. package/build-module/components/off-canvas-editor/block-contents.js +2 -1
  404. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  405. package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
  406. package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
  407. package/build-module/components/off-canvas-editor/block.js +6 -25
  408. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  409. package/build-module/components/off-canvas-editor/branch.js +23 -11
  410. package/build-module/components/off-canvas-editor/branch.js.map +1 -1
  411. package/build-module/components/off-canvas-editor/index.js +27 -19
  412. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  413. package/build-module/components/off-canvas-editor/link-ui.js +2 -2
  414. package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
  415. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  416. package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
  417. package/build-module/components/provider/index.js +16 -9
  418. package/build-module/components/provider/index.js.map +1 -1
  419. package/build-module/components/provider/index.native.js +4 -4
  420. package/build-module/components/provider/index.native.js.map +1 -1
  421. package/build-module/components/rich-text/use-before-input-rules.js +10 -2
  422. package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
  423. package/build-module/components/rich-text/utils.js +1 -1
  424. package/build-module/components/rich-text/utils.js.map +1 -1
  425. package/build-module/components/spacing-sizes-control/utils.js +2 -7
  426. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  427. package/build-module/components/tool-selector/index.js +3 -1
  428. package/build-module/components/tool-selector/index.js.map +1 -1
  429. package/build-module/components/url-popover/image-url-input-ui.js +8 -8
  430. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  431. package/build-module/components/use-block-display-information/index.js +1 -1
  432. package/build-module/components/use-block-display-information/index.js.map +1 -1
  433. package/build-module/experiments.js +25 -0
  434. package/build-module/experiments.js.map +1 -0
  435. package/build-module/experiments.native.js +23 -0
  436. package/build-module/experiments.native.js.map +1 -0
  437. package/build-module/hooks/anchor.js +2 -1
  438. package/build-module/hooks/anchor.js.map +1 -1
  439. package/build-module/hooks/border.js +1 -1
  440. package/build-module/hooks/border.js.map +1 -1
  441. package/build-module/hooks/child-layout.js +5 -1
  442. package/build-module/hooks/child-layout.js.map +1 -1
  443. package/build-module/hooks/color-panel.js +1 -1
  444. package/build-module/hooks/color-panel.js.map +1 -1
  445. package/build-module/hooks/color.js +3 -3
  446. package/build-module/hooks/color.js.map +1 -1
  447. package/build-module/hooks/custom-class-name.js +2 -1
  448. package/build-module/hooks/custom-class-name.js.map +1 -1
  449. package/build-module/hooks/dimensions.js +6 -5
  450. package/build-module/hooks/dimensions.js.map +1 -1
  451. package/build-module/hooks/margin.js +1 -0
  452. package/build-module/hooks/margin.js.map +1 -1
  453. package/build-module/hooks/padding.js +1 -0
  454. package/build-module/hooks/padding.js.map +1 -1
  455. package/build-module/hooks/position.js +36 -16
  456. package/build-module/hooks/position.js.map +1 -1
  457. package/build-module/hooks/typography.js +1 -1
  458. package/build-module/hooks/typography.js.map +1 -1
  459. package/build-module/hooks/use-color-props.js +3 -3
  460. package/build-module/hooks/use-color-props.js.map +1 -1
  461. package/build-module/hooks/utils.js +70 -4
  462. package/build-module/hooks/utils.js.map +1 -1
  463. package/build-module/index.js +1 -0
  464. package/build-module/index.js.map +1 -1
  465. package/build-module/layouts/constrained.js +3 -0
  466. package/build-module/layouts/constrained.js.map +1 -1
  467. package/build-module/layouts/flex.js +60 -10
  468. package/build-module/layouts/flex.js.map +1 -1
  469. package/build-module/layouts/flow.js +0 -18
  470. package/build-module/layouts/flow.js.map +1 -1
  471. package/build-module/store/actions.js +2 -26
  472. package/build-module/store/actions.js.map +1 -1
  473. package/build-module/store/defaults.js +5 -2
  474. package/build-module/store/defaults.js.map +1 -1
  475. package/build-module/store/index.js +8 -2
  476. package/build-module/store/index.js.map +1 -1
  477. package/build-module/store/private-actions.js +66 -0
  478. package/build-module/store/private-actions.js.map +1 -0
  479. package/build-module/store/private-selectors.js +23 -0
  480. package/build-module/store/private-selectors.js.map +1 -0
  481. package/build-module/store/reducer.js +1 -1
  482. package/build-module/store/reducer.js.map +1 -1
  483. package/build-module/store/selectors.js +48 -37
  484. package/build-module/store/selectors.js.map +1 -1
  485. package/build-module/utils/block-variation-transforms.js +1 -1
  486. package/build-module/utils/block-variation-transforms.js.map +1 -1
  487. package/build-module/utils/parse-css-unit-to-px.js +1 -1
  488. package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
  489. package/build-module/utils/transform-styles/index.js +1 -6
  490. package/build-module/utils/transform-styles/index.js.map +1 -1
  491. package/build-style/content-rtl.css +283 -3
  492. package/build-style/content.css +283 -3
  493. package/build-style/style-rtl.css +105 -221
  494. package/build-style/style.css +105 -221
  495. package/package.json +30 -29
  496. package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
  497. package/src/components/alignment-control/test/index.js +5 -15
  498. package/src/components/alignment-control/ui.js +1 -1
  499. package/src/components/autocomplete/index.js +3 -6
  500. package/src/components/block-actions/index.js +9 -0
  501. package/src/components/block-alignment-control/test/index.js +3 -11
  502. package/src/components/block-alignment-matrix-control/index.js +1 -2
  503. package/src/components/block-card/index.js +1 -4
  504. package/src/components/block-content-overlay/content.scss +4 -4
  505. package/src/components/block-edit/index.js +15 -1
  506. package/src/components/block-icon/content.scss +31 -0
  507. package/src/components/block-inspector/index.js +13 -17
  508. package/src/components/block-list/use-in-between-inserter.js +5 -0
  509. package/src/components/block-lock/modal.js +0 -1
  510. package/src/components/block-mover/mover-description.js +2 -2
  511. package/src/components/block-mover/stories/index.js +3 -3
  512. package/src/components/block-navigation/dropdown.js +1 -1
  513. package/src/components/block-pattern-setup/index.js +1 -4
  514. package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
  515. package/src/components/block-patterns-list/index.js +29 -3
  516. package/src/components/block-preview/README.md +9 -9
  517. package/src/components/block-preview/auto.js +9 -11
  518. package/src/components/block-preview/content.scss +23 -0
  519. package/src/components/block-preview/index.js +40 -10
  520. package/src/components/block-preview/style.scss +0 -23
  521. package/src/components/block-selection-clearer/index.js +1 -1
  522. package/src/components/block-selection-clearer/test/index.js +6 -6
  523. package/src/components/block-settings/container.native.js +7 -26
  524. package/src/components/block-settings-menu/block-settings-dropdown.js +13 -5
  525. package/src/components/block-settings-menu-controls/index.js +2 -10
  526. package/src/components/block-switcher/test/index.js +43 -44
  527. package/src/components/block-switcher/utils.js +1 -1
  528. package/src/components/block-tools/selected-block-popover.js +77 -80
  529. package/src/components/block-tools/style.scss +0 -1
  530. package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
  531. package/src/components/block-vertical-alignment-control/icons.js +12 -0
  532. package/src/components/block-vertical-alignment-control/test/index.js +3 -11
  533. package/src/components/block-vertical-alignment-control/ui.js +16 -6
  534. package/src/components/color-style-selector/index.js +1 -1
  535. package/src/components/colors/test/with-colors.js +2 -8
  536. package/src/components/date-format-picker/index.js +23 -24
  537. package/src/components/date-format-picker/style.scss +0 -6
  538. package/src/components/default-block-appender/content.scss +18 -0
  539. package/src/components/default-block-appender/test/index.js +2 -8
  540. package/src/components/font-family/index.js +1 -6
  541. package/src/components/font-sizes/fluid-utils.js +1 -1
  542. package/src/components/font-sizes/utils.js +1 -1
  543. package/src/components/global-styles/README.md +77 -0
  544. package/src/components/global-styles/context.js +15 -0
  545. package/src/components/global-styles/hooks.js +145 -0
  546. package/src/components/global-styles/index.js +7 -0
  547. package/src/components/global-styles/test/typography-utils.js +393 -0
  548. package/src/components/global-styles/test/use-global-styles-output.js +814 -0
  549. package/src/components/global-styles/test/utils.js +206 -0
  550. package/src/components/global-styles/typography-utils.js +87 -0
  551. package/src/components/global-styles/use-global-styles-output.js +1088 -0
  552. package/src/components/global-styles/utils.js +373 -0
  553. package/src/components/height-control/README.md +55 -0
  554. package/src/components/height-control/index.js +13 -1
  555. package/src/components/iframe/index.js +8 -2
  556. package/src/components/image-editor/constants.js +1 -1
  557. package/src/components/image-editor/context.js +5 -9
  558. package/src/components/image-editor/cropper.js +3 -1
  559. package/src/components/image-editor/index.js +13 -4
  560. package/src/components/image-editor/use-transform-image.js +14 -55
  561. package/src/components/image-size-control/index.js +1 -6
  562. package/src/components/index.js +2 -6
  563. package/src/components/inner-blocks/index.js +29 -33
  564. package/src/components/inner-blocks/index.native.js +27 -47
  565. package/src/components/inner-blocks/use-block-context.js +47 -0
  566. package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
  567. package/src/components/inserter/block-patterns-tab.js +9 -1
  568. package/src/components/inserter/block-types-tab.js +3 -4
  569. package/src/components/inserter/hooks/use-patterns-state.js +1 -6
  570. package/src/components/inserter/index.js +3 -4
  571. package/src/components/inserter/media-tab/hooks.js +167 -65
  572. package/src/components/inserter/media-tab/media-list.js +94 -26
  573. package/src/components/inserter/media-tab/media-panel.js +9 -20
  574. package/src/components/inserter/media-tab/media-tab.js +12 -4
  575. package/src/components/inserter/media-tab/utils.js +20 -10
  576. package/src/components/inserter/menu.js +8 -0
  577. package/src/components/inserter/preview-panel.js +4 -2
  578. package/src/components/inserter/search-results.js +2 -6
  579. package/src/components/inserter/stories/index.js +9 -9
  580. package/src/components/inserter/style.scss +58 -11
  581. package/src/components/inserter-list-item/index.js +0 -7
  582. package/src/components/inspector-controls/README.md +3 -7
  583. package/src/components/inspector-controls/fill.js +15 -1
  584. package/src/components/inspector-controls/fill.native.js +14 -1
  585. package/src/components/inspector-controls/groups.js +3 -0
  586. package/src/components/inspector-controls/index.js +2 -6
  587. package/src/components/inspector-controls/slot.js +14 -1
  588. package/src/components/inspector-controls/slot.native.js +14 -1
  589. package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
  590. package/src/components/inspector-controls-tabs/index.js +2 -4
  591. package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -1
  592. package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
  593. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +21 -10
  594. package/src/components/justify-content-control/ui.js +9 -0
  595. package/src/components/link-control/index.js +59 -23
  596. package/src/components/link-control/style.scss +7 -24
  597. package/src/components/link-control/test/index.js +134 -5
  598. package/src/components/list-view/block.js +1 -1
  599. package/src/components/list-view/use-list-view-drop-zone.js +1 -1
  600. package/src/components/media-replace-flow/test/index.js +4 -12
  601. package/src/components/media-upload/index.native.js +2 -2
  602. package/src/components/off-canvas-editor/README.md +2 -2
  603. package/src/components/off-canvas-editor/appender.js +93 -37
  604. package/src/components/off-canvas-editor/block-contents.js +2 -1
  605. package/src/components/off-canvas-editor/block-select-button.js +12 -1
  606. package/src/components/off-canvas-editor/block.js +3 -42
  607. package/src/components/off-canvas-editor/branch.js +32 -5
  608. package/src/components/off-canvas-editor/index.js +20 -20
  609. package/src/components/off-canvas-editor/link-ui.js +2 -2
  610. package/src/components/off-canvas-editor/style.scss +5 -1
  611. package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
  612. package/src/components/provider/index.js +33 -14
  613. package/src/components/provider/index.native.js +4 -3
  614. package/src/components/provider/test/experimental-provider.js +94 -0
  615. package/src/components/provider/test/use-block-sync.js +10 -0
  616. package/src/components/responsive-block-control/test/index.js +1 -5
  617. package/src/components/rich-text/use-before-input-rules.js +10 -2
  618. package/src/components/rich-text/utils.js +1 -1
  619. package/src/components/spacing-sizes-control/utils.js +2 -7
  620. package/src/components/tool-selector/index.js +1 -1
  621. package/src/components/url-input/test/button.js +24 -24
  622. package/src/components/url-popover/image-url-input-ui.js +7 -8
  623. package/src/components/url-popover/style.scss +0 -10
  624. package/src/components/use-block-display-information/index.js +1 -1
  625. package/src/components/warning/{style.scss → content.scss} +0 -0
  626. package/src/components/warning/test/index.js +1 -5
  627. package/src/content.scss +7 -0
  628. package/src/experiments.js +27 -0
  629. package/src/experiments.native.js +25 -0
  630. package/src/hooks/anchor.js +2 -1
  631. package/src/hooks/border.js +1 -1
  632. package/src/hooks/child-layout.js +6 -1
  633. package/src/hooks/color-panel.js +1 -1
  634. package/src/hooks/color.js +3 -3
  635. package/src/hooks/custom-class-name.js +2 -1
  636. package/src/hooks/dimensions.js +6 -6
  637. package/src/hooks/layout.scss +4 -0
  638. package/src/hooks/margin.js +1 -0
  639. package/src/hooks/padding.js +1 -0
  640. package/src/hooks/position.js +56 -36
  641. package/src/hooks/test/align.native.js +1 -1
  642. package/src/hooks/test/utils.js +104 -0
  643. package/src/hooks/typography.js +1 -1
  644. package/src/hooks/use-color-props.js +3 -3
  645. package/src/hooks/utils.js +68 -2
  646. package/src/index.js +1 -0
  647. package/src/layouts/constrained.js +3 -0
  648. package/src/layouts/flex.js +66 -14
  649. package/src/layouts/flow.js +0 -9
  650. package/src/store/actions.js +2 -26
  651. package/src/store/defaults.js +7 -2
  652. package/src/store/index.js +8 -2
  653. package/src/store/private-actions.js +65 -0
  654. package/src/store/private-selectors.js +20 -0
  655. package/src/store/reducer.js +1 -1
  656. package/src/store/selectors.js +103 -62
  657. package/src/store/test/actions.js +0 -18
  658. package/src/store/test/private-actions.js +22 -0
  659. package/src/store/test/private-selectors.js +52 -0
  660. package/src/store/test/selectors.js +52 -54
  661. package/src/style.scss +3 -5
  662. package/src/utils/block-variation-transforms.js +1 -1
  663. package/src/utils/parse-css-unit-to-px.js +3 -1
  664. package/src/utils/test/parse-css-unit-to-px.js +16 -24
  665. package/src/utils/transform-styles/index.js +1 -6
  666. package/build/components/inner-blocks/get-block-context.js +0 -45
  667. package/build/components/inner-blocks/get-block-context.js.map +0 -1
  668. package/build/components/off-canvas-editor/block-edit-button.js +0 -50
  669. package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
  670. package/build-module/components/inner-blocks/get-block-context.js +0 -37
  671. package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
  672. package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
  673. package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
  674. package/src/components/inner-blocks/get-block-context.js +0 -39
  675. package/src/components/off-canvas-editor/block-edit-button.js +0 -27
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeFactor","minimumFontSizeLimit","getTypographyValueAndUnit","fontSizeParsed","unit","minimumFontSizeLimitParsed","coerceTo","value","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","Math","pow","Number","round","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,gCAAgC,GAAG,IAAzC;AACA,MAAMC,+BAA+B,GAAG,MAAxC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,OASH;AAAA,MAT6C;AAChDC,IAAAA,eADgD;AAEhDC,IAAAA,eAFgD;AAGhDC,IAAAA,QAHgD;AAIhDC,IAAAA,oBAAoB,GAAGR,8BAJyB;AAKhDS,IAAAA,oBAAoB,GAAGV,8BALyB;AAMhDW,IAAAA,WAAW,GAAGT,oBANkC;A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AI,CAACC,GAAL,CAAU,EAAV,EAAcH,MAAd,CAAb;AACA,SAAOI,MAAM,CAAChB,QAAP,CAAiBhB,KAAjB,IACJ2B,UAAU,CAAEG,IAAI,CAACG,KAAL,CAAYjC,KAAK,GAAG6B,IAApB,IAA6BA,IAA/B,CADN,GAEJK,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maxinmum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down by\n * minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and\n * maximum sizes.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,\n\tminimumFontSizeLimit,\n} ) {\n\t// Validate incoming settings and set defaults.\n\tminimumFontSizeLimit = !! getTypographyValueAndUnit( minimumFontSizeLimit )\n\t\t? minimumFontSizeLimit\n\t\t: DEFAULT_MINIMUM_FONT_SIZE_LIMIT;\n\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset =\n\t\troundToPrecision( minViewPortWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeFactor","minimumFontSizeLimit","getTypographyValueAndUnit","fontSizeParsed","unit","minimumFontSizeLimitParsed","coerceTo","value","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","Math","pow","Number","round","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,gCAAgC,GAAG,IAAzC;AACA,MAAMC,+BAA+B,GAAG,MAAxC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,OASH;AAAA,MAT6C;AAChDC,IAAAA,eADgD;AAEh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;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,gBAAT,CAA2BF,KAA3B,EAA+C;AAAA,MAAb4B,MAAa,uEAAJ,CAAI;AACrD,QAAMC,IAAI,GAAGC,IAAI,CAACC,GAAL,CAAU,EAAV,EAAcH,MAAd,CAAb;AACA,SAAOI,MAAM,CAAChB,QAAP,CAAiBhB,KAAjB,IACJ2B,UAAU,CAAEG,IAAI,CAACG,KAAL,CAAYjC,KAAK,GAAG6B,IAApB,IAA6BA,IAA/B,CADN,GAEJK,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maximum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down by\n * minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and\n * maximum sizes.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,\n\tminimumFontSizeLimit,\n} ) {\n\t// Validate incoming settings and set defaults.\n\tminimumFontSizeLimit = !! getTypographyValueAndUnit( minimumFontSizeLimit )\n\t\t? minimumFontSizeLimit\n\t\t: DEFAULT_MINIMUM_FONT_SIZE_LIMIT;\n\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset =\n\t\troundToPrecision( minViewPortWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
@@ -62,7 +62,7 @@ export function getFontSizeObjectByValue(fontSizes, value) {
62
62
  *
63
63
  * @param {string} fontSizeSlug Slug of the fontSize.
64
64
  *
65
- * @return {string} String with the class corresponding to the fontSize passed.
65
+ * @return {string | undefined} String with the class corresponding to the fontSize passed.
66
66
  * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
67
67
  */
68
68
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/utils.js"],"names":["kebabCase","getFontSize","fontSizes","fontSizeAttribute","customFontSizeAttribute","fontSizeObject","find","slug","size","getFontSizeObjectByValue","value","getFontSizeClass","fontSizeSlug"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,CAC1BC,SAD0B,EAE1BC,iBAF0B,EAG1BC,uBAH0B,KAItB;AACJ,MAAKD,iBAAL,EAAyB;AACxB,UAAME,cAAc,GAAGH,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEI,IAAX,CACtB;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAgBA,IAAI,KAAKJ,iBAAzB;AAAA,KADsB,CAAvB;;AAGA,QAAKE,cAAL,EAAsB;AACrB,aAAOA,cAAP;AACA;AACD;;AACD,SAAO;AACNG,IAAAA,IAAI,EAAEJ;AADA,GAAP;AAGA,CAhBM;AAkBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,wBAAT,CAAmCP,SAAnC,EAA8CQ,KAA9C,EAAsD;AAC5D,QAAML,cAAc,GAAGH,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEI,IAAX,CAAiB;AAAA,QAAE;AAAEE,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAKE,KAAzB;AAAA,GAAjB,CAAvB;;AACA,MAAKL,cAAL,EAAsB;AACrB,WAAOA,cAAP;AACA;;AAED,SAAO;AACNG,IAAAA,IAAI,EAAEE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA2BC,YAA3B,EAA0C;AAChD,MAAK,CAAEA,YAAP,EAAsB;AACrB;AACA;;AAED,SAAQ,OAAOZ,SAAS,CAAEY,YAAF,CAAkB,YAA1C;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.\n * \tIf namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.\n *\n * @param {Array} fontSizes Array of font size objects containing at least the \"name\" and \"size\" values as properties.\n * @param {?string} fontSizeAttribute Content of the font size attribute (slug).\n * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value).\n *\n * @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug.\n * \t\t\t\t\t Otherwise, an object with just the size value based on customFontSize is returned.\n */\nexport const getFontSize = (\n\tfontSizes,\n\tfontSizeAttribute,\n\tcustomFontSizeAttribute\n) => {\n\tif ( fontSizeAttribute ) {\n\t\tconst fontSizeObject = fontSizes?.find(\n\t\t\t( { slug } ) => slug === fontSizeAttribute\n\t\t);\n\t\tif ( fontSizeObject ) {\n\t\t\treturn fontSizeObject;\n\t\t}\n\t}\n\treturn {\n\t\tsize: customFontSizeAttribute,\n\t};\n};\n\n/**\n * Returns the corresponding font size object for a given value.\n *\n * @param {Array} fontSizes Array of font size objects.\n * @param {number} value Font size value.\n *\n * @return {Object} Font size object.\n */\nexport function getFontSizeObjectByValue( fontSizes, value ) {\n\tconst fontSizeObject = fontSizes?.find( ( { size } ) => size === value );\n\tif ( fontSizeObject ) {\n\t\treturn fontSizeObject;\n\t}\n\n\treturn {\n\t\tsize: value,\n\t};\n}\n\n/**\n * Returns a class based on fontSizeName.\n *\n * @param {string} fontSizeSlug Slug of the fontSize.\n *\n * @return {string} String with the class corresponding to the fontSize passed.\n * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.\n */\nexport function getFontSizeClass( fontSizeSlug ) {\n\tif ( ! fontSizeSlug ) {\n\t\treturn;\n\t}\n\n\treturn `has-${ kebabCase( fontSizeSlug ) }-font-size`;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/utils.js"],"names":["kebabCase","getFontSize","fontSizes","fontSizeAttribute","customFontSizeAttribute","fontSizeObject","find","slug","size","getFontSizeObjectByValue","value","getFontSizeClass","fontSizeSlug"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,CAC1BC,SAD0B,EAE1BC,iBAF0B,EAG1BC,uBAH0B,KAItB;AACJ,MAAKD,iBAAL,EAAyB;AACxB,UAAME,cAAc,GAAGH,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEI,IAAX,CACtB;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAgBA,IAAI,KAAKJ,iBAAzB;AAAA,KADsB,CAAvB;;AAGA,QAAKE,cAAL,EAAsB;AACrB,aAAOA,cAAP;AACA;AACD;;AACD,SAAO;AACNG,IAAAA,IAAI,EAAEJ;AADA,GAAP;AAGA,CAhBM;AAkBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,wBAAT,CAAmCP,SAAnC,EAA8CQ,KAA9C,EAAsD;AAC5D,QAAML,cAAc,GAAGH,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEI,IAAX,CAAiB;AAAA,QAAE;AAAEE,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAKE,KAAzB;AAAA,GAAjB,CAAvB;;AACA,MAAKL,cAAL,EAAsB;AACrB,WAAOA,cAAP;AACA;;AAED,SAAO;AACNG,IAAAA,IAAI,EAAEE;AADA,GAAP;AAGA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,CAA2BC,YAA3B,EAA0C;AAChD,MAAK,CAAEA,YAAP,EAAsB;AACrB;AACA;;AAED,SAAQ,OAAOZ,SAAS,CAAEY,YAAF,CAAkB,YAA1C;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.\n * \tIf namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.\n *\n * @param {Array} fontSizes Array of font size objects containing at least the \"name\" and \"size\" values as properties.\n * @param {?string} fontSizeAttribute Content of the font size attribute (slug).\n * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value).\n *\n * @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug.\n * \t\t\t\t\t Otherwise, an object with just the size value based on customFontSize is returned.\n */\nexport const getFontSize = (\n\tfontSizes,\n\tfontSizeAttribute,\n\tcustomFontSizeAttribute\n) => {\n\tif ( fontSizeAttribute ) {\n\t\tconst fontSizeObject = fontSizes?.find(\n\t\t\t( { slug } ) => slug === fontSizeAttribute\n\t\t);\n\t\tif ( fontSizeObject ) {\n\t\t\treturn fontSizeObject;\n\t\t}\n\t}\n\treturn {\n\t\tsize: customFontSizeAttribute,\n\t};\n};\n\n/**\n * Returns the corresponding font size object for a given value.\n *\n * @param {Array} fontSizes Array of font size objects.\n * @param {number} value Font size value.\n *\n * @return {Object} Font size object.\n */\nexport function getFontSizeObjectByValue( fontSizes, value ) {\n\tconst fontSizeObject = fontSizes?.find( ( { size } ) => size === value );\n\tif ( fontSizeObject ) {\n\t\treturn fontSizeObject;\n\t}\n\n\treturn {\n\t\tsize: value,\n\t};\n}\n\n/**\n * Returns a class based on fontSizeName.\n *\n * @param {string} fontSizeSlug Slug of the fontSize.\n *\n * @return {string | undefined} String with the class corresponding to the fontSize passed.\n * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.\n */\nexport function getFontSizeClass( fontSizeSlug ) {\n\tif ( ! fontSizeSlug ) {\n\t\treturn;\n\t}\n\n\treturn `has-${ kebabCase( fontSizeSlug ) }-font-size`;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createContext } from '@wordpress/element';
5
+ export const DEFAULT_GLOBAL_STYLES_CONTEXT = {
6
+ user: {},
7
+ base: {},
8
+ merged: {},
9
+ setUserConfig: () => {}
10
+ };
11
+ export const GlobalStylesContext = createContext(DEFAULT_GLOBAL_STYLES_CONTEXT);
12
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/context.js"],"names":["createContext","DEFAULT_GLOBAL_STYLES_CONTEXT","user","base","merged","setUserConfig","GlobalStylesContext"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,oBAA9B;AAEA,OAAO,MAAMC,6BAA6B,GAAG;AAC5CC,EAAAA,IAAI,EAAE,EADsC;AAE5CC,EAAAA,IAAI,EAAE,EAFsC;AAG5CC,EAAAA,MAAM,EAAE,EAHoC;AAI5CC,EAAAA,aAAa,EAAE,MAAM,CAAE;AAJqB,CAAtC;AAOP,OAAO,MAAMC,mBAAmB,GAAGN,aAAa,CAC/CC,6BAD+C,CAAzC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const DEFAULT_GLOBAL_STYLES_CONTEXT = {\n\tuser: {},\n\tbase: {},\n\tmerged: {},\n\tsetUserConfig: () => {},\n};\n\nexport const GlobalStylesContext = createContext(\n\tDEFAULT_GLOBAL_STYLES_CONTEXT\n);\n"]}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import fastDeepEqual from 'fast-deep-equal/es6';
5
+ import { get, set } from 'lodash';
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+
10
+ import { useContext, useCallback } from '@wordpress/element';
11
+ /**
12
+ * Internal dependencies
13
+ */
14
+
15
+ import { getValueFromVariable, getPresetVariableFromValue } from './utils';
16
+ import { GlobalStylesContext } from './context';
17
+ const EMPTY_CONFIG = {
18
+ settings: {},
19
+ styles: {}
20
+ };
21
+ export const useGlobalStylesReset = () => {
22
+ const {
23
+ user: config,
24
+ setUserConfig
25
+ } = useContext(GlobalStylesContext);
26
+ const canReset = !!config && !fastDeepEqual(config, EMPTY_CONFIG);
27
+ return [canReset, useCallback(() => setUserConfig(() => EMPTY_CONFIG), [setUserConfig])];
28
+ };
29
+ export function useGlobalSetting(path, blockName) {
30
+ var _getSettingValueForCo;
31
+
32
+ let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
33
+ const {
34
+ merged: mergedConfig,
35
+ base: baseConfig,
36
+ user: userConfig,
37
+ setUserConfig
38
+ } = useContext(GlobalStylesContext);
39
+ const fullPath = !blockName ? `settings.${path}` : `settings.blocks.${blockName}.${path}`;
40
+
41
+ const setSetting = newValue => {
42
+ setUserConfig(currentConfig => {
43
+ // Deep clone `currentConfig` to avoid mutating it later.
44
+ const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
45
+ set(newUserConfig, fullPath, newValue);
46
+ return newUserConfig;
47
+ });
48
+ };
49
+
50
+ const getSettingValueForContext = name => {
51
+ const currentPath = !name ? `settings.${path}` : `settings.blocks.${name}.${path}`;
52
+ let result;
53
+
54
+ switch (source) {
55
+ case 'all':
56
+ result = get(mergedConfig, currentPath);
57
+ break;
58
+
59
+ case 'user':
60
+ result = get(userConfig, currentPath);
61
+ break;
62
+
63
+ case 'base':
64
+ result = get(baseConfig, currentPath);
65
+ break;
66
+
67
+ default:
68
+ throw 'Unsupported source';
69
+ }
70
+
71
+ return result;
72
+ }; // Unlike styles settings get inherited from top level settings.
73
+
74
+
75
+ const resultWithFallback = (_getSettingValueForCo = getSettingValueForContext(blockName)) !== null && _getSettingValueForCo !== void 0 ? _getSettingValueForCo : getSettingValueForContext();
76
+ return [resultWithFallback, setSetting];
77
+ }
78
+ export function useGlobalStyle(path, blockName) {
79
+ var _get;
80
+
81
+ let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'all';
82
+ const {
83
+ merged: mergedConfig,
84
+ base: baseConfig,
85
+ user: userConfig,
86
+ setUserConfig
87
+ } = useContext(GlobalStylesContext);
88
+ const finalPath = !blockName ? `styles.${path}` : `styles.blocks.${blockName}.${path}`;
89
+
90
+ const setStyle = newValue => {
91
+ setUserConfig(currentConfig => {
92
+ // Deep clone `currentConfig` to avoid mutating it later.
93
+ const newUserConfig = JSON.parse(JSON.stringify(currentConfig));
94
+ set(newUserConfig, finalPath, getPresetVariableFromValue(mergedConfig.settings, blockName, path, newValue));
95
+ return newUserConfig;
96
+ });
97
+ };
98
+
99
+ let result;
100
+
101
+ switch (source) {
102
+ case 'all':
103
+ result = getValueFromVariable(mergedConfig, blockName, // The stlyes.css path is allowed to be empty, so don't revert to base if undefined.
104
+ finalPath === 'styles.css' ? get(userConfig, finalPath) : (_get = get(userConfig, finalPath)) !== null && _get !== void 0 ? _get : get(baseConfig, finalPath));
105
+ break;
106
+
107
+ case 'user':
108
+ result = getValueFromVariable(mergedConfig, blockName, get(userConfig, finalPath));
109
+ break;
110
+
111
+ case 'base':
112
+ result = getValueFromVariable(baseConfig, blockName, get(baseConfig, finalPath));
113
+ break;
114
+
115
+ default:
116
+ throw 'Unsupported source';
117
+ }
118
+
119
+ return [result, setStyle];
120
+ }
121
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/hooks.js"],"names":["fastDeepEqual","get","set","useContext","useCallback","getValueFromVariable","getPresetVariableFromValue","GlobalStylesContext","EMPTY_CONFIG","settings","styles","useGlobalStylesReset","user","config","setUserConfig","canReset","useGlobalSetting","path","blockName","source","merged","mergedConfig","base","baseConfig","userConfig","fullPath","setSetting","newValue","currentConfig","newUserConfig","JSON","parse","stringify","getSettingValueForContext","name","currentPath","result","resultWithFallback","useGlobalStyle","finalPath","setStyle"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAP,MAA0B,qBAA1B;AACA,SAASC,GAAT,EAAcC,GAAd,QAAyB,QAAzB;AAEA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,oBAAxC;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,EAA+BC,0BAA/B,QAAiE,SAAjE;AACA,SAASC,mBAAT,QAAoC,WAApC;AAEA,MAAMC,YAAY,GAAG;AAAEC,EAAAA,QAAQ,EAAE,EAAZ;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAArB;AAEA,OAAO,MAAMC,oBAAoB,GAAG,MAAM;AACzC,QAAM;AAAEC,IAAAA,IAAI,EAAEC,MAAR;AAAgBC,IAAAA;AAAhB,MAAkCX,UAAU,CAAEI,mBAAF,CAAlD;AACA,QAAMQ,QAAQ,GAAG,CAAC,CAAEF,MAAH,IAAa,CAAEb,aAAa,CAAEa,MAAF,EAAUL,YAAV,CAA7C;AACA,SAAO,CACNO,QADM,EAENX,WAAW,CACV,MAAMU,aAAa,CAAE,MAAMN,YAAR,CADT,EAEV,CAAEM,aAAF,CAFU,CAFL,CAAP;AAOA,CAVM;AAYP,OAAO,SAASE,gBAAT,CAA2BC,IAA3B,EAAiCC,SAAjC,EAA6D;AAAA;;AAAA,MA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,CAAEuB,UAAF,EAAce,SAAd,CAHyB,CAA7B;AAKA;;AACD,SAAK,MAAL;AACCH,MAAAA,MAAM,GAAG/B,oBAAoB,CAC5BkB,UAD4B,EAE5BL,SAF4B,EAG5BjB,GAAG,CAAEsB,UAAF,EAAcgB,SAAd,CAHyB,CAA7B;AAKA;;AACD;AACC,YAAM,oBAAN;AA3BF;;AA8BA,SAAO,CAAEH,MAAF,EAAUI,QAAV,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { GlobalStylesContext } from './context';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nexport const useGlobalStylesReset = () => {\n\tconst { user: config, setUserConfig } = useContext( GlobalStylesContext );\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback(\n\t\t\t() => setUserConfig( () => EMPTY_CONFIG ),\n\t\t\t[ setUserConfig ]\n\t\t),\n\t];\n};\n\nexport function useGlobalSetting( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\n\tconst fullPath = ! blockName\n\t\t? `settings.${ path }`\n\t\t: `settings.blocks.${ blockName }.${ path }`;\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset( newUserConfig, fullPath, newValue );\n\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tconst getSettingValueForContext = ( name ) => {\n\t\tconst currentPath = ! name\n\t\t\t? `settings.${ path }`\n\t\t\t: `settings.blocks.${ name }.${ path }`;\n\n\t\tlet result;\n\t\tswitch ( source ) {\n\t\t\tcase 'all':\n\t\t\t\tresult = get( mergedConfig, currentPath );\n\t\t\t\tbreak;\n\t\t\tcase 'user':\n\t\t\t\tresult = get( userConfig, currentPath );\n\t\t\t\tbreak;\n\t\t\tcase 'base':\n\t\t\t\tresult = get( baseConfig, currentPath );\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\treturn result;\n\t};\n\n\t// Unlike styles settings get inherited from top level settings.\n\tconst resultWithFallback =\n\t\tgetSettingValueForContext( blockName ) ?? getSettingValueForContext();\n\n\treturn [ resultWithFallback, setSetting ];\n}\n\nexport function useGlobalStyle( path, blockName, source = 'all' ) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst finalPath = ! blockName\n\t\t? `styles.${ path }`\n\t\t: `styles.blocks.${ blockName }.${ path }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) => {\n\t\t\t// Deep clone `currentConfig` to avoid mutating it later.\n\t\t\tconst newUserConfig = JSON.parse( JSON.stringify( currentConfig ) );\n\t\t\tset(\n\t\t\t\tnewUserConfig,\n\t\t\t\tfinalPath,\n\t\t\t\tgetPresetVariableFromValue(\n\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\tblockName,\n\t\t\t\t\tpath,\n\t\t\t\t\tnewValue\n\t\t\t\t)\n\t\t\t);\n\t\t\treturn newUserConfig;\n\t\t} );\n\t};\n\n\tlet result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\t// The stlyes.css path is allowed to be empty, so don't revert to base if undefined.\n\t\t\t\tfinalPath === 'styles.css'\n\t\t\t\t\t? get( userConfig, finalPath )\n\t\t\t\t\t: get( userConfig, finalPath ) ??\n\t\t\t\t\t\t\tget( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tmergedConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( userConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\tresult = getValueFromVariable(\n\t\t\t\tbaseConfig,\n\t\t\t\tblockName,\n\t\t\t\tget( baseConfig, finalPath )\n\t\t\t);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export { useGlobalStylesReset, useGlobalSetting, useGlobalStyle } from './hooks';
2
+ export { useGlobalStylesOutput } from './use-global-styles-output';
3
+ export { GlobalStylesContext } from './context';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/index.js"],"names":["useGlobalStylesReset","useGlobalSetting","useGlobalStyle","useGlobalStylesOutput","GlobalStylesContext"],"mappings":"AAAA,SACCA,oBADD,EAECC,gBAFD,EAGCC,cAHD,QAIO,SAJP;AAKA,SAASC,qBAAT,QAAsC,4BAAtC;AACA,SAASC,mBAAT,QAAoC,WAApC","sourcesContent":["export {\n\tuseGlobalStylesReset,\n\tuseGlobalSetting,\n\tuseGlobalStyle,\n} from './hooks';\nexport { useGlobalStylesOutput } from './use-global-styles-output';\nexport { GlobalStylesContext } from './context';\n"]}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The fluid utilities must match the backend equivalent.
3
+ * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
4
+ * ---------------------------------------------------------------
5
+ */
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { getComputedFluidTypographyValue } from '../font-sizes/fluid-utils';
11
+ /**
12
+ * @typedef {Object} FluidPreset
13
+ * @property {string|undefined} max A maximum font size value.
14
+ * @property {?string|undefined} min A minimum font size value.
15
+ */
16
+
17
+ /**
18
+ * @typedef {Object} Preset
19
+ * @property {?string|?number} size A default font size.
20
+ * @property {string} name A font size name, displayed in the UI.
21
+ * @property {string} slug A font size slug
22
+ * @property {boolean|FluidPreset|undefined} fluid A font size slug
23
+ */
24
+
25
+ /**
26
+ * @typedef {Object} TypographySettings
27
+ * @property {?string|?number} size A default font size.
28
+ * @property {?string} minViewPortWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.
29
+ * @property {?string} maxViewPortWidth Maximum size up to which type will have fluidity. Optional if size is specified.
30
+ * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
31
+ * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.
32
+ * @property {?string} minFontSize The smallest a calculated font size may be. Optional.
33
+ */
34
+
35
+ /**
36
+ * Returns a font-size value based on a given font-size preset.
37
+ * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
38
+ *
39
+ * @param {Preset} preset
40
+ * @param {Object} typographySettings
41
+ * @param {boolean|TypographySettings} typographySettings.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.
42
+ *
43
+ * @return {string|*} A font-size value or the value of preset.size.
44
+ */
45
+
46
+ export function getTypographyFontSizeValue(preset, typographySettings) {
47
+ var _preset$fluid, _preset$fluid2;
48
+
49
+ const {
50
+ size: defaultSize
51
+ } = preset;
52
+ /*
53
+ * Catches falsy values and 0/'0'.
54
+ * Fluid calculations cannot be performed on 0.
55
+ */
56
+
57
+ if (!defaultSize || '0' === defaultSize) {
58
+ return defaultSize;
59
+ }
60
+
61
+ if (!(typographySettings !== null && typographySettings !== void 0 && typographySettings.fluid) || typeof (typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid) === 'object' && Object.keys(typographySettings.fluid).length === 0) {
62
+ return defaultSize;
63
+ } // A font size has explicitly bypassed fluid calculations.
64
+
65
+
66
+ if (false === (preset === null || preset === void 0 ? void 0 : preset.fluid)) {
67
+ return defaultSize;
68
+ }
69
+
70
+ const fluidTypographySettings = typeof (typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid) === 'object' ? typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid : {};
71
+ const fluidFontSizeValue = getComputedFluidTypographyValue({
72
+ minimumFontSize: preset === null || preset === void 0 ? void 0 : (_preset$fluid = preset.fluid) === null || _preset$fluid === void 0 ? void 0 : _preset$fluid.min,
73
+ maximumFontSize: preset === null || preset === void 0 ? void 0 : (_preset$fluid2 = preset.fluid) === null || _preset$fluid2 === void 0 ? void 0 : _preset$fluid2.max,
74
+ fontSize: defaultSize,
75
+ minimumFontSizeLimit: fluidTypographySettings === null || fluidTypographySettings === void 0 ? void 0 : fluidTypographySettings.minFontSize
76
+ });
77
+
78
+ if (!!fluidFontSizeValue) {
79
+ return fluidFontSizeValue;
80
+ }
81
+
82
+ return defaultSize;
83
+ }
84
+ //# sourceMappingURL=typography-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/typography-utils.js"],"names":["getComputedFluidTypographyValue","getTypographyFontSizeValue","preset","typographySettings","size","defaultSize","fluid","Object","keys","length","fluidTypographySettings","fluidFontSizeValue","minimumFontSize","min","maximumFontSize","max","fontSize","minimumFontSizeLimit","minFontSize"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,SAASA,+BAAT,QAAgD,2BAAhD;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,0BAAT,CAAqCC,MAArC,EAA6CC,kBAA7C,EAAkE;AAAA;;AACxE,QAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAAwBH,MAA9B;AAEA;AACD;AACA;AACA;;AACC,MAAK,CAAEG,WAAF,IAAiB,QAAQA,WAA9B,EAA4C;AAC3C,WAAOA,WAAP;AACA;;AAED,MACC,EAAEF,kBAAF,aAAEA,kBAAF,eAAEA,kBAAkB,CAAEG,KAAtB,KACE,QAAOH,kBAAP,aAAOA,kBAAP,uBAAOA,kBAAkB,CAAEG,KAA3B,MAAqC,QAArC,IACDC,MAAM,CAACC,IAAP,CAAaL,kBAAkB,CAACG,KAAhC,EAAwCG,MAAxC,KAAmD,CAHrD,EAIE;AACD,WAAOJ,WAAP;AACA,GAjBuE,CAmBxE;;;AACA,MAAK,WAAUH,MAAV,aAAUA,MAAV,uBAAUA,MAAM,CAAEI,KAAlB,CAAL,EAA+B;AAC9B,WAAOD,WAAP;AACA;;AAED,QAAMK,uBAAuB,GAC5B,QAAOP,kBAAP,aAAOA,kBAAP,uBAAOA,kBAAkB,CAAEG,KAA3B,MAAqC,QAArC,GACGH,kBADH,aACGA,kBADH,uBACGA,kBAAkB,CAAEG,KADvB,GAEG,EAHJ;AAKA,QAAMK,kBAAkB,GAAGX,+BAA+B,CAAE;AAC3DY,IAAAA,eAAe,EAAEV,MAAF,aAAEA,MAAF,wCAAEA,MAAM,CAAEI,KAAV,kDAAE,cAAeO,GAD2B;AAE3DC,IAAAA,eAAe,EAAEZ,MAAF,aAAEA,MAAF,yCAAEA,MAAM,CAAEI,KAAV,mDAAE,eAAeS,GAF2B;AAG3DC,IAAAA,QAAQ,EAAEX,WAHiD;AAI3DY,IAAAA,oBAAoB,EAAEP,uBAAF,aAAEA,uBAAF,uBAAEA,uBAAuB,CAAEQ;AAJY,GAAF,CAA1D;;AAOA,MAAK,CAAC,CAAEP,kBAAR,EAA6B;AAC5B,WAAOA,kBAAP;AACA;;AAED,SAAON,WAAP;AACA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n/**\n * Internal dependencies\n */\nimport { getComputedFluidTypographyValue } from '../font-sizes/fluid-utils';\n\n/**\n * @typedef {Object} FluidPreset\n * @property {string|undefined} max A maximum font size value.\n * @property {?string|undefined} min A minimum font size value.\n */\n\n/**\n * @typedef {Object} Preset\n * @property {?string|?number} size A default font size.\n * @property {string} name A font size name, displayed in the UI.\n * @property {string} slug A font size slug\n * @property {boolean|FluidPreset|undefined} fluid A font size slug\n */\n\n/**\n * @typedef {Object} TypographySettings\n * @property {?string|?number} size A default font size.\n * @property {?string} minViewPortWidth Minimum viewport size from which type will have fluidity. Optional if size is specified.\n * @property {?string} maxViewPortWidth Maximum size up to which type will have fluidity. Optional if size is specified.\n * @property {?number} scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @property {?number} minFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @property {?string} minFontSize The smallest a calculated font size may be. Optional.\n */\n\n/**\n * Returns a font-size value based on a given font-size preset.\n * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.\n *\n * @param {Preset} preset\n * @param {Object} typographySettings\n * @param {boolean|TypographySettings} typographySettings.fluid Whether fluid typography is enabled, and, optionally, fluid font size options.\n *\n * @return {string|*} A font-size value or the value of preset.size.\n */\nexport function getTypographyFontSizeValue( preset, typographySettings ) {\n\tconst { size: defaultSize } = preset;\n\n\t/*\n\t * Catches falsy values and 0/'0'.\n\t * Fluid calculations cannot be performed on 0.\n\t */\n\tif ( ! defaultSize || '0' === defaultSize ) {\n\t\treturn defaultSize;\n\t}\n\n\tif (\n\t\t! typographySettings?.fluid ||\n\t\t( typeof typographySettings?.fluid === 'object' &&\n\t\t\tObject.keys( typographySettings.fluid ).length === 0 )\n\t) {\n\t\treturn defaultSize;\n\t}\n\n\t// A font size has explicitly bypassed fluid calculations.\n\tif ( false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tconst fluidTypographySettings =\n\t\ttypeof typographySettings?.fluid === 'object'\n\t\t\t? typographySettings?.fluid\n\t\t\t: {};\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t\tminimumFontSizeLimit: fluidTypographySettings?.minFontSize,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n"]}