@wordpress/global-styles-ui 1.1.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 (701) hide show
  1. package/LICENSE.md +788 -0
  2. package/README.md +48 -0
  3. package/build/background-panel.js +62 -0
  4. package/build/background-panel.js.map +7 -0
  5. package/build/block-preview-panel.js +90 -0
  6. package/build/block-preview-panel.js.map +7 -0
  7. package/build/color-indicator-wrapper.js +55 -0
  8. package/build/color-indicator-wrapper.js.map +7 -0
  9. package/build/color-palette-panel.js +123 -0
  10. package/build/color-palette-panel.js.map +7 -0
  11. package/build/color-preview.js +94 -0
  12. package/build/color-preview.js.map +7 -0
  13. package/build/color-variations.js +41 -0
  14. package/build/color-variations.js.map +7 -0
  15. package/build/confirm-reset-shadow-dialog.js +55 -0
  16. package/build/confirm-reset-shadow-dialog.js.map +7 -0
  17. package/build/context.js +37 -0
  18. package/build/context.js.map +7 -0
  19. package/build/dimensions-panel.js +89 -0
  20. package/build/dimensions-panel.js.map +7 -0
  21. package/build/font-families.js +114 -0
  22. package/build/font-families.js.map +7 -0
  23. package/build/font-family-item.js +48 -0
  24. package/build/font-family-item.js.map +7 -0
  25. package/build/font-library-modal/collection-font-variant.js +75 -0
  26. package/build/font-library-modal/collection-font-variant.js.map +7 -0
  27. package/build/font-library-modal/context.js +386 -0
  28. package/build/font-library-modal/context.js.map +7 -0
  29. package/build/font-library-modal/font-card.js +81 -0
  30. package/build/font-library-modal/font-card.js.map +7 -0
  31. package/build/font-library-modal/font-collection.js +510 -0
  32. package/build/font-library-modal/font-collection.js.map +7 -0
  33. package/build/font-library-modal/font-demo.js +111 -0
  34. package/build/font-library-modal/font-demo.js.map +7 -0
  35. package/build/font-library-modal/google-fonts-confirm-dialog.js +58 -0
  36. package/build/font-library-modal/google-fonts-confirm-dialog.js.map +7 -0
  37. package/build/font-library-modal/index.js +110 -0
  38. package/build/font-library-modal/index.js.map +7 -0
  39. package/build/font-library-modal/installed-fonts.js +453 -0
  40. package/build/font-library-modal/installed-fonts.js.map +7 -0
  41. package/build/font-library-modal/lib/inflate.js +2628 -0
  42. package/build/font-library-modal/lib/inflate.js.map +7 -0
  43. package/build/font-library-modal/lib/lib-font.browser.d.js +33 -0
  44. package/build/font-library-modal/lib/lib-font.browser.d.js.map +7 -0
  45. package/build/font-library-modal/lib/lib-font.browser.js +3788 -0
  46. package/build/font-library-modal/lib/lib-font.browser.js.map +7 -0
  47. package/build/font-library-modal/lib/unbrotli.js +3678 -0
  48. package/build/font-library-modal/lib/unbrotli.js.map +7 -0
  49. package/build/font-library-modal/library-font-details.js +63 -0
  50. package/build/font-library-modal/library-font-details.js.map +7 -0
  51. package/build/font-library-modal/library-font-variant.js +81 -0
  52. package/build/font-library-modal/library-font-variant.js.map +7 -0
  53. package/build/font-library-modal/resolvers.js +115 -0
  54. package/build/font-library-modal/resolvers.js.map +7 -0
  55. package/build/font-library-modal/types.js +17 -0
  56. package/build/font-library-modal/types.js.map +7 -0
  57. package/build/font-library-modal/upload-fonts.js +207 -0
  58. package/build/font-library-modal/upload-fonts.js.map +7 -0
  59. package/build/font-library-modal/utils/constants.js +49 -0
  60. package/build/font-library-modal/utils/constants.js.map +7 -0
  61. package/build/font-library-modal/utils/filter-fonts.js +39 -0
  62. package/build/font-library-modal/utils/filter-fonts.js.map +7 -0
  63. package/build/font-library-modal/utils/fonts-outline.js +51 -0
  64. package/build/font-library-modal/utils/fonts-outline.js.map +7 -0
  65. package/build/font-library-modal/utils/index.js +274 -0
  66. package/build/font-library-modal/utils/index.js.map +7 -0
  67. package/build/font-library-modal/utils/make-families-from-faces.js +45 -0
  68. package/build/font-library-modal/utils/make-families-from-faces.js.map +7 -0
  69. package/build/font-library-modal/utils/preview-styles.js +119 -0
  70. package/build/font-library-modal/utils/preview-styles.js.map +7 -0
  71. package/build/font-library-modal/utils/set-immutably.js +40 -0
  72. package/build/font-library-modal/utils/set-immutably.js.map +7 -0
  73. package/build/font-library-modal/utils/sort-font-faces.js +59 -0
  74. package/build/font-library-modal/utils/sort-font-faces.js.map +7 -0
  75. package/build/font-library-modal/utils/toggleFont.js +67 -0
  76. package/build/font-library-modal/utils/toggleFont.js.map +7 -0
  77. package/build/font-sizes/confirm-delete-font-size-dialog.js +60 -0
  78. package/build/font-sizes/confirm-delete-font-size-dialog.js.map +7 -0
  79. package/build/font-sizes/confirm-reset-font-sizes-dialog.js +55 -0
  80. package/build/font-sizes/confirm-reset-font-sizes-dialog.js.map +7 -0
  81. package/build/font-sizes/font-size-preview.js +50 -0
  82. package/build/font-sizes/font-size-preview.js.map +7 -0
  83. package/build/font-sizes/font-size.js +261 -0
  84. package/build/font-sizes/font-size.js.map +7 -0
  85. package/build/font-sizes/font-sizes-count.js +40 -0
  86. package/build/font-sizes/font-sizes-count.js.map +7 -0
  87. package/build/font-sizes/font-sizes.js +215 -0
  88. package/build/font-sizes/font-sizes.js.map +7 -0
  89. package/build/font-sizes/rename-font-size-dialog.js +96 -0
  90. package/build/font-sizes/rename-font-size-dialog.js.map +7 -0
  91. package/build/global-styles-ui.js +213 -0
  92. package/build/global-styles-ui.js.map +7 -0
  93. package/build/gradients-palette-panel.js +133 -0
  94. package/build/gradients-palette-panel.js.map +7 -0
  95. package/build/highlighted-colors.js +57 -0
  96. package/build/highlighted-colors.js.map +7 -0
  97. package/build/hooks.js +176 -0
  98. package/build/hooks.js.map +7 -0
  99. package/build/icon-with-current-color.js +56 -0
  100. package/build/icon-with-current-color.js.map +7 -0
  101. package/build/index.js +51 -0
  102. package/build/index.js.map +7 -0
  103. package/build/lock-unlock.js +35 -0
  104. package/build/lock-unlock.js.map +7 -0
  105. package/build/navigation-button.js +52 -0
  106. package/build/navigation-button.js.map +7 -0
  107. package/build/pagination/index.js +133 -0
  108. package/build/pagination/index.js.map +7 -0
  109. package/build/palette.js +93 -0
  110. package/build/palette.js.map +7 -0
  111. package/build/preset-colors.js +40 -0
  112. package/build/preset-colors.js.map +7 -0
  113. package/build/preview-colors.js +86 -0
  114. package/build/preview-colors.js.map +7 -0
  115. package/build/preview-hooks.js +60 -0
  116. package/build/preview-hooks.js.map +7 -0
  117. package/build/preview-styles.js +219 -0
  118. package/build/preview-styles.js.map +7 -0
  119. package/build/preview-typography.js +72 -0
  120. package/build/preview-typography.js.map +7 -0
  121. package/build/preview-wrapper.js +102 -0
  122. package/build/preview-wrapper.js.map +7 -0
  123. package/build/provider.js +54 -0
  124. package/build/provider.js.map +7 -0
  125. package/build/root-menu.js +72 -0
  126. package/build/root-menu.js.map +7 -0
  127. package/build/screen-background.js +58 -0
  128. package/build/screen-background.js.map +7 -0
  129. package/build/screen-block-list.js +160 -0
  130. package/build/screen-block-list.js.map +7 -0
  131. package/build/screen-block.js +316 -0
  132. package/build/screen-block.js.map +7 -0
  133. package/build/screen-color-palette.js +64 -0
  134. package/build/screen-color-palette.js.map +7 -0
  135. package/build/screen-colors.js +85 -0
  136. package/build/screen-colors.js.map +7 -0
  137. package/build/screen-css.js +68 -0
  138. package/build/screen-css.js.map +7 -0
  139. package/build/screen-header.js +61 -0
  140. package/build/screen-header.js.map +7 -0
  141. package/build/screen-layout.js +54 -0
  142. package/build/screen-layout.js.map +7 -0
  143. package/build/screen-revisions/index.js +147 -0
  144. package/build/screen-revisions/index.js.map +7 -0
  145. package/build/screen-revisions/revisions-buttons.js +198 -0
  146. package/build/screen-revisions/revisions-buttons.js.map +7 -0
  147. package/build/screen-revisions/types.js +17 -0
  148. package/build/screen-revisions/types.js.map +7 -0
  149. package/build/screen-revisions/use-global-styles-revisions.js +163 -0
  150. package/build/screen-revisions/use-global-styles-revisions.js.map +7 -0
  151. package/build/screen-root.js +134 -0
  152. package/build/screen-root.js.map +7 -0
  153. package/build/screen-shadows.js +49 -0
  154. package/build/screen-shadows.js.map +7 -0
  155. package/build/screen-style-variations.js +52 -0
  156. package/build/screen-style-variations.js.map +7 -0
  157. package/build/screen-typography-element.js +167 -0
  158. package/build/screen-typography-element.js.map +7 -0
  159. package/build/screen-typography.js +65 -0
  160. package/build/screen-typography.js.map +7 -0
  161. package/build/shadow-utils.js +125 -0
  162. package/build/shadow-utils.js.map +7 -0
  163. package/build/shadows-edit-panel.js +503 -0
  164. package/build/shadows-edit-panel.js.map +7 -0
  165. package/build/shadows-panel.js +203 -0
  166. package/build/shadows-panel.js.map +7 -0
  167. package/build/size-control/index.js +86 -0
  168. package/build/size-control/index.js.map +7 -0
  169. package/build/style-variations-container.js +130 -0
  170. package/build/style-variations-container.js.map +7 -0
  171. package/build/style-variations-content.js +52 -0
  172. package/build/style-variations-content.js.map +7 -0
  173. package/build/style-variations.js +41 -0
  174. package/build/style-variations.js.map +7 -0
  175. package/build/subtitle.js +33 -0
  176. package/build/subtitle.js.map +7 -0
  177. package/build/typography-elements.js +117 -0
  178. package/build/typography-elements.js.map +7 -0
  179. package/build/typography-example.js +79 -0
  180. package/build/typography-example.js.map +7 -0
  181. package/build/typography-panel.js +64 -0
  182. package/build/typography-panel.js.map +7 -0
  183. package/build/typography-preview.js +70 -0
  184. package/build/typography-preview.js.map +7 -0
  185. package/build/typography-variations.js +41 -0
  186. package/build/typography-variations.js.map +7 -0
  187. package/build/utils.js +210 -0
  188. package/build/utils.js.map +7 -0
  189. package/build/variations/variation.js +116 -0
  190. package/build/variations/variation.js.map +7 -0
  191. package/build/variations/variations-color.js +64 -0
  192. package/build/variations/variations-color.js.map +7 -0
  193. package/build/variations/variations-panel.js +69 -0
  194. package/build/variations/variations-panel.js.map +7 -0
  195. package/build/variations/variations-typography.js +80 -0
  196. package/build/variations/variations-typography.js.map +7 -0
  197. package/build/with-global-styles-provider.js +48 -0
  198. package/build/with-global-styles-provider.js.map +7 -0
  199. package/build-module/background-panel.js +38 -0
  200. package/build-module/background-panel.js.map +7 -0
  201. package/build-module/block-preview-panel.js +70 -0
  202. package/build-module/block-preview-panel.js.map +7 -0
  203. package/build-module/color-indicator-wrapper.js +25 -0
  204. package/build-module/color-indicator-wrapper.js.map +7 -0
  205. package/build-module/color-palette-panel.js +97 -0
  206. package/build-module/color-palette-panel.js.map +7 -0
  207. package/build-module/color-preview.js +70 -0
  208. package/build-module/color-preview.js.map +7 -0
  209. package/build-module/color-variations.js +7 -0
  210. package/build-module/color-variations.js.map +7 -0
  211. package/build-module/confirm-reset-shadow-dialog.js +35 -0
  212. package/build-module/confirm-reset-shadow-dialog.js.map +7 -0
  213. package/build-module/context.js +13 -0
  214. package/build-module/context.js.map +7 -0
  215. package/build-module/dimensions-panel.js +69 -0
  216. package/build-module/dimensions-panel.js.map +7 -0
  217. package/build-module/font-families.js +92 -0
  218. package/build-module/font-families.js.map +7 -0
  219. package/build-module/font-family-item.js +32 -0
  220. package/build-module/font-family-item.js.map +7 -0
  221. package/build-module/font-library-modal/collection-font-variant.js +45 -0
  222. package/build-module/font-library-modal/collection-font-variant.js.map +7 -0
  223. package/build-module/font-library-modal/context.js +382 -0
  224. package/build-module/font-library-modal/context.js.map +7 -0
  225. package/build-module/font-library-modal/font-card.js +57 -0
  226. package/build-module/font-library-modal/font-card.js.map +7 -0
  227. package/build-module/font-library-modal/font-collection.js +510 -0
  228. package/build-module/font-library-modal/font-collection.js.map +7 -0
  229. package/build-module/font-library-modal/font-demo.js +94 -0
  230. package/build-module/font-library-modal/font-demo.js.map +7 -0
  231. package/build-module/font-library-modal/google-fonts-confirm-dialog.js +45 -0
  232. package/build-module/font-library-modal/google-fonts-confirm-dialog.js.map +7 -0
  233. package/build-module/font-library-modal/index.js +83 -0
  234. package/build-module/font-library-modal/index.js.map +7 -0
  235. package/build-module/font-library-modal/installed-fonts.js +442 -0
  236. package/build-module/font-library-modal/installed-fonts.js.map +7 -0
  237. package/build-module/font-library-modal/lib/inflate.js +2636 -0
  238. package/build-module/font-library-modal/lib/inflate.js.map +7 -0
  239. package/build-module/font-library-modal/lib/lib-font.browser.d.js +9 -0
  240. package/build-module/font-library-modal/lib/lib-font.browser.d.js.map +7 -0
  241. package/build-module/font-library-modal/lib/lib-font.browser.js +3754 -0
  242. package/build-module/font-library-modal/lib/lib-font.browser.js.map +7 -0
  243. package/build-module/font-library-modal/lib/unbrotli.js +3686 -0
  244. package/build-module/font-library-modal/lib/unbrotli.js.map +7 -0
  245. package/build-module/font-library-modal/library-font-details.js +36 -0
  246. package/build-module/font-library-modal/library-font-details.js.map +7 -0
  247. package/build-module/font-library-modal/library-font-variant.js +51 -0
  248. package/build-module/font-library-modal/library-font-variant.js.map +7 -0
  249. package/build-module/font-library-modal/resolvers.js +76 -0
  250. package/build-module/font-library-modal/resolvers.js.map +7 -0
  251. package/build-module/font-library-modal/types.js +1 -0
  252. package/build-module/font-library-modal/types.js.map +7 -0
  253. package/build-module/font-library-modal/upload-fonts.js +187 -0
  254. package/build-module/font-library-modal/upload-fonts.js.map +7 -0
  255. package/build-module/font-library-modal/utils/constants.js +23 -0
  256. package/build-module/font-library-modal/utils/constants.js.map +7 -0
  257. package/build-module/font-library-modal/utils/filter-fonts.js +19 -0
  258. package/build-module/font-library-modal/utils/filter-fonts.js.map +7 -0
  259. package/build-module/font-library-modal/utils/fonts-outline.js +26 -0
  260. package/build-module/font-library-modal/utils/fonts-outline.js.map +7 -0
  261. package/build-module/font-library-modal/utils/index.js +238 -0
  262. package/build-module/font-library-modal/utils/index.js.map +7 -0
  263. package/build-module/font-library-modal/utils/make-families-from-faces.js +25 -0
  264. package/build-module/font-library-modal/utils/make-families-from-faces.js.map +7 -0
  265. package/build-module/font-library-modal/utils/preview-styles.js +92 -0
  266. package/build-module/font-library-modal/utils/preview-styles.js.map +7 -0
  267. package/build-module/font-library-modal/utils/set-immutably.js +16 -0
  268. package/build-module/font-library-modal/utils/set-immutably.js.map +7 -0
  269. package/build-module/font-library-modal/utils/sort-font-faces.js +35 -0
  270. package/build-module/font-library-modal/utils/sort-font-faces.js.map +7 -0
  271. package/build-module/font-library-modal/utils/toggleFont.js +43 -0
  272. package/build-module/font-library-modal/utils/toggleFont.js.map +7 -0
  273. package/build-module/font-sizes/confirm-delete-font-size-dialog.js +40 -0
  274. package/build-module/font-sizes/confirm-delete-font-size-dialog.js.map +7 -0
  275. package/build-module/font-sizes/confirm-reset-font-sizes-dialog.js +35 -0
  276. package/build-module/font-sizes/confirm-reset-font-sizes-dialog.js.map +7 -0
  277. package/build-module/font-sizes/font-size-preview.js +30 -0
  278. package/build-module/font-sizes/font-size-preview.js.map +7 -0
  279. package/build-module/font-sizes/font-size.js +241 -0
  280. package/build-module/font-sizes/font-size.js.map +7 -0
  281. package/build-module/font-sizes/font-sizes-count.js +25 -0
  282. package/build-module/font-sizes/font-sizes-count.js.map +7 -0
  283. package/build-module/font-sizes/font-sizes.js +200 -0
  284. package/build-module/font-sizes/font-sizes.js.map +7 -0
  285. package/build-module/font-sizes/rename-font-size-dialog.js +82 -0
  286. package/build-module/font-sizes/rename-font-size-dialog.js.map +7 -0
  287. package/build-module/global-styles-ui.js +182 -0
  288. package/build-module/global-styles-ui.js.map +7 -0
  289. package/build-module/gradients-palette-panel.js +118 -0
  290. package/build-module/gradients-palette-panel.js.map +7 -0
  291. package/build-module/highlighted-colors.js +37 -0
  292. package/build-module/highlighted-colors.js.map +7 -0
  293. package/build-module/hooks.js +144 -0
  294. package/build-module/hooks.js.map +7 -0
  295. package/build-module/icon-with-current-color.js +22 -0
  296. package/build-module/icon-with-current-color.js.map +7 -0
  297. package/build-module/index.js +13 -0
  298. package/build-module/index.js.map +7 -0
  299. package/build-module/lock-unlock.js +10 -0
  300. package/build-module/lock-unlock.js.map +7 -0
  301. package/build-module/navigation-button.js +32 -0
  302. package/build-module/navigation-button.js.map +7 -0
  303. package/build-module/pagination/index.js +107 -0
  304. package/build-module/pagination/index.js.map +7 -0
  305. package/build-module/palette.js +70 -0
  306. package/build-module/palette.js.map +7 -0
  307. package/build-module/preset-colors.js +20 -0
  308. package/build-module/preset-colors.js.map +7 -0
  309. package/build-module/preview-colors.js +59 -0
  310. package/build-module/preview-colors.js.map +7 -0
  311. package/build-module/preview-hooks.js +36 -0
  312. package/build-module/preview-hooks.js.map +7 -0
  313. package/build-module/preview-styles.js +193 -0
  314. package/build-module/preview-styles.js.map +7 -0
  315. package/build-module/preview-typography.js +42 -0
  316. package/build-module/preview-typography.js.map +7 -0
  317. package/build-module/preview-wrapper.js +86 -0
  318. package/build-module/preview-wrapper.js.map +7 -0
  319. package/build-module/provider.js +30 -0
  320. package/build-module/provider.js.map +7 -0
  321. package/build-module/root-menu.js +58 -0
  322. package/build-module/root-menu.js.map +7 -0
  323. package/build-module/screen-background.js +28 -0
  324. package/build-module/screen-background.js.map +7 -0
  325. package/build-module/screen-block-list.js +150 -0
  326. package/build-module/screen-block-list.js.map +7 -0
  327. package/build-module/screen-block.js +293 -0
  328. package/build-module/screen-block.js.map +7 -0
  329. package/build-module/screen-color-palette.js +34 -0
  330. package/build-module/screen-color-palette.js.map +7 -0
  331. package/build-module/screen-colors.js +55 -0
  332. package/build-module/screen-colors.js.map +7 -0
  333. package/build-module/screen-css.js +48 -0
  334. package/build-module/screen-css.js.map +7 -0
  335. package/build-module/screen-header.js +44 -0
  336. package/build-module/screen-header.js.map +7 -0
  337. package/build-module/screen-layout.js +24 -0
  338. package/build-module/screen-layout.js.map +7 -0
  339. package/build-module/screen-revisions/index.js +121 -0
  340. package/build-module/screen-revisions/index.js.map +7 -0
  341. package/build-module/screen-revisions/revisions-buttons.js +178 -0
  342. package/build-module/screen-revisions/revisions-buttons.js.map +7 -0
  343. package/build-module/screen-revisions/types.js +1 -0
  344. package/build-module/screen-revisions/types.js.map +7 -0
  345. package/build-module/screen-revisions/use-global-styles-revisions.js +145 -0
  346. package/build-module/screen-revisions/use-global-styles-revisions.js.map +7 -0
  347. package/build-module/screen-root.js +114 -0
  348. package/build-module/screen-root.js.map +7 -0
  349. package/build-module/screen-shadows.js +14 -0
  350. package/build-module/screen-shadows.js.map +7 -0
  351. package/build-module/screen-style-variations.js +32 -0
  352. package/build-module/screen-style-variations.js.map +7 -0
  353. package/build-module/screen-typography-element.js +141 -0
  354. package/build-module/screen-typography-element.js.map +7 -0
  355. package/build-module/screen-typography.js +35 -0
  356. package/build-module/screen-typography.js.map +7 -0
  357. package/build-module/shadow-utils.js +98 -0
  358. package/build-module/shadow-utils.js.map +7 -0
  359. package/build-module/shadows-edit-panel.js +502 -0
  360. package/build-module/shadows-edit-panel.js.map +7 -0
  361. package/build-module/shadows-panel.js +182 -0
  362. package/build-module/shadows-panel.js.map +7 -0
  363. package/build-module/size-control/index.js +72 -0
  364. package/build-module/size-control/index.js.map +7 -0
  365. package/build-module/style-variations-container.js +100 -0
  366. package/build-module/style-variations-container.js.map +7 -0
  367. package/build-module/style-variations-content.js +18 -0
  368. package/build-module/style-variations-content.js.map +7 -0
  369. package/build-module/style-variations.js +7 -0
  370. package/build-module/style-variations.js.map +7 -0
  371. package/build-module/subtitle.js +9 -0
  372. package/build-module/subtitle.js.map +7 -0
  373. package/build-module/typography-elements.js +102 -0
  374. package/build-module/typography-elements.js.map +7 -0
  375. package/build-module/typography-example.js +59 -0
  376. package/build-module/typography-example.js.map +7 -0
  377. package/build-module/typography-panel.js +44 -0
  378. package/build-module/typography-panel.js.map +7 -0
  379. package/build-module/typography-preview.js +50 -0
  380. package/build-module/typography-preview.js.map +7 -0
  381. package/build-module/typography-variations.js +7 -0
  382. package/build-module/typography-variations.js.map +7 -0
  383. package/build-module/utils.js +179 -0
  384. package/build-module/utils.js.map +7 -0
  385. package/build-module/variations/variation.js +86 -0
  386. package/build-module/variations/variation.js.map +7 -0
  387. package/build-module/variations/variations-color.js +37 -0
  388. package/build-module/variations/variations-color.js.map +7 -0
  389. package/build-module/variations/variations-panel.js +44 -0
  390. package/build-module/variations/variations-panel.js.map +7 -0
  391. package/build-module/variations/variations-typography.js +53 -0
  392. package/build-module/variations/variations-typography.js.map +7 -0
  393. package/build-module/with-global-styles-provider.js +24 -0
  394. package/build-module/with-global-styles-provider.js.map +7 -0
  395. package/build-style/style-rtl.css +717 -0
  396. package/build-style/style.css +718 -0
  397. package/build-types/background-panel.d.ts +10 -0
  398. package/build-types/background-panel.d.ts.map +1 -0
  399. package/build-types/block-preview-panel.d.ts +7 -0
  400. package/build-types/block-preview-panel.d.ts.map +1 -0
  401. package/build-types/color-indicator-wrapper.d.ts +7 -0
  402. package/build-types/color-indicator-wrapper.d.ts.map +1 -0
  403. package/build-types/color-palette-panel.d.ts +6 -0
  404. package/build-types/color-palette-panel.d.ts.map +1 -0
  405. package/build-types/color-preview.d.ts +2 -0
  406. package/build-types/color-preview.d.ts.map +1 -0
  407. package/build-types/color-variations.d.ts +27 -0
  408. package/build-types/color-variations.d.ts.map +1 -0
  409. package/build-types/confirm-reset-shadow-dialog.d.ts +10 -0
  410. package/build-types/confirm-reset-shadow-dialog.d.ts.map +1 -0
  411. package/build-types/context.d.ts +10 -0
  412. package/build-types/context.d.ts.map +1 -0
  413. package/build-types/dimensions-panel.d.ts +2 -0
  414. package/build-types/dimensions-panel.d.ts.map +1 -0
  415. package/build-types/font-families.d.ts +4 -0
  416. package/build-types/font-families.d.ts.map +1 -0
  417. package/build-types/font-family-item.d.ts +7 -0
  418. package/build-types/font-family-item.d.ts.map +1 -0
  419. package/build-types/font-library-modal/collection-font-variant.d.ts +4 -0
  420. package/build-types/font-library-modal/collection-font-variant.d.ts.map +1 -0
  421. package/build-types/font-library-modal/context.d.ts +7 -0
  422. package/build-types/font-library-modal/context.d.ts.map +1 -0
  423. package/build-types/font-library-modal/font-card.d.ts +9 -0
  424. package/build-types/font-library-modal/font-card.d.ts.map +1 -0
  425. package/build-types/font-library-modal/font-collection.d.ts +5 -0
  426. package/build-types/font-library-modal/font-collection.d.ts.map +1 -0
  427. package/build-types/font-library-modal/font-demo.d.ts +4 -0
  428. package/build-types/font-library-modal/font-demo.d.ts.map +1 -0
  429. package/build-types/font-library-modal/google-fonts-confirm-dialog.d.ts +3 -0
  430. package/build-types/font-library-modal/google-fonts-confirm-dialog.d.ts.map +1 -0
  431. package/build-types/font-library-modal/index.d.ts +6 -0
  432. package/build-types/font-library-modal/index.d.ts.map +1 -0
  433. package/build-types/font-library-modal/installed-fonts.d.ts +3 -0
  434. package/build-types/font-library-modal/installed-fonts.d.ts.map +1 -0
  435. package/build-types/font-library-modal/library-font-details.d.ts +6 -0
  436. package/build-types/font-library-modal/library-font-details.d.ts.map +1 -0
  437. package/build-types/font-library-modal/library-font-variant.d.ts +7 -0
  438. package/build-types/font-library-modal/library-font-variant.d.ts.map +1 -0
  439. package/build-types/font-library-modal/resolvers.d.ts +43 -0
  440. package/build-types/font-library-modal/resolvers.d.ts.map +1 -0
  441. package/build-types/font-library-modal/types.d.ts +133 -0
  442. package/build-types/font-library-modal/types.d.ts.map +1 -0
  443. package/build-types/font-library-modal/upload-fonts.d.ts +3 -0
  444. package/build-types/font-library-modal/upload-fonts.d.ts.map +1 -0
  445. package/build-types/font-library-modal/utils/constants.d.ts +4 -0
  446. package/build-types/font-library-modal/utils/constants.d.ts.map +1 -0
  447. package/build-types/font-library-modal/utils/filter-fonts.d.ts +25 -0
  448. package/build-types/font-library-modal/utils/filter-fonts.d.ts.map +1 -0
  449. package/build-types/font-library-modal/utils/fonts-outline.d.ts +7 -0
  450. package/build-types/font-library-modal/utils/fonts-outline.d.ts.map +1 -0
  451. package/build-types/font-library-modal/utils/index.d.ts +21 -0
  452. package/build-types/font-library-modal/utils/index.d.ts.map +1 -0
  453. package/build-types/font-library-modal/utils/make-families-from-faces.d.ts +6 -0
  454. package/build-types/font-library-modal/utils/make-families-from-faces.d.ts.map +1 -0
  455. package/build-types/font-library-modal/utils/preview-styles.d.ts +13 -0
  456. package/build-types/font-library-modal/utils/preview-styles.d.ts.map +1 -0
  457. package/build-types/font-library-modal/utils/set-immutably.d.ts +13 -0
  458. package/build-types/font-library-modal/utils/set-immutably.d.ts.map +1 -0
  459. package/build-types/font-library-modal/utils/sort-font-faces.d.ts +6 -0
  460. package/build-types/font-library-modal/utils/sort-font-faces.d.ts.map +1 -0
  461. package/build-types/font-library-modal/utils/toggleFont.d.ts +38 -0
  462. package/build-types/font-library-modal/utils/toggleFont.d.ts.map +1 -0
  463. package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts +10 -0
  464. package/build-types/font-sizes/confirm-delete-font-size-dialog.d.ts.map +1 -0
  465. package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts +10 -0
  466. package/build-types/font-sizes/confirm-reset-font-sizes-dialog.d.ts.map +1 -0
  467. package/build-types/font-sizes/font-size-preview.d.ts +7 -0
  468. package/build-types/font-sizes/font-size-preview.d.ts.map +1 -0
  469. package/build-types/font-sizes/font-size.d.ts +4 -0
  470. package/build-types/font-sizes/font-size.d.ts.map +1 -0
  471. package/build-types/font-sizes/font-sizes-count.d.ts +3 -0
  472. package/build-types/font-sizes/font-sizes-count.d.ts.map +1 -0
  473. package/build-types/font-sizes/font-sizes.d.ts +3 -0
  474. package/build-types/font-sizes/font-sizes.d.ts.map +1 -0
  475. package/build-types/font-sizes/rename-font-size-dialog.d.ts +9 -0
  476. package/build-types/font-sizes/rename-font-size-dialog.d.ts.map +1 -0
  477. package/build-types/global-styles-ui.d.ts +26 -0
  478. package/build-types/global-styles-ui.d.ts.map +1 -0
  479. package/build-types/gradients-palette-panel.d.ts +6 -0
  480. package/build-types/gradients-palette-panel.d.ts.map +1 -0
  481. package/build-types/highlighted-colors.d.ts +7 -0
  482. package/build-types/highlighted-colors.d.ts.map +1 -0
  483. package/build-types/hooks.d.ts +46 -0
  484. package/build-types/hooks.d.ts.map +1 -0
  485. package/build-types/icon-with-current-color.d.ts +9 -0
  486. package/build-types/icon-with-current-color.d.ts.map +1 -0
  487. package/build-types/index.d.ts +6 -0
  488. package/build-types/index.d.ts.map +1 -0
  489. package/build-types/lock-unlock.d.ts +2 -0
  490. package/build-types/lock-unlock.d.ts.map +1 -0
  491. package/build-types/navigation-button.d.ts +10 -0
  492. package/build-types/navigation-button.d.ts.map +1 -0
  493. package/build-types/pagination/index.d.ts +13 -0
  494. package/build-types/pagination/index.d.ts.map +1 -0
  495. package/build-types/palette.d.ts +6 -0
  496. package/build-types/palette.d.ts.map +1 -0
  497. package/build-types/preset-colors.d.ts +2 -0
  498. package/build-types/preset-colors.d.ts.map +1 -0
  499. package/build-types/preview-colors.d.ts +8 -0
  500. package/build-types/preview-colors.d.ts.map +1 -0
  501. package/build-types/preview-hooks.d.ts +9 -0
  502. package/build-types/preview-hooks.d.ts.map +1 -0
  503. package/build-types/preview-styles.d.ts +9 -0
  504. package/build-types/preview-styles.d.ts.map +1 -0
  505. package/build-types/preview-typography.d.ts +8 -0
  506. package/build-types/preview-typography.d.ts.map +1 -0
  507. package/build-types/preview-wrapper.d.ts +15 -0
  508. package/build-types/preview-wrapper.d.ts.map +1 -0
  509. package/build-types/provider.d.ts +15 -0
  510. package/build-types/provider.d.ts.map +1 -0
  511. package/build-types/root-menu.d.ts +3 -0
  512. package/build-types/root-menu.d.ts.map +1 -0
  513. package/build-types/screen-background.d.ts +3 -0
  514. package/build-types/screen-background.d.ts.map +1 -0
  515. package/build-types/screen-block-list.d.ts +4 -0
  516. package/build-types/screen-block-list.d.ts.map +1 -0
  517. package/build-types/screen-block.d.ts +7 -0
  518. package/build-types/screen-block.d.ts.map +1 -0
  519. package/build-types/screen-color-palette.d.ts +5 -0
  520. package/build-types/screen-color-palette.d.ts.map +1 -0
  521. package/build-types/screen-colors.d.ts +3 -0
  522. package/build-types/screen-colors.d.ts.map +1 -0
  523. package/build-types/screen-css.d.ts +3 -0
  524. package/build-types/screen-css.d.ts.map +1 -0
  525. package/build-types/screen-header.d.ts +8 -0
  526. package/build-types/screen-header.d.ts.map +1 -0
  527. package/build-types/screen-layout.d.ts +3 -0
  528. package/build-types/screen-layout.d.ts.map +1 -0
  529. package/build-types/screen-revisions/index.d.ts +6 -0
  530. package/build-types/screen-revisions/index.d.ts.map +1 -0
  531. package/build-types/screen-revisions/revisions-buttons.d.ts +23 -0
  532. package/build-types/screen-revisions/revisions-buttons.d.ts.map +1 -0
  533. package/build-types/screen-revisions/types.d.ts +17 -0
  534. package/build-types/screen-revisions/types.d.ts.map +1 -0
  535. package/build-types/screen-revisions/use-global-styles-revisions.d.ts +17 -0
  536. package/build-types/screen-revisions/use-global-styles-revisions.d.ts.map +1 -0
  537. package/build-types/screen-root.d.ts +3 -0
  538. package/build-types/screen-root.d.ts.map +1 -0
  539. package/build-types/screen-shadows.d.ts +3 -0
  540. package/build-types/screen-shadows.d.ts.map +1 -0
  541. package/build-types/screen-style-variations.d.ts +3 -0
  542. package/build-types/screen-style-variations.d.ts.map +1 -0
  543. package/build-types/screen-typography-element.d.ts +28 -0
  544. package/build-types/screen-typography-element.d.ts.map +1 -0
  545. package/build-types/screen-typography.d.ts +3 -0
  546. package/build-types/screen-typography.d.ts.map +1 -0
  547. package/build-types/shadow-utils.d.ts +126 -0
  548. package/build-types/shadow-utils.d.ts.map +1 -0
  549. package/build-types/shadows-edit-panel.d.ts +2 -0
  550. package/build-types/shadows-edit-panel.d.ts.map +1 -0
  551. package/build-types/shadows-panel.d.ts +3 -0
  552. package/build-types/shadows-panel.d.ts.map +1 -0
  553. package/build-types/size-control/index.d.ts +11 -0
  554. package/build-types/size-control/index.d.ts.map +1 -0
  555. package/build-types/stories/index.story.d.ts +6 -0
  556. package/build-types/stories/index.story.d.ts.map +1 -0
  557. package/build-types/style-variations-container.d.ts +6 -0
  558. package/build-types/style-variations-container.d.ts.map +1 -0
  559. package/build-types/style-variations-content.d.ts +2 -0
  560. package/build-types/style-variations-content.d.ts.map +1 -0
  561. package/build-types/style-variations.d.ts +25 -0
  562. package/build-types/style-variations.d.ts.map +1 -0
  563. package/build-types/subtitle.d.ts +7 -0
  564. package/build-types/subtitle.d.ts.map +1 -0
  565. package/build-types/test/shadow-utils.spec.d.ts +2 -0
  566. package/build-types/test/shadow-utils.spec.d.ts.map +1 -0
  567. package/build-types/test/utils.spec.d.ts +2 -0
  568. package/build-types/test/utils.spec.d.ts.map +1 -0
  569. package/build-types/typography-elements.d.ts +3 -0
  570. package/build-types/typography-elements.d.ts.map +1 -0
  571. package/build-types/typography-example.d.ts +7 -0
  572. package/build-types/typography-example.d.ts.map +1 -0
  573. package/build-types/typography-panel.d.ts +7 -0
  574. package/build-types/typography-panel.d.ts.map +1 -0
  575. package/build-types/typography-preview.d.ts +8 -0
  576. package/build-types/typography-preview.d.ts.map +1 -0
  577. package/build-types/typography-variations.d.ts +27 -0
  578. package/build-types/typography-variations.d.ts.map +1 -0
  579. package/build-types/utils.d.ts +63 -0
  580. package/build-types/utils.d.ts.map +1 -0
  581. package/build-types/variations/variation.d.ts +10 -0
  582. package/build-types/variations/variation.d.ts.map +1 -0
  583. package/build-types/variations/variations-color.d.ts +7 -0
  584. package/build-types/variations/variations-color.d.ts.map +1 -0
  585. package/build-types/variations/variations-panel.d.ts +13 -0
  586. package/build-types/variations/variations-panel.d.ts.map +1 -0
  587. package/build-types/variations/variations-typography.d.ts +7 -0
  588. package/build-types/variations/variations-typography.d.ts.map +1 -0
  589. package/build-types/with-global-styles-provider.d.ts +20 -0
  590. package/build-types/with-global-styles-provider.d.ts.map +1 -0
  591. package/package.json +67 -0
  592. package/src/README.md +99 -0
  593. package/src/background-panel.tsx +56 -0
  594. package/src/block-preview-panel.tsx +91 -0
  595. package/src/color-indicator-wrapper.tsx +34 -0
  596. package/src/color-palette-panel.tsx +111 -0
  597. package/src/color-preview.tsx +78 -0
  598. package/src/color-variations.tsx +35 -0
  599. package/src/confirm-reset-shadow-dialog.tsx +45 -0
  600. package/src/context.ts +21 -0
  601. package/src/dimensions-panel.tsx +85 -0
  602. package/src/font-families.tsx +127 -0
  603. package/src/font-family-item.tsx +52 -0
  604. package/src/font-library-modal/collection-font-variant.tsx +52 -0
  605. package/src/font-library-modal/context.tsx +591 -0
  606. package/src/font-library-modal/font-card.tsx +77 -0
  607. package/src/font-library-modal/font-collection.tsx +592 -0
  608. package/src/font-library-modal/font-demo.tsx +123 -0
  609. package/src/font-library-modal/google-fonts-confirm-dialog.tsx +57 -0
  610. package/src/font-library-modal/index.tsx +110 -0
  611. package/src/font-library-modal/installed-fonts.tsx +547 -0
  612. package/src/font-library-modal/lib/inflate.js +4112 -0
  613. package/src/font-library-modal/lib/lib-font.browser.d.ts +11 -0
  614. package/src/font-library-modal/lib/lib-font.browser.js +3861 -0
  615. package/src/font-library-modal/lib/unbrotli.js +2706 -0
  616. package/src/font-library-modal/library-font-details.tsx +46 -0
  617. package/src/font-library-modal/library-font-variant.tsx +67 -0
  618. package/src/font-library-modal/resolvers.tsx +100 -0
  619. package/src/font-library-modal/style.scss +222 -0
  620. package/src/font-library-modal/types.ts +176 -0
  621. package/src/font-library-modal/upload-fonts.tsx +269 -0
  622. package/src/font-library-modal/utils/constants.ts +23 -0
  623. package/src/font-library-modal/utils/filter-fonts.ts +47 -0
  624. package/src/font-library-modal/utils/fonts-outline.ts +33 -0
  625. package/src/font-library-modal/utils/index.ts +368 -0
  626. package/src/font-library-modal/utils/make-families-from-faces.ts +34 -0
  627. package/src/font-library-modal/utils/preview-styles.ts +167 -0
  628. package/src/font-library-modal/utils/set-immutably.ts +37 -0
  629. package/src/font-library-modal/utils/sort-font-faces.ts +46 -0
  630. package/src/font-library-modal/utils/toggleFont.ts +109 -0
  631. package/src/font-sizes/confirm-delete-font-size-dialog.tsx +51 -0
  632. package/src/font-sizes/confirm-reset-font-sizes-dialog.tsx +45 -0
  633. package/src/font-sizes/font-size-preview.tsx +47 -0
  634. package/src/font-sizes/font-size.tsx +289 -0
  635. package/src/font-sizes/font-sizes-count.tsx +37 -0
  636. package/src/font-sizes/font-sizes.tsx +265 -0
  637. package/src/font-sizes/rename-font-size-dialog.tsx +83 -0
  638. package/src/global-styles-ui.tsx +292 -0
  639. package/src/gradients-palette-panel.tsx +126 -0
  640. package/src/highlighted-colors.tsx +44 -0
  641. package/src/hooks.ts +251 -0
  642. package/src/icon-with-current-color.tsx +31 -0
  643. package/src/index.ts +7 -0
  644. package/src/lock-unlock.ts +10 -0
  645. package/src/navigation-button.tsx +53 -0
  646. package/src/pagination/index.tsx +107 -0
  647. package/src/pagination/style.scss +7 -0
  648. package/src/palette.tsx +101 -0
  649. package/src/preset-colors.tsx +18 -0
  650. package/src/preview-colors.tsx +68 -0
  651. package/src/preview-hooks.tsx +58 -0
  652. package/src/preview-styles.tsx +196 -0
  653. package/src/preview-typography.tsx +49 -0
  654. package/src/preview-wrapper.tsx +137 -0
  655. package/src/provider.tsx +54 -0
  656. package/src/root-menu.tsx +87 -0
  657. package/src/screen-background.tsx +37 -0
  658. package/src/screen-block-list.tsx +198 -0
  659. package/src/screen-block.tsx +370 -0
  660. package/src/screen-color-palette.tsx +47 -0
  661. package/src/screen-colors.tsx +67 -0
  662. package/src/screen-css.tsx +56 -0
  663. package/src/screen-header.tsx +56 -0
  664. package/src/screen-layout.tsx +34 -0
  665. package/src/screen-revisions/index.tsx +158 -0
  666. package/src/screen-revisions/revisions-buttons.tsx +259 -0
  667. package/src/screen-revisions/style.scss +194 -0
  668. package/src/screen-revisions/types.ts +18 -0
  669. package/src/screen-revisions/use-global-styles-revisions.tsx +204 -0
  670. package/src/screen-root.tsx +146 -0
  671. package/src/screen-shadows.tsx +13 -0
  672. package/src/screen-style-variations.tsx +36 -0
  673. package/src/screen-typography-element.tsx +127 -0
  674. package/src/screen-typography.tsx +41 -0
  675. package/src/shadow-utils.ts +167 -0
  676. package/src/shadows-edit-panel.tsx +559 -0
  677. package/src/shadows-panel.tsx +207 -0
  678. package/src/size-control/index.tsx +97 -0
  679. package/src/size-control/style.scss +7 -0
  680. package/src/stories/index.story.js +410 -0
  681. package/src/style-variations-container.tsx +153 -0
  682. package/src/style-variations-content.tsx +24 -0
  683. package/src/style-variations.tsx +33 -0
  684. package/src/style.scss +287 -0
  685. package/src/subtitle.tsx +17 -0
  686. package/src/test/shadow-utils.spec.js +251 -0
  687. package/src/test/utils.spec.js +59 -0
  688. package/src/typography-elements.tsx +113 -0
  689. package/src/typography-example.tsx +78 -0
  690. package/src/typography-panel.tsx +56 -0
  691. package/src/typography-preview.tsx +61 -0
  692. package/src/typography-variations.tsx +35 -0
  693. package/src/utils.ts +301 -0
  694. package/src/variations/style.scss +43 -0
  695. package/src/variations/variation.tsx +113 -0
  696. package/src/variations/variations-color.tsx +54 -0
  697. package/src/variations/variations-panel.tsx +79 -0
  698. package/src/variations/variations-typography.tsx +65 -0
  699. package/src/with-global-styles-provider.tsx +44 -0
  700. package/tsconfig.json +26 -0
  701. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,59 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useContext } from "@wordpress/element";
