@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.
- package/LICENSE +12 -0
- package/package.json +4 -5
- package/src/assets/icons/action-sprite/svg/symbols.svg +1 -0
- package/src/assets/icons/brand-sprite/svg/symbols.svg +1381 -0
- package/src/assets/icons/custom-sprite/svg/symbols.svg +1 -0
- package/src/assets/icons/doctype-sprite/svg/symbols.svg +1 -0
- package/src/assets/icons/general-sprite/svg/symbols.svg +3013 -0
- package/src/assets/icons/salesforcebrand-sprite/svg/symbols.svg +257 -0
- package/src/assets/icons/standard-sprite/svg/symbols.svg +1 -0
- package/src/assets/icons/utility-sprite/svg/symbols.svg +1 -0
- package/src/assets/svg/card-news-learn-moar.svg +415 -0
- package/src/assets/svg/cloud-1.svg +24 -0
- package/src/assets/svg/cloud-2.svg +18 -0
- package/src/assets/svg/codey.svg +93 -0
- package/src/assets/svg/command.svg +9 -0
- package/src/assets/svg/control.svg +10 -0
- package/src/assets/svg/docs-empty-state-small.svg +72 -0
- package/src/assets/svg/docs-empty-state.svg +86 -0
- package/src/assets/svg/dsc-home-news-bear.svg +3 -0
- package/src/assets/svg/dsc-home-news-community.png +0 -0
- package/src/assets/svg/dsc-home-news-goatbear.svg +257 -0
- package/src/assets/svg/dsc-home-news-samplegallery.svg +76 -0
- package/src/assets/svg/empty-state-assistant.svg +1 -0
- package/src/assets/svg/fch-blog-cloud-1.png +0 -0
- package/src/assets/svg/fch-blog-cloud-2.png +0 -0
- package/src/assets/svg/fch-blog-planet.png +0 -0
- package/src/assets/svg/feature-backdrop1.svg +10 -0
- package/src/assets/svg/feature-backdrop2.svg +10 -0
- package/src/assets/svg/featured-demo-art-blank.svg +76 -0
- package/src/assets/svg/featured-demo-art-eBikes.svg +77 -0
- package/src/assets/svg/footer-graphic-large.svg +207 -0
- package/src/assets/svg/footer-graphic-mountains-small.svg +17 -0
- package/src/assets/svg/footer-graphic-mountains.svg +21 -0
- package/src/assets/svg/footer-graphic-trees-small.svg +33 -0
- package/src/assets/svg/footer-graphic-trees.svg +62 -0
- package/src/assets/svg/lake-mountain.svg +79 -0
- package/src/assets/svg/podcast-subscription-clouds-small.svg +49 -0
- package/src/assets/svg/podcast-subscription-clouds.svg +57 -0
- package/src/assets/svg/podcasts-subscription-apple.svg +164 -0
- package/src/assets/svg/podcasts-subscription-google.svg +29 -0
- package/src/assets/svg/podcasts-subscription-spotify.svg +11 -0
- package/src/assets/svg/salesforce-cloud.svg +7 -0
- package/src/assets/svg/salesforce-logo-corporate.svg +21 -0
- package/src/assets/svg/salesforce-logo.svg +14 -0
- package/src/assets/svg/sidebar-loading.svg +34 -0
- package/src/assets/svg/slack-cta-podcast-background-left.svg +28 -0
- package/src/assets/svg/slack-cta-podcast-background-right.svg +38 -0
- package/src/assets/svg/trees.svg +42 -0
- package/src/modules/dx/banner/__tests__/banner.test.ts +33 -0
- package/src/modules/dx/banner/banner.css +46 -0
- package/src/modules/dx/banner/banner.html +13 -0
- package/src/modules/dx/banner/banner.ts +14 -0
- package/src/modules/dx/brandThemeProvider/__tests__/brandThemeProvider.test.ts +49 -0
- package/src/modules/dx/brandThemeProvider/brandCssVars.ts +10 -0
- package/src/modules/dx/brandThemeProvider/brandThemeProvider.html +3 -0
- package/src/modules/dx/brandThemeProvider/brandThemeProvider.stories.ts +321 -0
- package/src/modules/dx/brandThemeProvider/brandThemeProvider.ts +46 -0
- package/src/modules/dx/breadcrumbs/__tests__/breadcrumbs.test.ts +140 -0
- package/src/modules/dx/breadcrumbs/__tests__/mockProps.ts +28 -0
- package/src/modules/dx/breadcrumbs/breadcrumbs.css +111 -0
- package/src/modules/dx/breadcrumbs/breadcrumbs.html +44 -0
- package/src/modules/dx/breadcrumbs/breadcrumbs.stories.ts +39 -0
- package/src/modules/dx/breadcrumbs/breadcrumbs.ts +122 -0
- package/src/modules/dx/button/__tests__/button.test.ts +107 -0
- package/src/modules/dx/button/button.css +175 -0
- package/src/modules/dx/button/button.html +43 -0
- package/src/modules/dx/button/button.stories.ts +150 -0
- package/src/modules/dx/button/button.ts +63 -0
- package/src/modules/dx/cardBlogPost/__tests__/cardBlogPost.test.ts +26 -0
- package/src/modules/dx/cardBlogPost/__tests__/mockProps.ts +12 -0
- package/src/modules/dx/cardBlogPost/cardBlogPost.css +13 -0
- package/src/modules/dx/cardBlogPost/cardBlogPost.html +24 -0
- package/src/modules/dx/cardBlogPost/cardBlogPost.stories.ts +164 -0
- package/src/modules/dx/cardBlogPost/cardBlogPost.ts +23 -0
- package/src/modules/dx/cardBlogPostProvider/__tests__/cardBlogPostProvider.test.ts +34 -0
- package/src/modules/dx/cardBlogPostProvider/__tests__/mockWordpressPosts.ts +44 -0
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.css +3 -0
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.html +16 -0
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.ts +29 -0
- package/src/modules/dx/cardCallout/__tests__/cardCallout.test.ts +20 -0
- package/src/modules/dx/cardCallout/__tests__/mockProps.ts +7 -0
- package/src/modules/dx/cardCallout/cardCallout.css +57 -0
- package/src/modules/dx/cardCallout/cardCallout.html +15 -0
- package/src/modules/dx/cardCallout/cardCallout.stories.ts +33 -0
- package/src/modules/dx/cardCallout/cardCallout.ts +37 -0
- package/src/modules/dx/cardContent/__tests__/cardContent.test.ts +100 -0
- package/src/modules/dx/cardContent/__tests__/mockProps.ts +13 -0
- package/src/modules/dx/cardContent/cardContent.css +52 -0
- package/src/modules/dx/cardContent/cardContent.html +59 -0
- package/src/modules/dx/cardContent/cardContent.stories.ts +127 -0
- package/src/modules/dx/cardContent/cardContent.ts +68 -0
- package/src/modules/dx/cardDemo/cardDemo.css +1 -0
- package/src/modules/dx/cardDemo/cardDemo.html +12 -0
- package/src/modules/dx/cardDemo/cardDemo.stories.ts +115 -0
- package/src/modules/dx/cardDemo/cardDemo.ts +11 -0
- package/src/modules/dx/cardDocs/__tests__/cardDocs.test.ts +48 -0
- package/src/modules/dx/cardDocs/__tests__/mockProps.ts +9 -0
- package/src/modules/dx/cardDocs/cardDocs.css +50 -0
- package/src/modules/dx/cardDocs/cardDocs.html +20 -0
- package/src/modules/dx/cardDocs/cardDocs.stories.ts +299 -0
- package/src/modules/dx/cardDocs/cardDocs.ts +30 -0
- package/src/modules/dx/cardEvent/__tests__/cardEvent.test.ts +95 -0
- package/src/modules/dx/cardEvent/__tests__/mockProps.ts +10 -0
- package/src/modules/dx/cardEvent/cardEvent.css +107 -0
- package/src/modules/dx/cardEvent/cardEvent.html +94 -0
- package/src/modules/dx/cardEvent/cardEvent.stories.ts +153 -0
- package/src/modules/dx/cardEvent/cardEvent.ts +42 -0
- package/src/modules/dx/cardExpanded/__tests__/cardExpanded.test.ts +193 -0
- package/src/modules/dx/cardExpanded/__tests__/mockProps.ts +21 -0
- package/src/modules/dx/cardExpanded/cardExpanded.css +49 -0
- package/src/modules/dx/cardExpanded/cardExpanded.html +37 -0
- package/src/modules/dx/cardExpanded/cardExpanded.stories.ts +59 -0
- package/src/modules/dx/cardExpanded/cardExpanded.ts +45 -0
- package/src/modules/dx/cardGrid/__tests__/cardMockProps.ts +431 -0
- package/src/modules/dx/cardGrid/__tests__/mockProps.ts +15 -0
- package/src/modules/dx/cardGrid/cardGrid.css +89 -0
- package/src/modules/dx/cardGrid/cardGrid.html +46 -0
- package/src/modules/dx/cardGrid/cardGrid.stories.ts +111 -0
- package/src/modules/dx/cardGrid/cardGrid.ts +140 -0
- package/src/modules/dx/cardMinimal/__tests__/cardMinimal.test.ts +87 -0
- package/src/modules/dx/cardMinimal/__tests__/mockProps.ts +10 -0
- package/src/modules/dx/cardMinimal/cardMinimal.css +31 -0
- package/src/modules/dx/cardMinimal/cardMinimal.html +13 -0
- package/src/modules/dx/cardMinimal/cardMinimal.stories.ts +32 -0
- package/src/modules/dx/cardMinimal/cardMinimal.ts +3 -0
- package/src/modules/dx/cardNews/__tests__/cardNews.test.ts +58 -0
- package/src/modules/dx/cardNews/__tests__/mockProps.ts +7 -0
- package/src/modules/dx/cardNews/cardNews.css +159 -0
- package/src/modules/dx/cardNews/cardNews.html +37 -0
- package/src/modules/dx/cardNews/cardNews.stories.ts +115 -0
- package/src/modules/dx/cardNews/cardNews.ts +62 -0
- package/src/modules/dx/cardPodcastEpisode/__tests__/cardPodcastEpisode.test.ts +68 -0
- package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.css +19 -0
- package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.html +36 -0
- package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.stories.ts +31 -0
- package/src/modules/dx/cardPodcastEpisode/cardPodcastEpisode.ts +36 -0
- package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/cardPodcastEpisodeProvider.test.ts +36 -0
- package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/mockWordpressEpisodes.ts +50 -0
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +3 -0
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +12 -0
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.ts +29 -0
- package/src/modules/dx/cardSmall/__tests__/cardSmall.test.ts +66 -0
- package/src/modules/dx/cardSmall/__tests__/mockProps.ts +8 -0
- package/src/modules/dx/cardSmall/cardSmall.css +32 -0
- package/src/modules/dx/cardSmall/cardSmall.html +42 -0
- package/src/modules/dx/cardSmall/cardSmall.stories.ts +166 -0
- package/src/modules/dx/cardSmall/cardSmall.ts +38 -0
- package/src/modules/dx/cardTitle/__tests__/cardTitle.test.ts +46 -0
- package/src/modules/dx/cardTitle/cardTitle.css +41 -0
- package/src/modules/dx/cardTitle/cardTitle.html +20 -0
- package/src/modules/dx/cardTitle/cardTitle.ts +27 -0
- package/src/modules/dx/cardTrailheadModule/__tests__/cardTrailheadModule.test.ts +18 -0
- package/src/modules/dx/cardTrailheadModule/__tests__/mockProps.ts +11 -0
- package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.css +24 -0
- package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.html +20 -0
- package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.stories.ts +122 -0
- package/src/modules/dx/cardTrailheadModule/cardTrailheadModule.ts +18 -0
- package/src/modules/dx/cardVideoPreview/__tests__/cardVideoPreview.test.ts +22 -0
- package/src/modules/dx/cardVideoPreview/__tests__/mockProps.ts +11 -0
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.css +14 -0
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.html +26 -0
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.stories.ts +147 -0
- package/src/modules/dx/cardVideoPreview/cardVideoPreview.ts +13 -0
- package/src/modules/dx/checkbox/__tests__/checkbox.test.ts +85 -0
- package/src/modules/dx/checkbox/__tests__/mockProps.ts +5 -0
- package/src/modules/dx/checkbox/checkbox.css +168 -0
- package/src/modules/dx/checkbox/checkbox.html +26 -0
- package/src/modules/dx/checkbox/checkbox.stories.ts +38 -0
- package/src/modules/dx/checkbox/checkbox.ts +55 -0
- package/src/modules/dx/checkboxGroup/__tests__/checkboxGroup.test.ts +80 -0
- package/src/modules/dx/checkboxGroup/__tests__/mockProps.ts +14 -0
- package/src/modules/dx/checkboxGroup/checkboxGroup.css +12 -0
- package/src/modules/dx/checkboxGroup/checkboxGroup.html +15 -0
- package/src/modules/dx/checkboxGroup/checkboxGroup.stories.ts +33 -0
- package/src/modules/dx/checkboxGroup/checkboxGroup.ts +77 -0
- package/src/modules/dx/codeBlock/__tests__/codeBlock.test.ts +238 -0
- package/src/modules/dx/codeBlock/__tests__/mockProps.ts +160 -0
- package/src/modules/dx/codeBlock/codeBlock.css +128 -0
- package/src/modules/dx/codeBlock/codeBlock.html +79 -0
- package/src/modules/dx/codeBlock/codeBlock.stories.ts +143 -0
- package/src/modules/dx/codeBlock/codeBlock.ts +215 -0
- package/src/modules/dx/codeBlock/darkTheme.css +88 -0
- package/src/modules/dx/codeBlock/lightTheme.css +72 -0
- package/src/modules/dx/dropdown/__tests__/dropdown.test.ts +165 -0
- package/src/modules/dx/dropdown/__tests__/mockNestedOptions.ts +96 -0
- package/src/modules/dx/dropdown/__tests__/mockOptions.ts +10 -0
- package/src/modules/dx/dropdown/__tests__/mockProps.ts +6 -0
- package/src/modules/dx/dropdown/dropdown.css +93 -0
- package/src/modules/dx/dropdown/dropdown.html +67 -0
- package/src/modules/dx/dropdown/dropdown.stories.ts +89 -0
- package/src/modules/dx/dropdown/dropdown.ts +182 -0
- package/src/modules/dx/dropdownOption/__tests__/dropdownOption.test.ts +112 -0
- package/src/modules/dx/dropdownOption/__tests__/mockProps.ts +20 -0
- package/src/modules/dx/dropdownOption/dropdownOption.css +61 -0
- package/src/modules/dx/dropdownOption/dropdownOption.html +53 -0
- package/src/modules/dx/dropdownOption/dropdownOption.ts +39 -0
- package/src/modules/dx/emptyState/__tests__/emptyState.test.ts +52 -0
- package/src/modules/dx/emptyState/__tests__/mockProps.ts +4 -0
- package/src/modules/dx/emptyState/emptyState.css +64 -0
- package/src/modules/dx/emptyState/emptyState.html +9 -0
- package/src/modules/dx/emptyState/emptyState.stories.ts +45 -0
- package/src/modules/dx/emptyState/emptyState.ts +20 -0
- package/src/modules/dx/feature/__tests__/feature.test.ts +51 -0
- package/src/modules/dx/feature/__tests__/mockProps.ts +8 -0
- package/src/modules/dx/feature/feature.css +135 -0
- package/src/modules/dx/feature/feature.html +33 -0
- package/src/modules/dx/feature/feature.ts +34 -0
- package/src/modules/dx/featureGrid/__tests__/featureGrid.test.ts +21 -0
- package/src/modules/dx/featureGrid/featureGrid.html +3 -0
- package/src/modules/dx/featureGrid/featureGrid.stories.ts +120 -0
- package/src/modules/dx/featureGrid/featureGrid.ts +15 -0
- package/src/modules/dx/featuredContentHeader/__tests__/featuredContentHeader.test.ts +178 -0
- package/src/modules/dx/featuredContentHeader/__tests__/mockProps.ts +73 -0
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.css +469 -0
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.html +96 -0
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.stories.ts +153 -0
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.ts +113 -0
- package/src/modules/dx/featuredContentHeader/svgs.ts +35 -0
- package/src/modules/dx/featuresList/__tests__/featuresList.test.ts +43 -0
- package/src/modules/dx/featuresList/__tests__/mockProps.ts +17 -0
- package/src/modules/dx/featuresList/featuresList.css +24 -0
- package/src/modules/dx/featuresList/featuresList.html +20 -0
- package/src/modules/dx/featuresList/featuresList.stories.ts +30 -0
- package/src/modules/dx/featuresList/featuresList.ts +21 -0
- package/src/modules/dx/footer/__tests__/footer.test.ts +147 -0
- package/src/modules/dx/footer/__tests__/mockLocales.ts +7 -0
- package/src/modules/dx/footer/footer.css +405 -0
- package/src/modules/dx/footer/footer.html +145 -0
- package/src/modules/dx/footer/footer.stories.ts +88 -0
- package/src/modules/dx/footer/footer.ts +124 -0
- package/src/modules/dx/footer/links.ts +140 -0
- package/src/modules/dx/footerOption/__tests__/footerOption.test.ts +34 -0
- package/src/modules/dx/footerOption/__tests__/mockProps.ts +7 -0
- package/src/modules/dx/footerOption/footerOption.css +4 -0
- package/src/modules/dx/footerOption/footerOption.html +12 -0
- package/src/modules/dx/footerOption/footerOption.ts +19 -0
- package/src/modules/dx/formattedDateTime/__tests__/formattedDateTime.test.ts +25 -0
- package/src/modules/dx/formattedDateTime/__tests__/mockProps.ts +13 -0
- package/src/modules/dx/formattedDateTime/formattedDateTime.html +1 -0
- package/src/modules/dx/formattedDateTime/formattedDateTime.stories.ts +103 -0
- package/src/modules/dx/formattedDateTime/formattedDateTime.ts +72 -0
- package/src/modules/dx/grid/__tests__/grid.test.ts +32 -0
- package/src/modules/dx/grid/grid.css +48 -0
- package/src/modules/dx/grid/grid.html +3 -0
- package/src/modules/dx/grid/grid.md +14 -0
- package/src/modules/dx/grid/grid.stories.ts +134 -0
- package/src/modules/dx/grid/grid.ts +72 -0
- package/src/modules/dx/groupBio/__tests__/groupBio.test.ts +82 -0
- package/src/modules/dx/groupBio/__tests__/mockProps.ts +15 -0
- package/src/modules/dx/groupBio/groupBio.css +49 -0
- package/src/modules/dx/groupBio/groupBio.html +29 -0
- package/src/modules/dx/groupBio/groupBio.stories.ts +66 -0
- package/src/modules/dx/groupBio/groupBio.ts +41 -0
- package/src/modules/dx/groupText/__tests__/groupText.test.ts +69 -0
- package/src/modules/dx/groupText/__tests__/mockProps.ts +35 -0
- package/src/modules/dx/groupText/groupText.css +119 -0
- package/src/modules/dx/groupText/groupText.html +65 -0
- package/src/modules/dx/groupText/groupText.stories.ts +81 -0
- package/src/modules/dx/groupText/groupText.ts +93 -0
- package/src/modules/dx/headTags/headTags.html +3 -0
- package/src/modules/dx/headTags/headTags.ts +39 -0
- package/src/modules/dx/header/__benchmarks__/header.benchmark.js +45 -0
- package/src/modules/dx/header/__tests__/header.test.ts +236 -0
- package/src/modules/dx/header/__tests__/mockNavArchitects.ts +169 -0
- package/src/modules/dx/header/__tests__/mockNavDevelopers.ts +419 -0
- package/src/modules/dx/header/__tests__/mockNavs.ts +115 -0
- package/src/modules/dx/header/__tests__/mockProps.ts +164 -0
- package/src/modules/dx/header/header.css +109 -0
- package/src/modules/dx/header/header.html +129 -0
- package/src/modules/dx/header/header.stories.ts +172 -0
- package/src/modules/dx/header/header.ts +27 -0
- package/src/modules/dx/headerMobileNavMenu/__tests__/headerMobileNavMenu.test.ts +123 -0
- package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.css +160 -0
- package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.html +73 -0
- package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.ts +102 -0
- package/src/modules/dx/headerMobileNavMenuOption/__tests__/headerMobileNavMenuOption.test.ts +38 -0
- package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.css +5 -0
- package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.html +14 -0
- package/src/modules/dx/headerMobileNavMenuOption/headerMobileNavMenuOption.ts +20 -0
- package/src/modules/dx/headerNav/__tests__/headerNav.test.ts +49 -0
- package/src/modules/dx/headerNav/headerNav.css +31 -0
- package/src/modules/dx/headerNav/headerNav.html +48 -0
- package/src/modules/dx/headerNav/headerNav.ts +56 -0
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +182 -0
- package/src/modules/dx/headerSearch/__tests__/mockData.ts +11 -0
- package/src/modules/dx/headerSearch/__tests__/mockProps.ts +6 -0
- package/src/modules/dx/headerSearch/headerSearch.css +62 -0
- package/src/modules/dx/headerSearch/headerSearch.html +64 -0
- package/src/modules/dx/headerSearch/headerSearch.ts +159 -0
- package/src/modules/dx/helmet/__tests__/helmet.test.ts +52 -0
- package/src/modules/dx/helmet/helmet.css +83 -0
- package/src/modules/dx/helmet/helmet.html +39 -0
- package/src/modules/dx/helmet/helmet.stories.ts +53 -0
- package/src/modules/dx/helmet/helmet.ts +27 -0
- package/src/modules/dx/hr/__tests__/hr.test.ts +53 -0
- package/src/modules/dx/hr/__tests__/mockProps.ts +16 -0
- package/src/modules/dx/hr/hr.css +55 -0
- package/src/modules/dx/hr/hr.html +23 -0
- package/src/modules/dx/hr/hr.stories.ts +50 -0
- package/src/modules/dx/hr/hr.ts +45 -0
- package/src/modules/dx/icon/__tests__/icon.test.ts +54 -0
- package/src/modules/dx/icon/icon.css +14 -0
- package/src/modules/dx/icon/icon.html +11 -0
- package/src/modules/dx/icon/icon.stories.ts +100 -0
- package/src/modules/dx/icon/icon.ts +85 -0
- package/src/modules/dx/iconBadge/__tests__/iconBadge.test.ts +17 -0
- package/src/modules/dx/iconBadge/iconBadge.css +40 -0
- package/src/modules/dx/iconBadge/iconBadge.html +10 -0
- package/src/modules/dx/iconBadge/iconBadge.stories.ts +32 -0
- package/src/modules/dx/iconBadge/iconBadge.ts +42 -0
- package/src/modules/dx/imageAndLabel/__tests__/imageAndLabel.test.ts +39 -0
- package/src/modules/dx/imageAndLabel/__tests__/mockProps.ts +6 -0
- package/src/modules/dx/imageAndLabel/imageAndLabel.css +54 -0
- package/src/modules/dx/imageAndLabel/imageAndLabel.html +22 -0
- package/src/modules/dx/imageAndLabel/imageAndLabel.stories.ts +48 -0
- package/src/modules/dx/imageAndLabel/imageAndLabel.ts +16 -0
- package/src/modules/dx/input/__tests__/input.test.ts +357 -0
- package/src/modules/dx/input/input.css +165 -0
- package/src/modules/dx/input/input.html +58 -0
- package/src/modules/dx/input/input.stories.ts +102 -0
- package/src/modules/dx/input/input.ts +238 -0
- package/src/modules/dx/input/validators.ts +5 -0
- package/src/modules/dx/instrumentation/__tests__/instrumentation.test.ts +86 -0
- package/src/modules/dx/instrumentation/instrumentation.html +1 -0
- package/src/modules/dx/instrumentation/instrumentation.ts +116 -0
- package/src/modules/dx/interactiveImage/__tests__/interactiveImage.test.ts +83 -0
- package/src/modules/dx/interactiveImage/__tests__/mockProps.ts +39 -0
- package/src/modules/dx/interactiveImage/interactiveImage.css +59 -0
- package/src/modules/dx/interactiveImage/interactiveImage.html +32 -0
- package/src/modules/dx/interactiveImage/interactiveImage.stories.ts +31 -0
- package/src/modules/dx/interactiveImage/interactiveImage.ts +71 -0
- package/src/modules/dx/lazy/__tests__/lazy.test.ts +43 -0
- package/src/modules/dx/lazy/lazy.html +5 -0
- package/src/modules/dx/lazy/lazy.stories.ts +132 -0
- package/src/modules/dx/lazy/lazy.ts +163 -0
- package/src/modules/dx/logo/logo.css +33 -0
- package/src/modules/dx/logo/logo.html +6 -0
- package/src/modules/dx/logo/logo.ts +8 -0
- package/src/modules/dx/newsletterForm/newsletterForm.css +73 -0
- package/src/modules/dx/newsletterForm/newsletterForm.html +73 -0
- package/src/modules/dx/newsletterForm/newsletterForm.ts +238 -0
- package/src/modules/dx/pagination/__tests__/pagination.test.ts +121 -0
- package/src/modules/dx/pagination/pagination.css +51 -0
- package/src/modules/dx/pagination/pagination.html +45 -0
- package/src/modules/dx/pagination/pagination.stories.ts +88 -0
- package/src/modules/dx/pagination/pagination.ts +93 -0
- package/src/modules/dx/podcastHost/__tests__/mockProps.ts +8 -0
- package/src/modules/dx/podcastHost/__tests__/podcastHost.test.ts +21 -0
- package/src/modules/dx/podcastHost/podcastHost.css +62 -0
- package/src/modules/dx/podcastHost/podcastHost.html +28 -0
- package/src/modules/dx/podcastHost/podcastHost.stories.ts +17 -0
- package/src/modules/dx/podcastHost/podcastHost.ts +13 -0
- package/src/modules/dx/podcastPlayer/__tests__/podcastPlayer.test.ts +20 -0
- package/src/modules/dx/podcastPlayer/podcastPlayer.css +10 -0
- package/src/modules/dx/podcastPlayer/podcastPlayer.html +3 -0
- package/src/modules/dx/podcastPlayer/podcastPlayer.stories.ts +13 -0
- package/src/modules/dx/podcastPlayer/podcastPlayer.ts +5 -0
- package/src/modules/dx/podcastSubscription/__tests__/podcastSubscription.test.ts +16 -0
- package/src/modules/dx/podcastSubscription/podcastSubscription.css +91 -0
- package/src/modules/dx/podcastSubscription/podcastSubscription.html +24 -0
- package/src/modules/dx/podcastSubscription/podcastSubscription.stories.ts +23 -0
- package/src/modules/dx/podcastSubscription/podcastSubscription.ts +58 -0
- package/src/modules/dx/popover/__tests__/mockProps.ts +8 -0
- package/src/modules/dx/popover/__tests__/popover.test.ts +313 -0
- package/src/modules/dx/popover/popover.css +63 -0
- package/src/modules/dx/popover/popover.html +16 -0
- package/src/modules/dx/popover/popover.stories.ts +82 -0
- package/src/modules/dx/popover/popover.ts +313 -0
- package/src/modules/dx/radioGroup/__tests__/mockProps.ts +12 -0
- package/src/modules/dx/radioGroup/__tests__/radioGroup.test.ts +42 -0
- package/src/modules/dx/radioGroup/radioGroup.css +12 -0
- package/src/modules/dx/radioGroup/radioGroup.html +16 -0
- package/src/modules/dx/radioGroup/radioGroup.stories.ts +25 -0
- package/src/modules/dx/radioGroup/radioGroup.ts +65 -0
- package/src/modules/dx/relativeDateTime/__tests__/mockProps.ts +55 -0
- package/src/modules/dx/relativeDateTime/__tests__/relativeDateTime.test.ts +52 -0
- package/src/modules/dx/relativeDateTime/relativeDateTime.html +3 -0
- package/src/modules/dx/relativeDateTime/relativeDateTime.stories.ts +83 -0
- package/src/modules/dx/relativeDateTime/relativeDateTime.ts +113 -0
- package/src/modules/dx/searchResults/coveo.css +18989 -0
- package/src/modules/dx/searchResults/searchResults.css +387 -0
- package/src/modules/dx/searchResults/searchResults.html +104 -0
- package/src/modules/dx/searchResults/searchResults.stories.ts +36 -0
- package/src/modules/dx/searchResults/searchResults.ts +186 -0
- package/src/modules/dx/section/__tests__/section.test.ts +17 -0
- package/src/modules/dx/section/section.css +130 -0
- package/src/modules/dx/section/section.html +66 -0
- package/src/modules/dx/section/section.stories.ts +381 -0
- package/src/modules/dx/section/section.ts +41 -0
- package/src/modules/dx/sectionSignup/__tests__/sectionSignup.test.ts +66 -0
- package/src/modules/dx/sectionSignup/sectionSignup.css +43 -0
- package/src/modules/dx/sectionSignup/sectionSignup.html +23 -0
- package/src/modules/dx/sectionSignup/sectionSignup.stories.ts +49 -0
- package/src/modules/dx/sectionSignup/sectionSignup.ts +44 -0
- package/src/modules/dx/select/select.css +44 -0
- package/src/modules/dx/select/select.html +60 -0
- package/src/modules/dx/select/select.stories.ts +59 -0
- package/src/modules/dx/select/select.ts +23 -0
- package/src/modules/dx/sidebar/__tests__/mockProps.ts +181 -0
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEmptyEvent.ts +6 -0
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEvent.ts +527 -0
- package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +568 -0
- package/src/modules/dx/sidebar/sidebar.css +192 -0
- package/src/modules/dx/sidebar/sidebar.html +94 -0
- package/src/modules/dx/sidebar/sidebar.stories.ts +188 -0
- package/src/modules/dx/sidebar/sidebar.ts +255 -0
- package/src/modules/dx/sidebarOld/__tests__/mockProps.ts +178 -0
- package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +570 -0
- package/src/modules/dx/sidebarOld/sidebarOld.css +160 -0
- package/src/modules/dx/sidebarOld/sidebarOld.html +70 -0
- package/src/modules/dx/sidebarOld/sidebarOld.stories.ts +139 -0
- package/src/modules/dx/sidebarOld/sidebarOld.ts +187 -0
- package/src/modules/dx/sidebarSearch/__tests__/mockPreloadedState.ts +1686 -0
- package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +175 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.css +3 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.html +26 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +440 -0
- package/src/modules/dx/sidebarSearchResult/__tests__/sidebarSearchResult.test.ts +96 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.css +36 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.html +14 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.ts +70 -0
- package/src/modules/dx/skipNavLink/skipNavLink.css +21 -0
- package/src/modules/dx/skipNavLink/skipNavLink.html +3 -0
- package/src/modules/dx/skipNavLink/skipNavLink.ts +3 -0
- package/src/modules/dx/slackCta/__tests__/slackCta.test.ts +36 -0
- package/src/modules/dx/slackCta/slackCta.css +47 -0
- package/src/modules/dx/slackCta/slackCta.html +17 -0
- package/src/modules/dx/slackCta/slackCta.stories.ts +25 -0
- package/src/modules/dx/slackCta/slackCta.ts +12 -0
- package/src/modules/dx/socials/__tests__/socials.test.ts +114 -0
- package/src/modules/dx/socials/socials.css +35 -0
- package/src/modules/dx/socials/socials.html +22 -0
- package/src/modules/dx/socials/socials.stories.ts +24 -0
- package/src/modules/dx/socials/socials.ts +81 -0
- package/src/modules/dx/spinner/__tests__/spinner.test.ts +37 -0
- package/src/modules/dx/spinner/spinner.css +750 -0
- package/src/modules/dx/spinner/spinner.html +6 -0
- package/src/modules/dx/spinner/spinner.stories.ts +69 -0
- package/src/modules/dx/spinner/spinner.ts +20 -0
- package/src/modules/dx/tab/__tests__/tab.test.ts +129 -0
- package/src/modules/dx/tab/tab.css +106 -0
- package/src/modules/dx/tab/tab.html +13 -0
- package/src/modules/dx/tab/tab.stories.ts +57 -0
- package/src/modules/dx/tab/tab.ts +52 -0
- package/src/modules/dx/toc/__tests__/mockProps.ts +28 -0
- package/src/modules/dx/toc/__tests__/toc.test.ts +109 -0
- package/src/modules/dx/toc/toc.css +94 -0
- package/src/modules/dx/toc/toc.html +28 -0
- package/src/modules/dx/toc/toc.stories.ts +26 -0
- package/src/modules/dx/toc/toc.ts +77 -0
- package/src/modules/dx/tooltip/__tests__/tooltip.test.ts +22 -0
- package/src/modules/dx/tooltip/microtip.css +269 -0
- package/src/modules/dx/tooltip/tooltip.css +36 -0
- package/src/modules/dx/tooltip/tooltip.html +5 -0
- package/src/modules/dx/tooltip/tooltip.stories.ts +46 -0
- package/src/modules/dx/tooltip/tooltip.ts +6 -0
- package/src/modules/dx/topics/__tests__/mockProps.ts +3 -0
- package/src/modules/dx/topics/__tests__/topics.test.ts +31 -0
- package/src/modules/dx/topics/topics.css +25 -0
- package/src/modules/dx/topics/topics.html +12 -0
- package/src/modules/dx/topics/topics.ts +25 -0
- package/src/modules/dx/tree/__tests__/mockProps.ts +215 -0
- package/src/modules/dx/tree/__tests__/tree.test.ts +346 -0
- package/src/modules/dx/tree/__tests__/treeHandler.test.ts +194 -0
- package/src/modules/dx/tree/tree.css +5 -0
- package/src/modules/dx/tree/tree.html +11 -0
- package/src/modules/dx/tree/tree.stories.ts +65 -0
- package/src/modules/dx/tree/tree.ts +72 -0
- package/src/modules/dx/tree/treeHandler.ts +100 -0
- package/src/modules/dx/treeItem/__tests__/mockProps.ts +46 -0
- package/src/modules/dx/treeItem/__tests__/treeItem.test.ts +377 -0
- package/src/modules/dx/treeItem/treeItem.css +14 -0
- package/src/modules/dx/treeItem/treeItem.html +22 -0
- package/src/modules/dx/treeItem/treeItem.ts +110 -0
- package/src/modules/dx/treeTile/__tests__/mockProps.ts +16 -0
- package/src/modules/dx/treeTile/__tests__/treeTile.test.ts +168 -0
- package/src/modules/dx/treeTile/treeTile.css +190 -0
- package/src/modules/dx/treeTile/treeTile.html +27 -0
- package/src/modules/dx/treeTile/treeTile.ts +59 -0
- package/src/modules/dx/typeBadge/__tests__/typeBadge.test.ts +77 -0
- package/src/modules/dx/typeBadge/typeBadge.css +74 -0
- package/src/modules/dx/typeBadge/typeBadge.html +5 -0
- package/src/modules/dx/typeBadge/typeBadge.stories.ts +114 -0
- package/src/modules/dx/typeBadge/typeBadge.ts +65 -0
- package/src/modules/dx/typeBadgeGroup/__tests__/mockProps.ts +11 -0
- package/src/modules/dx/typeBadgeGroup/__tests__/typeBadgeGroup.test.ts +72 -0
- package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.css +12 -0
- package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.html +11 -0
- package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.stories.ts +19 -0
- package/src/modules/dx/typeBadgeGroup/typeBadgeGroup.ts +18 -0
- package/src/modules/helpers/animations/animations.css +15 -0
- package/src/modules/helpers/button/button.css +4 -0
- package/src/modules/helpers/card/card.css +258 -0
- package/src/modules/helpers/code/code.css +296 -0
- package/src/modules/helpers/commonHeader/commonHeader.css +130 -0
- package/src/modules/helpers/reset/reset.css +559 -0
- package/src/modules/helpers/sidebar/sidebar.css +21 -0
- package/src/modules/helpers/slds/slds.css +191 -0
- package/src/modules/helpers/table/table.css +110 -0
- package/src/modules/helpers/text/text.css +163 -0
- package/src/modules/test-components/buttonTest/buttonTest.html +3 -0
- package/src/modules/test-components/buttonTest/buttonTest.ts +3 -0
- package/src/modules/test-components/codeBlockTest/codeBlockTest.js +4 -0
- package/src/modules/test-components/featureGridTest/featureGridTest.html +7 -0
- package/src/modules/test-components/featureGridTest/featureGridTest.ts +5 -0
- package/src/modules/test-components/instrumentationTest/instrumentationTest.html +4 -0
- package/src/modules/test-components/instrumentationTest/instrumentationTest.ts +8 -0
- package/src/modules/test-components/popoverTest/popoverTest.html +6 -0
- package/src/modules/test-components/popoverTest/popoverTest.ts +5 -0
- package/src/modules/test-components/slackCtaTest/slackCtaTest.html +3 -0
- package/src/modules/test-components/slackCtaTest/slackCtaTest.ts +3 -0
- package/src/modules/utils/highlight/__tests__/highlight.test.ts +108 -0
- package/src/modules/utils/highlight/__tests__/mockProps.ts +45 -0
- package/src/modules/utils/highlight/highlight.ts +32 -0
- package/src/modules/utils/normalizers/normalizers.ts +91 -0
- package/src/modules/utils-internal/archiveCard/archiveCard.ts +35 -0
- package/src/modules/utils-internal/coveo/coveo.ts +70 -0
- package/src/modules/utils-internal/css/css.ts +43 -0
- package/src/modules/utils-internal/devices/devices.ts +1 -0
- package/src/modules/utils-internal/headerBase/headerBase.ts +204 -0
- package/src/modules/utils-internal/jest/jest.ts +58 -0
- package/src/modules/utils-internal/options/options.ts +39 -0
- package/src/modules/utils-internal/prismjs/prismjs.html +3 -0
- package/src/modules/utils-internal/prismjs/prismjs.ts +3321 -0
- package/src/modules/utils-internal/recentSearches/__tests__/recentSearches.test.ts +83 -0
- package/src/modules/utils-internal/recentSearches/recentSearches.ts +57 -0
- package/src/modules/utils-internal/regexps/regexps.ts +5 -0
- package/src/modules/utils-internal/seo/seo.ts +4 -0
- package/src/modules/utils-internal/slot/slot.ts +17 -0
- package/src/modules/utils-internal/storybook/storybook.ts +32 -0
- package/src/modules/utils-internal/tests/tests.ts +38 -0
- package/src/modules/utils-internal/wordpress/__tests__/wordpress.test.ts +15 -0
- package/src/modules/utils-internal/wordpress/wordpress.ts +13 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Option, PopperPlacement } from "typings/custom";
|
|
2
|
+
import { LightningElement, api, track } from "lwc";
|
|
3
|
+
import cx from "classnames";
|
|
4
|
+
import get from "lodash.get";
|
|
5
|
+
import { deepmapOptions } from "utils-internal/options";
|
|
6
|
+
import { toJson } from "utils/normalizers";
|
|
7
|
+
|
|
8
|
+
interface DropdownOption extends Option {
|
|
9
|
+
// link that gets shown as a highlighted link at end of option group
|
|
10
|
+
calloutLink?: {
|
|
11
|
+
href: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default class Dropdown extends LightningElement {
|
|
18
|
+
@api value: string | null = null; // "active option" id
|
|
19
|
+
@api valuePath: string = "id"; // path to match for the active value (useful for url matching)
|
|
20
|
+
@api stayOpenAfterChange?: boolean = false;
|
|
21
|
+
|
|
22
|
+
// props forwarded to popover:
|
|
23
|
+
@api ariaLabel: string | null = null;
|
|
24
|
+
@api tempId: string | null = null;
|
|
25
|
+
@api offset?: "small" | "medium";
|
|
26
|
+
@api open: boolean | null = null;
|
|
27
|
+
@api pagePadding?: number = 16; // padding between dropdown and the edge of the page
|
|
28
|
+
@api placement?: PopperPlacement = "bottom-start";
|
|
29
|
+
@api small?: boolean = false;
|
|
30
|
+
@api openOnHover?: boolean = false; // dropdown opens/closes with hover
|
|
31
|
+
@api width?: string | null = null;
|
|
32
|
+
@api fullWidth?: boolean | null;
|
|
33
|
+
@api navItemLabel: string | null = null;
|
|
34
|
+
|
|
35
|
+
// props forwarded to dropdown option
|
|
36
|
+
@api analyticsEvent: string | null = null;
|
|
37
|
+
|
|
38
|
+
@api
|
|
39
|
+
get options() {
|
|
40
|
+
return deepmapOptions(this._options, (option: DropdownOption) => ({
|
|
41
|
+
...option,
|
|
42
|
+
active: this.value === get(option, this.valuePath),
|
|
43
|
+
keyValue: get(option, this.valuePath)
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
set options(value: DropdownOption[]) {
|
|
47
|
+
this._options = toJson(value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@api
|
|
51
|
+
get focusedValue() {
|
|
52
|
+
return this._focusedValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@track
|
|
56
|
+
private _options!: DropdownOption[];
|
|
57
|
+
|
|
58
|
+
// PRIVATE VARS
|
|
59
|
+
|
|
60
|
+
private _focusedValue: string | null = null;
|
|
61
|
+
private popoverEl: HTMLElement | null = null;
|
|
62
|
+
|
|
63
|
+
constructor() {
|
|
64
|
+
super();
|
|
65
|
+
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
this.addEventListener("keydown", this.onKeyDown);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// GETTERS
|
|
71
|
+
|
|
72
|
+
private get role() {
|
|
73
|
+
return this.areOptionsEmpty ? null : "menu";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private get className() {
|
|
77
|
+
return cx(
|
|
78
|
+
this.isNested && "menu-nested",
|
|
79
|
+
this.isNested && this.options.length >= 2 && "menu-nested-2-col",
|
|
80
|
+
this.offset && `menu-offset-${this.offset}`,
|
|
81
|
+
this.areOptionsEmpty && "menu-hidden"
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private get isNested() {
|
|
86
|
+
return this.options.some((option) => !!option.options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private get optionsElements() {
|
|
90
|
+
return this.template.querySelectorAll("dx-dropdown-option");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private get areOptionsEmpty() {
|
|
94
|
+
return this.options.length === 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// CLASS FNS
|
|
98
|
+
|
|
99
|
+
private onKeyDown = (e: KeyboardEvent) => {
|
|
100
|
+
switch (e.key) {
|
|
101
|
+
case "ArrowDown":
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
this.incrementOptionFocus(1);
|
|
104
|
+
break;
|
|
105
|
+
case "ArrowUp":
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
this.incrementOptionFocus(-1);
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
private onOptionClick(e: CustomEvent) {
|
|
114
|
+
if (e.detail !== this.value) {
|
|
115
|
+
this.dispatchEvent(new CustomEvent("change", { detail: e.detail }));
|
|
116
|
+
}
|
|
117
|
+
if (!this.stayOpenAfterChange && this.popoverEl) {
|
|
118
|
+
this.popoverEl.closePopover();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private onOptionFocus(e: PointerEvent) {
|
|
123
|
+
if (e.target) {
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
this._focusedValue = e.target.option.id;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private findOptionElementIndex(value: string) {
|
|
130
|
+
return Array.from(this.optionsElements).findIndex(
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
(el) => el.option.id === value
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private incrementOptionFocus(indexChange: number) {
|
|
137
|
+
if (!this._focusedValue) {
|
|
138
|
+
this.focusDefaultOption();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const focusedOptionIndex = this.findOptionElementIndex(
|
|
143
|
+
this._focusedValue
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
let nextIndex = focusedOptionIndex + indexChange;
|
|
147
|
+
if (nextIndex < 0) {
|
|
148
|
+
nextIndex = this.optionsElements.length - 1;
|
|
149
|
+
}
|
|
150
|
+
if (nextIndex >= this.optionsElements.length) {
|
|
151
|
+
nextIndex = 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const element = this.optionsElements[nextIndex];
|
|
155
|
+
if (element) {
|
|
156
|
+
element.focus();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private onClose(): void {
|
|
161
|
+
this._focusedValue = null;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private focusDefaultOption() {
|
|
165
|
+
const defaultIndex = this.value
|
|
166
|
+
? this.findOptionElementIndex(this.value)
|
|
167
|
+
: 0;
|
|
168
|
+
|
|
169
|
+
const optionToFocus: any =
|
|
170
|
+
this.optionsElements[defaultIndex < 0 ? 0 : defaultIndex];
|
|
171
|
+
if (optionToFocus) {
|
|
172
|
+
optionToFocus.focus();
|
|
173
|
+
this._focusedValue = optionToFocus.option.id;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
renderedCallback() {
|
|
178
|
+
if (!this.popoverEl) {
|
|
179
|
+
this.popoverEl = this.template.querySelector("dx-popover");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import DropdownOption from "dx/dropdownOption";
|
|
2
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
3
|
+
import { MOCK_BUTTON_PROPS, MOCK_LINK_PROPS } from "./mockProps";
|
|
4
|
+
import * as instrumentation from "dx/instrumentation";
|
|
5
|
+
|
|
6
|
+
const TAG = "dx-dropdown-option";
|
|
7
|
+
const render = createRenderComponent(TAG, DropdownOption);
|
|
8
|
+
|
|
9
|
+
const appendToMenu = (element: HTMLElement) => {
|
|
10
|
+
const menu = document.createElement("DIV");
|
|
11
|
+
document.body.appendChild(menu);
|
|
12
|
+
menu.setAttribute("role", "menu");
|
|
13
|
+
menu.appendChild(element);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe(TAG, () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
jest.clearAllMocks();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("renders a button by default", () => {
|
|
22
|
+
const component = render(MOCK_BUTTON_PROPS);
|
|
23
|
+
expect(component.shadowRoot.querySelector("button")).not.toBeNull();
|
|
24
|
+
|
|
25
|
+
appendToMenu(component);
|
|
26
|
+
return expect(component).toBeAccessible();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("renders the correct label, description, and img", () => {
|
|
30
|
+
const component = render(MOCK_BUTTON_PROPS);
|
|
31
|
+
const label =
|
|
32
|
+
component.shadowRoot.querySelector(".option_label").textContent;
|
|
33
|
+
expect(label).toEqual(MOCK_BUTTON_PROPS.option.label);
|
|
34
|
+
|
|
35
|
+
const description = component.shadowRoot.querySelector(
|
|
36
|
+
".option_description"
|
|
37
|
+
).textContent;
|
|
38
|
+
expect(description).toEqual(MOCK_BUTTON_PROPS.option.description);
|
|
39
|
+
|
|
40
|
+
const img = component.shadowRoot.querySelector(".option_icon");
|
|
41
|
+
expect(img).not.toBeNull();
|
|
42
|
+
|
|
43
|
+
appendToMenu(component);
|
|
44
|
+
return expect(component).toBeAccessible();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("renders a link with the correct href when given link props", () => {
|
|
48
|
+
const component = render(MOCK_LINK_PROPS);
|
|
49
|
+
|
|
50
|
+
const href = component.shadowRoot
|
|
51
|
+
.querySelector("a")
|
|
52
|
+
.getAttribute("href");
|
|
53
|
+
expect(href).toEqual(MOCK_LINK_PROPS.option.link.href);
|
|
54
|
+
|
|
55
|
+
appendToMenu(component);
|
|
56
|
+
return expect(component).toBeAccessible();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it("applies the active class correctly", () => {
|
|
60
|
+
const component = render({ ...MOCK_BUTTON_PROPS, active: true });
|
|
61
|
+
const optionEl = component.shadowRoot.querySelector(".option-active");
|
|
62
|
+
expect(optionEl).not.toBeNull();
|
|
63
|
+
|
|
64
|
+
appendToMenu(component);
|
|
65
|
+
return expect(component).toBeAccessible();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("can focus itself", () => {
|
|
69
|
+
const component = render(MOCK_BUTTON_PROPS);
|
|
70
|
+
component.focus();
|
|
71
|
+
|
|
72
|
+
expect(document.activeElement).toEqual(component);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("onClick function is fired when button is clicked", () => {
|
|
76
|
+
const onClickMock = jest.fn();
|
|
77
|
+
const component = render({
|
|
78
|
+
...MOCK_BUTTON_PROPS,
|
|
79
|
+
onclick: onClickMock
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const option = component.shadowRoot.querySelector(".option");
|
|
83
|
+
option.click();
|
|
84
|
+
|
|
85
|
+
expect(onClickMock).toBeCalled();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("fires analytics when given an analytics event", () => {
|
|
89
|
+
const track = jest.spyOn(instrumentation, "track");
|
|
90
|
+
|
|
91
|
+
const component = render({
|
|
92
|
+
...MOCK_BUTTON_PROPS,
|
|
93
|
+
analyticsEvent: "mock"
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const option = component.shadowRoot.querySelector(".option");
|
|
97
|
+
option.click();
|
|
98
|
+
|
|
99
|
+
expect(track).toHaveBeenCalledTimes(1);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("doesn't fire analytics when not given an analytics event", () => {
|
|
103
|
+
const track = jest.spyOn(instrumentation, "track");
|
|
104
|
+
|
|
105
|
+
const component = render(MOCK_BUTTON_PROPS);
|
|
106
|
+
|
|
107
|
+
const option = component.shadowRoot.querySelector(".option");
|
|
108
|
+
option.click();
|
|
109
|
+
|
|
110
|
+
expect(track).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const MOCK_BUTTON_PROPS = {
|
|
2
|
+
option: {
|
|
3
|
+
id: "documentation",
|
|
4
|
+
label: "Documentation",
|
|
5
|
+
description: "Documentation is kewl",
|
|
6
|
+
iconSymbol: "heroku",
|
|
7
|
+
iconSprite: "salesforcebrand"
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const MOCK_LINK_PROPS = {
|
|
12
|
+
option: {
|
|
13
|
+
id: "documentation",
|
|
14
|
+
label: "Documentation",
|
|
15
|
+
link: {
|
|
16
|
+
href: "/documentation",
|
|
17
|
+
target: null
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
@import "helpers/reset";
|
|
2
|
+
|
|
3
|
+
.option {
|
|
4
|
+
display: flex;
|
|
5
|
+
font-family: var(--dx-g-font-sans);
|
|
6
|
+
width: 100%;
|
|
7
|
+
padding: var(--dx-g-spacing-sm);
|
|
8
|
+
font-size: var(--dx-g-text-sm);
|
|
9
|
+
border-radius: var(--dx-g-spacing-xs);
|
|
10
|
+
transition: var(--dx-g-transition-hue-1x);
|
|
11
|
+
align-items: center;
|
|
12
|
+
outline: none !important;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.option:focus {
|
|
16
|
+
box-shadow: inset 0 0 0 1px var(--dx-g-blue-vibrant-50);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.option:active {
|
|
20
|
+
background: var(--dx-g-blue-vibrant-95) !important;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.option:not(.option-active):hover {
|
|
24
|
+
background: var(--dx-g-gray-95);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.option-active {
|
|
28
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.option_details {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
font-family: var(--dx-g-font-sans);
|
|
36
|
+
font-size: var(--dx-g-text-sm);
|
|
37
|
+
text-align: left;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.option_label {
|
|
41
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
font-weight: var(--dx-g-font-bold);
|
|
45
|
+
font-size: var(--dx-c-dropdown-option-font-size, var(--dx-g-text-base));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.option_label > *:last-child {
|
|
49
|
+
margin-left: var(--dx-g-spacing-sm);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.option_description {
|
|
53
|
+
color: var(--dx-g-gray-30);
|
|
54
|
+
margin-top: var(--dx-g-spacing-xs);
|
|
55
|
+
line-height: 18px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.option_icon {
|
|
59
|
+
margin-right: var(--dx-g-spacing-md);
|
|
60
|
+
flex-shrink: 0;
|
|
61
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a
|
|
3
|
+
if:true={option.link}
|
|
4
|
+
class={className}
|
|
5
|
+
href={option.link.href}
|
|
6
|
+
target={option.link.target}
|
|
7
|
+
key={option.id}
|
|
8
|
+
role="menuitem"
|
|
9
|
+
tabindex="-1"
|
|
10
|
+
onclick={onClick}
|
|
11
|
+
>
|
|
12
|
+
<dx-icon
|
|
13
|
+
class="option_icon"
|
|
14
|
+
symbol={option.iconSymbol}
|
|
15
|
+
sprite={option.iconSprite}
|
|
16
|
+
if:true={option.iconSymbol}
|
|
17
|
+
size="large"
|
|
18
|
+
></dx-icon>
|
|
19
|
+
<div class="option_details">
|
|
20
|
+
<div class="option_label">
|
|
21
|
+
{option.label}
|
|
22
|
+
<dx-icon
|
|
23
|
+
symbol="new_window"
|
|
24
|
+
if:true={option.link.target}
|
|
25
|
+
></dx-icon>
|
|
26
|
+
</div>
|
|
27
|
+
<div if:true={option.description} class="option_description">
|
|
28
|
+
{option.description}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</a>
|
|
32
|
+
<button
|
|
33
|
+
if:false={option.link}
|
|
34
|
+
class={className}
|
|
35
|
+
role="menuitem"
|
|
36
|
+
tabindex="-1"
|
|
37
|
+
onclick={onClick}
|
|
38
|
+
>
|
|
39
|
+
<dx-icon
|
|
40
|
+
class="option_icon"
|
|
41
|
+
symbol={option.iconSymbol}
|
|
42
|
+
sprite={option.iconSprite}
|
|
43
|
+
if:true={option.iconSymbol}
|
|
44
|
+
size="large"
|
|
45
|
+
></dx-icon>
|
|
46
|
+
<div class="option_details">
|
|
47
|
+
<div class="option_label">{option.label}</div>
|
|
48
|
+
<div if:true={option.description} class="option_description">
|
|
49
|
+
{option.description}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</button>
|
|
53
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
import { Option } from "typings/custom";
|
|
4
|
+
import { track } from "dx/instrumentation";
|
|
5
|
+
|
|
6
|
+
export default class DropdownOption extends LightningElement {
|
|
7
|
+
@api option!: Option;
|
|
8
|
+
@api keyValue!: string;
|
|
9
|
+
@api active: boolean = false;
|
|
10
|
+
@api navItemLabel: String | null = null;
|
|
11
|
+
@api analyticsEvent: string | null = null;
|
|
12
|
+
|
|
13
|
+
@api focus() {
|
|
14
|
+
const option = this.template.querySelector(".option");
|
|
15
|
+
if (!option) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
option.focus();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private get className(): string {
|
|
22
|
+
return cx("option", this.active && "option-active");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private onClick(e: PointerEvent) {
|
|
26
|
+
this.dispatchEvent(
|
|
27
|
+
new CustomEvent("select", { detail: this.keyValue })
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (this.analyticsEvent && e.currentTarget) {
|
|
31
|
+
track(e.currentTarget, this.analyticsEvent, {
|
|
32
|
+
navHeading: this.navItemLabel || undefined,
|
|
33
|
+
navSubHeading: this.option.label || undefined,
|
|
34
|
+
clickText: this.keyValue || undefined,
|
|
35
|
+
pageLocation: window.location.pathname || undefined
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import EmptyState from "dx/emptyState";
|
|
2
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
3
|
+
import mockProps from "./mockProps";
|
|
4
|
+
|
|
5
|
+
const TAG = "dx-empty-state";
|
|
6
|
+
const render = createRenderComponent(TAG, EmptyState);
|
|
7
|
+
|
|
8
|
+
describe(TAG, () => {
|
|
9
|
+
it("renders", () => {
|
|
10
|
+
const element = render(mockProps);
|
|
11
|
+
const container: HTMLElement =
|
|
12
|
+
element.shadowRoot.querySelector(".container");
|
|
13
|
+
const renderedTitle: HTMLElement =
|
|
14
|
+
element.shadowRoot.querySelector("h3");
|
|
15
|
+
const renderedSubTitle: HTMLElement =
|
|
16
|
+
element.shadowRoot.querySelector("p");
|
|
17
|
+
const image: HTMLImageElement = element.shadowRoot.querySelector("img");
|
|
18
|
+
|
|
19
|
+
expect(renderedTitle).not.toBeNull();
|
|
20
|
+
expect(renderedSubTitle).not.toBeNull();
|
|
21
|
+
expect(container).not.toBeNull();
|
|
22
|
+
expect(image).not.toBeNull();
|
|
23
|
+
|
|
24
|
+
expect(renderedSubTitle.textContent).toEqual(mockProps.subtitle);
|
|
25
|
+
expect(renderedTitle.textContent).toEqual(mockProps.title);
|
|
26
|
+
|
|
27
|
+
return expect(element).toBeAccessible();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("renders as the large variant by default", () => {
|
|
31
|
+
const element = render(mockProps);
|
|
32
|
+
const container: HTMLElement =
|
|
33
|
+
element.shadowRoot.querySelector(".container");
|
|
34
|
+
const image: HTMLImageElement = element.shadowRoot.querySelector("img");
|
|
35
|
+
expect(container.classList).toContain("size-large");
|
|
36
|
+
expect(container.classList).toHaveLength(2);
|
|
37
|
+
expect(image.src).not.toContain("-small.svg");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("renders as the small variant when specified", () => {
|
|
41
|
+
const element = render({
|
|
42
|
+
...mockProps,
|
|
43
|
+
size: "small"
|
|
44
|
+
});
|
|
45
|
+
const container: HTMLElement =
|
|
46
|
+
element.shadowRoot.querySelector(".container");
|
|
47
|
+
const image: HTMLImageElement = element.shadowRoot.querySelector("img");
|
|
48
|
+
expect(container.classList).toContain("size-small");
|
|
49
|
+
expect(container.classList).toHaveLength(2);
|
|
50
|
+
expect(image.src).toContain("-small.svg");
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@import "helpers/reset";
|
|
2
|
+
@import "helpers/text";
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
--dx-c-empty-state-background: var(--dx-g-gray-95);
|
|
6
|
+
--dx-c-empty-state-image-width: 600px;
|
|
7
|
+
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.container {
|
|
12
|
+
position: relative;
|
|
13
|
+
background: var(--dx-c-empty-state-background);
|
|
14
|
+
border-radius: var(--dx-g-spacing-md);
|
|
15
|
+
padding: var(--dx-g-spacing-2xl) 0;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
img {
|
|
23
|
+
width: var(--dx-c-empty-state-image-width);
|
|
24
|
+
min-width: var(--dx-c-empty-state-image-width);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.size-small img {
|
|
28
|
+
max-width: 250px;
|
|
29
|
+
min-width: unset;
|
|
30
|
+
width: calc(100% - 40px);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.text {
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 35%;
|
|
36
|
+
min-height: 15%;
|
|
37
|
+
left: 0;
|
|
38
|
+
width: 100%;
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
align-items: center;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
text-align: center;
|
|
44
|
+
padding: 0 var(--dx-g-spacing-xl);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.size-small .text {
|
|
48
|
+
top: 40%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.title {
|
|
52
|
+
font-size: var(--dx-g-text-2xl);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.size-small .title {
|
|
56
|
+
font-size: var(--dx-g-text-base);
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.subtitle {
|
|
61
|
+
padding-top: var(--dx-g-spacing-sm);
|
|
62
|
+
color: var(--dx-g-text-heading-color);
|
|
63
|
+
font-weight: bold;
|
|
64
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class={containerClassName} part="container">
|
|
3
|
+
<img src={imageAssetPath} alt="Mountains" />
|
|
4
|
+
<div class="text">
|
|
5
|
+
<h3 class="title dx-text-heading-3">{title}</h3>
|
|
6
|
+
<p class="subtitle dx-text-body-2" if:true={subtitle}>{subtitle}</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { html } from "lit-html";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "dx/dx-empty-state",
|
|
5
|
+
component: "dx-empty-state"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const createStyles = () => html`
|
|
9
|
+
<style>
|
|
10
|
+
body {
|
|
11
|
+
padding: 12px !important;
|
|
12
|
+
}
|
|
13
|
+
.title {
|
|
14
|
+
font-weight: bold;
|
|
15
|
+
margin: 24px;
|
|
16
|
+
}
|
|
17
|
+
#styled {
|
|
18
|
+
--dx-c-empty-state-background: var(--sds-g-gray-2);
|
|
19
|
+
--dx-c-empty-state-image-width: 400px;
|
|
20
|
+
width: 300px;
|
|
21
|
+
display: block;
|
|
22
|
+
}
|
|
23
|
+
.small-container {
|
|
24
|
+
width: 250px;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
const title = (value: string) => html`<p class="title">${value}</p>`;
|
|
30
|
+
|
|
31
|
+
export const Base = () => html`
|
|
32
|
+
${createStyles()} ${title("Default")}
|
|
33
|
+
<dx-empty-state
|
|
34
|
+
title="Beep boop. That did not compute."
|
|
35
|
+
subtitle="No results"
|
|
36
|
+
></dx-empty-state>
|
|
37
|
+
|
|
38
|
+
${title("No subtitle and customized with style hooks")}
|
|
39
|
+
<dx-empty-state id="styled" title="No Results"></dx-empty-state>
|
|
40
|
+
|
|
41
|
+
${title("Small variant")}
|
|
42
|
+
<div class="small-container">
|
|
43
|
+
<dx-empty-state title="No Results" size="small"></dx-empty-state>
|
|
44
|
+
</div>
|
|
45
|
+
`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import { EmptyStateSize } from "typings/custom";
|
|
3
|
+
|
|
4
|
+
export default class EmptyState extends LightningElement {
|
|
5
|
+
@api title: string = "";
|
|
6
|
+
@api subtitle?: string | null = null;
|
|
7
|
+
@api size?: EmptyStateSize = "large";
|
|
8
|
+
|
|
9
|
+
get containerClassName() {
|
|
10
|
+
return `container ${
|
|
11
|
+
!this.size || this.size === "large" ? "size-large" : "size-small"
|
|
12
|
+
}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
get imageAssetPath() {
|
|
16
|
+
return `/assets/svg/docs-empty-state${
|
|
17
|
+
this.size === "small" ? "-small" : ""
|
|
18
|
+
}.svg`;
|
|
19
|
+
}
|
|
20
|
+
}
|