@content-blocks/js 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +111 -3
  3. package/THIRD-PARTY-NOTICES.md +21 -0
  4. package/dist/cjs/{app-globals-3a1e7e63.js → app-globals-V2Kpy_OQ.js} +0 -2
  5. package/dist/cjs/content-accordion.cjs.entry.js +87 -0
  6. package/dist/cjs/content-blocks.cjs.js +35 -11
  7. package/dist/cjs/content-button.cjs.entry.js +113 -0
  8. package/dist/cjs/content-carousel.cjs.entry.js +153 -47
  9. package/dist/cjs/content-grid-formatter.cjs.entry.js +102 -0
  10. package/dist/cjs/content-hero-block.cjs.entry.js +45 -0
  11. package/dist/cjs/content-image.cjs.entry.js +153 -0
  12. package/dist/cjs/content-line.cjs.entry.js +61 -0
  13. package/dist/cjs/content-navigation-block.cjs.entry.js +51 -34
  14. package/dist/cjs/content-overlay.cjs.entry.js +641 -0
  15. package/dist/cjs/content-spacer.cjs.entry.js +75 -0
  16. package/dist/cjs/content-split-block.cjs.entry.js +22 -19
  17. package/dist/cjs/content-tabs.cjs.entry.js +38 -21
  18. package/dist/cjs/content-text-block.cjs.entry.js +63 -0
  19. package/dist/cjs/content-tout-block.cjs.entry.js +34 -0
  20. package/dist/cjs/{content-accordion_11.cjs.entry.js → content-video.cjs.entry.js} +14560 -12927
  21. package/dist/cjs/{focus-trap.esm-7bc384a0.js → focus-trap.esm-ZwN-anf1.js} +484 -190
  22. package/dist/cjs/{index-2e0ce692.js → index-B1U6Gweq.js} +348 -246
  23. package/dist/cjs/index-ClnpH9XB.js +2170 -0
  24. package/dist/cjs/index-CyalvZJn.js +1719 -0
  25. package/dist/cjs/index-DUvWvBDN.js +290 -0
  26. package/dist/cjs/index-voGY4Tkl.js +4705 -0
  27. package/dist/cjs/index.cjs.js +2 -5
  28. package/dist/cjs/loader.cjs.js +3 -8
  29. package/dist/cjs/responsive-component-C5eJS82z.js +171 -0
  30. package/dist/cjs/responsive-component-DMdnQIPV.js +171 -0
  31. package/dist/cjs/swiper-KLYbvU1K.js +3931 -0
  32. package/dist/cjs/{swiper-8221f4e8.js → swiper-_Z8Y4IJI.js} +269 -236
  33. package/dist/cjs/utils-BCHaRGm_.js +462 -0
  34. package/dist/cjs/{utils-df044337.js → utils-C3gXIS2t.js} +51 -49
  35. package/dist/cjs/utils-DUvWvBDN.js +290 -0
  36. package/dist/collection/blocks/content-hero-block/content-hero-block.css +1 -1
  37. package/dist/collection/blocks/content-hero-block/content-hero-block.js +33 -48
  38. package/dist/collection/blocks/content-split-block/content-split-block.css +16 -5
  39. package/dist/collection/blocks/content-split-block/content-split-block.js +29 -48
  40. package/dist/collection/blocks/content-text-block/content-text-block.js +65 -59
  41. package/dist/collection/blocks/content-tout-block/content-tout-block.css +3 -0
  42. package/dist/collection/blocks/content-tout-block/content-tout-block.js +22 -47
  43. package/dist/collection/collection-manifest.json +8 -5
  44. package/dist/collection/components/content-accordion/content-accordion.css +20 -1
  45. package/dist/collection/components/content-accordion/content-accordion.js +67 -33
  46. package/dist/collection/components/content-accordion/libraries/w3_disclosure_button.js +0 -1
  47. package/dist/collection/components/content-carousel/content-carousel.css +60 -4
  48. package/dist/collection/components/content-carousel/content-carousel.js +294 -44
  49. package/dist/collection/components/content-navigation-block/content-navigation-block.css +15 -1
  50. package/dist/collection/components/content-navigation-block/content-navigation-block.js +86 -42
  51. package/dist/collection/components/content-overlay/content-overlay.css +36 -5
  52. package/dist/collection/components/content-overlay/content-overlay.js +181 -120
  53. package/dist/collection/components/content-overlay/libraries/aria-dialog.js +0 -1
  54. package/dist/collection/components/content-overlay/libraries/aria-utilities.js +0 -1
  55. package/dist/collection/components/content-tabs/content-tabs.js +7 -49
  56. package/dist/collection/components/content-tabs/libraries/w3_tabs.js +0 -1
  57. package/dist/collection/elements/content-button/content-button.css +8 -7
  58. package/dist/collection/elements/content-button/content-button.js +103 -84
  59. package/dist/collection/elements/content-image/content-image.css +3 -1
  60. package/dist/collection/elements/content-image/content-image.js +176 -95
  61. package/dist/collection/elements/content-line/content-line.js +63 -54
  62. package/dist/collection/elements/content-video/content-video.css +1 -1
  63. package/dist/collection/elements/content-video/content-video.js +165 -92
  64. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.css +8 -2
  65. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js +167 -89
  66. package/dist/collection/formatters/content-spacer/content-spacer.js +86 -209
  67. package/dist/collection/global/content-blocks-reset.css +77 -0
  68. package/dist/collection/index.js +1 -1
  69. package/dist/collection/sass/_mixins.scss +21 -5
  70. package/dist/collection/sass/_variables.scss +15 -15
  71. package/dist/collection/setupFiles.js +0 -1
  72. package/dist/collection/site/site.js +67 -0
  73. package/dist/collection/utils/breakpoints.js +162 -0
  74. package/dist/collection/utils/responsive-component.js +249 -0
  75. package/dist/collection/utils/utils.js +32 -42
  76. package/dist/components/content-accordion.js +65 -44
  77. package/dist/components/content-button.js +89 -43
  78. package/dist/components/content-carousel.js +172 -55
  79. package/dist/components/content-grid-formatter.js +127 -3
  80. package/dist/components/content-hero-block.js +33 -26
  81. package/dist/components/content-image.js +127 -71
  82. package/dist/components/content-line.js +56 -35
  83. package/dist/components/content-navigation-block.js +62 -39
  84. package/dist/components/content-overlay.js +128 -67
  85. package/dist/components/content-spacer.js +70 -54
  86. package/dist/components/content-split-block.js +33 -32
  87. package/dist/components/content-tabs.js +46 -25
  88. package/dist/components/content-text-block.js +55 -35
  89. package/dist/components/content-tout-block.js +29 -27
  90. package/dist/components/content-video.js +14624 -11972
  91. package/dist/{esm/focus-trap.esm-8fb54175.js → components/focus-trap.esm.js} +484 -190
  92. package/dist/components/index.d.ts +2 -0
  93. package/dist/components/index.js +3 -3
  94. package/dist/components/{p-5a91aa1b.js → index2.js} +348 -246
  95. package/dist/components/p-BWRCeMvO.js +1 -0
  96. package/dist/components/p-CYF5GU_q.js +1 -0
  97. package/dist/components/p-DXUoPIwl.js +10 -0
  98. package/dist/components/p-D_Ll4QNj.js +1 -0
  99. package/dist/components/p-DhIoW7H3.js +1 -0
  100. package/dist/components/responsive-component.js +168 -0
  101. package/dist/components/{p-e5dc4ea4.js → swiper.js} +268 -235
  102. package/dist/components/utils.js +4969 -0
  103. package/dist/{esm/utils-1c9f0ec1.js → components/utils2.js} +51 -50
  104. package/dist/content-blocks/content-accordion.entry.js +85 -0
  105. package/dist/content-blocks/content-blocks.esm.js +47 -2
  106. package/dist/content-blocks/content-button.entry.js +111 -0
  107. package/dist/content-blocks/content-carousel.entry.js +188 -0
  108. package/dist/content-blocks/content-grid-formatter.entry.js +100 -0
  109. package/dist/content-blocks/content-hero-block.entry.js +43 -0
  110. package/dist/content-blocks/content-image.entry.js +151 -0
  111. package/dist/content-blocks/content-line.entry.js +59 -0
  112. package/dist/content-blocks/content-navigation-block.entry.js +105 -0
  113. package/dist/content-blocks/content-overlay.entry.js +639 -0
  114. package/dist/content-blocks/content-spacer.entry.js +73 -0
  115. package/dist/content-blocks/content-split-block.entry.js +34 -0
  116. package/dist/content-blocks/content-tabs.entry.js +245 -0
  117. package/dist/content-blocks/content-text-block.entry.js +61 -0
  118. package/dist/content-blocks/content-tout-block.entry.js +32 -0
  119. package/dist/{esm/content-accordion_11.entry.js → content-blocks/content-video.entry.js} +14535 -12890
  120. package/dist/{components/p-a2fedf8a.js → content-blocks/focus-trap.esm-DXUoPIwl.js} +484 -190
  121. package/dist/content-blocks/global/content-blocks-reset.css +77 -0
  122. package/dist/content-blocks/index-BFDJMblF.js +4690 -0
  123. package/dist/{esm/index-f45a9c45.js → content-blocks/index-P1YnSd-O.js} +348 -246
  124. package/dist/content-blocks/index.esm.js +1 -2
  125. package/dist/content-blocks/p-008457f0.entry.js +1 -0
  126. package/dist/content-blocks/p-052692f1.entry.js +1 -0
  127. package/dist/content-blocks/p-0f71bd32.entry.js +1 -0
  128. package/dist/content-blocks/p-1f154617.entry.js +1 -0
  129. package/dist/content-blocks/p-2554ebd8.entry.js +1 -0
  130. package/dist/content-blocks/p-4afd6511.entry.js +1 -0
  131. package/dist/content-blocks/p-78d5de9f.entry.js +1 -0
  132. package/dist/content-blocks/p-7bcf7e7e.entry.js +1 -0
  133. package/dist/content-blocks/p-9058031c.entry.js +1 -0
  134. package/dist/content-blocks/p-9c41ac23.entry.js +17 -0
  135. package/dist/content-blocks/p-CLwOzPEO.js +3 -0
  136. package/dist/content-blocks/p-CYF5GU_q.js +1 -0
  137. package/dist/content-blocks/p-CjR_4mPu.js +1 -0
  138. package/dist/content-blocks/p-DQuL1Twl.js +1 -0
  139. package/dist/content-blocks/p-DXUoPIwl.js +10 -0
  140. package/dist/content-blocks/p-D_Ll4QNj.js +1 -0
  141. package/dist/content-blocks/p-DhIoW7H3.js +1 -0
  142. package/dist/content-blocks/p-DzYwy_62.js +1 -0
  143. package/dist/content-blocks/p-b2e6358a.entry.js +1 -0
  144. package/dist/content-blocks/p-c783bc68.entry.js +1 -0
  145. package/dist/content-blocks/p-e3d81e15.entry.js +1 -0
  146. package/dist/content-blocks/p-f23b4aae.entry.js +1 -0
  147. package/dist/content-blocks/p-f75c9094.entry.js +1 -0
  148. package/dist/content-blocks/responsive-component-BsLrcKbS.js +169 -0
  149. package/dist/content-blocks/sass/_mixins.scss +21 -5
  150. package/dist/content-blocks/sass/_variables.scss +15 -15
  151. package/dist/{esm/swiper-e9621adb.js → content-blocks/swiper-nBv069TB.js} +268 -235
  152. package/dist/{components/p-b85cfa86.js → content-blocks/utils--SDsQnWS.js} +51 -50
  153. package/dist/content-blocks/utils-Bak__24s.js +280 -0
  154. package/dist/docs.d.ts +480 -0
  155. package/dist/docs.json +5312 -0
  156. package/dist/esm/{app-globals-0f993ce5.js → app-globals-DQuL1Twl.js} +0 -2
  157. package/dist/esm/content-accordion.entry.js +85 -0
  158. package/dist/esm/content-blocks.js +33 -8
  159. package/dist/esm/content-button.entry.js +111 -0
  160. package/dist/esm/content-carousel.entry.js +153 -45
  161. package/dist/esm/content-grid-formatter.entry.js +100 -0
  162. package/dist/esm/content-hero-block.entry.js +43 -0
  163. package/dist/esm/content-image.entry.js +151 -0
  164. package/dist/esm/content-line.entry.js +59 -0
  165. package/dist/esm/content-navigation-block.entry.js +51 -32
  166. package/dist/esm/content-overlay.entry.js +639 -0
  167. package/dist/esm/content-spacer.entry.js +73 -0
  168. package/dist/esm/content-split-block.entry.js +22 -17
  169. package/dist/esm/content-tabs.entry.js +38 -19
  170. package/dist/esm/content-text-block.entry.js +61 -0
  171. package/dist/esm/content-tout-block.entry.js +32 -0
  172. package/dist/esm/content-video.entry.js +72033 -0
  173. package/dist/esm/focus-trap.esm-DXUoPIwl.js +1801 -0
  174. package/dist/esm/index-BASCLGuP.js +1713 -0
  175. package/dist/esm/index-BFDJMblF.js +4690 -0
  176. package/dist/esm/index-CLwOzPEO.js +2161 -0
  177. package/dist/esm/index-CjR_4mPu.js +280 -0
  178. package/dist/esm/index-P1YnSd-O.js +5397 -0
  179. package/dist/esm/index.js +1 -3
  180. package/dist/esm/loader.js +3 -6
  181. package/dist/esm/responsive-component-BsLrcKbS.js +169 -0
  182. package/dist/esm/responsive-component-D7dJHMp0.js +169 -0
  183. package/dist/esm/swiper-CtypHPwF.js +3928 -0
  184. package/dist/esm/swiper-nBv069TB.js +3941 -0
  185. package/dist/esm/utils--SDsQnWS.js +460 -0
  186. package/dist/esm/utils-Bak__24s.js +280 -0
  187. package/dist/esm/utils-CYF5GU_q.js +438 -0
  188. package/dist/node_modules/video.js/dist/video-js.min.css +1 -0
  189. package/dist/test/axe.js +60 -0
  190. package/dist/types/Users/shahrukceo/Developer/content-blocks/packages/js/.stencil/test/axe.d.ts +16 -0
  191. package/dist/types/blocks/content-hero-block/content-hero-block.d.ts +7 -11
  192. package/dist/types/blocks/content-split-block/content-split-block.d.ts +5 -9
  193. package/dist/types/blocks/content-text-block/content-text-block.d.ts +4 -9
  194. package/dist/types/blocks/content-tout-block/content-tout-block.d.ts +5 -10
  195. package/dist/types/components/content-accordion/content-accordion.d.ts +4 -3
  196. package/dist/types/components/content-accordion/libraries/w3_disclosure_button.d.ts +0 -1
  197. package/dist/types/components/content-carousel/content-carousel.d.ts +44 -7
  198. package/dist/types/components/content-navigation-block/content-navigation-block.d.ts +14 -8
  199. package/dist/types/components/content-overlay/content-overlay.d.ts +15 -16
  200. package/dist/types/components/content-overlay/libraries/aria-dialog.d.ts +0 -1
  201. package/dist/types/components/content-overlay/libraries/aria-utilities.d.ts +0 -1
  202. package/dist/types/components/content-tabs/content-tabs.d.ts +4 -10
  203. package/dist/types/components/content-tabs/libraries/w3_tabs.d.ts +0 -1
  204. package/dist/types/components.d.ts +900 -196
  205. package/dist/types/elements/content-button/content-button.d.ts +8 -13
  206. package/dist/types/elements/content-image/content-image.d.ts +15 -9
  207. package/dist/types/elements/content-line/content-line.d.ts +5 -12
  208. package/dist/types/elements/content-video/content-video.d.ts +12 -11
  209. package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +14 -9
  210. package/dist/types/formatters/content-spacer/content-spacer.d.ts +4 -36
  211. package/dist/types/index.d.ts +3 -1
  212. package/dist/types/setupFiles.d.ts +0 -1
  213. package/dist/types/stencil-public-runtime.d.ts +265 -60
  214. package/dist/types/typings.d.ts +10 -0
  215. package/dist/types/utils/breakpoints.d.ts +57 -0
  216. package/dist/types/utils/responsive-component.d.ts +49 -0
  217. package/dist/types/utils/utils.d.ts +11 -8
  218. package/loader/cdn.js +1 -0
  219. package/loader/index.cjs.js +1 -0
  220. package/loader/index.d.ts +24 -0
  221. package/loader/index.es2017.js +1 -0
  222. package/loader/index.js +2 -0
  223. package/package.json +75 -65
  224. package/dist/cjs/BehaviorSubject-12116537.js +0 -655
  225. package/dist/cjs/BehaviorSubject-12116537.js.map +0 -1
  226. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  227. package/dist/cjs/content-accordion_11.cjs.entry.js.map +0 -1
  228. package/dist/cjs/content-blocks.cjs.js.map +0 -1
  229. package/dist/cjs/content-carousel.cjs.entry.js.map +0 -1
  230. package/dist/cjs/content-navigation-block.cjs.entry.js.map +0 -1
  231. package/dist/cjs/content-split-block.cjs.entry.js.map +0 -1
  232. package/dist/cjs/content-tabs.cjs.entry.js.map +0 -1
  233. package/dist/cjs/focus-trap.esm-7bc384a0.js.map +0 -1
  234. package/dist/cjs/index-2e0ce692.js.map +0 -1
  235. package/dist/cjs/index-8af2820a.js +0 -1650
  236. package/dist/cjs/index-8af2820a.js.map +0 -1
  237. package/dist/cjs/index.cjs.js.map +0 -1
  238. package/dist/cjs/loader.cjs.js.map +0 -1
  239. package/dist/cjs/swiper-8221f4e8.js.map +0 -1
  240. package/dist/cjs/utils-df044337.js.map +0 -1
  241. package/dist/cjs/utils-f8ccab0a.js +0 -126
  242. package/dist/cjs/utils-f8ccab0a.js.map +0 -1
  243. package/dist/cjs/window-resize-service-65a5a370.js +0 -37
  244. package/dist/cjs/window-resize-service-65a5a370.js.map +0 -1
  245. package/dist/collection/blocks/content-hero-block/content-hero-block.js.map +0 -1
  246. package/dist/collection/blocks/content-split-block/content-split-block.js.map +0 -1
  247. package/dist/collection/blocks/content-text-block/content-text-block.js.map +0 -1
  248. package/dist/collection/blocks/content-tout-block/content-tout-block.js.map +0 -1
  249. package/dist/collection/components/content-accordion/content-accordion.js.map +0 -1
  250. package/dist/collection/components/content-accordion/libraries/w3_disclosure_button.js.map +0 -1
  251. package/dist/collection/components/content-carousel/content-carousel.js.map +0 -1
  252. package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +0 -1
  253. package/dist/collection/components/content-overlay/content-overlay.js.map +0 -1
  254. package/dist/collection/components/content-overlay/libraries/aria-dialog.js.map +0 -1
  255. package/dist/collection/components/content-overlay/libraries/aria-utilities.js.map +0 -1
  256. package/dist/collection/components/content-tabs/content-tabs.js.map +0 -1
  257. package/dist/collection/components/content-tabs/libraries/w3_tabs.js.map +0 -1
  258. package/dist/collection/elements/content-button/content-button.js.map +0 -1
  259. package/dist/collection/elements/content-image/content-image.js.map +0 -1
  260. package/dist/collection/elements/content-line/content-line.js.map +0 -1
  261. package/dist/collection/elements/content-video/content-video.js.map +0 -1
  262. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +0 -1
  263. package/dist/collection/formatters/content-spacer/content-spacer.js.map +0 -1
  264. package/dist/collection/globalScript.js +0 -15
  265. package/dist/collection/globalScript.js.map +0 -1
  266. package/dist/collection/index.js.map +0 -1
  267. package/dist/collection/services/content-events-service.js +0 -23
  268. package/dist/collection/services/content-events-service.js.map +0 -1
  269. package/dist/collection/services/window-resize-service.js +0 -31
  270. package/dist/collection/services/window-resize-service.js.map +0 -1
  271. package/dist/collection/setupFiles.js.map +0 -1
  272. package/dist/collection/stories/ContentHeroBlock.stories.js +0 -51
  273. package/dist/collection/stories/ContentHeroBlock.stories.js.map +0 -1
  274. package/dist/collection/stories/ContentNavigationBlock.stories.js +0 -33
  275. package/dist/collection/stories/ContentNavigationBlock.stories.js.map +0 -1
  276. package/dist/collection/stories/ContentSpacer.stories.js +0 -20
  277. package/dist/collection/stories/ContentSpacer.stories.js.map +0 -1
  278. package/dist/collection/stories/ContentTextBlock.stories.js +0 -17
  279. package/dist/collection/stories/ContentTextBlock.stories.js.map +0 -1
  280. package/dist/collection/stories/ContentToutBlock.stories.js +0 -17
  281. package/dist/collection/stories/ContentToutBlock.stories.js.map +0 -1
  282. package/dist/collection/stories/FullPageExample.stories.js +0 -432
  283. package/dist/collection/stories/FullPageExample.stories.js.map +0 -1
  284. package/dist/collection/stories/assets/accessibility.svg +0 -5
  285. package/dist/collection/stories/assets/discord.svg +0 -15
  286. package/dist/collection/stories/assets/github.svg +0 -3
  287. package/dist/collection/stories/assets/tutorials.svg +0 -12
  288. package/dist/collection/stories/assets/youtube.svg +0 -4
  289. package/dist/collection/utils/utils.js.map +0 -1
  290. package/dist/components/content-accordion.js.map +0 -1
  291. package/dist/components/content-button.js.map +0 -1
  292. package/dist/components/content-carousel.js.map +0 -1
  293. package/dist/components/content-grid-formatter.js.map +0 -1
  294. package/dist/components/content-hero-block.js.map +0 -1
  295. package/dist/components/content-image.js.map +0 -1
  296. package/dist/components/content-line.js.map +0 -1
  297. package/dist/components/content-navigation-block.js.map +0 -1
  298. package/dist/components/content-overlay.js.map +0 -1
  299. package/dist/components/content-spacer.js.map +0 -1
  300. package/dist/components/content-split-block.js.map +0 -1
  301. package/dist/components/content-tabs.js.map +0 -1
  302. package/dist/components/content-text-block.js.map +0 -1
  303. package/dist/components/content-tout-block.js.map +0 -1
  304. package/dist/components/content-video.js.map +0 -1
  305. package/dist/components/index.js.map +0 -1
  306. package/dist/components/p-26483b46.js +0 -35
  307. package/dist/components/p-26483b46.js.map +0 -1
  308. package/dist/components/p-5a91aa1b.js.map +0 -1
  309. package/dist/components/p-74be971f.js +0 -652
  310. package/dist/components/p-74be971f.js.map +0 -1
  311. package/dist/components/p-7a436263.js +0 -122
  312. package/dist/components/p-7a436263.js.map +0 -1
  313. package/dist/components/p-a2fedf8a.js.map +0 -1
  314. package/dist/components/p-b85cfa86.js.map +0 -1
  315. package/dist/components/p-e28db040.js +0 -1452
  316. package/dist/components/p-e28db040.js.map +0 -1
  317. package/dist/components/p-e5dc4ea4.js.map +0 -1
  318. package/dist/components/p-e9bce2ab.js +0 -88
  319. package/dist/components/p-e9bce2ab.js.map +0 -1
  320. package/dist/content-blocks/content-blocks.esm.js.map +0 -1
  321. package/dist/content-blocks/index.esm.js.map +0 -1
  322. package/dist/content-blocks/p-13c3cc4f.js +0 -3
  323. package/dist/content-blocks/p-13c3cc4f.js.map +0 -1
  324. package/dist/content-blocks/p-5422c25b.entry.js +0 -2
  325. package/dist/content-blocks/p-5422c25b.entry.js.map +0 -1
  326. package/dist/content-blocks/p-5a91aa1b.js +0 -2
  327. package/dist/content-blocks/p-5a91aa1b.js.map +0 -1
  328. package/dist/content-blocks/p-650d1757.js +0 -2
  329. package/dist/content-blocks/p-650d1757.js.map +0 -1
  330. package/dist/content-blocks/p-74be971f.js +0 -2
  331. package/dist/content-blocks/p-74be971f.js.map +0 -1
  332. package/dist/content-blocks/p-8deb755c.entry.js +0 -26
  333. package/dist/content-blocks/p-8deb755c.entry.js.map +0 -1
  334. package/dist/content-blocks/p-a2fedf8a.js +0 -10
  335. package/dist/content-blocks/p-a2fedf8a.js.map +0 -1
  336. package/dist/content-blocks/p-b305392e.entry.js +0 -2
  337. package/dist/content-blocks/p-b305392e.entry.js.map +0 -1
  338. package/dist/content-blocks/p-b85cfa86.js +0 -2
  339. package/dist/content-blocks/p-b85cfa86.js.map +0 -1
  340. package/dist/content-blocks/p-cc7397cf.js +0 -2
  341. package/dist/content-blocks/p-cc7397cf.js.map +0 -1
  342. package/dist/content-blocks/p-d62775d7.entry.js +0 -2
  343. package/dist/content-blocks/p-d62775d7.entry.js.map +0 -1
  344. package/dist/content-blocks/p-e1255160.js +0 -2
  345. package/dist/content-blocks/p-e1255160.js.map +0 -1
  346. package/dist/content-blocks/p-e5dc4ea4.js +0 -2
  347. package/dist/content-blocks/p-e5dc4ea4.js.map +0 -1
  348. package/dist/content-blocks/p-f73f934a.entry.js +0 -2
  349. package/dist/content-blocks/p-f73f934a.entry.js.map +0 -1
  350. package/dist/esm/BehaviorSubject-f7a12fd8.js +0 -652
  351. package/dist/esm/BehaviorSubject-f7a12fd8.js.map +0 -1
  352. package/dist/esm/app-globals-0f993ce5.js.map +0 -1
  353. package/dist/esm/content-accordion_11.entry.js.map +0 -1
  354. package/dist/esm/content-blocks.js.map +0 -1
  355. package/dist/esm/content-carousel.entry.js.map +0 -1
  356. package/dist/esm/content-navigation-block.entry.js.map +0 -1
  357. package/dist/esm/content-split-block.entry.js.map +0 -1
  358. package/dist/esm/content-tabs.entry.js.map +0 -1
  359. package/dist/esm/focus-trap.esm-8fb54175.js.map +0 -1
  360. package/dist/esm/index-ec24af7a.js +0 -1621
  361. package/dist/esm/index-ec24af7a.js.map +0 -1
  362. package/dist/esm/index-f45a9c45.js.map +0 -1
  363. package/dist/esm/index.js.map +0 -1
  364. package/dist/esm/loader.js.map +0 -1
  365. package/dist/esm/swiper-e9621adb.js.map +0 -1
  366. package/dist/esm/utils-1c9f0ec1.js.map +0 -1
  367. package/dist/esm/utils-9a901aa9.js +0 -122
  368. package/dist/esm/utils-9a901aa9.js.map +0 -1
  369. package/dist/esm/window-resize-service-354f2ac5.js +0 -35
  370. package/dist/esm/window-resize-service-354f2ac5.js.map +0 -1
  371. package/dist/types/globalScript.d.ts +0 -1
  372. package/dist/types/old-components.d.ts +0 -1239
  373. package/dist/types/services/content-events-service.d.ts +0 -11
  374. package/dist/types/services/window-resize-service.d.ts +0 -11
  375. package/dist/types/stories/ContentHeroBlock.stories.d.ts +0 -11
  376. package/dist/types/stories/ContentNavigationBlock.stories.d.ts +0 -9
  377. package/dist/types/stories/ContentSpacer.stories.d.ts +0 -15
  378. package/dist/types/stories/ContentTextBlock.stories.d.ts +0 -9
  379. package/dist/types/stories/ContentToutBlock.stories.d.ts +0 -9
  380. package/dist/types/stories/FullPageExample.stories.d.ts +0 -10
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Breakpoints, and how a responsive value is read against them.
3
+ *
4
+ * A responsive value is written in one of two ways:
5
+ *
6
+ * Named: columns="1|tablet=2|desktop=4" or by width: columns="1|640=2"
7
+ * The first value may leave out the name: it is the base, from 0. A value names the breakpoint,
8
+ * or the width in pixels, it starts at, and applies from that width up. A later value without
9
+ * a name starts at the next breakpoint above the one before it: 1|640=2|4 is 4 from tablet up.
10
+ *
11
+ * Positional: columns="1|2|4"
12
+ * One value per breakpoint, smallest first. A breakpoint without a value keeps the one before it.
13
+ *
14
+ * A site sets its own breakpoints, by name, before the components load or at any time after:
15
+ *
16
+ * window.$contentBlocks = { breakpoints: { tablet: 768, desktop: 1024 } };
17
+ * setBreakpoints({ tablet: 768, desktop: 1024 });
18
+ *
19
+ * State lives on window, not in this module: a page can load the library more than once (the lazy loader, the
20
+ * custom elements build and the npm entry each have their own copy of this file), and every copy must agree.
21
+ */
22
+ // Used when the site sets none
23
+ export const defaultBreakpoints = {
24
+ mobile: 0,
25
+ tablet: 768,
26
+ laptop: 1024,
27
+ desktop: 1366,
28
+ wide: 1440,
29
+ ultrawide: 1920,
30
+ };
31
+ // The event setBreakpoints sends, so every copy of the library works its values out again
32
+ export const BREAKPOINTS_CHANGED = 'contentblocks:breakpoints';
33
+ // name=value, or width=value with the width in pixels (640= or 640px=). A name starts with a letter and a
34
+ // width is only digits, so values that contain = after other characters, such as an image URL with ?w=600,
35
+ // are never read as named.
36
+ const NAMED = /^([a-z][a-z0-9-]*|\d+(?:px)?)=(.*)$/;
37
+ // Widths written in values, such as 640 in 1|640=2, that are not breakpoints. The components watch them too,
38
+ // so a value switches when the screen crosses one.
39
+ const widths = new Set();
40
+ const widthListeners = new Set();
41
+ /** Widths written in values that are not breakpoints, and a way to hear of new ones. */
42
+ export function getValueWidths() {
43
+ return [...widths];
44
+ }
45
+ export function onValueWidth(listener) {
46
+ widthListeners.add(listener);
47
+ }
48
+ const warned = new Set();
49
+ function warn(message) {
50
+ if (warned.has(message))
51
+ return;
52
+ warned.add(message);
53
+ console.warn(`Content Blocks: ${message}`);
54
+ }
55
+ // Breakpoints from the site's setting, checked and sorted. Kept until the setting is replaced.
56
+ let cache;
57
+ function fromSetting(source) {
58
+ const list = [];
59
+ const entries = Array.isArray(source) ? source.map(width => ['', width]) : Object.entries(source);
60
+ for (const [name, width] of entries) {
61
+ if (name && !/^[a-z][a-z0-9-]*$/.test(name)) {
62
+ warn(`the breakpoint name "${name}" is left out. Use lowercase letters, numbers and hyphens, starting with a letter.`);
63
+ continue;
64
+ }
65
+ if (typeof width !== 'number' || !Number.isInteger(width) || width < 0) {
66
+ warn(`the breakpoint ${name ? `"${name}" ` : ''}is left out: its width must be a whole number of pixels, 0 or more.`);
67
+ continue;
68
+ }
69
+ const same = list.find(breakpoint => breakpoint.width === width);
70
+ if (same) {
71
+ warn(`"${name}" and "${same.name}" are both ${width}px. Only "${same.name}" is used.`);
72
+ continue;
73
+ }
74
+ list.push({ name, width });
75
+ }
76
+ list.sort((a, b) => a.width - b.width);
77
+ // Every screen is covered: below the smallest breakpoint is the base
78
+ if (list[0]?.width !== 0)
79
+ list.unshift({ name: '', width: 0 });
80
+ return list;
81
+ }
82
+ /** The breakpoints in use, smallest first. The first always starts at 0. */
83
+ export function getBreakpoints() {
84
+ const config = typeof window === 'undefined' ? undefined : window.$contentBlocks;
85
+ const source = config?.breakpoints ?? config?.breakpointValues ?? defaultBreakpoints;
86
+ if (cache?.source !== source)
87
+ cache = { source, list: fromSetting(source) };
88
+ return cache.list;
89
+ }
90
+ /**
91
+ * Sets the site's breakpoints, by name and the width in pixels each starts at, replacing the defaults.
92
+ * Components already on the page work their values out again.
93
+ */
94
+ export function setBreakpoints(breakpoints) {
95
+ if (typeof window === 'undefined')
96
+ return;
97
+ window.$contentBlocks = { ...window.$contentBlocks, breakpoints };
98
+ window.dispatchEvent(new CustomEvent(BREAKPOINTS_CHANGED));
99
+ }
100
+ /** Each value in a responsive value and the screen width it starts at, smallest first. */
101
+ export function parseResponsiveValue(value) {
102
+ const breakpoints = getBreakpoints();
103
+ const parts = value.split('|').map(part => part.trim());
104
+ // Positional: one value per breakpoint, a blank keeping the one before it
105
+ if (!parts.some(part => NAMED.test(part))) {
106
+ let last = parts[0];
107
+ return breakpoints.map((breakpoint, index) => {
108
+ last = parts[index] || last;
109
+ return { from: breakpoint.width, value: last };
110
+ });
111
+ }
112
+ // Named. The first value may leave out its name, as the base from 0. A later value without a name starts at
113
+ // the next breakpoint above the value before it, so 1|640=2|4 is 4 from tablet (768) up. A blank one moves on
114
+ // a breakpoint without a value of its own, as in positional values.
115
+ const found = new Map();
116
+ let previous = -1;
117
+ parts.forEach(part => {
118
+ const match = part.match(NAMED);
119
+ if (!match) {
120
+ const next = breakpoints.find(breakpoint => breakpoint.width > previous);
121
+ if (!next) {
122
+ if (part)
123
+ warn(`"${part}" in "${value}" is left out: there is no breakpoint after the value before it.`);
124
+ return;
125
+ }
126
+ if (part)
127
+ found.set(next.width, part);
128
+ previous = next.width;
129
+ return;
130
+ }
131
+ const [, name, named] = match;
132
+ if (/^\d/.test(name)) {
133
+ const width = parseInt(name, 10);
134
+ if (!breakpoints.some(breakpoint => breakpoint.width === width) && !widths.has(width)) {
135
+ widths.add(width);
136
+ widthListeners.forEach(listener => listener(width));
137
+ }
138
+ found.set(width, named.trim());
139
+ previous = width;
140
+ return;
141
+ }
142
+ const breakpoint = breakpoints.find(candidate => candidate.name === name);
143
+ if (!breakpoint) {
144
+ const names = breakpoints.map(candidate => candidate.name).filter(Boolean);
145
+ warn(`"${part}" in "${value}" is left out: there is no breakpoint called "${name}". The breakpoints are ${names.join(', ') || 'unnamed'}.`);
146
+ return;
147
+ }
148
+ // Written last wins, so a later value for the same breakpoint replaces an earlier one
149
+ found.set(breakpoint.width, named.trim());
150
+ previous = breakpoint.width;
151
+ });
152
+ return [...found.entries()].sort(([a], [b]) => a - b).map(([from, named]) => ({ from, value: named }));
153
+ }
154
+ /** A parsed value at a screen width: the value that starts at or below it, else the smallest one. */
155
+ export function valueAt(parsed, width) {
156
+ let found = parsed[0]?.value ?? '';
157
+ for (const entry of parsed) {
158
+ if (entry.from <= width)
159
+ found = entry.value;
160
+ }
161
+ return found;
162
+ }
@@ -0,0 +1,249 @@
1
+ import { getElement } from "@stencil/core";
2
+ import { BREAKPOINTS_CHANGED, getBreakpoints, getValueWidths, onValueWidth } from "./breakpoints";
3
+ import { getCurrentBreakpointIndex, getCurrentValue } from "./utils";
4
+ // The props every component gets from the base class
5
+ const baseProps = ['classes', 'padding'];
6
+ // A prop's attribute name, worked out the way Stencil does it: contentPosition is content-position.
7
+ const attributeName = (prop) => prop.replace(/([A-Z0-9])/g, letter => `-${letter}`).toLowerCase();
8
+ // Every connected responsive component, told when the page crosses a breakpoint.
9
+ const breakpointListeners = new Set();
10
+ let currentBreakpoint;
11
+ let watching = false;
12
+ let queries = [];
13
+ // The current breakpoint's name on <html data-breakpoint="tablet">, so a site's own CSS can follow the same
14
+ // breakpoints without repeating their widths. "base" below a site's smallest breakpoint, if it did not name 0.
15
+ function markDocument() {
16
+ if (typeof document === 'undefined')
17
+ return;
18
+ document.documentElement.dataset.breakpoint = getBreakpoints()[currentBreakpoint]?.name || 'base';
19
+ }
20
+ function onCrossing() {
21
+ const breakpoint = getCurrentBreakpointIndex();
22
+ if (breakpoint === currentBreakpoint)
23
+ return;
24
+ currentBreakpoint = breakpoint;
25
+ markDocument();
26
+ breakpointListeners.forEach(listener => listener());
27
+ }
28
+ // One media query per breakpoint. They only fire when a breakpoint is crossed, not on every resize.
29
+ function listen() {
30
+ queries.forEach(query => query.removeEventListener('change', onCrossing));
31
+ queries = getBreakpoints()
32
+ .filter(breakpoint => breakpoint.width)
33
+ .map(breakpoint => window.matchMedia(`(min-width: ${breakpoint.width}px)`));
34
+ queries.forEach(query => query.addEventListener('change', onCrossing));
35
+ currentBreakpoint = getCurrentBreakpointIndex();
36
+ markDocument();
37
+ }
38
+ // A width written in a value, such as 640 in 1|640=2, is not a breakpoint, so crossing it does not change
39
+ // data-breakpoint. Every component works its values out again, once, however many widths a resize crosses.
40
+ let crossingQueued = false;
41
+ function onWidthCrossing() {
42
+ if (crossingQueued)
43
+ return;
44
+ crossingQueued = true;
45
+ queueMicrotask(() => {
46
+ crossingQueued = false;
47
+ breakpointListeners.forEach(listener => listener());
48
+ });
49
+ }
50
+ function listenToWidth(width) {
51
+ window.matchMedia(`(min-width: ${width}px)`).addEventListener('change', onWidthCrossing);
52
+ }
53
+ // Set up when the first responsive component loads. When the site sets new breakpoints, listen to those
54
+ // instead, and have every component work its values out again.
55
+ function watchBreakpoints() {
56
+ if (watching || typeof window === 'undefined')
57
+ return;
58
+ watching = true;
59
+ listen();
60
+ getValueWidths().forEach(listenToWidth);
61
+ onValueWidth(listenToWidth);
62
+ window.addEventListener(BREAKPOINTS_CHANGED, () => {
63
+ listen();
64
+ breakpointListeners.forEach(listener => listener());
65
+ });
66
+ }
67
+ /**
68
+ * Base class for components whose props take a value per breakpoint, written with pipes: columns="1|2".
69
+ *
70
+ * Every component gets responsive classes and padding props from this class. A component lists any other responsive
71
+ * props once, in componentWillLoad:
72
+ *
73
+ * this.responsive({
74
+ * columns: true,
75
+ * hamburger: value => (this.bodyToggle = value === 'fixed'),
76
+ * });
77
+ *
78
+ * Each prop then holds its value for the current breakpoint, so reflected attributes and selectors such
79
+ * as [hamburger='fixed'] keep working. The value the page wrote is remembered separately. The props are
80
+ * worked out again, and the callbacks run again, whenever the breakpoint changes or the page sets a new
81
+ * value. Responsive props must be declared with mutable: true, since this class writes to them, and
82
+ * reflect: true, like every prop.
83
+ */
84
+ export class ResponsiveComponent {
85
+ /**
86
+ * Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order:
87
+ * classes="stacked|laptop=side-by-side".
88
+ * @type String
89
+ * @responsive
90
+ */
91
+ classes;
92
+ /**
93
+ * Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by
94
+ * name or in order: padding="1rem|tablet=2rem 4rem" or padding="1rem|2rem 4rem|3rem 5rem 4rem".
95
+ * @type String
96
+ * @responsive
97
+ */
98
+ padding;
99
+ responsiveConfig = {
100
+ classes: true,
101
+ padding: value => this.applyPadding(value),
102
+ };
103
+ // Whether this component has set the element's padding, so it only clears padding it set itself, never an
104
+ // inline style the page wrote.
105
+ hasPadding = false;
106
+ // The value the page gave each prop, such as "1|2", and the value last written back for it.
107
+ responsiveValues = new Map();
108
+ onBreakpointChange = () => this.applyResponsiveValues();
109
+ // The component's own members, read and written by prop name.
110
+ get members() {
111
+ return this;
112
+ }
113
+ responsive(config) {
114
+ if (Object.keys(this.responsiveConfig).length > baseProps.length) {
115
+ throw new Error('responsive() can only be called once per component. List every responsive prop in one call.');
116
+ }
117
+ Object.assign(this.responsiveConfig, config);
118
+ this.track(Object.keys(config));
119
+ }
120
+ // Remembers the value the page gave each prop, then works it out for the current breakpoint.
121
+ track(names) {
122
+ for (const name of names) {
123
+ this.responsiveValues.set(name, { given: this.members[name], written: undefined });
124
+ }
125
+ watchBreakpoints();
126
+ this.applyResponsiveValues(names);
127
+ breakpointListeners.add(this.onBreakpointChange);
128
+ }
129
+ // Works out each prop for the current breakpoint, writes it back and runs its callback.
130
+ applyResponsiveValues(names = [...this.responsiveValues.keys()]) {
131
+ for (const name of names) {
132
+ const entry = this.responsiveValues.get(name);
133
+ const value = getCurrentValue(entry.given);
134
+ // Leave a prop the page never set as it is. Writing "" would add an empty attribute to every
135
+ // reflected prop, such as classes="".
136
+ entry.written = entry.given == null ? entry.given : value;
137
+ this.members[name] = entry.written;
138
+ // Every prop is reflected, but write the attribute here as well. On first load Stencil looks up an
139
+ // attribute the page already has by its attribute name rather than the prop name, so a two word
140
+ // prop such as content-position="below|above" kept the page's value and its CSS never applied.
141
+ if (entry.written != null)
142
+ getElement(this).setAttribute(attributeName(name), entry.written);
143
+ const callback = this.responsiveConfig[name];
144
+ if (typeof callback === 'function')
145
+ callback(value);
146
+ }
147
+ }
148
+ // Stencil calls this whenever a prop changes. A value other than the one written back came from the
149
+ // page, so remember it as the prop's new value and work it out for the current breakpoint.
150
+ componentShouldUpdate(newValue, _oldValue, name) {
151
+ const entry = this.responsiveValues.get(name);
152
+ if (entry && newValue !== entry.written) {
153
+ entry.given = newValue;
154
+ this.applyResponsiveValues([name]);
155
+ }
156
+ return true;
157
+ }
158
+ // Runs before componentWillLoad, so classes is worked out before the first render. A component that is
159
+ // moved in the page is disconnected and connected again: listen again, and catch up in case the
160
+ // breakpoint changed while it was out of the page.
161
+ connectedCallback() {
162
+ if (!this.responsiveValues.has('classes')) {
163
+ this.track(baseProps);
164
+ }
165
+ else if (!breakpointListeners.has(this.onBreakpointChange)) {
166
+ breakpointListeners.add(this.onBreakpointChange);
167
+ this.applyResponsiveValues();
168
+ }
169
+ }
170
+ // Written straight to the element's style, so it works the same in every component without each one
171
+ // rendering it.
172
+ applyPadding(value) {
173
+ if (!value && !this.hasPadding)
174
+ return;
175
+ getElement(this).style.padding = value;
176
+ this.hasPadding = !!value;
177
+ }
178
+ disconnectedCallback() {
179
+ breakpointListeners.delete(this.onBreakpointChange);
180
+ }
181
+ static get properties() {
182
+ return {
183
+ "classes": {
184
+ "type": "string",
185
+ "mutable": true,
186
+ "complexType": {
187
+ "original": "ResponsiveString",
188
+ "resolved": "string",
189
+ "references": {
190
+ "ResponsiveString": {
191
+ "location": "import",
192
+ "path": "../typings",
193
+ "id": "src/typings.d.ts::ResponsiveString",
194
+ "referenceLocation": "ResponsiveString"
195
+ }
196
+ }
197
+ },
198
+ "required": false,
199
+ "optional": false,
200
+ "docs": {
201
+ "tags": [{
202
+ "name": "type",
203
+ "text": "String"
204
+ }, {
205
+ "name": "responsive",
206
+ "text": undefined
207
+ }],
208
+ "text": "Classes to add to the component. Use pipes for different classes per breakpoint, by name or in order:\nclasses=\"stacked|laptop=side-by-side\"."
209
+ },
210
+ "getter": false,
211
+ "setter": false,
212
+ "reflect": true,
213
+ "attribute": "classes"
214
+ },
215
+ "padding": {
216
+ "type": "string",
217
+ "mutable": true,
218
+ "complexType": {
219
+ "original": "ResponsiveString",
220
+ "resolved": "string",
221
+ "references": {
222
+ "ResponsiveString": {
223
+ "location": "import",
224
+ "path": "../typings",
225
+ "id": "src/typings.d.ts::ResponsiveString",
226
+ "referenceLocation": "ResponsiveString"
227
+ }
228
+ }
229
+ },
230
+ "required": false,
231
+ "optional": false,
232
+ "docs": {
233
+ "tags": [{
234
+ "name": "type",
235
+ "text": "String"
236
+ }, {
237
+ "name": "responsive",
238
+ "text": undefined
239
+ }],
240
+ "text": "Padding around the component, written as CSS padding. Use pipes for different padding per breakpoint, by\nname or in order: padding=\"1rem|tablet=2rem 4rem\" or padding=\"1rem|2rem 4rem|3rem 5rem 4rem\"."
241
+ },
242
+ "getter": false,
243
+ "setter": false,
244
+ "reflect": true,
245
+ "attribute": "padding"
246
+ }
247
+ };
248
+ }
249
+ }
@@ -1,66 +1,53 @@
1
- export const breakpoints = ['mobile', 'tablet-portrait', 'tablet-landscape', 'tablet-pro', 'desktop-large', 'desktop-wide'];
2
- export const breakpointLabels = ['Mobile', 'Tablet (Portrait)', 'Tablet (Landscape)', 'iPad Pro', 'Desktop Large', 'Desktop Wide'];
1
+ import { getBreakpoints, parseResponsiveValue, valueAt } from "./breakpoints";
2
+ export { defaultBreakpoints, getBreakpoints, getValueWidths, parseResponsiveValue, setBreakpoints, valueAt } from './breakpoints';
3
+ // The default breakpoints' names, labels and widths, smallest first
4
+ export const breakpoints = ['mobile', 'tablet', 'laptop', 'desktop', 'wide', 'ultrawide'];
5
+ export const breakpointLabels = ['Mobile', 'Tablet', 'Laptop', 'Desktop', 'Wide', 'Ultrawide'];
3
6
  export const breakpointValues = [0, 768, 1024, 1366, 1440, 1920];
