@salesforcedevs/dx-components 0.26.1-alpha0.4 → 0.26.2

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 (533) hide show
  1. package/LICENSE +12 -0
  2. package/package.json +4 -5
  3. package/src/assets/icons/action-sprite/svg/symbols.svg +1 -0
  4. package/src/assets/icons/brand-sprite/svg/symbols.svg +1381 -0
  5. package/src/assets/icons/custom-sprite/svg/symbols.svg +1 -0
  6. package/src/assets/icons/doctype-sprite/svg/symbols.svg +1 -0
  7. package/src/assets/icons/general-sprite/svg/symbols.svg +3013 -0
  8. package/src/assets/icons/salesforcebrand-sprite/svg/symbols.svg +257 -0
  9. package/src/assets/icons/standard-sprite/svg/symbols.svg +1 -0
  10. package/src/assets/icons/utility-sprite/svg/symbols.svg +1 -0
  11. package/src/assets/svg/card-news-learn-moar.svg +415 -0
  12. package/src/assets/svg/cloud-1.svg +24 -0
  13. package/src/assets/svg/cloud-2.svg +18 -0
  14. package/src/assets/svg/codey.svg +93 -0
  15. package/src/assets/svg/command.svg +9 -0
  16. package/src/assets/svg/control.svg +10 -0
  17. package/src/assets/svg/docs-empty-state-small.svg +72 -0
  18. package/src/assets/svg/docs-empty-state.svg +86 -0
  19. package/src/assets/svg/dsc-home-news-bear.svg +3 -0
  20. package/src/assets/svg/dsc-home-news-community.png +0 -0
  21. package/src/assets/svg/dsc-home-news-goatbear.svg +257 -0
  22. package/src/assets/svg/dsc-home-news-samplegallery.svg +76 -0
  23. package/src/assets/svg/empty-state-assistant.svg +1 -0
  24. package/src/assets/svg/fch-blog-cloud-1.png +0 -0
  25. package/src/assets/svg/fch-blog-cloud-2.png +0 -0
  26. package/src/assets/svg/fch-blog-planet.png +0 -0
  27. package/src/assets/svg/feature-backdrop1.svg +10 -0
  28. package/src/assets/svg/feature-backdrop2.svg +10 -0
  29. package/src/assets/svg/featured-demo-art-blank.svg +76 -0
  30. package/src/assets/svg/featured-demo-art-eBikes.svg +77 -0
  31. package/src/assets/svg/footer-graphic-large.svg +207 -0
  32. package/src/assets/svg/footer-graphic-mountains-small.svg +17 -0
  33. package/src/assets/svg/footer-graphic-mountains.svg +21 -0
  34. package/src/assets/svg/footer-graphic-trees-small.svg +33 -0
  35. package/src/assets/svg/footer-graphic-trees.svg +62 -0
  36. package/src/assets/svg/lake-mountain.svg +79 -0
  37. package/src/assets/svg/podcast-subscription-clouds-small.svg +49 -0
  38. package/src/assets/svg/podcast-subscription-clouds.svg +57 -0
  39. package/src/assets/svg/podcasts-subscription-apple.svg +164 -0
  40. package/src/assets/svg/podcasts-subscription-google.svg +29 -0
  41. package/src/assets/svg/podcasts-subscription-spotify.svg +11 -0
  42. package/src/assets/svg/salesforce-cloud.svg +7 -0
  43. package/src/assets/svg/salesforce-logo-corporate.svg +21 -0
  44. package/src/assets/svg/salesforce-logo.svg +14 -0
  45. package/src/assets/svg/sidebar-loading.svg +34 -0
  46. package/src/assets/svg/slack-cta-podcast-background-left.svg +28 -0
  47. package/src/assets/svg/slack-cta-podcast-background-right.svg +38 -0
  48. package/src/assets/svg/trees.svg +42 -0
  49. package/src/modules/dx/banner/__tests__/banner.test.ts +33 -0
  50. package/src/modules/dx/banner/banner.css +46 -0
  51. package/src/modules/dx/banner/banner.html +13 -0
  52. package/src/modules/dx/banner/banner.ts +14 -0
  53. package/src/modules/dx/brandThemeProvider/__tests__/brandThemeProvider.test.ts +49 -0
  54. package/src/modules/dx/brandThemeProvider/brandCssVars.ts +10 -0
  55. package/src/modules/dx/brandThemeProvider/brandThemeProvider.html +3 -0
  56. package/src/modules/dx/brandThemeProvider/brandThemeProvider.stories.ts +321 -0
  57. package/src/modules/dx/brandThemeProvider/brandThemeProvider.ts +46 -0
  58. package/src/modules/dx/breadcrumbs/__tests__/breadcrumbs.test.ts +140 -0
  59. package/src/modules/dx/breadcrumbs/__tests__/mockProps.ts +28 -0
  60. package/src/modules/dx/breadcrumbs/breadcrumbs.css +111 -0
  61. package/src/modules/dx/breadcrumbs/breadcrumbs.html +44 -0
  62. package/src/modules/dx/breadcrumbs/breadcrumbs.stories.ts +39 -0
  63. package/src/modules/dx/breadcrumbs/breadcrumbs.ts +122 -0
  64. package/src/modules/dx/button/__tests__/button.test.ts +107 -0
  65. package/src/modules/dx/button/button.css +175 -0
  66. package/src/modules/dx/button/button.html +43 -0
  67. package/src/modules/dx/button/button.stories.ts +150 -0
  68. package/src/modules/dx/button/button.ts +63 -0
  69. package/src/modules/dx/cardBlogPost/__tests__/cardBlogPost.test.ts +26 -0
  70. package/src/modules/dx/cardBlogPost/__tests__/mockProps.ts +12 -0
  71. package/src/modules/dx/cardBlogPost/cardBlogPost.css +13 -0
  72. package/src/modules/dx/cardBlogPost/cardBlogPost.html +24 -0
  73. package/src/modules/dx/cardBlogPost/cardBlogPost.stories.ts +164 -0
  74. package/src/modules/dx/cardBlogPost/cardBlogPost.ts +23 -0
  75. package/src/modules/dx/cardBlogPostProvider/__tests__/cardBlogPostProvider.test.ts +34 -0
  76. package/src/modules/dx/cardBlogPostProvider/__tests__/mockWordpressPosts.ts +44 -0
  77. package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.css +3 -0
  78. package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.html +16 -0
  79. package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.ts +29 -0
  80. package/src/modules/dx/cardCallout/__tests__/cardCallout.test.ts +20 -0
  81. package/src/modules/dx/cardCallout/__tests__/mockProps.ts +7 -0
  82. package/src/modules/dx/cardCallout/cardCallout.css +57 -0
  83. package/src/modules/dx/cardCallout/cardCallout.html +15 -0
  84. package/src/modules/dx/cardCallout/cardCallout.stories.ts +33 -0
  85. package/src/modules/dx/cardCallout/cardCallout.ts +37 -0
  86. package/src/modules/dx/cardContent/__tests__/cardContent.test.ts +100 -0
  87. package/src/modules/dx/cardContent/__tests__/mockProps.ts +13 -0
  88. package/src/modules/dx/cardContent/cardContent.css +52 -0
  89. package/src/modules/dx/cardContent/cardContent.html +59 -0
  90. package/src/modules/dx/cardContent/cardContent.stories.ts +127 -0
  91. package/src/modules/dx/cardContent/cardContent.ts +68 -0
  92. package/src/modules/dx/cardDemo/cardDemo.css +1 -0
  93. package/src/modules/dx/cardDemo/cardDemo.html +12 -0
  94. package/src/modules/dx/cardDemo/cardDemo.stories.ts +115 -0
  95. package/src/modules/dx/cardDemo/cardDemo.ts +11 -0
  96. package/src/modules/dx/cardDocs/__tests__/cardDocs.test.ts +48 -0
  97. package/src/modules/dx/cardDocs/__tests__/mockProps.ts +9 -0
  98. package/src/modules/dx/cardDocs/cardDocs.css +50 -0
  99. package/src/modules/dx/cardDocs/cardDocs.html +20 -0
  100. package/src/modules/dx/cardDocs/cardDocs.stories.ts +299 -0
  101. package/src/modules/dx/cardDocs/cardDocs.ts +30 -0
  102. package/src/modules/dx/cardEvent/__tests__/cardEvent.test.ts +95 -0
  103. package/src/modules/dx/cardEvent/__tests__/mockProps.ts +10 -0
  104. package/src/modules/dx/cardEvent/cardEvent.css +107 -0
  105. package/src/modules/dx/cardEvent/cardEvent.html +94 -0
  106. package/src/modules/dx/cardEvent/cardEvent.stories.ts +153 -0
  107. package/src/modules/dx/cardEvent/cardEvent.ts +42 -0
  108. package/src/modules/dx/cardExpanded/__tests__/cardExpanded.test.ts +193 -0
  109. package/src/modules/dx/cardExpanded/__tests__/mockProps.ts +21 -0
  110. package/src/modules/dx/cardExpanded/cardExpanded.css +49 -0
  111. package/src/modules/dx/cardExpanded/cardExpanded.html +37 -0
  112. package/src/modules/dx/cardExpanded/cardExpanded.stories.ts +59 -0
  113. package/src/modules/dx/cardExpanded/cardExpanded.ts +45 -0
  114. package/src/modules/dx/cardGrid/__tests__/cardMockProps.ts +431 -0
  115. package/src/modules/dx/cardGrid/__tests__/mockProps.ts +15 -0
  116. package/src/modules/dx/cardGrid/cardGrid.css +89 -0
  117. package/src/modules/dx/cardGrid/cardGrid.html +46 -0
  118. package/src/modules/dx/cardGrid/cardGrid.stories.ts +111 -0
  119. package/src/modules/dx/cardGrid/cardGrid.ts +140 -0
  120. package/src/modules/dx/cardMinimal/__tests__/cardMinimal.test.ts +87 -0
  121. package/src/modules/dx/cardMinimal/__tests__/mockProps.ts +10 -0
  122. package/src/modules/dx/cardMinimal/cardMinimal.css +31 -0
  123. package/src/modules/dx/cardMinimal/cardMinimal.html +13 -0
  124. package/src/modules/dx/cardMinimal/cardMinimal.stories.ts +32 -0
  125. package/src/modules/dx/cardMinimal/cardMinimal.ts +3 -0
  126. package/src/modules/dx/cardNews/__tests__/cardNews.test.ts +58 -0
  127. package/src/modules/dx/cardNews/__tests__/mockProps.ts +7 -0
  128. package/src/modules/dx/cardNews/cardNews.css +159 -0
  129. package/src/modules/dx/cardNews/cardNews.html +37 -0
  130. package/src/modules/dx/cardNews/cardNews.stories.ts +115 -0
  131. package/src/modules/dx/cardNews/cardNews.ts +62 -0
  132. package/src/modules/dx/cardPodcastEpisode/__tests__/cardPodcastEpisode.test.ts +68 -0
  133. package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.css +19 -0
  134. package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.html +36 -0
  135. package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.stories.ts +31 -0
  136. package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.ts +36 -0
  137. package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/cardPodcastEpisodeProvider.test.ts +36 -0
  138. package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/mockWordpressEpisodes.ts +50 -0
  139. package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +3 -0
  140. package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +12 -0
  141. package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.ts +29 -0
  142. package/src/modules/dx/cardSmall/__tests__/cardSmall.test.ts +66 -0
  143. package/src/modules/dx/cardSmall/__tests__/mockProps.ts +8 -0
  144. package/src/modules/dx/cardSmall/cardSmall.css +32 -0
  145. package/src/modules/dx/cardSmall/cardSmall.html +42 -0
  146. package/src/modules/dx/cardSmall/cardSmall.stories.ts +166 -0
  147. package/src/modules/dx/cardSmall/cardSmall.ts +38 -0
  148. package/src/modules/dx/cardTitle/__tests__/cardTitle.test.ts +46 -0
  149. package/src/modules/dx/cardTitle/cardTitle.css +41 -0
  150. package/src/modules/dx/cardTitle/cardTitle.html +20 -0
  151. package/src/modules/dx/cardTitle/cardTitle.ts +27 -0
  152. package/src/modules/dx/cardTrailheadModule/__tests__/cardTrailheadModule.test.ts +18 -0
  153. package/src/modules/dx/cardTrailheadModule/__tests__/mockProps.ts +11 -0
  154. package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.css +24 -0
  155. package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.html +20 -0
  156. package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.stories.ts +122 -0
  157. package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.ts +18 -0
  158. package/src/modules/dx/cardVideoPreview/__tests__/cardVideoPreview.test.ts +22 -0
  159. package/src/modules/dx/cardVideoPreview/__tests__/mockProps.ts +11 -0
  160. package/src/modules/dx/cardVideoPreview/cardVideoPreview.css +14 -0
  161. package/src/modules/dx/cardVideoPreview/cardVideoPreview.html +26 -0
  162. package/src/modules/dx/cardVideoPreview/cardVideoPreview.stories.ts +147 -0
  163. package/src/modules/dx/cardVideoPreview/cardVideoPreview.ts +13 -0
  164. package/src/modules/dx/checkbox/__tests__/checkbox.test.ts +85 -0
  165. package/src/modules/dx/checkbox/__tests__/mockProps.ts +5 -0
  166. package/src/modules/dx/checkbox/checkbox.css +168 -0
  167. package/src/modules/dx/checkbox/checkbox.html +26 -0
  168. package/src/modules/dx/checkbox/checkbox.stories.ts +38 -0
  169. package/src/modules/dx/checkbox/checkbox.ts +55 -0
  170. package/src/modules/dx/checkboxGroup/__tests__/checkboxGroup.test.ts +80 -0
  171. package/src/modules/dx/checkboxGroup/__tests__/mockProps.ts +14 -0
  172. package/src/modules/dx/checkboxGroup/checkboxGroup.css +12 -0
  173. package/src/modules/dx/checkboxGroup/checkboxGroup.html +15 -0
  174. package/src/modules/dx/checkboxGroup/checkboxGroup.stories.ts +33 -0
  175. package/src/modules/dx/checkboxGroup/checkboxGroup.ts +77 -0
  176. package/src/modules/dx/codeBlock/__tests__/codeBlock.test.ts +238 -0
  177. package/src/modules/dx/codeBlock/__tests__/mockProps.ts +160 -0
  178. package/src/modules/dx/codeBlock/codeBlock.css +128 -0
  179. package/src/modules/dx/codeBlock/codeBlock.html +79 -0
  180. package/src/modules/dx/codeBlock/codeBlock.stories.ts +143 -0
  181. package/src/modules/dx/codeBlock/codeBlock.ts +215 -0
  182. package/src/modules/dx/codeBlock/darkTheme.css +88 -0
  183. package/src/modules/dx/codeBlock/lightTheme.css +72 -0
  184. package/src/modules/dx/dropdown/__tests__/dropdown.test.ts +165 -0
  185. package/src/modules/dx/dropdown/__tests__/mockNestedOptions.ts +96 -0
  186. package/src/modules/dx/dropdown/__tests__/mockOptions.ts +10 -0
  187. package/src/modules/dx/dropdown/__tests__/mockProps.ts +6 -0
  188. package/src/modules/dx/dropdown/dropdown.css +93 -0
  189. package/src/modules/dx/dropdown/dropdown.html +67 -0
  190. package/src/modules/dx/dropdown/dropdown.stories.ts +89 -0
  191. package/src/modules/dx/dropdown/dropdown.ts +182 -0
  192. package/src/modules/dx/dropdownOption/__tests__/dropdownOption.test.ts +112 -0
  193. package/src/modules/dx/dropdownOption/__tests__/mockProps.ts +20 -0
  194. package/src/modules/dx/dropdownOption/dropdownOption.css +61 -0
  195. package/src/modules/dx/dropdownOption/dropdownOption.html +53 -0
  196. package/src/modules/dx/dropdownOption/dropdownOption.ts +39 -0
  197. package/src/modules/dx/emptyState/__tests__/emptyState.test.ts +52 -0
  198. package/src/modules/dx/emptyState/__tests__/mockProps.ts +4 -0
  199. package/src/modules/dx/emptyState/emptyState.css +64 -0
  200. package/src/modules/dx/emptyState/emptyState.html +9 -0
  201. package/src/modules/dx/emptyState/emptyState.stories.ts +45 -0
  202. package/src/modules/dx/emptyState/emptyState.ts +20 -0
  203. package/src/modules/dx/feature/__tests__/feature.test.ts +51 -0
  204. package/src/modules/dx/feature/__tests__/mockProps.ts +8 -0
  205. package/src/modules/dx/feature/feature.css +135 -0
  206. package/src/modules/dx/feature/feature.html +33 -0
  207. package/src/modules/dx/feature/feature.ts +34 -0
  208. package/src/modules/dx/featureGrid/__tests__/featureGrid.test.ts +21 -0
  209. package/src/modules/dx/featureGrid/featureGrid.html +3 -0
  210. package/src/modules/dx/featureGrid/featureGrid.stories.ts +120 -0
  211. package/src/modules/dx/featureGrid/featureGrid.ts +15 -0
  212. package/src/modules/dx/featuredContentHeader/__tests__/featuredContentHeader.test.ts +178 -0
  213. package/src/modules/dx/featuredContentHeader/__tests__/mockProps.ts +73 -0
  214. package/src/modules/dx/featuredContentHeader/featuredContentHeader.css +469 -0
  215. package/src/modules/dx/featuredContentHeader/featuredContentHeader.html +96 -0
  216. package/src/modules/dx/featuredContentHeader/featuredContentHeader.stories.ts +153 -0
  217. package/src/modules/dx/featuredContentHeader/featuredContentHeader.ts +113 -0
  218. package/src/modules/dx/featuredContentHeader/svgs.ts +35 -0
  219. package/src/modules/dx/featuresList/__tests__/featuresList.test.ts +43 -0
  220. package/src/modules/dx/featuresList/__tests__/mockProps.ts +17 -0
  221. package/src/modules/dx/featuresList/featuresList.css +24 -0
  222. package/src/modules/dx/featuresList/featuresList.html +20 -0
  223. package/src/modules/dx/featuresList/featuresList.stories.ts +30 -0
  224. package/src/modules/dx/featuresList/featuresList.ts +21 -0
  225. package/src/modules/dx/footer/__tests__/footer.test.ts +147 -0
  226. package/src/modules/dx/footer/__tests__/mockLocales.ts +7 -0
  227. package/src/modules/dx/footer/footer.css +405 -0
  228. package/src/modules/dx/footer/footer.html +145 -0
  229. package/src/modules/dx/footer/footer.stories.ts +88 -0
  230. package/src/modules/dx/footer/footer.ts +124 -0
  231. package/src/modules/dx/footer/links.ts +140 -0
  232. package/src/modules/dx/footerOption/__tests__/footerOption.test.ts +34 -0
  233. package/src/modules/dx/footerOption/__tests__/mockProps.ts +7 -0
  234. package/src/modules/dx/footerOption/footerOption.css +4 -0
  235. package/src/modules/dx/footerOption/footerOption.html +12 -0
  236. package/src/modules/dx/footerOption/footerOption.ts +19 -0
  237. package/src/modules/dx/formattedDateTime/__tests__/formattedDateTime.test.ts +25 -0
  238. package/src/modules/dx/formattedDateTime/__tests__/mockProps.ts +13 -0
  239. package/src/modules/dx/formattedDateTime/formattedDateTime.html +1 -0
  240. package/src/modules/dx/formattedDateTime/formattedDateTime.stories.ts +103 -0
  241. package/src/modules/dx/formattedDateTime/formattedDateTime.ts +72 -0
  242. package/src/modules/dx/grid/__tests__/grid.test.ts +32 -0
  243. package/src/modules/dx/grid/grid.css +48 -0
  244. package/src/modules/dx/grid/grid.html +3 -0
  245. package/src/modules/dx/grid/grid.md +14 -0
  246. package/src/modules/dx/grid/grid.stories.ts +134 -0
  247. package/src/modules/dx/grid/grid.ts +72 -0
  248. package/src/modules/dx/groupBio/__tests__/groupBio.test.ts +82 -0
  249. package/src/modules/dx/groupBio/__tests__/mockProps.ts +15 -0
  250. package/src/modules/dx/groupBio/groupBio.css +49 -0
  251. package/src/modules/dx/groupBio/groupBio.html +29 -0
  252. package/src/modules/dx/groupBio/groupBio.stories.ts +66 -0
  253. package/src/modules/dx/groupBio/groupBio.ts +41 -0
  254. package/src/modules/dx/groupText/__tests__/groupText.test.ts +69 -0
  255. package/src/modules/dx/groupText/__tests__/mockProps.ts +35 -0
  256. package/src/modules/dx/groupText/groupText.css +119 -0
  257. package/src/modules/dx/groupText/groupText.html +65 -0
  258. package/src/modules/dx/groupText/groupText.stories.ts +81 -0
  259. package/src/modules/dx/groupText/groupText.ts +93 -0
  260. package/src/modules/dx/headTags/headTags.html +3 -0
  261. package/src/modules/dx/headTags/headTags.ts +39 -0
  262. package/src/modules/dx/header/__benchmarks__/header.benchmark.js +45 -0
  263. package/src/modules/dx/header/__tests__/header.test.ts +236 -0
  264. package/src/modules/dx/header/__tests__/mockNavArchitects.ts +169 -0
  265. package/src/modules/dx/header/__tests__/mockNavDevelopers.ts +419 -0
  266. package/src/modules/dx/header/__tests__/mockNavs.ts +115 -0
  267. package/src/modules/dx/header/__tests__/mockProps.ts +164 -0
  268. package/src/modules/dx/header/header.css +109 -0
  269. package/src/modules/dx/header/header.html +129 -0
  270. package/src/modules/dx/header/header.stories.ts +172 -0
  271. package/src/modules/dx/header/header.ts +27 -0
  272. package/src/modules/dx/headerMobileNavMenu/__tests__/headerMobileNavMenu.test.ts +123 -0
  273. package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.css +160 -0
  274. package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.html +73 -0
  275. package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.ts +102 -0
  276. package/src/modules/dx/headerMobileNavMenuOption/__tests__/headerMobileNavMenuOption.test.ts +38 -0
  277. package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.css +5 -0
  278. package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.html +14 -0
  279. package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.ts +20 -0
  280. package/src/modules/dx/headerNav/__tests__/headerNav.test.ts +49 -0
  281. package/src/modules/dx/headerNav/headerNav.css +31 -0
  282. package/src/modules/dx/headerNav/headerNav.html +48 -0
  283. package/src/modules/dx/headerNav/headerNav.ts +56 -0
  284. package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +182 -0
  285. package/src/modules/dx/headerSearch/__tests__/mockData.ts +11 -0
  286. package/src/modules/dx/headerSearch/__tests__/mockProps.ts +6 -0
  287. package/src/modules/dx/headerSearch/headerSearch.css +62 -0
  288. package/src/modules/dx/headerSearch/headerSearch.html +64 -0
  289. package/src/modules/dx/headerSearch/headerSearch.ts +159 -0
  290. package/src/modules/dx/helmet/__tests__/helmet.test.ts +52 -0
  291. package/src/modules/dx/helmet/helmet.css +83 -0
  292. package/src/modules/dx/helmet/helmet.html +39 -0
  293. package/src/modules/dx/helmet/helmet.stories.ts +53 -0
  294. package/src/modules/dx/helmet/helmet.ts +27 -0
  295. package/src/modules/dx/hr/__tests__/hr.test.ts +53 -0
  296. package/src/modules/dx/hr/__tests__/mockProps.ts +16 -0
  297. package/src/modules/dx/hr/hr.css +55 -0
  298. package/src/modules/dx/hr/hr.html +23 -0
  299. package/src/modules/dx/hr/hr.stories.ts +50 -0
  300. package/src/modules/dx/hr/hr.ts +45 -0
  301. package/src/modules/dx/icon/__tests__/icon.test.ts +54 -0
  302. package/src/modules/dx/icon/icon.css +14 -0
  303. package/src/modules/dx/icon/icon.html +11 -0
  304. package/src/modules/dx/icon/icon.stories.ts +100 -0
  305. package/src/modules/dx/icon/icon.ts +85 -0
  306. package/src/modules/dx/iconBadge/__tests__/iconBadge.test.ts +17 -0
  307. package/src/modules/dx/iconBadge/iconBadge.css +40 -0
  308. package/src/modules/dx/iconBadge/iconBadge.html +10 -0
  309. package/src/modules/dx/iconBadge/iconBadge.stories.ts +32 -0
  310. package/src/modules/dx/iconBadge/iconBadge.ts +42 -0
  311. package/src/modules/dx/imageAndLabel/__tests__/imageAndLabel.test.ts +39 -0
  312. package/src/modules/dx/imageAndLabel/__tests__/mockProps.ts +6 -0
  313. package/src/modules/dx/imageAndLabel/imageAndLabel.css +54 -0
  314. package/src/modules/dx/imageAndLabel/imageAndLabel.html +22 -0
  315. package/src/modules/dx/imageAndLabel/imageAndLabel.stories.ts +48 -0
  316. package/src/modules/dx/imageAndLabel/imageAndLabel.ts +16 -0
  317. package/src/modules/dx/input/__tests__/input.test.ts +357 -0
  318. package/src/modules/dx/input/input.css +165 -0
  319. package/src/modules/dx/input/input.html +58 -0
  320. package/src/modules/dx/input/input.stories.ts +102 -0
  321. package/src/modules/dx/input/input.ts +238 -0
  322. package/src/modules/dx/input/validators.ts +5 -0
  323. package/src/modules/dx/instrumentation/__tests__/instrumentation.test.ts +86 -0
  324. package/src/modules/dx/instrumentation/instrumentation.html +1 -0
  325. package/src/modules/dx/instrumentation/instrumentation.ts +116 -0
  326. package/src/modules/dx/interactiveImage/__tests__/interactiveImage.test.ts +83 -0
  327. package/src/modules/dx/interactiveImage/__tests__/mockProps.ts +39 -0
  328. package/src/modules/dx/interactiveImage/interactiveImage.css +59 -0
  329. package/src/modules/dx/interactiveImage/interactiveImage.html +32 -0
  330. package/src/modules/dx/interactiveImage/interactiveImage.stories.ts +31 -0
  331. package/src/modules/dx/interactiveImage/interactiveImage.ts +71 -0
  332. package/src/modules/dx/lazy/__tests__/lazy.test.ts +43 -0
  333. package/src/modules/dx/lazy/lazy.html +5 -0
  334. package/src/modules/dx/lazy/lazy.stories.ts +132 -0
  335. package/src/modules/dx/lazy/lazy.ts +163 -0
  336. package/src/modules/dx/logo/logo.css +33 -0
  337. package/src/modules/dx/logo/logo.html +6 -0
  338. package/src/modules/dx/logo/logo.ts +8 -0
  339. package/src/modules/dx/newsletterForm/newsletterForm.css +73 -0
  340. package/src/modules/dx/newsletterForm/newsletterForm.html +73 -0
  341. package/src/modules/dx/newsletterForm/newsletterForm.ts +238 -0
  342. package/src/modules/dx/pagination/__tests__/pagination.test.ts +121 -0
  343. package/src/modules/dx/pagination/pagination.css +51 -0
  344. package/src/modules/dx/pagination/pagination.html +45 -0
  345. package/src/modules/dx/pagination/pagination.stories.ts +88 -0
  346. package/src/modules/dx/pagination/pagination.ts +93 -0
  347. package/src/modules/dx/podcastHost/__tests__/mockProps.ts +8 -0
  348. package/src/modules/dx/podcastHost/__tests__/podcastHost.test.ts +21 -0
  349. package/src/modules/dx/podcastHost/podcastHost.css +62 -0
  350. package/src/modules/dx/podcastHost/podcastHost.html +28 -0
  351. package/src/modules/dx/podcastHost/podcastHost.stories.ts +17 -0
  352. package/src/modules/dx/podcastHost/podcastHost.ts +13 -0
  353. package/src/modules/dx/podcastPlayer/__tests__/podcastPlayer.test.ts +20 -0
  354. package/src/modules/dx/podcastPlayer/podcastPlayer.css +10 -0
  355. package/src/modules/dx/podcastPlayer/podcastPlayer.html +3 -0
  356. package/src/modules/dx/podcastPlayer/podcastPlayer.stories.ts +13 -0
  357. package/src/modules/dx/podcastPlayer/podcastPlayer.ts +5 -0
  358. package/src/modules/dx/podcastSubscription/__tests__/podcastSubscription.test.ts +16 -0
  359. package/src/modules/dx/podcastSubscription/podcastSubscription.css +91 -0
  360. package/src/modules/dx/podcastSubscription/podcastSubscription.html +24 -0
  361. package/src/modules/dx/podcastSubscription/podcastSubscription.stories.ts +23 -0
  362. package/src/modules/dx/podcastSubscription/podcastSubscription.ts +58 -0
  363. package/src/modules/dx/popover/__tests__/mockProps.ts +8 -0
  364. package/src/modules/dx/popover/__tests__/popover.test.ts +313 -0
  365. package/src/modules/dx/popover/popover.css +63 -0
  366. package/src/modules/dx/popover/popover.html +16 -0
  367. package/src/modules/dx/popover/popover.stories.ts +82 -0
  368. package/src/modules/dx/popover/popover.ts +313 -0
  369. package/src/modules/dx/radioGroup/__tests__/mockProps.ts +12 -0
  370. package/src/modules/dx/radioGroup/__tests__/radioGroup.test.ts +42 -0
  371. package/src/modules/dx/radioGroup/radioGroup.css +12 -0
  372. package/src/modules/dx/radioGroup/radioGroup.html +16 -0
  373. package/src/modules/dx/radioGroup/radioGroup.stories.ts +25 -0
  374. package/src/modules/dx/radioGroup/radioGroup.ts +65 -0
  375. package/src/modules/dx/relativeDateTime/__tests__/mockProps.ts +55 -0
  376. package/src/modules/dx/relativeDateTime/__tests__/relativeDateTime.test.ts +52 -0
  377. package/src/modules/dx/relativeDateTime/relativeDateTime.html +3 -0
  378. package/src/modules/dx/relativeDateTime/relativeDateTime.stories.ts +83 -0
  379. package/src/modules/dx/relativeDateTime/relativeDateTime.ts +113 -0
  380. package/src/modules/dx/searchResults/coveo.css +18989 -0
  381. package/src/modules/dx/searchResults/searchResults.css +387 -0
  382. package/src/modules/dx/searchResults/searchResults.html +104 -0
  383. package/src/modules/dx/searchResults/searchResults.stories.ts +36 -0
  384. package/src/modules/dx/searchResults/searchResults.ts +186 -0
  385. package/src/modules/dx/section/__tests__/section.test.ts +17 -0
  386. package/src/modules/dx/section/section.css +130 -0
  387. package/src/modules/dx/section/section.html +66 -0
  388. package/src/modules/dx/section/section.stories.ts +381 -0
  389. package/src/modules/dx/section/section.ts +41 -0
  390. package/src/modules/dx/sectionSignup/__tests__/sectionSignup.test.ts +66 -0
  391. package/src/modules/dx/sectionSignup/sectionSignup.css +43 -0
  392. package/src/modules/dx/sectionSignup/sectionSignup.html +23 -0
  393. package/src/modules/dx/sectionSignup/sectionSignup.stories.ts +49 -0
  394. package/src/modules/dx/sectionSignup/sectionSignup.ts +44 -0
  395. package/src/modules/dx/select/select.css +44 -0
  396. package/src/modules/dx/select/select.html +60 -0
  397. package/src/modules/dx/select/select.stories.ts +59 -0
  398. package/src/modules/dx/select/select.ts +23 -0
  399. package/src/modules/dx/sidebar/__tests__/mockProps.ts +181 -0
  400. package/src/modules/dx/sidebar/__tests__/mockSearchChangeEmptyEvent.ts +6 -0
  401. package/src/modules/dx/sidebar/__tests__/mockSearchChangeEvent.ts +527 -0
  402. package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +568 -0
  403. package/src/modules/dx/sidebar/sidebar.css +192 -0
  404. package/src/modules/dx/sidebar/sidebar.html +94 -0
  405. package/src/modules/dx/sidebar/sidebar.stories.ts +188 -0
  406. package/src/modules/dx/sidebar/sidebar.ts +255 -0
  407. package/src/modules/dx/sidebarOld/__tests__/mockProps.ts +178 -0
  408. package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +570 -0
  409. package/src/modules/dx/sidebarOld/sidebarOld.css +160 -0
  410. package/src/modules/dx/sidebarOld/sidebarOld.html +70 -0
  411. package/src/modules/dx/sidebarOld/sidebarOld.stories.ts +139 -0
  412. package/src/modules/dx/sidebarOld/sidebarOld.ts +187 -0
  413. package/src/modules/dx/sidebarSearch/__tests__/mockPreloadedState.ts +1686 -0
  414. package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +175 -0
  415. package/src/modules/dx/sidebarSearch/sidebarSearch.css +3 -0
  416. package/src/modules/dx/sidebarSearch/sidebarSearch.html +26 -0
  417. package/src/modules/dx/sidebarSearch/sidebarSearch.ts +440 -0
  418. package/src/modules/dx/sidebarSearchResult/__tests__/sidebarSearchResult.test.ts +96 -0
  419. package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.css +36 -0
  420. package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.html +14 -0
  421. package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.ts +70 -0
  422. package/src/modules/dx/skipNavLink/skipNavLink.css +21 -0
  423. package/src/modules/dx/skipNavLink/skipNavLink.html +3 -0
  424. package/src/modules/dx/skipNavLink/skipNavLink.ts +3 -0
  425. package/src/modules/dx/slackCta/__tests__/slackCta.test.ts +36 -0
  426. package/src/modules/dx/slackCta/slackCta.css +47 -0
  427. package/src/modules/dx/slackCta/slackCta.html +17 -0
  428. package/src/modules/dx/slackCta/slackCta.stories.ts +25 -0
  429. package/src/modules/dx/slackCta/slackCta.ts +12 -0
  430. package/src/modules/dx/socials/__tests__/socials.test.ts +114 -0
  431. package/src/modules/dx/socials/socials.css +35 -0
  432. package/src/modules/dx/socials/socials.html +22 -0
  433. package/src/modules/dx/socials/socials.stories.ts +24 -0
  434. package/src/modules/dx/socials/socials.ts +81 -0
  435. package/src/modules/dx/spinner/__tests__/spinner.test.ts +37 -0
  436. package/src/modules/dx/spinner/spinner.css +750 -0
  437. package/src/modules/dx/spinner/spinner.html +6 -0
  438. package/src/modules/dx/spinner/spinner.stories.ts +69 -0
  439. package/src/modules/dx/spinner/spinner.ts +20 -0
  440. package/src/modules/dx/tab/__tests__/tab.test.ts +129 -0
  441. package/src/modules/dx/tab/tab.css +106 -0
  442. package/src/modules/dx/tab/tab.html +13 -0
  443. package/src/modules/dx/tab/tab.stories.ts +57 -0
  444. package/src/modules/dx/tab/tab.ts +52 -0
  445. package/src/modules/dx/toc/__tests__/mockProps.ts +28 -0
  446. package/src/modules/dx/toc/__tests__/toc.test.ts +109 -0
  447. package/src/modules/dx/toc/toc.css +94 -0
  448. package/src/modules/dx/toc/toc.html +28 -0
  449. package/src/modules/dx/toc/toc.stories.ts +26 -0
  450. package/src/modules/dx/toc/toc.ts +77 -0
  451. package/src/modules/dx/tooltip/__tests__/tooltip.test.ts +22 -0
  452. package/src/modules/dx/tooltip/microtip.css +269 -0
  453. package/src/modules/dx/tooltip/tooltip.css +36 -0
  454. package/src/modules/dx/tooltip/tooltip.html +5 -0
  455. package/src/modules/dx/tooltip/tooltip.stories.ts +46 -0
  456. package/src/modules/dx/tooltip/tooltip.ts +6 -0
  457. package/src/modules/dx/topics/__tests__/mockProps.ts +3 -0
  458. package/src/modules/dx/topics/__tests__/topics.test.ts +31 -0
  459. package/src/modules/dx/topics/topics.css +25 -0
  460. package/src/modules/dx/topics/topics.html +12 -0
  461. package/src/modules/dx/topics/topics.ts +25 -0
  462. package/src/modules/dx/tree/__tests__/mockProps.ts +215 -0
  463. package/src/modules/dx/tree/__tests__/tree.test.ts +346 -0
  464. package/src/modules/dx/tree/__tests__/treeHandler.test.ts +194 -0
  465. package/src/modules/dx/tree/tree.css +5 -0
  466. package/src/modules/dx/tree/tree.html +11 -0
  467. package/src/modules/dx/tree/tree.stories.ts +65 -0
  468. package/src/modules/dx/tree/tree.ts +72 -0
  469. package/src/modules/dx/tree/treeHandler.ts +100 -0
  470. package/src/modules/dx/treeItem/__tests__/mockProps.ts +46 -0
  471. package/src/modules/dx/treeItem/__tests__/treeItem.test.ts +377 -0
  472. package/src/modules/dx/treeItem/treeItem.css +14 -0
  473. package/src/modules/dx/treeItem/treeItem.html +22 -0
  474. package/src/modules/dx/treeItem/treeItem.ts +110 -0
  475. package/src/modules/dx/treeTile/__tests__/mockProps.ts +16 -0
  476. package/src/modules/dx/treeTile/__tests__/treeTile.test.ts +168 -0
  477. package/src/modules/dx/treeTile/treeTile.css +190 -0
  478. package/src/modules/dx/treeTile/treeTile.html +27 -0
  479. package/src/modules/dx/treeTile/treeTile.ts +59 -0
  480. package/src/modules/dx/typeBadge/__tests__/typeBadge.test.ts +77 -0
  481. package/src/modules/dx/typeBadge/typeBadge.css +74 -0
  482. package/src/modules/dx/typeBadge/typeBadge.html +5 -0
  483. package/src/modules/dx/typeBadge/typeBadge.stories.ts +114 -0
  484. package/src/modules/dx/typeBadge/typeBadge.ts +65 -0
  485. package/src/modules/dx/typeBadgeGroup/__tests__/mockProps.ts +11 -0
  486. package/src/modules/dx/typeBadgeGroup/__tests__/typeBadgeGroup.test.ts +72 -0
  487. package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.css +12 -0
  488. package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.html +11 -0
  489. package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.stories.ts +19 -0
  490. package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.ts +18 -0
  491. package/src/modules/helpers/animations/animations.css +15 -0
  492. package/src/modules/helpers/button/button.css +4 -0
  493. package/src/modules/helpers/card/card.css +258 -0
  494. package/src/modules/helpers/code/code.css +296 -0
  495. package/src/modules/helpers/commonHeader/commonHeader.css +130 -0
  496. package/src/modules/helpers/reset/reset.css +559 -0
  497. package/src/modules/helpers/sidebar/sidebar.css +21 -0
  498. package/src/modules/helpers/slds/slds.css +191 -0
  499. package/src/modules/helpers/table/table.css +110 -0
  500. package/src/modules/helpers/text/text.css +163 -0
  501. package/src/modules/test-components/buttonTest/buttonTest.html +3 -0
  502. package/src/modules/test-components/buttonTest/buttonTest.ts +3 -0
  503. package/src/modules/test-components/codeBlockTest/codeBlockTest.js +4 -0
  504. package/src/modules/test-components/featureGridTest/featureGridTest.html +7 -0
  505. package/src/modules/test-components/featureGridTest/featureGridTest.ts +5 -0
  506. package/src/modules/test-components/instrumentationTest/instrumentationTest.html +4 -0
  507. package/src/modules/test-components/instrumentationTest/instrumentationTest.ts +8 -0
  508. package/src/modules/test-components/popoverTest/popoverTest.html +6 -0
  509. package/src/modules/test-components/popoverTest/popoverTest.ts +5 -0
  510. package/src/modules/test-components/slackCtaTest/slackCtaTest.html +3 -0
  511. package/src/modules/test-components/slackCtaTest/slackCtaTest.ts +3 -0
  512. package/src/modules/utils/highlight/__tests__/highlight.test.ts +108 -0
  513. package/src/modules/utils/highlight/__tests__/mockProps.ts +45 -0
  514. package/src/modules/utils/highlight/highlight.ts +32 -0
  515. package/src/modules/utils/normalizers/normalizers.ts +91 -0
  516. package/src/modules/utils-internal/archiveCard/archiveCard.ts +35 -0
  517. package/src/modules/utils-internal/coveo/coveo.ts +70 -0
  518. package/src/modules/utils-internal/css/css.ts +43 -0
  519. package/src/modules/utils-internal/devices/devices.ts +1 -0
  520. package/src/modules/utils-internal/headerBase/headerBase.ts +204 -0
  521. package/src/modules/utils-internal/jest/jest.ts +58 -0
  522. package/src/modules/utils-internal/options/options.ts +39 -0
  523. package/src/modules/utils-internal/prismjs/prismjs.html +3 -0
  524. package/src/modules/utils-internal/prismjs/prismjs.ts +3321 -0
  525. package/src/modules/utils-internal/recentSearches/__tests__/recentSearches.test.ts +83 -0
  526. package/src/modules/utils-internal/recentSearches/recentSearches.ts +57 -0
  527. package/src/modules/utils-internal/regexps/regexps.ts +5 -0
  528. package/src/modules/utils-internal/seo/seo.ts +4 -0
  529. package/src/modules/utils-internal/slot/slot.ts +17 -0
  530. package/src/modules/utils-internal/storybook/storybook.ts +32 -0
  531. package/src/modules/utils-internal/tests/tests.ts +38 -0
  532. package/src/modules/utils-internal/wordpress/__tests__/wordpress.test.ts +15 -0
  533. package/src/modules/utils-internal/wordpress/wordpress.ts +13 -0
