@wordpress/edit-site 4.15.1-next.4d3b314fd5.0 → 4.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/block-editor/block-inspector-button.js +1 -1
  3. package/build/components/block-editor/block-inspector-button.js.map +1 -1
  4. package/build/components/block-editor/index.js +17 -11
  5. package/build/components/block-editor/index.js.map +1 -1
  6. package/build/components/block-editor/resizable-editor.js +11 -35
  7. package/build/components/block-editor/resizable-editor.js.map +1 -1
  8. package/build/components/editor/index.js +5 -7
  9. package/build/components/editor/index.js.map +1 -1
  10. package/build/components/global-styles/preview.js +85 -50
  11. package/build/components/global-styles/preview.js.map +1 -1
  12. package/build/components/global-styles/screen-style-variations.js +35 -4
  13. package/build/components/global-styles/screen-style-variations.js.map +1 -1
  14. package/build/components/global-styles/screen-typography-element.js +49 -2
  15. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  16. package/build/components/global-styles/typography-panel.js +143 -83
  17. package/build/components/global-styles/typography-panel.js.map +1 -1
  18. package/build/components/global-styles/typography-preview.js +54 -0
  19. package/build/components/global-styles/typography-preview.js.map +1 -0
  20. package/build/components/global-styles/typography-utils.js +39 -176
  21. package/build/components/global-styles/typography-utils.js.map +1 -1
  22. package/build/components/global-styles/use-global-styles-output.js +34 -16
  23. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  24. package/build/components/{header → header-edit-mode}/document-actions/index.js +58 -24
  25. package/build/components/header-edit-mode/document-actions/index.js.map +1 -0
  26. package/build/components/{header → header-edit-mode}/index.js +13 -49
  27. package/build/components/header-edit-mode/index.js.map +1 -0
  28. package/build/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
  29. package/build/components/header-edit-mode/mode-switcher/index.js.map +1 -0
  30. package/build/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
  31. package/build/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +1 -0
  32. package/build/components/{header → header-edit-mode}/more-menu/index.js +0 -0
  33. package/build/components/header-edit-mode/more-menu/index.js.map +1 -0
  34. package/build/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
  35. package/build/components/header-edit-mode/more-menu/site-export.js.map +1 -0
  36. package/build/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
  37. package/build/components/header-edit-mode/more-menu/welcome-guide-menu-item.js.map +1 -0
  38. package/build/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
  39. package/build/components/header-edit-mode/plugin-more-menu-item/index.js.map +1 -0
  40. package/build/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
  41. package/build/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js.map +1 -0
  42. package/build/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
  43. package/build/components/header-edit-mode/tools-more-menu-group/index.js.map +1 -0
  44. package/build/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
  45. package/build/components/header-edit-mode/undo-redo/redo.js.map +1 -0
  46. package/build/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
  47. package/build/components/header-edit-mode/undo-redo/undo.js.map +1 -0
  48. package/build/components/keyboard-shortcuts/index.js +1 -1
  49. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  50. package/build/components/main-dashboard-button/index.js +2 -2
  51. package/build/components/main-dashboard-button/index.js.map +1 -1
  52. package/build/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
  53. package/build/components/sidebar-edit-mode/constants.js.map +1 -0
  54. package/build/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
  55. package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -0
  56. package/build/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
  57. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -0
  58. package/build/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
  59. package/build/components/sidebar-edit-mode/index.js.map +1 -0
  60. package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
  61. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +1 -0
  62. package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
  63. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  64. package/build/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
  65. package/build/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  66. package/build/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
  67. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -0
  68. package/build/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
  69. package/build/components/sidebar-edit-mode/settings-header/index.js.map +1 -0
  70. package/build/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
  71. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -0
  72. package/build/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
  73. package/build/components/sidebar-edit-mode/template-card/template-actions.js.map +1 -0
  74. package/build/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
  75. package/build/components/sidebar-edit-mode/template-card/template-areas.js.map +1 -0
  76. package/build/index.js +23 -4
  77. package/build/index.js.map +1 -1
  78. package/build-module/components/block-editor/block-inspector-button.js +1 -1
  79. package/build-module/components/block-editor/block-inspector-button.js.map +1 -1
  80. package/build-module/components/block-editor/index.js +16 -10
  81. package/build-module/components/block-editor/index.js.map +1 -1
  82. package/build-module/components/block-editor/resizable-editor.js +10 -34
  83. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  84. package/build-module/components/editor/index.js +4 -6
  85. package/build-module/components/editor/index.js.map +1 -1
  86. package/build-module/components/global-styles/preview.js +85 -50
  87. package/build-module/components/global-styles/preview.js.map +1 -1
  88. package/build-module/components/global-styles/screen-style-variations.js +36 -6
  89. package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
  90. package/build-module/components/global-styles/screen-typography-element.js +48 -2
  91. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  92. package/build-module/components/global-styles/typography-panel.js +143 -85
  93. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  94. package/build-module/components/global-styles/typography-preview.js +46 -0
  95. package/build-module/components/global-styles/typography-preview.js.map +1 -0
  96. package/build-module/components/global-styles/typography-utils.js +37 -169
  97. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  98. package/build-module/components/global-styles/use-global-styles-output.js +33 -16
  99. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  100. package/build-module/components/{header → header-edit-mode}/document-actions/index.js +53 -24
  101. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -0
  102. package/build-module/components/{header → header-edit-mode}/index.js +13 -46
  103. package/build-module/components/header-edit-mode/index.js.map +1 -0
  104. package/build-module/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
  105. package/build-module/components/header-edit-mode/mode-switcher/index.js.map +1 -0
  106. package/build-module/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
  107. package/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js.map +1 -0
  108. package/build-module/components/{header → header-edit-mode}/more-menu/index.js +0 -0
  109. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -0
  110. package/build-module/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
  111. package/build-module/components/header-edit-mode/more-menu/site-export.js.map +1 -0
  112. package/build-module/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
  113. package/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js.map +1 -0
  114. package/build-module/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
  115. package/build-module/components/header-edit-mode/plugin-more-menu-item/index.js.map +1 -0
  116. package/build-module/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
  117. package/build-module/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js.map +1 -0
  118. package/build-module/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
  119. package/build-module/components/header-edit-mode/tools-more-menu-group/index.js.map +1 -0
  120. package/build-module/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
  121. package/build-module/components/header-edit-mode/undo-redo/redo.js.map +1 -0
  122. package/build-module/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
  123. package/build-module/components/header-edit-mode/undo-redo/undo.js.map +1 -0
  124. package/build-module/components/keyboard-shortcuts/index.js +1 -1
  125. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  126. package/build-module/components/main-dashboard-button/index.js +3 -3
  127. package/build-module/components/main-dashboard-button/index.js.map +1 -1
  128. package/build-module/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
  129. package/build-module/components/sidebar-edit-mode/constants.js.map +1 -0
  130. package/build-module/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
  131. package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -0
  132. package/build-module/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
  133. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -0
  134. package/build-module/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
  135. package/build-module/components/sidebar-edit-mode/index.js.map +1 -0
  136. package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
  137. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/index.js.map +1 -0
  138. package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
  139. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
  140. package/build-module/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
  141. package/build-module/components/sidebar-edit-mode/navigation-menu-sidebar/navigation-menu.js.map +1 -0
  142. package/build-module/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
  143. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -0
  144. package/build-module/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
  145. package/build-module/components/sidebar-edit-mode/settings-header/index.js.map +1 -0
  146. package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
  147. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -0
  148. package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
  149. package/build-module/components/sidebar-edit-mode/template-card/template-actions.js.map +1 -0
  150. package/build-module/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
  151. package/build-module/components/sidebar-edit-mode/template-card/template-areas.js.map +1 -0
  152. package/build-module/index.js +22 -4
  153. package/build-module/index.js.map +1 -1
  154. package/build-style/style-rtl.css +64 -89
  155. package/build-style/style.css +64 -89
  156. package/package.json +29 -29
  157. package/src/components/block-editor/block-inspector-button.js +1 -1
  158. package/src/components/block-editor/index.js +29 -11
  159. package/src/components/block-editor/resizable-editor.js +8 -37
  160. package/src/components/editor/index.js +2 -4
  161. package/src/components/global-styles/preview.js +81 -60
  162. package/src/components/global-styles/screen-style-variations.js +39 -4
  163. package/src/components/global-styles/screen-typography-element.js +65 -1
  164. package/src/components/global-styles/style.scss +2 -2
  165. package/src/components/global-styles/test/typography-utils.js +333 -103
  166. package/src/components/global-styles/test/use-global-styles-output.js +57 -3
  167. package/src/components/global-styles/typography-panel.js +205 -150
  168. package/src/components/global-styles/typography-preview.js +49 -0
  169. package/src/components/global-styles/typography-utils.js +34 -195
  170. package/src/components/global-styles/use-global-styles-output.js +31 -9
  171. package/src/components/{header → header-edit-mode}/document-actions/index.js +67 -46
  172. package/src/components/{header → header-edit-mode}/document-actions/style.scss +0 -0
  173. package/src/components/{header → header-edit-mode}/index.js +12 -44
  174. package/src/components/{header → header-edit-mode}/mode-switcher/index.js +0 -0
  175. package/src/components/{header → header-edit-mode}/more-menu/copy-content-menu-item.js +0 -0
  176. package/src/components/{header → header-edit-mode}/more-menu/index.js +0 -0
  177. package/src/components/{header → header-edit-mode}/more-menu/site-export.js +0 -0
  178. package/src/components/{header → header-edit-mode}/more-menu/welcome-guide-menu-item.js +0 -0
  179. package/src/components/{header → header-edit-mode}/plugin-more-menu-item/index.js +0 -0
  180. package/src/components/{header → header-edit-mode}/plugin-sidebar-more-menu-item/index.js +0 -0
  181. package/src/components/{header → header-edit-mode}/style.scss +20 -50
  182. package/src/components/{header → header-edit-mode}/tools-more-menu-group/index.js +0 -0
  183. package/src/components/{header → header-edit-mode}/undo-redo/redo.js +0 -0
  184. package/src/components/{header → header-edit-mode}/undo-redo/undo.js +0 -0
  185. package/src/components/keyboard-shortcuts/index.js +1 -1
  186. package/src/components/main-dashboard-button/index.js +3 -3
  187. package/src/components/{sidebar → sidebar-edit-mode}/constants.js +0 -0
  188. package/src/components/{sidebar → sidebar-edit-mode}/default-sidebar.js +0 -0
  189. package/src/components/{sidebar → sidebar-edit-mode}/global-styles-sidebar.js +0 -0
  190. package/src/components/{sidebar → sidebar-edit-mode}/index.js +1 -1
  191. package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/index.js +0 -0
  192. package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-inspector.js +0 -0
  193. package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/navigation-menu.js +0 -0
  194. package/src/components/{sidebar → sidebar-edit-mode}/navigation-menu-sidebar/style.scss +0 -0
  195. package/src/components/{sidebar → sidebar-edit-mode}/plugin-sidebar/index.js +1 -1
  196. package/src/components/{sidebar → sidebar-edit-mode}/settings-header/index.js +2 -2
  197. package/src/components/{sidebar → sidebar-edit-mode}/settings-header/style.scss +2 -2
  198. package/src/components/{sidebar → sidebar-edit-mode}/style.scss +2 -2
  199. package/src/components/{sidebar → sidebar-edit-mode}/template-card/index.js +0 -0
  200. package/src/components/{sidebar → sidebar-edit-mode}/template-card/style.scss +0 -0
  201. package/src/components/{sidebar → sidebar-edit-mode}/template-card/template-actions.js +0 -0
  202. package/src/components/{sidebar → sidebar-edit-mode}/template-card/template-areas.js +0 -0
  203. package/src/index.js +24 -3
  204. package/src/style.scss +6 -6
  205. package/build/components/header/document-actions/index.js.map +0 -1
  206. package/build/components/header/index.js.map +0 -1
  207. package/build/components/header/mode-switcher/index.js.map +0 -1
  208. package/build/components/header/more-menu/copy-content-menu-item.js.map +0 -1
  209. package/build/components/header/more-menu/index.js.map +0 -1
  210. package/build/components/header/more-menu/site-export.js.map +0 -1
  211. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
  212. package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
  213. package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
  214. package/build/components/header/tools-more-menu-group/index.js.map +0 -1
  215. package/build/components/header/undo-redo/redo.js.map +0 -1
  216. package/build/components/header/undo-redo/undo.js.map +0 -1
  217. package/build/components/sidebar/constants.js.map +0 -1
  218. package/build/components/sidebar/default-sidebar.js.map +0 -1
  219. package/build/components/sidebar/global-styles-sidebar.js.map +0 -1
  220. package/build/components/sidebar/index.js.map +0 -1
  221. package/build/components/sidebar/navigation-menu-sidebar/index.js.map +0 -1
  222. package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
  223. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +0 -1
  224. package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
  225. package/build/components/sidebar/settings-header/index.js.map +0 -1
  226. package/build/components/sidebar/template-card/index.js.map +0 -1
  227. package/build/components/sidebar/template-card/template-actions.js.map +0 -1
  228. package/build/components/sidebar/template-card/template-areas.js.map +0 -1
  229. package/build-module/components/header/document-actions/index.js.map +0 -1
  230. package/build-module/components/header/index.js.map +0 -1
  231. package/build-module/components/header/mode-switcher/index.js.map +0 -1
  232. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +0 -1
  233. package/build-module/components/header/more-menu/index.js.map +0 -1
  234. package/build-module/components/header/more-menu/site-export.js.map +0 -1
  235. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
  236. package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
  237. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
  238. package/build-module/components/header/tools-more-menu-group/index.js.map +0 -1
  239. package/build-module/components/header/undo-redo/redo.js.map +0 -1
  240. package/build-module/components/header/undo-redo/undo.js.map +0 -1
  241. package/build-module/components/sidebar/constants.js.map +0 -1
  242. package/build-module/components/sidebar/default-sidebar.js.map +0 -1
  243. package/build-module/components/sidebar/global-styles-sidebar.js.map +0 -1
  244. package/build-module/components/sidebar/index.js.map +0 -1
  245. package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +0 -1
  246. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +0 -1
  247. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +0 -1
  248. package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
  249. package/build-module/components/sidebar/settings-header/index.js.map +0 -1
  250. package/build-module/components/sidebar/template-card/index.js.map +0 -1
  251. package/build-module/components/sidebar/template-card/template-actions.js.map +0 -1
  252. package/build-module/components/sidebar/template-card/template-areas.js.map +0 -1