7
+ /** The widths of the breakpoints in use, smallest first. */
4
8
  export function getBreakpointValues() {
5
- if (!window.$contentBlocks)
6
- window.$contentBlocks = {};
7
- if (!window.$contentBlocks.breakpointValues) {
8
- window.$contentBlocks.breakpointValues = breakpointValues;
9
- }
10
- return window.$contentBlocks.breakpointValues;
9
+ return getBreakpoints().map(breakpoint => breakpoint.width);
11
10
  }
12
- // Fills in default value if none exists for a breakpoint
11
+ /** A responsive value's value at each breakpoint in use, smallest first. Named values work too. */
13
12
  export function generateResponsiveValues(responsiveValue) {
14
13
  if (!responsiveValue) {
15
14
  return [];
16
15
  }
17
- let responseArray = [];
18
- let splitResponsiveValues = responsiveValue.split('|');
19
- let lastGoodValue = splitResponsiveValues[0];
20
- getBreakpointValues().forEach((_value, index) => {
21
- let thisBreakpointValue = splitResponsiveValues[index];
22
- if (thisBreakpointValue) {
23
- lastGoodValue = thisBreakpointValue;
24
- }
25
- responseArray.push(thisBreakpointValue ? thisBreakpointValue : lastGoodValue);
26
- });
27
- return responseArray;
16
+ const parsed = parseResponsiveValue(responsiveValue);
17
+ return getBreakpointValues().map(width => valueAt(parsed, width));
28
18
  }