@@ -0,0 +1,175 @@
1
+ import { createElement } from "lwc";
2
+ import SidebarSearch from "dx/sidebarSearch";
3
+ import {
4
+ createRenderComponent,
5
+ renderLightningElement
6
+ } from "utils-internal/tests";
7
+ import { coveoXMLDocsConfig } from "utils-internal/coveo";
8
+ import { mockQueryParameter, unmockQueryParameter } from "utils-internal/jest";
9
+ import { SESSION_KEY } from "dx/sidebarSearch";
10
+ import mockPreloadedState from "./mockPreloadedState";
11
+
12
+ const TAG = "dx-sidebar-search";
13
+ const render = createRenderComponent(TAG, SidebarSearch);
14
+
15
+ const PROPS = coveoXMLDocsConfig;
16
+ const QUERY = "test";
17
+
18
+ describe(TAG, () => {
19
+ beforeEach(() => {
20
+ window.sessionStorage.clear();
21
+ jest.restoreAllMocks();
22
+ });
23
+ afterEach(unmockQueryParameter);
24
+
25
+ it("correctly sets coveo advanced configuration", () => {
26
+ const element = render(PROPS);
27
+
28
+ element.coveoAdvancedQueryConfig = JSON.stringify(
29
+ coveoXMLDocsConfig.coveoAdvancedQueryConfig
30
+ );
31
+
32
+ expect(element.coveoAdvancedQueryConfig).toEqual(
33
+ coveoXMLDocsConfig.coveoAdvancedQueryConfig
34
+ );
35
+
36
+ return expect(element).toBeAccessible();
37
+ });
38
+
39
+ it("calls dispatchOnChangeEvent with empty query", () => {
40
+ const element = render(PROPS);
41
+
42
+ const mockOnChange = jest.fn();
43
+
44
+ element.addEventListener("change", mockOnChange);
45
+
46
+ element.setInputValue("reference");
47
+ element.setInputValue("");
48
+
49
+ expect(mockOnChange).toHaveBeenCalled();
50
+ return expect(element).toBeAccessible();
51
+ });
52
+
53
+ it("renders with the correct initial empty query", () => {
54
+ const element = render(PROPS);
55
+
56
+ const input = element.shadowRoot.querySelector("dx-input");
57
+
58
+ expect(input.value).toEqual("");
59
+
60
+ return expect(element).toBeAccessible();
61
+ });
62
+
63
+ it("renders with the correct initial query", () => {
64
+ mockQueryParameter(QUERY);
65
+
66
+ const element = render(PROPS);
67
+
68
+ const input = element.shadowRoot.querySelector("dx-input");
69
+
70
+ expect(input.value).toEqual(QUERY);
71
+
72
+ return expect(element).toBeAccessible();
73
+ });
74
+
75
+ describe("highlighting", () => {
76
+ afterEach(unmockQueryParameter);
77
+
78
+ it("triggers on initial render when a search value exists", () => {
79
+ mockQueryParameter(QUERY);
80
+ const element = createElement(TAG, { is: SidebarSearch });
81
+ const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
82
+ renderLightningElement(element, PROPS);
83
+ expect(dispatchEventSpy).toHaveBeenCalledWith(
84
+ expect.objectContaining({
85
+ type: "highlightedtermchange",
86
+ detail: QUERY
87
+ })
88
+ );
89
+ });
90
+
91
+ it("does not trigger on initial render when a search value does not exist", () => {
92
+ const element = createElement(TAG, { is: SidebarSearch });
93
+ const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
94
+ renderLightningElement(element, PROPS);
95
+ expect(dispatchEventSpy).not.toHaveBeenCalledWith(
96
+ expect.objectContaining({ type: "highlightedtermchange" })
97
+ );
98
+ });
99
+
100
+ it("triggers on input change with non-empty value", () => {
101
+ const element = render(PROPS);
102
+ const dxInput = element.shadowRoot.querySelector("dx-input");
103
+ const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
104
+
105
+ dxInput.dispatchEvent(new CustomEvent("change", { detail: QUERY }));
106
+
107
+ expect(dispatchEventSpy).toHaveBeenCalledWith(
108
+ expect.objectContaining({
109
+ type: "highlightedtermchange",
110
+ detail: QUERY
111
+ })
112
+ );
113
+ });
114
+
115
+ it("triggers on input change with empty value", () => {
116
+ const element = render(PROPS);
117
+ const dxInput = element.shadowRoot.querySelector("dx-input");
118
+ const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
119
+
120
+ dxInput.dispatchEvent(new CustomEvent("change", { detail: "" }));
121
+
122
+ expect(dispatchEventSpy).toHaveBeenCalledWith(
123
+ expect.objectContaining({
124
+ type: "highlightedtermchange",
125
+ detail: ""
126
+ })
127
+ );
128
+ });
129
+ });
130
+
131
+ it("correctly consumes a valid session storage object", () => {
132
+ mockQueryParameter(mockPreloadedState.state.query.q);
133
+
134
+ window.sessionStorage.setItem(
135
+ SESSION_KEY,
136
+ JSON.stringify(mockPreloadedState)
137
+ );
138
+
139
+ const element = render(PROPS);
140
+
141
+ expect(window.sessionStorage.getItem(SESSION_KEY)).not.toBeNull();
142
+
143
+ expect(element).toBeAccessible();
144
+ });
145
+
146
+ it("ignores and deletes a session storage object if query and config don't match", () => {
147
+ mockQueryParameter("test");
148
+
149
+ window.sessionStorage.setItem(
150
+ SESSION_KEY,
151
+ JSON.stringify(mockPreloadedState)
152
+ );
153
+
154
+ const element = render(PROPS);
155
+
156
+ expect(window.sessionStorage.getItem(SESSION_KEY)).toBeNull();
157
+
158
+ expect(element).toBeAccessible();
159
+ });
160
+
161
+ it("ignores and deletes a session storage object on incorrect config", () => {
162
+ mockQueryParameter(mockPreloadedState.state.query.q);
163
+
164
+ window.sessionStorage.setItem(
165
+ SESSION_KEY,
166
+ JSON.stringify({ state: { query: { q: "test" } } })
167
+ );
168
+
169
+ const element = render(PROPS);
170
+
171
+ expect(window.sessionStorage.getItem(SESSION_KEY)).toBeNull();
172
+
173
+ expect(element).toBeAccessible();
174
+ });
175
+ });
@@ -0,0 +1,3 @@
1
+ .search-box {
2
+ --dx-c-input-width: 100%;
3
+ }
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <dx-dropdown
3
+ aria-label="Recent Searches"
4
+ open={isDropdownOpen}
5
+ options={recentSearches}
6
+ onchange={onClickRecentSearch}
7
+ onrequestclose={onDropdownRequestClose}
8
+ full-width
9
+ >
10
+ <dx-input
11
+ class="search-box"
12
+ type="search"
13
+ placeholder="Search"
14
+ role="search"
15
+ aria-label="Search in this guide"
16
+ icon-symbol="search"
17
+ size="small"
18
+ value={value}
19
+ onchange={onInputChange}
20
+ onfocus={onInputFocus}
21
+ onclear={onInputClear}
22
+ shortcut-key="j"
23
+ clearable
24
+ ></dx-input>
25
+ </dx-dropdown>
26
+ </template>
@@ -0,0 +1,440 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import debounce from "debounce";
3
+ import {
4
+ Result,
5
+ ResultList,
6
+ Unsubscribe,
7
+ ResultsPerPage,
8
+ SearchBox,
9
+ buildResultList,
10
+ buildResultsPerPage,
11
+ buildSearchBox,
12
+ loadAdvancedSearchQueryActions,
13
+ SearchEngine,
14
+ SearchAppState,
15
+ loadQueryActions
16
+ } from "@coveo/headless";
17
+ import {
18
+ buildSearchEngine,
19
+ getSidebarSearchParams
20
+ } from "utils-internal/coveo";
21
+ import { RecentSearches } from "utils-internal/recentSearches";
22
+ import { toJson } from "utils/normalizers";
23
+ import {
24
+ Option,
25
+ PopoverRequestCloseType,
26
+ SidebarSearchResult
27
+ } from "typings/custom";
28
+
29
+ export const SESSION_KEY = "dx-sidebar-search-state";
30
+
31
+ const DEFAULT_RESULT_COUNT = 20;
32
+ const SEARCH_DEBOUNCE_DELAY = 780;
33
+
34
+ const UserRecentSearches = new RecentSearches();
35
+
36
+ const normalizeCoveoAdvancedQueryValue = (version: string): string =>
37
+ version.split(".").join("\\.");
38
+
39
+ export default class SidebarSearch extends LightningElement {
40
+ @api coveoOrganizationId!: string;
41
+ @api coveoPublicAccessToken!: string;
42
+ @api coveoSearchHub!: string;
43
+ @api
44
+ get coveoAdvancedQueryConfig(): { [key: string]: any } {
45
+ return this._coveoAdvancedQueryConfig;
46
+ }
47
+ set coveoAdvancedQueryConfig(value) {
48
+ const jsonValue = toJson(value);
49
+ const hasChanged =
50
+ this._coveoAdvancedQueryConfig &&
51
+ Object.entries(jsonValue).some(
52
+ ([key, val]: [string, any]) =>
53
+ this._coveoAdvancedQueryConfig[key] !== val
54
+ );
55
+ this._coveoAdvancedQueryConfig = jsonValue;
56
+
57
+ if (hasChanged && this.engine && this.value !== "") {
58
+ this.dispatchOnLoading(true);
59
+ }
60
+
61
+ if (hasChanged && this.engine) {
62
+ // set advanced filters needs access to the latest coveoAdvancedQueryConfig
63
+ this.setAdvancedFilters(this.engine);
64
+ this.submitSearch(true);
65
+ }
66
+ }
67
+
68
+ @api
69
+ public fetchMoreResults() {
70
+ if (this.resultList?.state?.moreResultsAvailable) {
71
+ this.fetchingMoreResults = true;
72
+ this.resultList.fetchMoreResults();
73
+ }
74
+ }
75
+
76
+ @api
77
+ setInputValue(searchTerm: string) {
78
+ if (searchTerm !== this.value) {
79
+ this.value = searchTerm || "";
80
+ this.handleValueChange(true);
81
+ }
82
+ }
83
+
84
+ private _coveoAdvancedQueryConfig!: { [key: string]: any };
85
+ private dropdownRequestedOpen: boolean = false;
86
+ private recentSearches: Option[] = [];
87
+ private unsubscribeFromResultList: Unsubscribe = () => {};
88
+ private resultList: ResultList | null = null;
89
+ private resultsPerPage: ResultsPerPage | null = null;
90
+ private preloadedState?: SearchAppState;
91
+ private searchBox: SearchBox | null = null;
92
+ private value?: string = "";
93
+ private engine: SearchEngine | null = null;
94
+ private fetchingMoreResults: boolean = false;
95
+ private didRender = false;
96
+
97
+ private get hasCorrectCoveoConfig(): boolean {
98
+ const coveoConfigurations = [
99
+ this.coveoOrganizationId,
100
+ this.coveoPublicAccessToken,
101
+ this.coveoSearchHub,
102
+ this.coveoAdvancedQueryConfig
103
+ ];
104
+
105
+ return coveoConfigurations.every(
106
+ (val) =>
107
+ !!val && (typeof val === "string" || typeof val === "object")
108
+ );
109
+ }
110
+
111
+ private get isDropdownOpen() {
112
+ return (
113
+ this.dropdownRequestedOpen &&
114
+ this.recentSearches &&
115
+ this.recentSearches.length > 0 &&
116
+ !this.value
117
+ );
118
+ }
119
+
120
+ constructor() {
121
+ super();
122
+
123
+ this.updateRecentSearches();
124
+ this.value = getSidebarSearchParams() || "";
125
+ }
126
+
127
+ disconnectedCallback() {
128
+ this.unsubscribeFromResultList();
129
+ }
130
+
131
+ renderedCallback() {
132
+ // in prod some of the critical coveo configuration attributes seem to arrive later
133
+ // so I needed to put this coveo startup flow here where we can wait for them to arrive
134
+
135
+ if (this.hasCorrectCoveoConfig && !this.engine) {
136
+ this.initializeUserSession();
137
+ this.initializeCoveo();
138
+ } else if (!this.hasCorrectCoveoConfig) {
139
+ console.error(
140
+ "Incorrect coveo search configuration provided. All coveo configuration attributes must be defined.",
141
+ {
142
+ coveoOrganizationId: this.coveoOrganizationId,
143
+ coveoPublicAccessToken: this.coveoPublicAccessToken,
144
+ coveoSearchHub: this.coveoSearchHub,
145
+ coveoAdvancedQueryConfig: this.coveoAdvancedQueryConfig
146
+ }
147
+ );
148
+ }
149
+
150
+ // If this is the first render and there is a search value, trigger
151
+ // term highlighting
152
+ if (!this.didRender && this.value) {
153
+ this.dispatchHighlightedTermChange();
154
+ }
155
+
156
+ this.didRender = true;
157
+ }
158
+
159
+ private initializeUserSession() {
160
+ const stringified = window.sessionStorage.getItem(SESSION_KEY);
161
+
162
+ if (!stringified) {
163
+ return;
164
+ }
165
+
166
+ try {
167
+ const json = JSON.parse(stringified);
168
+
169
+ const hasSameConfig = Object.entries(
170
+ json.coveoAdvancedQueryConfig
171
+ ).every(
172
+ ([key, value]: [string, any]) =>
173
+ this.coveoAdvancedQueryConfig[key] === value
174
+ );
175
+ const hasSameQuery = json?.state?.query?.q === this.value;
176
+
177
+ if (hasSameConfig && hasSameQuery) {
178
+ this.preloadedState = json?.state;
179
+ } else {
180
+ window.sessionStorage.removeItem(SESSION_KEY);
181
+ }
182
+ } catch (e) {
183
+ console.error(e);
184
+ window.sessionStorage.removeItem(SESSION_KEY);
185
+ }
186
+ }
187
+
188
+ private initializeCoveo = () => {
189
+ try {
190
+ this.engine = buildSearchEngine({
191
+ organizationId: this.coveoOrganizationId,
192
+ publicAccessToken: this.coveoPublicAccessToken,
193
+ searchHub: this.coveoSearchHub,
194
+ preloadedState: this.preloadedState
195
+ });
196
+ } catch (ex) {
197
+ console.error(`Coveo engine failed to initialize (${ex})`);
198
+ }
199
+
200
+ if (!this.engine) {
201
+ console.error("Coveo engine failed to initialize!");
202
+ return;
203
+ }
204
+
205
+ if (this.preloadedState) {
206
+ const actions = loadQueryActions(this.engine);
207
+ this.engine.dispatch(actions.updateQuery({ q: this.value || "" }));
208
+ }
209
+
210
+ this.resultList = buildResultList(this.engine, {
211
+ options: { fieldsToInclude: ["sfhtml_url__c"] }
212
+ });
213
+
214
+ this.resultsPerPage = buildResultsPerPage(this.engine, {
215
+ initialState: {
216
+ numberOfResults: DEFAULT_RESULT_COUNT
217
+ }
218
+ });
219
+
220
+ this.searchBox = buildSearchBox(this.engine, {
221
+ options: { numberOfSuggestions: 3 }
222
+ });
223
+
224
+ this.setAdvancedFilters(this.engine);
225
+
226
+ this.unsubscribeFromResultList = this.resultList?.subscribe(
227
+ this.onResultListChange
228
+ );
229
+
230
+ if (this.value) {
231
+ this.dispatchHighlightedTermChange();
232
+ }
233
+
234
+ if (!this.preloadedState) {
235
+ if (this.value) {
236
+ this.submitSearch();
237
+ } else {
238
+ this.dispatchOnLoading(false);
239
+ }
240
+ }
241
+ };
242
+
243
+ private onResultListChange = () => {
244
+ if (!this.resultList) {
245
+ return;
246
+ }
247
+
248
+ const { isLoading, firstSearchExecuted, results } =
249
+ this.resultList.state;
250
+
251
+ if ((!firstSearchExecuted && !isLoading) || !this.value) {
252
+ // coveo search is firing off some unwanted payloads on startup
253
+ return;
254
+ }
255
+
256
+ if (!isLoading) {
257
+ this.dispatchOnChangeEvent(results);
258
+ }
259
+
260
+ if (!this.fetchingMoreResults) {
261
+ this.dispatchOnLoading(isLoading);
262
+ }
263
+
264
+ if (!isLoading && this.fetchingMoreResults) {
265
+ this.fetchingMoreResults = false;
266
+ }
267
+ };
268
+
269
+ private setAdvancedFilters(engine: SearchEngine) {
270
+ const aq = Object.entries(this.coveoAdvancedQueryConfig).reduce(
271
+ (result, [key, value]) =>
272
+ `${result}(@${key}=="${normalizeCoveoAdvancedQueryValue(
273
+ value
274
+ )}")`,
275
+ ""
276
+ );
277
+
278
+ const registerSearchQueryAction = loadAdvancedSearchQueryActions(
279
+ engine
280
+ ).registerAdvancedSearchQueries({
281
+ aq: aq
282
+ });
283
+
284
+ engine.dispatch(registerSearchQueryAction);
285
+ }
286
+
287
+ private normalizeCoveoResult = ({
288
+ clickUri,
289
+ excerpt,
290
+ excerptHighlights,
291
+ raw: { sfhtml_url__c },
292
+ title,
293
+ titleHighlights,
294
+ uniqueId
295
+ }: Result): SidebarSearchResult => {
296
+ // discussion about this normalization here: https://salesforce-internal.slack.com/archives/C020S6784JX/p1639506238376600
297
+
298
+ let pathname;
299
+ if (sfhtml_url__c) {
300
+ pathname = `/docs/${sfhtml_url__c}`;
301
+ } else {
302
+ const isNestedGuide = clickUri.includes("/guide/");
303
+ const url = new URL(clickUri);
304
+ const extension =
305
+ isNestedGuide && !url.pathname?.endsWith(".html")
306
+ ? ".html"
307
+ : "";
308
+ pathname = `${url.pathname}${extension}`;
309
+ }
310
+
311
+ const href = `${pathname}?q=${this.value}`;
312
+
313
+ return {
314
+ title,
315
+ titleHighlights,
316
+ excerpt,
317
+ excerptHighlights,
318
+ uniqueId,
319
+ href,
320
+ selected: pathname === window.location.pathname
321
+ };
322
+ };
323
+
324
+ private updateSessionStorage() {
325
+ window.sessionStorage.setItem(
326
+ SESSION_KEY,
327
+ JSON.stringify({
328
+ coveoAdvancedQueryConfig: this.coveoAdvancedQueryConfig,
329
+ state: this.engine?.state
330
+ })
331
+ );
332
+ }
333
+
334
+ private dispatchOnChangeEvent(results: Result[]) {
335
+ this.updateSessionStorage();
336
+ this.dispatchEvent(
337
+ new CustomEvent("change", {
338
+ detail: {
339
+ results: results.map(this.normalizeCoveoResult),
340
+ value: this.value
341
+ }
342
+ })
343
+ );
344
+ }
345
+
346
+ private dispatchOnLoading(loading: boolean) {
347
+ this.dispatchEvent(new CustomEvent("loading", { detail: loading }));
348
+ }
349
+
350
+ private dispatchHighlightedTermChange() {
351
+ this.dispatchEvent(
352
+ new CustomEvent("highlightedtermchange", {
353
+ detail: this.value,
354
+ composed: true,
355
+ bubbles: true
356
+ })
357
+ );
358
+ }
359
+
360
+ private updateRecentSearches = () =>
361
+ (this.recentSearches = UserRecentSearches.get().map((item: string) => ({
362
+ id: item,
363
+ label: item
364
+ })));
365
+
366
+ private dispatchSidebarSearchChange(searchTerm: string | undefined): void {
367
+ this.dispatchEvent(
368
+ new CustomEvent("sidebarsearchchange", {
369
+ detail: searchTerm ?? "",
370
+ bubbles: true,
371
+ composed: true
372
+ })
373
+ );
374
+ }
375
+
376
+ private submitSearch = debounce((isSyncingSearchValue = false) => {
377
+ if (this.searchBox) {
378
+ UserRecentSearches.add(this.value);
379
+ this.updateRecentSearches();
380
+
381
+ // When `isSyncingSearchValue` is true, we are submitting in a case
382
+ // where the search box is already synced correctly.
383
+ if (!isSyncingSearchValue) {
384
+ this.dispatchSidebarSearchChange(this.value);
385
+ }
386
+
387
+ this.searchBox.updateText(this.value || "");
388
+ this.searchBox.submit();
389
+ }
390
+ }, SEARCH_DEBOUNCE_DELAY);
391
+
392
+ private onClickRecentSearch(e: CustomEvent) {
393
+ this.value = e.detail;
394
+ this.dispatchSidebarSearchChange(this.value);
395
+ this.submitSearch(true);
396
+ }
397
+
398
+ private onDropdownRequestClose(e: CustomEvent) {
399
+ switch (e.detail as PopoverRequestCloseType) {
400
+ case "interact-outside":
401
+ case "keypress-escape":
402
+ this.dropdownRequestedOpen = false;
403
+ break;
404
+ default:
405
+ break;
406
+ }
407
+ }
408
+
409
+ private onInputChange(e: CustomEvent) {
410
+ this.value = e.detail;
411
+
412
+ this.handleValueChange(false);
413
+ this.dispatchHighlightedTermChange();
414
+ }
415
+
416
+ private onInputFocus() {
417
+ this.dropdownRequestedOpen = true;
418
+ }
419
+
420
+ private onInputClear() {
421
+ this.dropdownRequestedOpen = false;
422
+ }
423
+
424
+ private handleValueChange(isSyncingSearchValue = false) {
425
+ if (this.value) {
426
+ this.dispatchOnLoading(true);
427
+ if (this.searchBox) {
428
+ this.submitSearch(isSyncingSearchValue);
429
+ }
430
+ } else {
431
+ // coveo's reaction to an empty value triggers a return of results
432
+ // bootlegging our own ux here`
433
+ this.dispatchOnLoading(false);
434
+ this.dispatchOnChangeEvent([]);
435
+ // Empty search values are not submitted for search, so we need to manually
436
+ // trigger a search change on our own here
437
+ this.dispatchSidebarSearchChange(this.value);
438
+ }
439
+ }
440
+ }