@@ -3,10 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getComputedFluidTypographyValue = getComputedFluidTypographyValue;
7
6
  exports.getTypographyFontSizeValue = getTypographyFontSizeValue;
8
- exports.getTypographyValueAndUnit = getTypographyValueAndUnit;
9
- exports.roundToPrecision = roundToPrecision;
7
+
8
+ var _blockEditor = require("@wordpress/block-editor");
10
9
 
11
10
  /**
12
11
  * The fluid utilities must match the backend equivalent.
@@ -14,68 +13,62 @@ exports.roundToPrecision = roundToPrecision;
14
13
  * ---------------------------------------------------------------
15
14
  */
16
15
 
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * @typedef {Object} FluidPreset
22
+ * @property {string|undefined} max A maximum font size value.
23
+ * @property {?string|undefined} min A minimum font size value.
24
+ */
25
+
26
+ /**
27
+ * @typedef {Object} Preset
28
+ * @property {?string|?number} size A default font size.
29
+ * @property {string} name A font size name, displayed in the UI.
30
+ * @property {string} slug A font size slug
31
+ * @property {boolean|FluidPreset|undefined} fluid A font size slug
32
+ */
33
+
17
34
  /**
18
35
  * Returns a font-size value based on a given font-size preset.
19
36
  * Takes into account fluid typography parameters and attempts to return a css formula depending on available, valid values.
20
37
  *
21
- * @param {Object} preset
22
- * @param {string} preset.size A default font size.
23
- * @param {string} preset.name A font size name, displayed in the UI.
24
- * @param {string} preset.slug A font size slug.
25
- * @param {Object} preset.fluid
26
- * @param {string|undefined} preset.fluid.max A maximum font size value.
27
- * @param {string|undefined} preset.fluid.min A minimum font size value.
28
- * @param {Object} typographySettings
29
- * @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
38
+ * @param {Preset} preset
39
+ * @param {Object} typographySettings
40
+ * @param {boolean} typographySettings.fluid Whether fluid typography is enabled.
30
41
  *
31
- * @return {string} An font-size value
42
+ * @return {string|*} A font-size value or the value of preset.size.
32
43
  */