3
+ import { __unstableMotion as motion } from "@wordpress/components";
4
+ import { _x } from "@wordpress/i18n";
5
+ import { GlobalStylesContext } from "./context";
6
+ import { getFamilyPreviewStyle } from "./font-library-modal/utils/preview-styles";
7
+ import { getFontFamilies } from "./utils";
8
+ import { useStyle } from "./hooks";
9
+ function PreviewTypography({
10
+ fontSize,
11
+ variation
12
+ }) {
13
+ const { base } = useContext(GlobalStylesContext);
14
+ let config = base;
15
+ if (variation) {
16
+ config = { ...base, ...variation };
17
+ }
18
+ const [textColor] = useStyle("color.text");
19
+ const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config);
20
+ const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {};
21
+ const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {};
22
+ if (textColor) {
23
+ bodyPreviewStyle.color = textColor;
24
+ headingPreviewStyle.color = textColor;
25
+ }
26
+ if (fontSize) {
27
+ bodyPreviewStyle.fontSize = fontSize;
28
+ headingPreviewStyle.fontSize = fontSize;
29
+ }
30
+ return /* @__PURE__ */ jsxs(
31
+ motion.div,
32
+ {
33
+ animate: {
34
+ scale: 1,
35
+ opacity: 1
36
+ },
37
+ initial: {
38
+ scale: 0.1,
39
+ opacity: 0
40
+ },
41
+ transition: {
42
+ delay: 0.3,
43
+ type: "tween"
44
+ },
45
+ style: {
46
+ textAlign: "center",
47
+ lineHeight: 1
48
+ },
49
+ children: [
50
+ /* @__PURE__ */ jsx("span", { style: headingPreviewStyle, children: _x("A", "Uppercase letter A") }),
51
+ /* @__PURE__ */ jsx("span", { style: bodyPreviewStyle, children: _x("a", "Lowercase letter A") })
52
+ ]
53
+ }
54
+ );
55
+ }
56
+ export {
57
+ PreviewTypography as default
58
+ };
59
+ //# sourceMappingURL=typography-example.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/typography-example.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { GlobalStylesContext } from './context';\nimport { getFamilyPreviewStyle } from './font-library-modal/utils/preview-styles';\nimport { getFontFamilies } from './utils';\nimport { useStyle } from './hooks';\n\ninterface TypographyExampleProps {\n\tfontSize?: number;\n\tvariation?: any;\n}\n\nexport default function PreviewTypography( {\n\tfontSize,\n\tvariation,\n}: TypographyExampleProps ) {\n\tconst { base } = useContext( GlobalStylesContext );\n\tlet config = base;\n\tif ( variation ) {\n\t\tconfig = { ...base, ...variation };\n\t}\n\n\tconst [ textColor ] = useStyle( 'color.text' );\n\n\tconst [ bodyFontFamilies, headingFontFamilies ] = getFontFamilies( config );\n\tconst bodyPreviewStyle: React.CSSProperties = bodyFontFamilies\n\t\t? getFamilyPreviewStyle( bodyFontFamilies )\n\t\t: {};\n\tconst headingPreviewStyle: React.CSSProperties = headingFontFamilies\n\t\t? getFamilyPreviewStyle( headingFontFamilies )\n\t\t: {};\n\n\tif ( textColor ) {\n\t\tbodyPreviewStyle.color = textColor;\n\t\theadingPreviewStyle.color = textColor;\n\t}\n\n\tif ( fontSize ) {\n\t\tbodyPreviewStyle.fontSize = fontSize;\n\t\theadingPreviewStyle.fontSize = fontSize;\n\t}\n\n\treturn (\n\t\t<motion.div\n\t\t\tanimate={ {\n\t\t\t\tscale: 1,\n\t\t\t\topacity: 1,\n\t\t\t} }\n\t\t\tinitial={ {\n\t\t\t\tscale: 0.1,\n\t\t\t\topacity: 0,\n\t\t\t} }\n\t\t\ttransition={ {\n\t\t\t\tdelay: 0.3,\n\t\t\t\ttype: 'tween',\n\t\t\t} }\n\t\t\tstyle={ {\n\t\t\t\ttextAlign: 'center',\n\t\t\t\tlineHeight: 1,\n\t\t\t} }\n\t\t>\n\t\t\t<span style={ headingPreviewStyle }>\n\t\t\t\t{ _x( 'A', 'Uppercase letter A' ) }\n\t\t\t</span>\n\t\t\t<span style={ bodyPreviewStyle }>\n\t\t\t\t{ _x( 'a', 'Lowercase letter A' ) }\n\t\t\t</span>\n\t\t</motion.div>\n\t);\n}\n"],
5
+ "mappings": "AAmDE,SAkBC,KAlBD;AAhDF,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB,cAAc;AAC3C,SAAS,UAAU;AAKnB,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAOV,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AACD,GAA4B;AAC3B,QAAM,EAAE,KAAK,IAAI,WAAY,mBAAoB;AACjD,MAAI,SAAS;AACb,MAAK,WAAY;AAChB,aAAS,EAAE,GAAG,MAAM,GAAG,UAAU;AAAA,EAClC;AAEA,QAAM,CAAE,SAAU,IAAI,SAAU,YAAa;AAE7C,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,gBAAiB,MAAO;AAC1E,QAAM,mBAAwC,mBAC3C,sBAAuB,gBAAiB,IACxC,CAAC;AACJ,QAAM,sBAA2C,sBAC9C,sBAAuB,mBAAoB,IAC3C,CAAC;AAEJ,MAAK,WAAY;AAChB,qBAAiB,QAAQ;AACzB,wBAAoB,QAAQ;AAAA,EAC7B;AAEA,MAAK,UAAW;AACf,qBAAiB,WAAW;AAC5B,wBAAoB,WAAW;AAAA,EAChC;AAEA,SACC;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACA,SAAU;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,MACV;AAAA,MACA,SAAU;AAAA,QACT,OAAO;AAAA,QACP,SAAS;AAAA,MACV;AAAA,MACA,YAAa;AAAA,QACZ,OAAO;AAAA,QACP,MAAM;AAAA,MACP;AAAA,MACA,OAAQ;AAAA,QACP,WAAW;AAAA,QACX,YAAY;AAAA,MACb;AAAA,MAEA;AAAA,4BAAC,UAAK,OAAQ,qBACX,aAAI,KAAK,oBAAqB,GACjC;AAAA,QACA,oBAAC,UAAK,OAAQ,kBACX,aAAI,KAAK,oBAAqB,GACjC;AAAA;AAAA;AAAA,EACD;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
3
+ import { useStyle, useSetting } from "./hooks";
4
+ import { unlock } from "./lock-unlock";
5
+ const { useSettingsForBlockElement, TypographyPanel: StylesTypographyPanel } = unlock(blockEditorPrivateApis);
6
+ function TypographyPanel({
7
+ element,
8
+ headingLevel
9
+ }) {
10
+ let prefixParts = [];
11
+ if (element === "heading") {
12
+ prefixParts = prefixParts.concat(["elements", headingLevel]);
13
+ } else if (element && element !== "text") {
14
+ prefixParts = prefixParts.concat(["elements", element]);
15
+ }
16
+ const prefix = prefixParts.join(".");
17
+ const [style] = useStyle(prefix, "", "user", false);
18
+ const [inheritedStyle, setStyle] = useStyle(
19
+ prefix,
20
+ "",
21
+ "merged",
22
+ false
23
+ );
24
+ const [rawSettings] = useSetting("");
25
+ const usedElement = element === "heading" ? headingLevel : element;
26
+ const settings = useSettingsForBlockElement(
27
+ rawSettings,
28
+ void 0,
29
+ usedElement
30
+ );
31
+ return /* @__PURE__ */ jsx(
32
+ StylesTypographyPanel,
33
+ {
34
+ inheritedValue: inheritedStyle,
35
+ value: style,
36
+ onChange: setStyle,
37
+ settings
38
+ }
39
+ );
40
+ }
41
+ export {
42
+ TypographyPanel as default
43
+ };
44
+ //# sourceMappingURL=typography-panel.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/typography-panel.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\n// @ts-expect-error: Not typed yet.\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { useStyle, useSetting } from './hooks';\nimport { unlock } from './lock-unlock';\n\nconst { useSettingsForBlockElement, TypographyPanel: StylesTypographyPanel } =\n\tunlock( blockEditorPrivateApis );\n\ninterface TypographyPanelProps {\n\telement: string;\n\theadingLevel: string;\n}\n\nexport default function TypographyPanel( {\n\telement,\n\theadingLevel,\n}: TypographyPanelProps ) {\n\tlet prefixParts: string[] = [];\n\tif ( element === 'heading' ) {\n\t\tprefixParts = prefixParts.concat( [ 'elements', headingLevel ] );\n\t} else if ( element && element !== 'text' ) {\n\t\tprefixParts = prefixParts.concat( [ 'elements', element ] );\n\t}\n\tconst prefix = prefixParts.join( '.' );\n\n\tconst [ style ] = useStyle( prefix, '', 'user', false );\n\tconst [ inheritedStyle, setStyle ] = useStyle(\n\t\tprefix,\n\t\t'',\n\t\t'merged',\n\t\tfalse\n\t);\n\tconst [ rawSettings ] = useSetting( '' );\n\tconst usedElement = element === 'heading' ? headingLevel : element;\n\tconst settings = useSettingsForBlockElement(\n\t\trawSettings,\n\t\tundefined,\n\t\tusedElement\n\t);\n\n\treturn (\n\t\t<StylesTypographyPanel\n\t\t\tinheritedValue={ inheritedStyle }\n\t\t\tvalue={ style }\n\t\t\tonChange={ setStyle }\n\t\t\tsettings={ settings }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": "AAgDE;AA5CF,SAAS,eAAe,8BAA8B;AAKtD,SAAS,UAAU,kBAAkB;AACrC,SAAS,cAAc;AAEvB,MAAM,EAAE,4BAA4B,iBAAiB,sBAAsB,IAC1E,OAAQ,sBAAuB;AAOjB,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA;AACD,GAA0B;AACzB,MAAI,cAAwB,CAAC;AAC7B,MAAK,YAAY,WAAY;AAC5B,kBAAc,YAAY,OAAQ,CAAE,YAAY,YAAa,CAAE;AAAA,EAChE,WAAY,WAAW,YAAY,QAAS;AAC3C,kBAAc,YAAY,OAAQ,CAAE,YAAY,OAAQ,CAAE;AAAA,EAC3D;AACA,QAAM,SAAS,YAAY,KAAM,GAAI;AAErC,QAAM,CAAE,KAAM,IAAI,SAAU,QAAQ,IAAI,QAAQ,KAAM;AACtD,QAAM,CAAE,gBAAgB,QAAS,IAAI;AAAA,IACpC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,CAAE,WAAY,IAAI,WAAY,EAAG;AACvC,QAAM,cAAc,YAAY,YAAY,eAAe;AAC3D,QAAM,WAAW;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,gBAAiB;AAAA,MACjB,OAAQ;AAAA,MACR,UAAW;AAAA,MACX;AAAA;AAAA,EACD;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,50 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useStyle } from "./hooks";
3
+ function TypographyPreview({
4
+ name,
5
+ element,
6
+ headingLevel
7
+ }) {
8
+ let prefix = "";
9
+ if (element === "heading") {
10
+ prefix = `elements.${headingLevel}.`;
11
+ } else if (element && element !== "text") {
12
+ prefix = `elements.${element}.`;
13
+ }
14
+ const [fontFamily] = useStyle(prefix + "typography.fontFamily", name);
15
+ const [gradientValue] = useStyle(prefix + "color.gradient", name);
16
+ const [backgroundColor] = useStyle(prefix + "color.background", name);
17
+ const [fallbackBackgroundColor] = useStyle("color.background");
18
+ const [color] = useStyle(prefix + "color.text", name);
19
+ const [fontSize] = useStyle(prefix + "typography.fontSize", name);
20
+ const [fontStyle] = useStyle(prefix + "typography.fontStyle", name);
21
+ const [fontWeight] = useStyle(prefix + "typography.fontWeight", name);
22
+ const [letterSpacing] = useStyle(
23
+ prefix + "typography.letterSpacing",
24
+ name
25
+ );
26
+ const extraStyles = element === "link" ? {
27
+ textDecoration: "underline"
28
+ } : {};
29
+ return /* @__PURE__ */ jsx(
30
+ "div",
31
+ {
32
+ className: "global-styles-ui-typography-preview",
33
+ style: {
34
+ fontFamily: fontFamily ?? "serif",
35
+ background: gradientValue ?? backgroundColor ?? fallbackBackgroundColor,
36
+ color,
37
+ fontSize,
38
+ fontStyle,
39
+ fontWeight,
40
+ letterSpacing,
41
+ ...extraStyles
42
+ },
43
+ children: "Aa"
44
+ }
45
+ );
46
+ }
47
+ export {
48
+ TypographyPreview as default
49
+ };
50
+ //# sourceMappingURL=typography-preview.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/typography-preview.tsx"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { useStyle } from './hooks';\n\ninterface TypographyPreviewProps {\n\tname?: string;\n\telement: string;\n\theadingLevel: string;\n}\n\nexport default function TypographyPreview( {\n\tname,\n\telement,\n\theadingLevel,\n}: TypographyPreviewProps ) {\n\tlet prefix = '';\n\tif ( element === 'heading' ) {\n\t\tprefix = `elements.${ headingLevel }.`;\n\t} else if ( element && element !== 'text' ) {\n\t\tprefix = `elements.${ element }.`;\n\t}\n\n\tconst [ fontFamily ] = useStyle( prefix + 'typography.fontFamily', name );\n\tconst [ gradientValue ] = useStyle( prefix + 'color.gradient', name );\n\tconst [ backgroundColor ] = useStyle( prefix + 'color.background', name );\n\tconst [ fallbackBackgroundColor ] = useStyle( 'color.background' );\n\tconst [ color ] = useStyle( prefix + 'color.text', name );\n\tconst [ fontSize ] = useStyle( prefix + 'typography.fontSize', name );\n\tconst [ fontStyle ] = useStyle( prefix + 'typography.fontStyle', name );\n\tconst [ fontWeight ] = useStyle( prefix + 'typography.fontWeight', name );\n\tconst [ letterSpacing ] = useStyle(\n\t\tprefix + 'typography.letterSpacing',\n\t\tname\n\t);\n\tconst extraStyles =\n\t\telement === 'link'\n\t\t\t? {\n\t\t\t\t\ttextDecoration: 'underline',\n\t\t\t }\n\t\t\t: {};\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"global-styles-ui-typography-preview\"\n\t\t\tstyle={ {\n\t\t\t\tfontFamily: fontFamily ?? 'serif',\n\t\t\t\tbackground:\n\t\t\t\t\tgradientValue ?? backgroundColor ?? fallbackBackgroundColor,\n\t\t\t\tcolor,\n\t\t\t\tfontSize,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tletterSpacing,\n\t\t\t\t...extraStyles,\n\t\t\t} }\n\t\t>\n\t\t\tAa\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": "AA2CE;AAxCF,SAAS,gBAAgB;AAQV,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACD,GAA4B;AAC3B,MAAI,SAAS;AACb,MAAK,YAAY,WAAY;AAC5B,aAAS,YAAa,YAAa;AAAA,EACpC,WAAY,WAAW,YAAY,QAAS;AAC3C,aAAS,YAAa,OAAQ;AAAA,EAC/B;AAEA,QAAM,CAAE,UAAW,IAAI,SAAU,SAAS,yBAAyB,IAAK;AACxE,QAAM,CAAE,aAAc,IAAI,SAAU,SAAS,kBAAkB,IAAK;AACpE,QAAM,CAAE,eAAgB,IAAI,SAAU,SAAS,oBAAoB,IAAK;AACxE,QAAM,CAAE,uBAAwB,IAAI,SAAU,kBAAmB;AACjE,QAAM,CAAE,KAAM,IAAI,SAAU,SAAS,cAAc,IAAK;AACxD,QAAM,CAAE,QAAS,IAAI,SAAU,SAAS,uBAAuB,IAAK;AACpE,QAAM,CAAE,SAAU,IAAI,SAAU,SAAS,wBAAwB,IAAK;AACtE,QAAM,CAAE,UAAW,IAAI,SAAU,SAAS,yBAAyB,IAAK;AACxE,QAAM,CAAE,aAAc,IAAI;AAAA,IACzB,SAAS;AAAA,IACT;AAAA,EACD;AACA,QAAM,cACL,YAAY,SACT;AAAA,IACA,gBAAgB;AAAA,EAChB,IACA,CAAC;AAEL,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAQ;AAAA,QACP,YAAY,cAAc;AAAA,QAC1B,YACC,iBAAiB,mBAAmB;AAAA,QACrC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACJ;AAAA,MACA;AAAA;AAAA,EAED;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,7 @@
1
+ import TypographyVariationsInternal from "./variations/variations-typography";
2
+ import { withGlobalStylesProvider } from "./with-global-styles-provider";
3
+ const TypographyVariations = withGlobalStylesProvider(TypographyVariationsInternal);
4
+ export {
5
+ TypographyVariations
6
+ };
7
+ //# sourceMappingURL=typography-variations.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/typography-variations.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { GlobalStylesConfig } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport TypographyVariationsInternal from './variations/variations-typography';\nimport { withGlobalStylesProvider } from './with-global-styles-provider';\n\nexport interface TypographyVariationsProps {\n\tvalue: GlobalStylesConfig;\n\tbaseValue: GlobalStylesConfig;\n\tonChange: ( config: GlobalStylesConfig ) => void;\n\ttitle?: string;\n\tgap?: number;\n}\n\n/**\n * Render Typography Variations.\n *\n * @example\n * ```tsx\n * <TypographyVariations\n * value={userConfig}\n * baseValue={baseConfig}\n * onChange={setUserConfig}\n * title=\"Typography\"\n * gap={3}\n * />\n * ```\n */\nexport const TypographyVariations: React.ComponentType< TypographyVariationsProps > =\n\twithGlobalStylesProvider( TypographyVariationsInternal );\n"],
5
+ "mappings": "AAQA,OAAO,kCAAkC;AACzC,SAAS,gCAAgC;AAwBlC,MAAM,uBACZ,yBAA0B,4BAA6B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,179 @@
1
+ import { areGlobalStylesEqual } from "@wordpress/global-styles-engine";
2
+ function removePropertiesFromObject(object, properties) {
3
+ if (!properties?.length) {
4
+ return object;
5
+ }
6
+ if (typeof object !== "object" || !object || !Object.keys(object).length) {
7
+ return object;
8
+ }
9
+ for (const key in object) {
10
+ if (properties.includes(key)) {
11
+ delete object[key];
12
+ } else if (typeof object[key] === "object") {
13
+ removePropertiesFromObject(object[key], properties);
14
+ }
15
+ }
16
+ return object;
17
+ }
18
+ const filterObjectByProperties = (object, properties) => {
19
+ if (!object || !properties?.length) {
20
+ return {};
21
+ }
22
+ const newObject = {};
23
+ Object.keys(object).forEach((key) => {
24
+ if (properties.includes(key)) {
25
+ newObject[key] = object[key];
26
+ } else if (typeof object[key] === "object") {
27
+ const newFilter = filterObjectByProperties(
28
+ object[key],
29
+ properties
30
+ );
31
+ if (Object.keys(newFilter).length) {
32
+ newObject[key] = newFilter;
33
+ }
34
+ }
35
+ });
36
+ return newObject;
37
+ };
38
+ function isVariationWithProperties(variation, properties) {
39
+ const variationWithProperties = filterObjectByProperties(
40
+ structuredClone(variation),
41
+ properties
42
+ );
43
+ return areGlobalStylesEqual(variationWithProperties, variation);
44
+ }
45
+ function getFontFamilyFromSetting(fontFamilies, setting) {
46
+ if (!Array.isArray(fontFamilies) || !setting) {
47
+ return null;
48
+ }
49
+ const fontFamilyVariable = setting.replace("var(", "").replace(")", "");
50
+ const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0];
51
+ return fontFamilies.find(
52
+ (fontFamily) => fontFamily.slug === fontFamilySlug
53
+ );
54
+ }
55
+ function getFontFamilies(themeJson) {
56
+ const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme;
57
+ const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom;
58
+ let fontFamilies = [];
59
+ if (themeFontFamilies && customFontFamilies) {
60
+ fontFamilies = [...themeFontFamilies, ...customFontFamilies];
61
+ } else if (themeFontFamilies) {
62
+ fontFamilies = themeFontFamilies;
63
+ } else if (customFontFamilies) {
64
+ fontFamilies = customFontFamilies;
65
+ }
66
+ const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily;
67
+ const bodyFontFamily = getFontFamilyFromSetting(
68
+ fontFamilies,
69
+ bodyFontFamilySetting
70
+ );
71
+ const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily;
72
+ let headingFontFamily;
73
+ if (!headingFontFamilySetting) {
74
+ headingFontFamily = bodyFontFamily;
75
+ } else {
76
+ headingFontFamily = getFontFamilyFromSetting(
77
+ fontFamilies,
78
+ themeJson?.styles?.elements?.heading?.typography?.fontFamily
79
+ );
80
+ }
81
+ return [bodyFontFamily, headingFontFamily];
82
+ }
83
+ function findNearest(input, numbers) {
84
+ if (numbers.length === 0) {
85
+ return null;
86
+ }
87
+ numbers.sort((a, b) => Math.abs(input - a) - Math.abs(input - b));
88
+ return numbers[0];
89
+ }
90
+ function extractFontWeights(fontFaces) {
91
+ const result = [];
92
+ fontFaces.forEach((face) => {
93
+ const weights = String(face.fontWeight).split(" ");
94
+ if (weights.length === 2) {
95
+ const start = parseInt(weights[0]);
96
+ const end = parseInt(weights[1]);
97
+ for (let i = start; i <= end; i += 100) {
98
+ result.push(i);
99
+ }
100
+ } else if (weights.length === 1) {
101
+ result.push(parseInt(weights[0]));
102
+ }
103
+ });
104
+ return result;
105
+ }
106
+ function formatFontFamily(input) {
107
+ const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
108
+ const output = input.trim();
109
+ const formatItem = (item) => {
110
+ item = item.trim();
111
+ if (item.match(regex)) {
112
+ item = item.replace(/^["']|["']$/g, "");
113
+ return `"${item}"`;
114
+ }
115
+ return item;
116
+ };
117
+ if (output.includes(",")) {
118
+ return output.split(",").map(formatItem).filter((item) => item !== "").join(", ");
119
+ }
120
+ return formatItem(output);
121
+ }
122
+ function getFamilyPreviewStyle(family) {
123
+ const style = {
124
+ fontFamily: formatFontFamily(family.fontFamily)
125
+ };
126
+ if (!Array.isArray(family.fontFace)) {
127
+ style.fontWeight = "400";
128
+ style.fontStyle = "normal";
129
+ return style;
130
+ }
131
+ if (family.fontFace) {
132
+ const normalFaces = family.fontFace.filter(
133
+ (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal"
134
+ );
135
+ if (normalFaces.length > 0) {
136
+ style.fontStyle = "normal";
137
+ const normalWeights = extractFontWeights(normalFaces);
138
+ const nearestWeight = findNearest(400, normalWeights);
139
+ style.fontWeight = String(nearestWeight) || "400";
140
+ } else {
141
+ style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal";
142
+ style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400";
143
+ }
144
+ }
145
+ return style;
146
+ }
147
+ function getVariationClassName(variation) {
148
+ if (!variation) {
149
+ return "";
150
+ }
151
+ return `is-style-${variation}`;
152
+ }
153
+ function getNewIndexFromPresets(presets, slugPrefix) {
154
+ const nameRegex = new RegExp(`^${slugPrefix}([\\d]+)$`);
155
+ const highestPresetValue = presets.reduce((currentHighest, preset) => {
156
+ if (typeof preset?.slug === "string") {
157
+ const matches = preset?.slug.match(nameRegex);
158
+ if (matches) {
159
+ const id = parseInt(matches[1], 10);
160
+ if (id > currentHighest) {
161
+ return id;
162
+ }
163
+ }
164
+ }
165
+ return currentHighest;
166
+ }, 0);
167
+ return highestPresetValue + 1;
168
+ }
169
+ export {
170
+ filterObjectByProperties,
171
+ formatFontFamily,
172
+ getFamilyPreviewStyle,
173
+ getFontFamilies,
174
+ getNewIndexFromPresets,
175
+ getVariationClassName,
176
+ isVariationWithProperties,
177
+ removePropertiesFromObject
178
+ };
179
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { areGlobalStylesEqual } from '@wordpress/global-styles-engine';\nimport type { GlobalStylesConfig } from '@wordpress/global-styles-engine';\n\n/**\n * Removes all instances of properties from an object.\n *\n * @param object The object to remove the properties from.\n * @param properties The properties to remove.\n * @return The modified object.\n */\nexport function removePropertiesFromObject(\n\tobject: any,\n\tproperties: string[]\n): any {\n\tif ( ! properties?.length ) {\n\t\treturn object;\n\t}\n\n\tif (\n\t\ttypeof object !== 'object' ||\n\t\t! object ||\n\t\t! Object.keys( object ).length\n\t) {\n\t\treturn object;\n\t}\n\n\tfor ( const key in object ) {\n\t\tif ( properties.includes( key ) ) {\n\t\t\tdelete object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tremovePropertiesFromObject( object[ key ], properties );\n\t\t}\n\t}\n\treturn object;\n}\n\n/**\n * Returns a new object, with properties specified in `properties` array.,\n * maintain the original object tree structure.\n * The function is recursive, so it will perform a deep search for the given properties.\n * E.g., the function will return `{ a: { b: { c: { test: 1 } } } }` if the properties are `[ 'test' ]`.\n *\n * @param object The object to filter\n * @param properties The properties to filter by\n * @return The merged object.\n */\nexport const filterObjectByProperties = (\n\tobject: any,\n\tproperties: string[]\n): any => {\n\tif ( ! object || ! properties?.length ) {\n\t\treturn {};\n\t}\n\n\tconst newObject: any = {};\n\tObject.keys( object ).forEach( ( key ) => {\n\t\tif ( properties.includes( key ) ) {\n\t\t\tnewObject[ key ] = object[ key ];\n\t\t} else if ( typeof object[ key ] === 'object' ) {\n\t\t\tconst newFilter = filterObjectByProperties(\n\t\t\t\tobject[ key ],\n\t\t\t\tproperties\n\t\t\t);\n\t\t\tif ( Object.keys( newFilter ).length ) {\n\t\t\t\tnewObject[ key ] = newFilter;\n\t\t\t}\n\t\t}\n\t} );\n\treturn newObject;\n};\n\n/**\n * Compares a style variation to the same variation filtered by the specified properties.\n * Returns true if the variation contains only the properties specified.\n *\n * @param variation The variation to compare.\n * @param properties The properties to compare.\n * @return Whether the variation contains only the specified properties.\n */\nexport function isVariationWithProperties(\n\tvariation: GlobalStylesConfig,\n\tproperties: string[]\n): boolean {\n\tconst variationWithProperties = filterObjectByProperties(\n\t\tstructuredClone( variation ),\n\t\tproperties\n\t);\n\n\treturn areGlobalStylesEqual( variationWithProperties, variation );\n}\n\nfunction getFontFamilyFromSetting( fontFamilies: any[], setting: string ): any {\n\tif ( ! Array.isArray( fontFamilies ) || ! setting ) {\n\t\treturn null;\n\t}\n\n\tconst fontFamilyVariable = setting.replace( 'var(', '' ).replace( ')', '' );\n\tconst fontFamilySlug = fontFamilyVariable?.split( '--' ).slice( -1 )[ 0 ];\n\n\treturn fontFamilies.find(\n\t\t( fontFamily ) => fontFamily.slug === fontFamilySlug\n\t);\n}\n\n/**\n * Extracts font families from a theme JSON configuration.\n *\n * @param themeJson The theme JSON configuration\n * @return Array containing [bodyFontFamily, headingFontFamily]\n */\nexport function getFontFamilies( themeJson: any ): [ any, any ] {\n\tconst themeFontFamilies =\n\t\tthemeJson?.settings?.typography?.fontFamilies?.theme;\n\tconst customFontFamilies =\n\t\tthemeJson?.settings?.typography?.fontFamilies?.custom;\n\n\tlet fontFamilies: any[] = [];\n\tif ( themeFontFamilies && customFontFamilies ) {\n\t\tfontFamilies = [ ...themeFontFamilies, ...customFontFamilies ];\n\t} else if ( themeFontFamilies ) {\n\t\tfontFamilies = themeFontFamilies;\n\t} else if ( customFontFamilies ) {\n\t\tfontFamilies = customFontFamilies;\n\t}\n\tconst bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily;\n\tconst bodyFontFamily = getFontFamilyFromSetting(\n\t\tfontFamilies,\n\t\tbodyFontFamilySetting\n\t);\n\n\tconst headingFontFamilySetting =\n\t\tthemeJson?.styles?.elements?.heading?.typography?.fontFamily;\n\n\tlet headingFontFamily;\n\tif ( ! headingFontFamilySetting ) {\n\t\theadingFontFamily = bodyFontFamily;\n\t} else {\n\t\theadingFontFamily = getFontFamilyFromSetting(\n\t\t\tfontFamilies,\n\t\t\tthemeJson?.styles?.elements?.heading?.typography?.fontFamily\n\t\t);\n\t}\n\n\treturn [ bodyFontFamily, headingFontFamily ];\n}\n\nfunction findNearest( input: number, numbers: number[] ): number | null {\n\t// If the numbers array is empty, return null\n\tif ( numbers.length === 0 ) {\n\t\treturn null;\n\t}\n\t// Sort the array based on the absolute difference with the input\n\tnumbers.sort( ( a, b ) => Math.abs( input - a ) - Math.abs( input - b ) );\n\t// Return the first element (which will be the nearest) from the sorted array\n\treturn numbers[ 0 ];\n}\n\nfunction extractFontWeights( fontFaces: any[] ): number[] {\n\tconst result: number[] = [];\n\n\tfontFaces.forEach( ( face ) => {\n\t\tconst weights = String( face.fontWeight ).split( ' ' );\n\n\t\tif ( weights.length === 2 ) {\n\t\t\tconst start = parseInt( weights[ 0 ] );\n\t\t\tconst end = parseInt( weights[ 1 ] );\n\n\t\t\tfor ( let i = start; i <= end; i += 100 ) {\n\t\t\t\tresult.push( i );\n\t\t\t}\n\t\t} else if ( weights.length === 1 ) {\n\t\t\tresult.push( parseInt( weights[ 0 ] ) );\n\t\t}\n\t} );\n\n\treturn result;\n}\n\n/*\n * Format the font family to use in the CSS font-family property of a CSS rule.\n *\n * The input can be a string with the font family name or a string with multiple font family names separated by commas.\n * It follows the recommendations from the CSS Fonts Module Level 4.\n * https://www.w3.org/TR/css-fonts-4/#font-family-prop\n *\n * @param input - The font family.\n * @return The formatted font family.\n */\nexport function formatFontFamily( input: string ): string {\n\t// Matches strings that are not exclusively alphabetic characters or hyphens, and do not exactly follow the pattern generic(alphabetic characters or hyphens).\n\tconst regex = /^(?!generic\\([ a-zA-Z\\-]+\\)$)(?!^[a-zA-Z\\-]+$).+/;\n\tconst output = input.trim();\n\n\tconst formatItem = ( item: string ) => {\n\t\titem = item.trim();\n\t\tif ( item.match( regex ) ) {\n\t\t\t// removes leading and trailing quotes.\n\t\t\titem = item.replace( /^[\"']|[\"']$/g, '' );\n\t\t\treturn `\"${ item }\"`;\n\t\t}\n\t\treturn item;\n\t};\n\n\tif ( output.includes( ',' ) ) {\n\t\treturn output\n\t\t\t.split( ',' )\n\t\t\t.map( formatItem )\n\t\t\t.filter( ( item ) => item !== '' )\n\t\t\t.join( ', ' );\n\t}\n\n\treturn formatItem( output );\n}\n\n/**\n * Gets the preview style for a font family.\n *\n * @param family The font family object\n * @return CSS style object for the font family\n */\nexport function getFamilyPreviewStyle( family: any ): React.CSSProperties {\n\tconst style: React.CSSProperties = {\n\t\tfontFamily: formatFontFamily( family.fontFamily ),\n\t};\n\n\tif ( ! Array.isArray( family.fontFace ) ) {\n\t\tstyle.fontWeight = '400';\n\t\tstyle.fontStyle = 'normal';\n\t\treturn style;\n\t}\n\n\tif ( family.fontFace ) {\n\t\t//get all the font faces with normal style\n\t\tconst normalFaces = family.fontFace.filter(\n\t\t\t( face: any ) =>\n\t\t\t\tface?.fontStyle && face.fontStyle.toLowerCase() === 'normal'\n\t\t);\n\t\tif ( normalFaces.length > 0 ) {\n\t\t\tstyle.fontStyle = 'normal';\n\t\t\tconst normalWeights = extractFontWeights( normalFaces );\n\t\t\tconst nearestWeight = findNearest( 400, normalWeights );\n\t\t\tstyle.fontWeight = String( nearestWeight ) || '400';\n\t\t} else {\n\t\t\tstyle.fontStyle =\n\t\t\t\t( family.fontFace.length && family.fontFace[ 0 ].fontStyle ) ||\n\t\t\t\t'normal';\n\t\t\tstyle.fontWeight =\n\t\t\t\t( family.fontFace.length &&\n\t\t\t\t\tString( family.fontFace[ 0 ].fontWeight ) ) ||\n\t\t\t\t'400';\n\t\t}\n\t}\n\n\treturn style;\n}\n\n/**\n * Iterates through the presets array and searches for slugs that start with the specified\n * slugPrefix followed by a numerical suffix. It identifies the highest numerical suffix found\n * and returns one greater than the highest found suffix, ensuring that the new index is unique.\n *\n * @param presets The array of preset objects, each potentially containing a slug property.\n * @param slugPrefix The prefix to look for in the preset slugs.\n *\n * @return The next available index for a preset with the specified slug prefix, or 1 if no matching slugs are found.\n */\n/**\n * Gets the variation class name for a block style variation.\n *\n * @param variation The variation name.\n * @return The variation class name.\n */\nexport function getVariationClassName( variation: string ): string {\n\tif ( ! variation ) {\n\t\treturn '';\n\t}\n\treturn `is-style-${ variation }`;\n}\n\nexport function getNewIndexFromPresets(\n\tpresets: any[],\n\tslugPrefix: string\n): number {\n\tconst nameRegex = new RegExp( `^${ slugPrefix }([\\\\d]+)$` );\n\tconst highestPresetValue = presets.reduce( ( currentHighest, preset ) => {\n\t\tif ( typeof preset?.slug === 'string' ) {\n\t\t\tconst matches = preset?.slug.match( nameRegex );\n\t\t\tif ( matches ) {\n\t\t\t\tconst id = parseInt( matches[ 1 ], 10 );\n\t\t\t\tif ( id > currentHighest ) {\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn currentHighest;\n\t}, 0 );\n\treturn highestPresetValue + 1;\n}\n"],
5
+ "mappings": "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",
6
+ "names": []
7
+ }
@@ -0,0 +1,86 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { Tooltip } from "@wordpress/components";
4
+ import { useMemo, useContext, useState } from "@wordpress/element";
5
+ import { ENTER } from "@wordpress/keycodes";
6
+ import { _x, sprintf } from "@wordpress/i18n";
7
+ import { areGlobalStylesEqual } from "@wordpress/global-styles-engine";
8
+ import { GlobalStylesContext } from "../context";
9
+ import { filterObjectByProperties } from "../utils";
10
+ function Variation({
11
+ variation,
12
+ children,
13
+ isPill = false,
14
+ properties,
15
+ showTooltip = false
16
+ }) {
17
+ const [isFocused, setIsFocused] = useState(false);
18
+ const {
19
+ base,
20
+ user,
21
+ onChange: setUserConfig
22
+ } = useContext(GlobalStylesContext);
23
+ const context = useMemo(() => {
24
+ let merged = { ...base, ...variation };
25
+ if (properties) {
26
+ merged = filterObjectByProperties(merged, properties);
27
+ }
28
+ return {
29
+ user: variation,
30
+ base,
31
+ merged,
32
+ onChange: () => {
33
+ }
34
+ };
35
+ }, [variation, base, properties]);
36
+ const selectVariation = () => setUserConfig(variation);
37
+ const selectOnEnter = (event) => {
38
+ if (event.keyCode === ENTER) {
39
+ event.preventDefault();
40
+ selectVariation();
41
+ }
42
+ };
43
+ const isActive = useMemo(
44
+ () => areGlobalStylesEqual(user, variation),
45
+ [user, variation]
46
+ );
47
+ let label = variation?.title;
48
+ if (variation?.description) {
49
+ label = sprintf(
50
+ /* translators: 1: variation title. 2: variation description. */
51
+ _x("%1$s (%2$s)", "variation label"),
52
+ variation?.title,
53
+ variation?.description
54
+ );
55
+ }
56
+ const content = /* @__PURE__ */ jsx(
57
+ "div",
58
+ {
59
+ className: clsx("global-styles-ui-variations_item", {
60
+ "is-active": isActive
61
+ }),
62
+ role: "button",
63
+ onClick: selectVariation,
64
+ onKeyDown: selectOnEnter,
65
+ tabIndex: 0,
66
+ "aria-label": label,
67
+ "aria-current": isActive,
68
+ onFocus: () => setIsFocused(true),
69
+ onBlur: () => setIsFocused(false),
70
+ children: /* @__PURE__ */ jsx(
71
+ "div",
72
+ {
73
+ className: clsx("global-styles-ui-variations_item-preview", {
74
+ "is-pill": isPill
75
+ }),
76
+ children: children(isFocused)
77
+ }
78
+ )
79
+ }
80
+ );
81
+ return /* @__PURE__ */ jsx(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ jsx(Tooltip, { text: variation?.title, children: content }) : content });
82
+ }
83
+ export {
84
+ Variation as default
85
+ };
86
+ //# sourceMappingURL=variation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/variations/variation.tsx"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Tooltip } from '@wordpress/components';\nimport { useMemo, useContext, useState } from '@wordpress/element';\nimport { ENTER } from '@wordpress/keycodes';\nimport { _x, sprintf } from '@wordpress/i18n';\nimport { areGlobalStylesEqual } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { GlobalStylesContext } from '../context';\nimport { filterObjectByProperties } from '../utils';\n\ninterface VariationProps {\n\tvariation: any;\n\tchildren: ( isFocused: boolean ) => React.ReactNode;\n\tisPill?: boolean;\n\tproperties?: string[];\n\tshowTooltip?: boolean;\n}\n\nexport default function Variation( {\n\tvariation,\n\tchildren,\n\tisPill = false,\n\tproperties,\n\tshowTooltip = false,\n}: VariationProps ) {\n\tconst [ isFocused, setIsFocused ] = useState( false );\n\tconst {\n\t\tbase,\n\t\tuser,\n\t\tonChange: setUserConfig,\n\t} = useContext( GlobalStylesContext );\n\n\tconst context = useMemo( () => {\n\t\tlet merged = { ...base, ...variation };\n\t\tif ( properties ) {\n\t\t\tmerged = filterObjectByProperties( merged, properties );\n\t\t}\n\t\treturn {\n\t\t\tuser: variation,\n\t\t\tbase,\n\t\t\tmerged,\n\t\t\tonChange: () => {},\n\t\t};\n\t}, [ variation, base, properties ] );\n\n\tconst selectVariation = () => setUserConfig( variation );\n\n\tconst selectOnEnter = ( event: React.KeyboardEvent ) => {\n\t\tif ( event.keyCode === ENTER ) {\n\t\t\tevent.preventDefault();\n\t\t\tselectVariation();\n\t\t}\n\t};\n\n\tconst isActive = useMemo(\n\t\t() => areGlobalStylesEqual( user, variation ),\n\t\t[ user, variation ]\n\t);\n\n\tlet label = variation?.title;\n\tif ( variation?.description ) {\n\t\tlabel = sprintf(\n\t\t\t/* translators: 1: variation title. 2: variation description. */\n\t\t\t_x( '%1$s (%2$s)', 'variation label' ),\n\t\t\tvariation?.title,\n\t\t\tvariation?.description\n\t\t);\n\t}\n\n\tconst content = (\n\t\t<div\n\t\t\tclassName={ clsx( 'global-styles-ui-variations_item', {\n\t\t\t\t'is-active': isActive,\n\t\t\t} ) }\n\t\t\trole=\"button\"\n\t\t\tonClick={ selectVariation }\n\t\t\tonKeyDown={ selectOnEnter }\n\t\t\ttabIndex={ 0 }\n\t\t\taria-label={ label }\n\t\t\taria-current={ isActive }\n\t\t\tonFocus={ () => setIsFocused( true ) }\n\t\t\tonBlur={ () => setIsFocused( false ) }\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'global-styles-ui-variations_item-preview', {\n\t\t\t\t\t'is-pill': isPill,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t{ children( isFocused ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<GlobalStylesContext.Provider value={ context }>\n\t\t\t{ showTooltip ? (\n\t\t\t\t<Tooltip text={ variation?.title }>{ content }</Tooltip>\n\t\t\t) : (\n\t\t\t\tcontent\n\t\t\t) }\n\t\t</GlobalStylesContext.Provider>\n\t);\n}\n"],
5
+ "mappings": "AA6FG;AA1FH,OAAO,UAAU;AAKjB,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY,gBAAgB;AAC9C,SAAS,aAAa;AACtB,SAAS,IAAI,eAAe;AAC5B,SAAS,4BAA4B;AAKrC,SAAS,2BAA2B;AACpC,SAAS,gCAAgC;AAU1B,SAAR,UAA4B;AAAA,EAClC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,cAAc;AACf,GAAoB;AACnB,QAAM,CAAE,WAAW,YAAa,IAAI,SAAU,KAAM;AACpD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACX,IAAI,WAAY,mBAAoB;AAEpC,QAAM,UAAU,QAAS,MAAM;AAC9B,QAAI,SAAS,EAAE,GAAG,MAAM,GAAG,UAAU;AACrC,QAAK,YAAa;AACjB,eAAS,yBAA0B,QAAQ,UAAW;AAAA,IACvD;AACA,WAAO;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA,UAAU,MAAM;AAAA,MAAC;AAAA,IAClB;AAAA,EACD,GAAG,CAAE,WAAW,MAAM,UAAW,CAAE;AAEnC,QAAM,kBAAkB,MAAM,cAAe,SAAU;AAEvD,QAAM,gBAAgB,CAAE,UAAgC;AACvD,QAAK,MAAM,YAAY,OAAQ;AAC9B,YAAM,eAAe;AACrB,sBAAgB;AAAA,IACjB;AAAA,EACD;AAEA,QAAM,WAAW;AAAA,IAChB,MAAM,qBAAsB,MAAM,SAAU;AAAA,IAC5C,CAAE,MAAM,SAAU;AAAA,EACnB;AAEA,MAAI,QAAQ,WAAW;AACvB,MAAK,WAAW,aAAc;AAC7B,YAAQ;AAAA;AAAA,MAEP,GAAI,eAAe,iBAAkB;AAAA,MACrC,WAAW;AAAA,MACX,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,QAAM,UACL;AAAA,IAAC;AAAA;AAAA,MACA,WAAY,KAAM,oCAAoC;AAAA,QACrD,aAAa;AAAA,MACd,CAAE;AAAA,MACF,MAAK;AAAA,MACL,SAAU;AAAA,MACV,WAAY;AAAA,MACZ,UAAW;AAAA,MACX,cAAa;AAAA,MACb,gBAAe;AAAA,MACf,SAAU,MAAM,aAAc,IAAK;AAAA,MACnC,QAAS,MAAM,aAAc,KAAM;AAAA,MAEnC;AAAA,QAAC;AAAA;AAAA,UACA,WAAY,KAAM,4CAA4C;AAAA,YAC7D,WAAW;AAAA,UACZ,CAAE;AAAA,UAEA,mBAAU,SAAU;AAAA;AAAA,MACvB;AAAA;AAAA,EACD;AAGD,SACC,oBAAC,oBAAoB,UAApB,EAA6B,OAAQ,SACnC,wBACD,oBAAC,WAAQ,MAAO,WAAW,OAAU,mBAAS,IAE9C,SAEF;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ __experimentalGrid as Grid,
4
+ __experimentalVStack as VStack
5
+ } from "@wordpress/components";
6
+ import StylesPreviewColors from "../preview-colors";
7
+ import { useCurrentMergeThemeStyleVariationsWithUserConfig } from "../hooks";
8
+ import { Subtitle } from "../subtitle";
9
+ import Variation from "./variation";
10
+ const propertiesToFilter = ["color"];
11
+ function ColorVariations({
12
+ title,
13
+ gap = 2
14
+ }) {
15
+ const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter);
16
+ if (colorVariations?.length <= 1) {
17
+ return null;
18
+ }
19
+ return /* @__PURE__ */ jsxs(VStack, { spacing: 3, children: [
20
+ title && /* @__PURE__ */ jsx(Subtitle, { level: 3, children: title }),
21
+ /* @__PURE__ */ jsx(Grid, { gap, children: colorVariations.map((variation, index) => /* @__PURE__ */ jsx(
22
+ Variation,
23
+ {
24
+ variation,
25
+ isPill: true,
26
+ properties: propertiesToFilter,
27
+ showTooltip: true,
28
+ children: () => /* @__PURE__ */ jsx(StylesPreviewColors, {})
29
+ },
30
+ index
31
+ )) })
32
+ ] });
33
+ }
34
+ export {
35
+ ColorVariations as default
36
+ };
37
+ //# sourceMappingURL=variations-color.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/variations/variations-color.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalGrid as Grid,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport StylesPreviewColors from '../preview-colors';\nimport { useCurrentMergeThemeStyleVariationsWithUserConfig } from '../hooks';\nimport { Subtitle } from '../subtitle';\nimport Variation from './variation';\n\ninterface ColorVariationsProps {\n\ttitle?: string;\n\tgap?: number;\n}\n\nconst propertiesToFilter = [ 'color' ];\n\nexport default function ColorVariations( {\n\ttitle,\n\tgap = 2,\n}: ColorVariationsProps ) {\n\tconst colorVariations =\n\t\tuseCurrentMergeThemeStyleVariationsWithUserConfig( propertiesToFilter );\n\n\t// Return null if there is only one variation (the default).\n\tif ( colorVariations?.length <= 1 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 3 }>\n\t\t\t{ title && <Subtitle level={ 3 }>{ title }</Subtitle> }\n\t\t\t<Grid gap={ gap }>\n\t\t\t\t{ colorVariations.map( ( variation: any, index: number ) => (\n\t\t\t\t\t<Variation\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tvariation={ variation }\n\t\t\t\t\t\tisPill\n\t\t\t\t\t\tproperties={ propertiesToFilter }\n\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t>\n\t\t\t\t\t\t{ () => <StylesPreviewColors /> }\n\t\t\t\t\t</Variation>\n\t\t\t\t) ) }\n\t\t\t</Grid>\n\t\t</VStack>\n\t);\n}\n"],
5
+ "mappings": "AAoCE,SACY,KADZ;AAjCF;AAAA,EACC,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,OAClB;AAKP,OAAO,yBAAyB;AAChC,SAAS,yDAAyD;AAClE,SAAS,gBAAgB;AACzB,OAAO,eAAe;AAOtB,MAAM,qBAAqB,CAAE,OAAQ;AAEtB,SAAR,gBAAkC;AAAA,EACxC;AAAA,EACA,MAAM;AACP,GAA0B;AACzB,QAAM,kBACL,kDAAmD,kBAAmB;AAGvE,MAAK,iBAAiB,UAAU,GAAI;AACnC,WAAO;AAAA,EACR;AAEA,SACC,qBAAC,UAAO,SAAU,GACf;AAAA,aAAS,oBAAC,YAAS,OAAQ,GAAM,iBAAO;AAAA,IAC1C,oBAAC,QAAK,KACH,0BAAgB,IAAK,CAAE,WAAgB,UACxC;AAAA,MAAC;AAAA;AAAA,QAEA;AAAA,QACA,QAAM;AAAA,QACN,YAAa;AAAA,QACb,aAAW;AAAA,QAET,gBAAM,oBAAC,uBAAoB;AAAA;AAAA,MANvB;AAAA,IAOP,CACC,GACH;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,44 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { store as blocksStore } from "@wordpress/blocks";
3
+ import { useSelect } from "@wordpress/data";
4
+ import { __experimentalItemGroup as ItemGroup } from "@wordpress/components";
5
+ import { NavigationButtonAsItem } from "../navigation-button";
6
+ import { useSetting } from "../hooks";
7
+ function getFilteredBlockStyles(blockStyles, variations) {
8
+ return blockStyles?.filter(
9
+ (style) => style.source === "block" || variations.includes(style.name)
10
+ ) || [];
11
+ }
12
+ function useBlockVariations(name) {
13
+ const blockStyles = useSelect(
14
+ (select) => {
15
+ const { getBlockStyles } = select(blocksStore);
16
+ return getBlockStyles(name);
17
+ },
18
+ [name]
19
+ );
20
+ const [variations] = useSetting("variations", name);
21
+ const variationNames = Object.keys(variations ?? {});
22
+ return getFilteredBlockStyles(blockStyles, variationNames);
23
+ }
24
+ function VariationsPanel({ name }) {
25
+ const coreBlockStyles = useBlockVariations(name);
26
+ return /* @__PURE__ */ jsx(ItemGroup, { isBordered: true, isSeparated: true, children: coreBlockStyles.map((style, index) => {
27
+ if (style?.isDefault) {
28
+ return null;
29
+ }
30
+ return /* @__PURE__ */ jsx(
31
+ NavigationButtonAsItem,
32
+ {
33
+ path: "/blocks/" + encodeURIComponent(name) + "/variations/" + encodeURIComponent(style.name),
34
+ children: style.label
35
+ },
36
+ index
37
+ );
38
+ }) });
39
+ }
40
+ export {
41
+ VariationsPanel,
42
+ useBlockVariations
43
+ };
44
+ //# sourceMappingURL=variations-panel.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/variations/variations-panel.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\n// @ts-expect-error: Not typed yet.\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { __experimentalItemGroup as ItemGroup } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { NavigationButtonAsItem } from '../navigation-button';\nimport { useSetting } from '../hooks';\n\ninterface BlockStyle {\n\tname: string;\n\tlabel: string;\n\tsource?: string;\n\tisDefault?: boolean;\n}\n\ninterface VariationsPanelProps {\n\tname: string;\n}\n\n// Only core block styles (source === block) or block styles with a matching\n// theme.json style variation will be configurable via Global Styles.\nfunction getFilteredBlockStyles(\n\tblockStyles: BlockStyle[],\n\tvariations: string[]\n): BlockStyle[] {\n\treturn (\n\t\tblockStyles?.filter(\n\t\t\t( style ) =>\n\t\t\t\tstyle.source === 'block' || variations.includes( style.name )\n\t\t) || []\n\t);\n}\n\nexport function useBlockVariations( name: string ): BlockStyle[] {\n\tconst blockStyles = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockStyles } = select( blocksStore );\n\t\t\treturn getBlockStyles( name );\n\t\t},\n\t\t[ name ]\n\t);\n\tconst [ variations ] = useSetting( 'variations', name );\n\tconst variationNames = Object.keys( variations ?? {} );\n\n\treturn getFilteredBlockStyles( blockStyles, variationNames );\n}\n\nexport function VariationsPanel( { name }: VariationsPanelProps ) {\n\tconst coreBlockStyles = useBlockVariations( name );\n\n\treturn (\n\t\t<ItemGroup isBordered isSeparated>\n\t\t\t{ coreBlockStyles.map( ( style, index ) => {\n\t\t\t\tif ( style?.isDefault ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\treturn (\n\t\t\t\t\t<NavigationButtonAsItem\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tpath={\n\t\t\t\t\t\t\t'/blocks/' +\n\t\t\t\t\t\t\tencodeURIComponent( name ) +\n\t\t\t\t\t\t\t'/variations/' +\n\t\t\t\t\t\t\tencodeURIComponent( style.name )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ style.label }\n\t\t\t\t\t</NavigationButtonAsItem>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ItemGroup>\n\t);\n}\n"],
5
+ "mappings": "AA+DK;AA3DL,SAAS,SAAS,mBAAmB;AACrC,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B,iBAAiB;AAKrD,SAAS,8BAA8B;AACvC,SAAS,kBAAkB;AAe3B,SAAS,uBACR,aACA,YACe;AACf,SACC,aAAa;AAAA,IACZ,CAAE,UACD,MAAM,WAAW,WAAW,WAAW,SAAU,MAAM,IAAK;AAAA,EAC9D,KAAK,CAAC;AAER;AAEO,SAAS,mBAAoB,MAA6B;AAChE,QAAM,cAAc;AAAA,IACnB,CAAE,WAAY;AACb,YAAM,EAAE,eAAe,IAAI,OAAQ,WAAY;AAC/C,aAAO,eAAgB,IAAK;AAAA,IAC7B;AAAA,IACA,CAAE,IAAK;AAAA,EACR;AACA,QAAM,CAAE,UAAW,IAAI,WAAY,cAAc,IAAK;AACtD,QAAM,iBAAiB,OAAO,KAAM,cAAc,CAAC,CAAE;AAErD,SAAO,uBAAwB,aAAa,cAAe;AAC5D;AAEO,SAAS,gBAAiB,EAAE,KAAK,GAA0B;AACjE,QAAM,kBAAkB,mBAAoB,IAAK;AAEjD,SACC,oBAAC,aAAU,YAAU,MAAC,aAAW,MAC9B,0BAAgB,IAAK,CAAE,OAAO,UAAW;AAC1C,QAAK,OAAO,WAAY;AACvB,aAAO;AAAA,IACR;AACA,WACC;AAAA,MAAC;AAAA;AAAA,QAEA,MACC,aACA,mBAAoB,IAAK,IACzB,iBACA,mBAAoB,MAAM,IAAK;AAAA,QAG9B,gBAAM;AAAA;AAAA,MARF;AAAA,IASP;AAAA,EAEF,CAAE,GACH;AAEF;",
6
+ "names": []
7
+ }