19
+ /** The index of the breakpoint the screen is in. */
29
20
  export function getCurrentBreakpointIndex() {
21
+ if (typeof window === 'undefined') {
22
+ return 0;
23
+ }
30
24
  let activeBreakpointIndex = 0;
31
- let windowWidth = window.innerWidth;
32
- getBreakpointValues().some(width => {
33
- // The first time this is true will end the loop
34
- let condition = width > windowWidth;
35
- if (!condition) {
36
- activeBreakpointIndex = getBreakpointValues().indexOf(width);
25
+ getBreakpointValues().forEach((width, index) => {
26
+ if (window.innerWidth >= width) {
27
+ activeBreakpointIndex = index;
37
28
  }
38
- return condition;
39
29
  });
40
30
  return activeBreakpointIndex;
41
31
  }
32
+ /** A responsive value's value on the current screen. */
42
33
  export function getCurrentValue(responsiveValue) {
43
34
  if (!responsiveValue) {
44
35
  return '';
45
36
  }
46
- let currentBreakpoint = getCurrentBreakpointIndex();
47
- let responsiveValues = generateResponsiveValues(responsiveValue.toString());
48
- let returnValue;
49
- for (var i = currentBreakpoint; i >= 0; i--) {
50
- if (responsiveValues[i]) {
51
- returnValue = responsiveValues[i];
52
- i = -1;
53
- }
54
- }
55
- return returnValue;
37
+ const width = typeof window === 'undefined' ? 0 : window.innerWidth;
38
+ return valueAt(parseResponsiveValue(responsiveValue.toString()), width);
39
+ }
40
+ // Unitless numbers get the default unit, anything else passes through. Empty stays empty so the style is removed.
41
+ export function withDefaultUnit(value, unit) {
42
+ return value && !isNaN(Number(value)) ? `${value}${unit}` : value;
56
43
  }
57
44
  /* Below Functions are Deprecated */
58
45
  export function getValueAtIndex(index, responsiveValue) {
59
- let responsiveValues = generateResponsiveValues(responsiveValue.toString());
46
+ const responsiveValues = generateResponsiveValues(responsiveValue.toString());
60
47
  return responsiveValues[index].trim();
61
48
  }
62
49
  export function getHydratedClassString(classString) {
63
- let cleanedString = getCurrentValue(classString).trim();
50
+ const cleanedString = getCurrentValue(classString).trim();
64
51
  if (cleanedString.includes('hydrated')) {
65
52
  return cleanedString.trim();
66
53
  }
@@ -71,13 +58,15 @@ export function getHydratedClassString(classString) {
71
58
  }
72
59
  export function objectToCssString(object) {
73
60
  let string = '';
74
- for (var key in object) {
61
+ for (const key in object) {
75
62
  if (object[key].length > 0 && !['px', '%'].includes(object[key])) {
76
63
  string += `${key}: ${object[key]};`;
77
64
  }
78
65
  }
79
66
  return string;
80
67
  }
68
+ // The breakpoint names before they were renamed, kept so the class names this makes do not change
69
+ const legacyBreakpointNames = ['mobile', 'tablet-portrait', 'tablet-landscape', 'tablet-pro', 'desktop-large', 'desktop-wide'];
81
70
  export function generateResponsiveClass(classPrefix, responsiveValue) {
82
71
  let index = -1;
83
72
  let classString = '';
@@ -86,7 +75,7 @@ export function generateResponsiveClass(classPrefix, responsiveValue) {
86
75
  if (!value || value === 'false') {
87
76
  return false;
88
77
  }
89
- classString += ` ${classPrefix}-${breakpoints[index]}-${value}`;
78
+ classString += ` ${classPrefix}-${legacyBreakpointNames[index]}-${value}`;
90
79
  });
91
80
  return classString;
92
81
  }
@@ -100,4 +89,5 @@ export function insertCssIntoHead(document, fontCssUrl) {
100
89
  document.head.prepend(element);
101
90
  }
102
91
  }
103
- //# sourceMappingURL=utils.js.map
92
+ /** True when the visitor has asked their system for less motion. */
93
+ export const prefersReducedMotion = () => typeof window !== 'undefined' && !!window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;