33
44
  function getTypographyFontSizeValue(preset, typographySettings) {
45
+ var _preset$fluid, _preset$fluid2;
46
+
34
47
  const {
35
48
  size: defaultSize
36
49
  } = preset;
50
+ /*
51
+ * Catches falsy values and 0/'0'.
52
+ * Fluid calculations cannot be performed on 0.
53
+ */
37
54
 
38
- if (true !== (typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid)) {
39
- return defaultSize;
40
- } // Defaults.
41
-
42
-
43
- const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
44
- const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';
45
- const DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;
46
- const DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;
47
- const DEFAULT_SCALE_FACTOR = 1; // Font sizes.
48
- // A font size has explicitly bypassed fluid calculations.
49
-
50
- if (false === (preset === null || preset === void 0 ? void 0 : preset.fluid)) {
55
+ if (!defaultSize || '0' === defaultSize) {
51
56
  return defaultSize;
52
57
  }
53
58
 
54
- const fluidFontSizeSettings = (preset === null || preset === void 0 ? void 0 : preset.fluid) || {}; // Try to grab explicit min and max fluid font sizes.
55
-
56
- let minimumFontSizeRaw = fluidFontSizeSettings === null || fluidFontSizeSettings === void 0 ? void 0 : fluidFontSizeSettings.min;
57
- let maximumFontSizeRaw = fluidFontSizeSettings === null || fluidFontSizeSettings === void 0 ? void 0 : fluidFontSizeSettings.max;
58
- const preferredSize = getTypographyValueAndUnit(defaultSize); // Protect against unsupported units.
59
-
60
- if (!(preferredSize !== null && preferredSize !== void 0 && preferredSize.unit)) {
59
+ if (true !== (typographySettings === null || typographySettings === void 0 ? void 0 : typographySettings.fluid)) {
61
60
  return defaultSize;
62
- } // If no fluid min or max font sizes are available, create some using min/max font size factors.
61
+ } // A font size has explicitly bypassed fluid calculations.
63
62
 
64
63
 
65
- if (!minimumFontSizeRaw) {
66
- minimumFontSizeRaw = preferredSize.value * DEFAULT_MINIMUM_FONT_SIZE_FACTOR + preferredSize.unit;
67
- }
68
-
69
- if (!maximumFontSizeRaw) {
70
- maximumFontSizeRaw = preferredSize.value * DEFAULT_MAXIMUM_FONT_SIZE_FACTOR + preferredSize.unit;
64
+ if (false === (preset === null || preset === void 0 ? void 0 : preset.fluid)) {
65
+ return defaultSize;
71
66
  }
72
67
 
73
- const fluidFontSizeValue = getComputedFluidTypographyValue({
74
- maximumViewPortWidth: DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
75
- minimumViewPortWidth: DEFAULT_MINIMUM_VIEWPORT_WIDTH,
76
- maximumFontSize: maximumFontSizeRaw,
77
- minimumFontSize: minimumFontSizeRaw,
78
- scaleFactor: DEFAULT_SCALE_FACTOR
68
+ const fluidFontSizeValue = (0, _blockEditor.getComputedFluidTypographyValue)({
69
+ minimumFontSize: preset === null || preset === void 0 ? void 0 : (_preset$fluid = preset.fluid) === null || _preset$fluid === void 0 ? void 0 : _preset$fluid.min,
70
+ maximumFontSize: preset === null || preset === void 0 ? void 0 : (_preset$fluid2 = preset.fluid) === null || _preset$fluid2 === void 0 ? void 0 : _preset$fluid2.max,
71
+ fontSize: defaultSize
79
72
  });
80
73
 
81
74
  if (!!fluidFontSizeValue) {
@@ -84,134 +77,4 @@ function getTypographyFontSizeValue(preset, typographySettings) {
84
77
 
85
78
  return defaultSize;
86
79
  }
87
- /**
88
- * Internal implementation of clamp() based on available min/max viewport width, and min/max font sizes.
89
- *
90
- * @param {Object} args
91
- * @param {string} args.maximumViewPortWidth Maximum size up to which type will have fluidity.
92
- * @param {string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity.
93
- * @param {string} args.maximumFontSize Maximum font size for any clamp() calculation.
94
- * @param {string} args.minimumFontSize Minimum font size for any clamp() calculation.
95
- * @param {number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries.
96
- *
97
- * @return {string|null} A font-size value using clamp().
98
- */
99
-
100
-
101
- function getComputedFluidTypographyValue(_ref) {
102
- let {
103
- maximumViewPortWidth,
104
- minimumViewPortWidth,
105
- maximumFontSize,
106
- minimumFontSize,
107
- scaleFactor
108
- } = _ref;
109
- // Grab the minimum font size and normalize it in order to use the value for calculations.
110
- const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); // We get a 'preferred' unit to keep units consistent when calculating,
111
- // otherwise the result will not be accurate.
112
-
113
- const fontSizeUnit = (minimumFontSizeParsed === null || minimumFontSizeParsed === void 0 ? void 0 : minimumFontSizeParsed.unit) || 'rem'; // Grab the maximum font size and normalize it in order to use the value for calculations.
114
-
115
- const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
116
- coerceTo: fontSizeUnit
117
- }); // Protect against unsupported units.
118
-
119
- if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
120
- return null;
121
- } // Use rem for accessible fluid target font scaling.
122
-
123
-
124
- const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
125
- coerceTo: 'rem'
126
- }); // Viewport widths defined for fluid typography. Normalize units
127
-
128
- const maximumViewPortWidthParsed = getTypographyValueAndUnit(maximumViewPortWidth, {
129
- coerceTo: fontSizeUnit
130
- });
131
- const minumumViewPortWidthParsed = getTypographyValueAndUnit(minimumViewPortWidth, {
132
- coerceTo: fontSizeUnit
133
- }); // Protect against unsupported units.
134
-
135
- if (!maximumViewPortWidthParsed || !minumumViewPortWidthParsed || !minimumFontSizeRem) {
136
- return null;
137
- } // Build CSS rule.
138
- // Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
139
-
140
-
141
- const minViewPortWidthOffsetValue = roundToPrecision(minumumViewPortWidthParsed.value / 100, 3);
142
- const viewPortWidthOffset = minViewPortWidthOffsetValue + fontSizeUnit;
143
- let linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / (maximumViewPortWidthParsed.value - minumumViewPortWidthParsed.value));
144
- linearFactor = roundToPrecision(linearFactor, 3) || 1;
145
- const linearFactorScaled = linearFactor * scaleFactor;
146
- const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewPortWidthOffset}) * ${linearFactorScaled})`;
147
- return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
148
- }
149
- /**
150
- *
151
- * @param {string} rawValue Raw size value from theme.json.
152
- * @param {Object|undefined} options Calculation options.
153
- *
154
- * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.
155
- */
156
-
157
-
158
- function getTypographyValueAndUnit(rawValue) {
159
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
160
-
161
- if (!rawValue) {
162
- return null;
163
- }
164
-
165
- const {
166
- coerceTo,
167
- rootSizeValue,
168
- acceptableUnits
169
- } = {
170
- coerceTo: '',
171
- // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
172
- rootSizeValue: 16,
173
- acceptableUnits: ['rem', 'px', 'em'],
174
- ...options
175
- };
176
- const acceptableUnitsGroup = acceptableUnits === null || acceptableUnits === void 0 ? void 0 : acceptableUnits.join('|');
177
- const regexUnits = new RegExp(`^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`);
178
- const matches = rawValue.match(regexUnits); // We need a number value and a unit.
179
-
180
- if (!matches || matches.length < 3) {
181
- return null;
182
- }
183
-
184
- let [, value, unit] = matches;
185
- let returnValue = parseFloat(value);
186
-
187
- if ('px' === coerceTo && ('em' === unit || 'rem' === unit)) {
188
- returnValue = returnValue * rootSizeValue;
189
- unit = coerceTo;
190
- }
191
-
192
- if ('px' === unit && ('em' === coerceTo || 'rem' === coerceTo)) {
193
- returnValue = returnValue / rootSizeValue;
194
- unit = coerceTo;
195
- }
196
-
197
- return {
198
- value: returnValue,
199
- unit
200
- };
201
- }
202
- /**
203
- * Returns a value rounded to defined precision.
204
- * Returns `undefined` if the value is not a valid finite number.
205
- *
206
- * @param {number} value Raw value.
207
- * @param {number} digits The number of digits to appear after the decimal point
208
- *
209
- * @return {number|undefined} Value rounded to standard precision.
210
- */
211
-
212
-
213
- function roundToPrecision(value) {
214
- let digits = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
215
- return Number.isFinite(value) ? parseFloat(value.toFixed(digits)) : undefined;
216
- }
217
80
  //# sourceMappingURL=typography-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-utils.js"],"names":["getTypographyFontSizeValue","preset","typographySettings","size","defaultSize","fluid","DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MAXIMUM_FONT_SIZE_FACTOR","DEFAULT_SCALE_FACTOR","fluidFontSizeSettings","minimumFontSizeRaw","min","maximumFontSizeRaw","max","preferredSize","getTypographyValueAndUnit","unit","value","fluidFontSizeValue","getComputedFluidTypographyValue","maximumViewPortWidth","minimumViewPortWidth","maximumFontSize","minimumFontSize","scaleFactor","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","coerceTo","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","roundToPrecision","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","Number","isFinite","toFixed","undefined"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,0BAAT,CAAqCC,MAArC,EAA6CC,kBAA7C,EAAkE;AACxE,QAAM;AAAEC,IAAAA,IAAI,EAAEC;AAAR,MAAwBH,MAA9B;;AAEA,MAAK,UAASC,kBAAT,aAASA,kBAAT,uBAASA,kBAAkB,CAAEG,KAA7B,CAAL,EAA0C;AACzC,WAAOD,WAAP;AACA,GALuE,CAOxE;;;AACA,QAAME,8BAA8B,GAAG,QAAvC;AACA,QAAMC,8BAA8B,GAAG,OAAvC;AACA,QAAMC,gCAAgC,GAAG,IAAzC;AACA,QAAMC,gCAAgC,GAAG,GAAzC;AACA,QAAMC,oBAAoB,GAAG,CAA7B,CAZwE,CAcxE;AACA;;AACA,MAAK,WAAUT,MAAV,aAAUA,MAAV,uBAAUA,MAAM,CAAEI,KAAlB,CAAL,EAA+B;AAC9B,WAAOD,WAAP;AACA;;AAED,QAAMO,qBAAqB,GAAG,CAAAV,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEI,KAAR,KAAiB,EAA/C,CApBwE,CAsBxE;;AACA,MA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GAAGT,aAA5B;AACAxB,IAAAA,IAAI,GAAGY,QAAP;AACA;;AAED,MAAK,SAASZ,IAAT,KAAmB,SAASY,QAAT,IAAqB,UAAUA,QAAlD,CAAL,EAAoE;AACnEqB,IAAAA,WAAW,GAAGA,WAAW,GAAGT,aAA5B;AACAxB,IAAAA,IAAI,GAAGY,QAAP;AACA;;AAED,SAAO;AACNX,IAAAA,KAAK,EAAEgC,WADD;AAENjC,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASiB,gBAAT,CAA2BhB,KAA3B,EAA+C;AAAA,MAAbkC,MAAa,uEAAJ,CAAI;AACrD,SAAOC,MAAM,CAACC,QAAP,CAAiBpC,KAAjB,IACJiC,UAAU,CAAEjC,KAAK,CAACqC,OAAN,CAAeH,MAAf,CAAF,CADN,GAEJI,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/**\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 {Object} preset\n * @param {string} preset.size A default font size.\n * @param {string} preset.name A font size name, displayed in the UI.\n * @param {string} preset.slug A font size slug.\n * @param {Object} preset.fluid\n * @param {string|undefined} preset.fluid.max A maximum font size value.\n * @param {string|undefined} preset.fluid.min A minimum font size value.\n * @param {Object} typographySettings\n * @param {boolean} typographySettings.fluid Whether fluid typography is enabled.\n *\n * @return {string} An font-size value\n */\nexport function getTypographyFontSizeValue( preset, typographySettings ) {\n\tconst { size: defaultSize } = preset;\n\n\tif ( true !== typographySettings?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\t// Defaults.\n\tconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\n\tconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\n\tconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\n\tconst DEFAULT_MAXIMUM_FONT_SIZE_FACTOR = 1.5;\n\tconst DEFAULT_SCALE_FACTOR = 1;\n\n\t// Font sizes.\n\t// A font size has explicitly bypassed fluid calculations.\n\tif ( false === preset?.fluid ) {\n\t\treturn defaultSize;\n\t}\n\n\tconst fluidFontSizeSettings = preset?.fluid || {};\n\n\t// Try to grab explicit min and max fluid font sizes.\n\tlet minimumFontSizeRaw = fluidFontSizeSettings?.min;\n\tlet maximumFontSizeRaw = fluidFontSizeSettings?.max;\n\tconst preferredSize = getTypographyValueAndUnit( defaultSize );\n\n\t// Protect against unsupported units.\n\tif ( ! preferredSize?.unit ) {\n\t\treturn defaultSize;\n\t}\n\n\t// If no fluid min or max font sizes are available, create some using min/max font size factors.\n\tif ( ! minimumFontSizeRaw ) {\n\t\tminimumFontSizeRaw =\n\t\t\tpreferredSize.value * DEFAULT_MINIMUM_FONT_SIZE_FACTOR +\n\t\t\tpreferredSize.unit;\n\t}\n\n\tif ( ! maximumFontSizeRaw ) {\n\t\tmaximumFontSizeRaw =\n\t\t\tpreferredSize.value * DEFAULT_MAXIMUM_FONT_SIZE_FACTOR +\n\t\t\tpreferredSize.unit;\n\t}\n\n\tconst fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tmaximumViewPortWidth: DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\t\tminimumViewPortWidth: DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\t\tmaximumFontSize: maximumFontSizeRaw,\n\t\tminimumFontSize: minimumFontSizeRaw,\n\t\tscaleFactor: DEFAULT_SCALE_FACTOR,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n\n/**\n * Internal implementation of clamp() based on available min/max viewport width, and min/max font sizes.\n *\n * @param {Object} args\n * @param {string} args.maximumViewPortWidth Maximum size up to which type will have fluidity.\n * @param {string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity.\n * @param {string} args.maximumFontSize Maximum font size for any clamp() calculation.\n * @param {string} args.minimumFontSize Minimum font size for any clamp() calculation.\n * @param {number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tmaximumViewPortWidth,\n\tminimumViewPortWidth,\n\tmaximumFontSize,\n\tminimumFontSize,\n\tscaleFactor,\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// Grab 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// Protect against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Use 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 = minViewPortWidthOffsetValue + fontSizeUnit;\n\tlet linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tlinearFactor = roundToPrecision( linearFactor, 3 ) || 1;\n\tconst linearFactorScaled = linearFactor * scaleFactor;\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n *\n * @param {string} 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 ( ! rawValue ) {\n\t\treturn null;\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\treturn {\n\t\tvalue: returnValue,\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\treturn Number.isFinite( value )\n\t\t? parseFloat( value.toFixed( digits ) )\n\t\t: undefined;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/typography-utils.js"],"names":["getTypographyFontSizeValue","preset","typographySettings","size","defaultSize","fluid","fluidFontSizeValue","minimumFontSize","min","maximumFontSize","max","fontSize"],"mappings":";;;;;;;AASA;;AATA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,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,MAAK,UAASF,kBAAT,aAASA,kBAAT,uBAASA,kBAAkB,CAAEG,KAA7B,CAAL,EAA0C;AACzC,WAAOD,WAAP;AACA,GAbuE,CAexE;;;AACA,MAAK,WAAUH,MAAV,aAAUA,MAAV,uBAAUA,MAAM,CAAEI,KAAlB,CAAL,EAA+B;AAC9B,WAAOD,WAAP;AACA;;AAED,QAAME,kBAAkB,GAAG,kDAAiC;AAC3DC,IAAAA,eAAe,EAAEN,MAAF,aAAEA,MAAF,wCAAEA,MAAM,CAAEI,KAAV,kDAAE,cAAeG,GAD2B;AAE3DC,IAAAA,eAAe,EAAER,MAAF,aAAEA,MAAF,yCAAEA,MAAM,CAAEI,KAAV,mDAAE,eAAeK,GAF2B;AAG3DC,IAAAA,QAAQ,EAAEP;AAHiD,GAAjC,CAA3B;;AAMA,MAAK,CAAC,CAAEE,kBAAR,EAA6B;AAC5B,WAAOA,kBAAP;AACA;;AAED,SAAOF,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 * WordPress dependencies\n */\nimport { getComputedFluidTypographyValue } from '@wordpress/block-editor';\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 * 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.fluid Whether fluid typography is enabled.\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 ( true !== typographySettings?.fluid ) {\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 fluidFontSizeValue = getComputedFluidTypographyValue( {\n\t\tminimumFontSize: preset?.fluid?.min,\n\t\tmaximumFontSize: preset?.fluid?.max,\n\t\tfontSize: defaultSize,\n\t} );\n\n\tif ( !! fluidFontSizeValue ) {\n\t\treturn fluidFontSizeValue;\n\t}\n\n\treturn defaultSize;\n}\n"]}
@@ -25,6 +25,8 @@ var _blockEditor = require("@wordpress/block-editor");
25
25
 
26
26
  var _utils = require("./utils");
27
27
 
28
+ var _typographyUtils = require("./typography-utils");
29
+
28
30
  var _context = require("./context");
29
31
 
30
32
  var _hooks = require("./hooks");
@@ -265,6 +267,22 @@ function getStylesDeclarations() {
265
267
  if (!ruleValue || !!((_ruleValue2 = ruleValue) !== null && _ruleValue2 !== void 0 && _ruleValue2.ref)) {
266
268
  return;
267
269
  }
270
+ } // Calculate fluid typography rules where available.
271
+
272
+
273
+ if (cssProperty === 'font-size') {
274
+ var _tree$settings;
275
+
276
+ /*
277
+ * getTypographyFontSizeValue() will check
278
+ * if fluid typography has been activated and also
279
+ * whether the incoming value can be converted to a fluid value.
280
+ * Values that already have a "clamp()" function will not pass the test,
281
+ * and therefore the original $value will be returned.
282
+ */
283
+ ruleValue = (0, _typographyUtils.getTypographyFontSizeValue)({
284
+ size: ruleValue
285
+ }, tree === null || tree === void 0 ? void 0 : (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.typography);
268
286
  }
269
287
 
270
288
  output.push(`${cssProperty}: ${ruleValue}`);
@@ -287,7 +305,7 @@ function getStylesDeclarations() {
287
305
 
288
306
 
289
307
  function getLayoutStyles(_ref6) {
290
- var _style$spacing, _tree$settings, _tree$settings$layout, _tree$settings2, _tree$settings2$layou;
308
+ var _style$spacing, _tree$settings2, _tree$settings2$layou, _tree$settings3, _tree$settings3$layou;
291
309
 
292
310
  let {
293
311
  tree,
@@ -309,7 +327,7 @@ function getLayoutStyles(_ref6) {
309
327
  }
310
328
  }
311
329
 
312
- if (gapValue && tree !== null && tree !== void 0 && (_tree$settings = tree.settings) !== null && _tree$settings !== void 0 && (_tree$settings$layout = _tree$settings.layout) !== null && _tree$settings$layout !== void 0 && _tree$settings$layout.definitions) {
330
+ if (gapValue && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
313
331
  Object.values(tree.settings.layout.definitions).forEach(_ref7 => {
314
332
  let {
315
333
  className,
@@ -355,7 +373,7 @@ function getLayoutStyles(_ref6) {
355
373
  } // Output base styles
356
374
 
357
375
 
358
- if (selector === _utils.ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
376
+ if (selector === _utils.ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings3 = tree.settings) !== null && _tree$settings3 !== void 0 && (_tree$settings3$layou = _tree$settings3.layout) !== null && _tree$settings3$layou !== void 0 && _tree$settings3$layou.definitions) {
359
377
  const validDisplayModes = ['block', 'flex', 'grid'];
360
378
  Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
361
379
  let {
@@ -400,7 +418,7 @@ const getNodesWithStyles = (tree, blockSelectors) => {
400
418
  return nodes;
401
419
  }
402
420
 
403
- const pickStyleKeys = treeToPickFrom => (0, _lodash.pickBy)(treeToPickFrom, (value, key) => ['border', 'color', 'spacing', 'typography', 'filter'].includes(key)); // Top-level.
421
+ const pickStyleKeys = treeToPickFrom => (0, _lodash.pickBy)(treeToPickFrom, (value, key) => ['border', 'color', 'spacing', 'typography', 'filter', 'outline', 'shadow'].includes(key)); // Top-level.
404
422
 
405
423
 
406
424
  const styles = pickStyleKeys(tree.styles);
@@ -465,7 +483,7 @@ const getNodesWithStyles = (tree, blockSelectors) => {
465
483
  exports.getNodesWithStyles = getNodesWithStyles;
466
484
 
467
485
  const getNodesWithSettings = (tree, blockSelectors) => {
468
- var _tree$settings3, _tree$settings$blocks, _tree$settings4;
486
+ var _tree$settings4, _tree$settings$blocks, _tree$settings5;
469
487
 
470
488
  const nodes = [];
471
489
 
@@ -492,7 +510,7 @@ const getNodesWithSettings = (tree, blockSelectors) => {
492
510
 
493
511
 
494
512
  const presets = pickPresets(tree.settings);
495
- const custom = (_tree$settings3 = tree.settings) === null || _tree$settings3 === void 0 ? void 0 : _tree$settings3.custom;
513
+ const custom = (_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.custom;
496
514
 
497
515
  if (!(0, _lodash.isEmpty)(presets) || !!custom) {
498
516
  nodes.push({
@@ -503,7 +521,7 @@ const getNodesWithSettings = (tree, blockSelectors) => {
503
521
  } // Blocks.
504
522
 
505
523
 
506
- Object.entries((_tree$settings$blocks = (_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref15 => {
524
+ Object.entries((_tree$settings$blocks = (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.blocks) !== null && _tree$settings$blocks !== void 0 ? _tree$settings$blocks : {}).forEach(_ref15 => {
507
525
  let [blockName, node] = _ref15;
508
526
  const blockPresets = pickPresets(node);
509
527
  const blockCustom = node.custom;
@@ -547,16 +565,16 @@ const toCustomProperties = (tree, blockSelectors) => {
547
565
  exports.toCustomProperties = toCustomProperties;
548
566
 
549
567
  const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) {
550
- var _tree$settings5, _tree$settings6;
568
+ var _tree$settings6, _tree$settings7;
551
569
 
552
570
  let disableLayoutStyles = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
553
571
  const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
554
572
  const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
555
- const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings5 = tree.settings) === null || _tree$settings5 === void 0 ? void 0 : _tree$settings5.useRootPaddingAwareAlignments;
573
+ const useRootPaddingAlign = tree === null || tree === void 0 ? void 0 : (_tree$settings6 = tree.settings) === null || _tree$settings6 === void 0 ? void 0 : _tree$settings6.useRootPaddingAwareAlignments;
556
574
  const {
557
575
  contentSize,
558
576
  wideSize
559
- } = (tree === null || tree === void 0 ? void 0 : (_tree$settings6 = tree.settings) === null || _tree$settings6 === void 0 ? void 0 : _tree$settings6.layout) || {};
577
+ } = (tree === null || tree === void 0 ? void 0 : (_tree$settings7 = tree.settings) === null || _tree$settings7 === void 0 ? void 0 : _tree$settings7.layout) || {};
560
578
  /*
561
579
  * Reset default browser margin on the root body element.
562
580
  * This is set on the root selector **before** generating the ruleset
@@ -577,12 +595,12 @@ const toStyles = function (tree, blockSelectors, hasBlockGapSupport, hasFallback
577
595
  }
578
596
 
579
597
  if (useRootPaddingAlign) {
580
- ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
581
- .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
582
- .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
583
- .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
584
- .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
585
- .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
598
+ ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }
599
+ .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
600
+ .has-global-padding :where(.has-global-padding) { padding-right: 0; padding-left: 0; }
601
+ .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }
602
+ .has-global-padding :where(.has-global-padding) > .alignfull { margin-right: 0; margin-left: 0; }
603
+ .has-global-padding > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }
586
604
  .has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0;`;
587
605
  }
588
606