@salesforcedevs/arch-components 1.20.17-alpha1
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/lwc.config.json +7 -0
- package/package.json +19 -0
- package/src/modules/common/context/context.html +1 -0
- package/src/modules/common/context/context.ts +137 -0
- package/src/modules/common/effectAdapter/__tests__/effectAdapter.test.ts +12 -0
- package/src/modules/common/effectAdapter/effectAdapter.html +1 -0
- package/src/modules/common/effectAdapter/effectAdapter.ts +18 -0
- package/src/modules/common/reflectedElement/__tests__/modules/test/select/select.html +3 -0
- package/src/modules/common/reflectedElement/__tests__/modules/test/select/select.ts +7 -0
- package/src/modules/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.html +3 -0
- package/src/modules/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.ts +18 -0
- package/src/modules/common/reflectedElement/__tests__/reflectedElement.test.ts +75 -0
- package/src/modules/common/reflectedElement/reflectedElement.ts +50 -0
- package/src/modules/common/slot/__tests__/slot.test.ts +96 -0
- package/src/modules/common/slot/slot.ts +20 -0
- package/src/modules/sa/coverage/coverage.css +35 -0
- package/src/modules/sa/coverage/coverage.html +15 -0
- package/src/modules/sa/coverage/coverage.ts +406 -0
- package/src/modules/sa/coverage/types.d.ts +26 -0
- package/src/modules/sa/expandableSection/expandableSection.css +24 -0
- package/src/modules/sa/expandableSection/expandableSection.html +20 -0
- package/src/modules/sa/expandableSection/expandableSection.stories.ts +37 -0
- package/src/modules/sa/expandableSection/expandableSection.ts +24 -0
- package/src/modules/sa/explorer/explorer.css +303 -0
- package/src/modules/sa/explorer/explorer.html +403 -0
- package/src/modules/sa/explorer/explorer.ts +664 -0
- package/src/modules/sa/explorer/types.d.ts +60 -0
- package/src/modules/sa/gallery/gallery.css +358 -0
- package/src/modules/sa/gallery/gallery.html +65 -0
- package/src/modules/sa/gallery/gallery.ts +300 -0
- package/src/modules/sa/gallery/types.d.ts +35 -0
- package/src/modules/sa/socialShare/socialShare.css +49 -0
- package/src/modules/sa/socialShare/socialShare.html +56 -0
- package/src/modules/sa/socialShare/socialShare.ts +29 -0
- package/src/modules/shared/a11y/a11y.ts +25 -0
- package/src/modules/shared/children/children.ts +29 -0
- package/src/modules/shared/color/color.ts +52 -0
- package/src/modules/shared/debounce/debounce.ts +32 -0
- package/src/modules/shared/dialog/dialog.ts +154 -0
- package/src/modules/shared/elements/__tests__/overflow.test.ts +39 -0
- package/src/modules/shared/elements/overflow.ts +71 -0
- package/src/modules/shared/fetch/fetch.ts +52 -0
- package/src/modules/shared/helpers/helpers.ts +141 -0
- package/src/modules/shared/i18n/i18n.ts +74 -0
- package/src/modules/shared/labels/__tests__/helpers.test.ts +107 -0
- package/src/modules/shared/labels/__tests__/pointHelpers.test.ts +33 -0
- package/src/modules/shared/labels/__tests__/timeHelpers.test.ts +89 -0
- package/src/modules/shared/labels/helpers.ts +23 -0
- package/src/modules/shared/labels/pointHelpers.ts +47 -0
- package/src/modules/shared/labels/timeHelpers.ts +182 -0
- package/src/modules/shared/labels/types.d.ts +5 -0
- package/src/modules/shared/logger/logger.ts +33 -0
- package/src/modules/shared/menu/menu.ts +239 -0
- package/src/modules/shared/overflow/__tests__/overflow.test.ts +39 -0
- package/src/modules/shared/overflow/overflow.ts +71 -0
- package/src/modules/shared/polling-request.ts +97 -0
- package/src/modules/shared/testutils.ts +118 -0
- package/src/modules/shared/track/track.ts +23 -0
- package/src/modules/shared/trailhead.ts +123 -0
- package/src/modules/shared/types.d.ts +1 -0
- package/src/modules/shared/useEffectAttr.ts +16 -0
- package/src/modules/shared/withState.ts +21 -0
- package/src/modules/tds/appLauncher/__fixtures__/index.ts +34 -0
- package/src/modules/tds/appLauncher/__tests__/appLauncher.test.ts +119 -0
- package/src/modules/tds/appLauncher/appLauncher.css +65 -0
- package/src/modules/tds/appLauncher/appLauncher.html +38 -0
- package/src/modules/tds/appLauncher/appLauncher.stories.ts +39 -0
- package/src/modules/tds/appLauncher/appLauncher.ts +79 -0
- package/src/modules/tds/appLauncher/types.ts +8 -0
- package/src/modules/tds/avatar/__tests__/avatar.test.ts +11 -0
- package/src/modules/tds/avatar/avatar.css +77 -0
- package/src/modules/tds/avatar/avatar.html +36 -0
- package/src/modules/tds/avatar/avatar.stories.ts +64 -0
- package/src/modules/tds/avatar/avatar.ts +50 -0
- package/src/modules/tds/badge/__tests__/badge.test.js +11 -0
- package/src/modules/tds/badge/badge.css +22 -0
- package/src/modules/tds/badge/badge.html +5 -0
- package/src/modules/tds/badge/badge.stories.ts +10 -0
- package/src/modules/tds/badge/badge.ts +9 -0
- package/src/modules/tds/button/__tests__/button.test.ts +52 -0
- package/src/modules/tds/button/button.css +1 -0
- package/src/modules/tds/button/button.html +20 -0
- package/src/modules/tds/button/button.stories.js +54 -0
- package/src/modules/tds/button/button.ts +59 -0
- package/src/modules/tds/buttonIcon/__tests__/buttonIcon.test.ts +17 -0
- package/src/modules/tds/buttonIcon/buttonIcon.css +1 -0
- package/src/modules/tds/buttonIcon/buttonIcon.html +12 -0
- package/src/modules/tds/buttonIcon/buttonIcon.stories.js +38 -0
- package/src/modules/tds/buttonIcon/buttonIcon.ts +6 -0
- package/src/modules/tds/buttonIconLink/buttonIconLink.css +1 -0
- package/src/modules/tds/buttonIconLink/buttonIconLink.html +14 -0
- package/src/modules/tds/buttonIconLink/buttonIconLink.stories.ts +32 -0
- package/src/modules/tds/buttonIconLink/buttonIconLink.ts +9 -0
- package/src/modules/tds/buttonLink/__tests__/buttonLink.test.ts +17 -0
- package/src/modules/tds/buttonLink/buttonLink.css +1 -0
- package/src/modules/tds/buttonLink/buttonLink.html +19 -0
- package/src/modules/tds/buttonLink/buttonLink.stories.js +24 -0
- package/src/modules/tds/buttonLink/buttonLink.ts +8 -0
- package/src/modules/tds/buttonStyles/buttonStyles.css +232 -0
- package/src/modules/tds/childSummary/__tests__/childSummary.test.js +99 -0
- package/src/modules/tds/childSummary/childSummary.css +74 -0
- package/src/modules/tds/childSummary/childSummary.html +38 -0
- package/src/modules/tds/childSummary/childSummary.stories.ts +40 -0
- package/src/modules/tds/childSummary/childSummary.ts +63 -0
- package/src/modules/tds/childSummary/types.d.ts +10 -0
- package/src/modules/tds/contentChildListItem/__tests__/contentChildListItem.test.ts +32 -0
- package/src/modules/tds/contentChildListItem/contentChildListItem.css +1 -0
- package/src/modules/tds/contentChildListItem/contentChildListItem.html +10 -0
- package/src/modules/tds/contentChildListItem/contentChildListItem.stories.ts +46 -0
- package/src/modules/tds/contentChildListItem/contentChildListItem.ts +34 -0
- package/src/modules/tds/contentIcon/contentIcon.css +47 -0
- package/src/modules/tds/contentIcon/contentIcon.html +15 -0
- package/src/modules/tds/contentIcon/contentIcon.stories.js +110 -0
- package/src/modules/tds/contentIcon/contentIcon.ts +66 -0
- package/src/modules/tds/contextAdapter/__tests__/contextAdapter.test.ts +76 -0
- package/src/modules/tds/contextAdapter/constants.ts +1 -0
- package/src/modules/tds/contextAdapter/contextAdapter.html +1 -0
- package/src/modules/tds/contextAdapter/contextAdapter.ts +54 -0
- package/src/modules/tds/dialogStyles/dialogStyles.css +90 -0
- package/src/modules/tds/footerLinks/__tests__/__snapshots__/footerLinks.test.ts.snap +3 -0
- package/src/modules/tds/footerLinks/__tests__/footerLinks.test.ts +142 -0
- package/src/modules/tds/footerLinks/footerLinks.css +80 -0
- package/src/modules/tds/footerLinks/footerLinks.html +30 -0
- package/src/modules/tds/footerLinks/footerLinks.ts +48 -0
- package/src/modules/tds/footerLinks/types.ts +11 -0
- package/src/modules/tds/footerMfe/footerMfe.html +3 -0
- package/src/modules/tds/footerMfe/footerMfe.ts +19 -0
- package/src/modules/tds/headerAvatar/__tests__/headerAvatar.test.ts +43 -0
- package/src/modules/tds/headerAvatar/headerAvatar.css +45 -0
- package/src/modules/tds/headerAvatar/headerAvatar.html +25 -0
- package/src/modules/tds/headerAvatar/headerAvatar.ts +15 -0
- package/src/modules/tds/headerHelpButton/__tests__/headerHelpButton.test.ts +32 -0
- package/src/modules/tds/headerHelpButton/headerHelpButton.css +14 -0
- package/src/modules/tds/headerHelpButton/headerHelpButton.html +19 -0
- package/src/modules/tds/headerHelpButton/headerHelpButton.ts +12 -0
- package/src/modules/tds/heading/__tests__/heading.test.ts +50 -0
- package/src/modules/tds/heading/heading.css +1 -0
- package/src/modules/tds/heading/heading.html +9 -0
- package/src/modules/tds/heading/heading.stories.ts +36 -0
- package/src/modules/tds/heading/heading.ts +36 -0
- package/src/modules/tds/icon/icon.css +28 -0
- package/src/modules/tds/icon/icon.html +17 -0
- package/src/modules/tds/icon/icon.stories.js +18 -0
- package/src/modules/tds/icon/icon.ts +79 -0
- package/src/modules/tds/input/__tests__/input.test.ts +41 -0
- package/src/modules/tds/input/input.css +34 -0
- package/src/modules/tds/input/input.html +12 -0
- package/src/modules/tds/input/input.stories.ts +25 -0
- package/src/modules/tds/input/input.ts +41 -0
- package/src/modules/tds/instrumentation/instrumentation.css +0 -0
- package/src/modules/tds/instrumentation/instrumentation.html +1 -0
- package/src/modules/tds/instrumentation/instrumentation.ts +113 -0
- package/src/modules/tds/pbCard/pbCard.css +28 -0
- package/src/modules/tds/pbCard/pbCard.html +21 -0
- package/src/modules/tds/pbCard/pbCard.ts +18 -0
- package/src/modules/tds/pill/__tests__/pill.test.ts +56 -0
- package/src/modules/tds/pill/pill.css +70 -0
- package/src/modules/tds/pill/pill.html +17 -0
- package/src/modules/tds/pill/pill.stories.ts +41 -0
- package/src/modules/tds/pill/pill.ts +34 -0
- package/src/modules/tds/progressBar/__tests__/progressBar.test.js +11 -0
- package/src/modules/tds/progressBar/progressBar.css +42 -0
- package/src/modules/tds/progressBar/progressBar.html +14 -0
- package/src/modules/tds/progressBar/progressBar.stories.ts +24 -0
- package/src/modules/tds/progressBar/progressBar.ts +14 -0
- package/src/modules/tds/radio/__tests__/radio.test.ts +29 -0
- package/src/modules/tds/radio/radio.css +89 -0
- package/src/modules/tds/radio/radio.html +17 -0
- package/src/modules/tds/radio/radio.stories.ts +31 -0
- package/src/modules/tds/radio/radio.ts +32 -0
- package/src/modules/tds/reset/reset.css +39 -0
- package/src/modules/tds/search/__fixtures__/index.ts +32 -0
- package/src/modules/tds/search/__tests__/search.test.ts +235 -0
- package/src/modules/tds/search/lib/__tests__/__snapshots__/listbox.test.ts.snap +115 -0
- package/src/modules/tds/search/lib/__tests__/listbox.test.ts +192 -0
- package/src/modules/tds/search/lib/listbox.ts +209 -0
- package/src/modules/tds/search/search.css +122 -0
- package/src/modules/tds/search/search.html +21 -0
- package/src/modules/tds/search/search.stories.ts +20 -0
- package/src/modules/tds/search/search.ts +107 -0
- package/src/modules/tds/search/types.d.ts +22 -0
- package/src/modules/tds/searchList/searchList.css +120 -0
- package/src/modules/tds/searchList/searchList.html +43 -0
- package/src/modules/tds/searchList/searchList.stories.ts +10 -0
- package/src/modules/tds/searchList/searchList.ts +53 -0
- package/src/modules/tds/select/__tests__/select.test.ts +150 -0
- package/src/modules/tds/select/select.css +42 -0
- package/src/modules/tds/select/select.html +24 -0
- package/src/modules/tds/select/select.stories.ts +59 -0
- package/src/modules/tds/select/select.ts +60 -0
- package/src/modules/tds/spinner/__tests__/spinner.test.ts +11 -0
- package/src/modules/tds/spinner/spinner.css +194 -0
- package/src/modules/tds/spinner/spinner.html +9 -0
- package/src/modules/tds/spinner/spinner.stories.ts +20 -0
- package/src/modules/tds/spinner/spinner.ts +15 -0
- package/src/modules/tds/styles/styles.css +24 -0
- package/src/modules/tds/summary/__tests__/summary.test.ts +135 -0
- package/src/modules/tds/summary/summary.css +135 -0
- package/src/modules/tds/summary/summary.html +69 -0
- package/src/modules/tds/summary/summary.stories.js +148 -0
- package/src/modules/tds/summary/summary.ts +95 -0
- package/src/modules/tds/tab/__tests__/tab.test.ts +25 -0
- package/src/modules/tds/tab/tab.css +3 -0
- package/src/modules/tds/tab/tab.html +5 -0
- package/src/modules/tds/tab/tab.ts +46 -0
- package/src/modules/tds/tabset/__tests__/tabset.test.ts +108 -0
- package/src/modules/tds/tabset/tabset.css +112 -0
- package/src/modules/tds/tabset/tabset.html +63 -0
- package/src/modules/tds/tabset/tabset.stories.ts +32 -0
- package/src/modules/tds/tabset/tabset.ts +232 -0
- package/src/modules/tds/themeProvider/themeProvider.css +502 -0
- package/src/modules/tds/themeProvider/themeProvider.html +3 -0
- package/src/modules/tds/themeProvider/themeProvider.ts +37 -0
- package/src/modules/tds/tile/tile.css +23 -0
- package/src/modules/tds/tile/tile.html +5 -0
- package/src/modules/tds/tile/tile.stories.js +14 -0
- package/src/modules/tds/tile/tile.ts +12 -0
- package/src/modules/tds/xsfMfeEvents/xsfMfeEvents.html +1 -0
- package/src/modules/tds/xsfMfeEvents/xsfMfeEvents.ts +47 -0
- package/src/modules/th/contextAdapter/__tests__/contextAdapter.test.ts +104 -0
- package/src/modules/th/contextAdapter/contextAdapter.html +1 -0
- package/src/modules/th/contextAdapter/contextAdapter.ts +49 -0
- package/src/modules/th/favoriteButton/__tests__/favoriteButton.test.ts +56 -0
- package/src/modules/th/favoriteButton/favoriteButton.css +3 -0
- package/src/modules/th/favoriteButton/favoriteButton.html +15 -0
- package/src/modules/th/favoriteButton/favoriteButton.stories.js +30 -0
- package/src/modules/th/favoriteButton/favoriteButton.ts +84 -0
- package/src/modules/th/favoriteButton/mocks/index.ts +12 -0
- package/src/modules/th/search/__fixtures__/index.ts +14 -0
- package/src/modules/th/search/__tests__/search.test.ts +233 -0
- package/src/modules/th/search/constants.ts +2 -0
- package/src/modules/th/search/mocks/index.ts +30 -0
- package/src/modules/th/search/mocks/responses.ts +54 -0
- package/src/modules/th/search/search.css +4 -0
- package/src/modules/th/search/search.html +12 -0
- package/src/modules/th/search/search.ts +172 -0
- package/src/modules/th/search/types.d.ts +29 -0
- package/src/modules/th/tbid/__tests__/__snapshots__/tbid.test.ts.snap +3 -0
- package/src/modules/th/tbid/__tests__/tbid.test.ts +242 -0
- package/src/modules/th/tbid/tbid.html +1 -0
- package/src/modules/th/tbid/tbid.stories.mdx +25 -0
- package/src/modules/th/tbid/tbid.ts +215 -0
- package/src/modules/tm/card/__tests__/card.test.ts +65 -0
- package/src/modules/tm/card/card.css +131 -0
- package/src/modules/tm/card/card.html +81 -0
- package/src/modules/tm/card/card.ts +269 -0
- package/src/modules/tm/cardBase/cardBase.css +11 -0
- package/src/modules/tm/cardGridA/cardGridA.css +11 -0
- package/src/modules/tm/cardGridA/cardGridA.html +21 -0
- package/src/modules/tm/cardGridA/cardGridA.stories.js +107 -0
- package/src/modules/tm/cardGridA/cardGridA.ts +24 -0
- package/src/modules/tm/cardGridB/cardGridB.css +88 -0
- package/src/modules/tm/cardGridB/cardGridB.html +20 -0
- package/src/modules/tm/cardGridB/cardGridB.stories.js +58 -0
- package/src/modules/tm/cardGridB/cardGridB.ts +19 -0
- package/src/modules/tm/cardGridC/cardGridC.css +24 -0
- package/src/modules/tm/cardGridC/cardGridC.html +22 -0
- package/src/modules/tm/cardGridC/cardGridC.stories.js +42 -0
- package/src/modules/tm/cardGridC/cardGridC.ts +11 -0
- package/src/modules/tm/cardGridD/cardGridD.css +17 -0
- package/src/modules/tm/cardGridD/cardGridD.html +20 -0
- package/src/modules/tm/cardGridD/cardGridD.stories.js +34 -0
- package/src/modules/tm/cardGridD/cardGridD.ts +7 -0
- package/src/modules/tm/cardNew/cardNew.css +31 -0
- package/src/modules/tm/cardNew/cardNew.html +29 -0
- package/src/modules/tm/cardNew/cardNew.ts +66 -0
- package/src/modules/tm/content/__fixtures__/index.ts +884 -0
- package/src/modules/tm/content/__tests__/content.test.ts +95 -0
- package/src/modules/tm/content/content.css +641 -0
- package/src/modules/tm/content/content.html +53 -0
- package/src/modules/tm/content/content.stories.js +14 -0
- package/src/modules/tm/content/content.ts +171 -0
- package/src/modules/tm/endCapA/__tests__/endCapA.test.ts +52 -0
- package/src/modules/tm/endCapA/endCapA.css +64 -0
- package/src/modules/tm/endCapA/endCapA.html +21 -0
- package/src/modules/tm/endCapA/endCapA.stories.js +37 -0
- package/src/modules/tm/endCapA/endCapA.ts +23 -0
- package/src/modules/tm/eventsA/eventsA.css +107 -0
- package/src/modules/tm/eventsA/eventsA.html +26 -0
- package/src/modules/tm/eventsA/eventsA.stories.js +51 -0
- package/src/modules/tm/eventsA/eventsA.ts +48 -0
- package/src/modules/tm/faqA/faqA.css +87 -0
- package/src/modules/tm/faqA/faqA.html +27 -0
- package/src/modules/tm/faqA/faqA.stories.js +25 -0
- package/src/modules/tm/faqA/faqA.ts +40 -0
- package/src/modules/tm/featureGridA/__tests__/featureGridA.test.ts +116 -0
- package/src/modules/tm/featureGridA/featureGridA.css +95 -0
- package/src/modules/tm/featureGridA/featureGridA.html +34 -0
- package/src/modules/tm/featureGridA/featureGridA.stories.js +45 -0
- package/src/modules/tm/featureGridA/featureGridA.ts +59 -0
- package/src/modules/tm/footnote/footnote.css +28 -0
- package/src/modules/tm/footnote/footnote.html +3 -0
- package/src/modules/tm/footnote/footnote.stories.js +29 -0
- package/src/modules/tm/footnote/footnote.ts +35 -0
- package/src/modules/tm/heroA/__tests__/heroA.test.ts +51 -0
- package/src/modules/tm/heroA/heroA.css +116 -0
- package/src/modules/tm/heroA/heroA.html +27 -0
- package/src/modules/tm/heroA/heroA.stories.js +49 -0
- package/src/modules/tm/heroA/heroA.ts +56 -0
- package/src/modules/tm/heroB/heroB.css +78 -0
- package/src/modules/tm/heroB/heroB.html +26 -0
- package/src/modules/tm/heroB/heroB.stories.js +44 -0
- package/src/modules/tm/heroB/heroB.ts +26 -0
- package/src/modules/tm/page/__tests__/page.test.ts +35 -0
- package/src/modules/tm/page/page.css +3 -0
- package/src/modules/tm/page/page.html +3 -0
- package/src/modules/tm/page/page.stories.js +10 -0
- package/src/modules/tm/page/page.ts +3 -0
- package/src/modules/tm/pageHeaderA/pageHeaderA.css +82 -0
- package/src/modules/tm/pageHeaderA/pageHeaderA.html +24 -0
- package/src/modules/tm/pageHeaderA/pageHeaderA.stories.js +18 -0
- package/src/modules/tm/pageHeaderA/pageHeaderA.ts +51 -0
- package/src/modules/tm/pageNavigationA/pageNavigationA.css +41 -0
- package/src/modules/tm/pageNavigationA/pageNavigationA.html +9 -0
- package/src/modules/tm/pageNavigationA/pageNavigationA.stories.js +34 -0
- package/src/modules/tm/pageNavigationA/pageNavigationA.ts +18 -0
- package/src/modules/tm/promoA/__tests__/promoA.test.ts +89 -0
- package/src/modules/tm/promoA/promoA.css +95 -0
- package/src/modules/tm/promoA/promoA.html +22 -0
- package/src/modules/tm/promoA/promoA.stories.js +38 -0
- package/src/modules/tm/promoA/promoA.ts +62 -0
- package/src/modules/tm/sectionA/sectionA.css +64 -0
- package/src/modules/tm/sectionA/sectionA.html +21 -0
- package/src/modules/tm/sectionA/sectionA.stories.js +18 -0
- package/src/modules/tm/sectionA/sectionA.ts +27 -0
- package/src/modules/tm/sectionSpacer/sectionSpacer.css +4 -0
- package/src/modules/tm/sectionSpacer/sectionSpacer.html +1 -0
- package/src/modules/tm/sectionSpacer/sectionSpacer.ts +3 -0
- package/src/modules/tm/skillsCardA/skillsCardA.css +73 -0
- package/src/modules/tm/skillsCardA/skillsCardA.html +37 -0
- package/src/modules/tm/skillsCardA/skillsCardA.ts +38 -0
- package/src/modules/tm/skillsGridA/skillsGridA.css +12 -0
- package/src/modules/tm/skillsGridA/skillsGridA.html +5 -0
- package/src/modules/tm/skillsGridA/skillsGridA.stories.ts +65 -0
- package/src/modules/tm/skillsGridA/skillsGridA.ts +3 -0
- package/src/modules/tm/statsA/statsA.css +26 -0
- package/src/modules/tm/statsA/statsA.html +10 -0
- package/src/modules/tm/statsA/statsA.stories.js +29 -0
- package/src/modules/tm/statsA/statsA.ts +20 -0
- package/src/modules/tm/textItem/textItem.css +53 -0
- package/src/modules/tm/textItem/textItem.html +18 -0
- package/src/modules/tm/textItem/textItem.ts +32 -0
- package/src/modules/tm/textItemGridA/textItemGridA.css +11 -0
- package/src/modules/tm/textItemGridA/textItemGridA.html +15 -0
- package/src/modules/tm/textItemGridA/textItemGridA.stories.js +67 -0
- package/src/modules/tm/textItemGridA/textItemGridA.ts +20 -0
- package/src/modules/tm/threeCardGrid/threeCardGrid.css +6 -0
- package/src/modules/tm/threeCardGrid/threeCardGrid.html +5 -0
- package/src/modules/tm/threeCardGrid/threeCardGrid.ts +3 -0
- package/src/modules/tm/trailblazersA/trailblazersA.css +70 -0
- package/src/modules/tm/trailblazersA/trailblazersA.html +42 -0
- package/src/modules/tm/trailblazersA/trailblazersA.stories.js +52 -0
- package/src/modules/tm/trailblazersA/trailblazersA.ts +43 -0
- package/src/modules/tm/utils/utils.ts +18 -0
- package/src/modules/tm/youtube/youtube.css +7 -0
- package/src/modules/tm/youtube/youtube.html +10 -0
- package/src/modules/tm/youtube/youtube.stories.js +15 -0
- package/src/modules/tm/youtube/youtube.ts +27 -0
- package/src/modules/ui/focusTrap/focusTrap.html +5 -0
- package/src/modules/ui/focusTrap/focusTrap.ts +104 -0
- package/src/modules/ui/focusVisible/__tests__/focusVisible.test.ts +95 -0
- package/src/modules/ui/focusVisible/focusVisible.html +3 -0
- package/src/modules/ui/focusVisible/focusVisible.ts +46 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CoveoCompletion, UserRecent } from '../types';
|
|
2
|
+
|
|
3
|
+
export const completions: { completions: CoveoCompletion[] } = {
|
|
4
|
+
completions: [
|
|
5
|
+
{
|
|
6
|
+
expression: 'LWC',
|
|
7
|
+
score: 1,
|
|
8
|
+
highlighted: 'LWC',
|
|
9
|
+
executableConfidence: 1
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
expression: 'Visualforce Pages',
|
|
13
|
+
score: 1,
|
|
14
|
+
highlighted: 'Visualforce Pages',
|
|
15
|
+
executableConfidence: 1
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const recents: { recents: UserRecent[] } = {
|
|
21
|
+
recents: [
|
|
22
|
+
{
|
|
23
|
+
color: null,
|
|
24
|
+
completion: null,
|
|
25
|
+
content_type: 'Module',
|
|
26
|
+
icon_url: '/images/badge-1.png',
|
|
27
|
+
path: '/en/content/learn/modules/salesforce-cms-basics',
|
|
28
|
+
title: 'Salesforce CMS Basics 1',
|
|
29
|
+
type: 'recent_favorite'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
color: null,
|
|
33
|
+
completion: null,
|
|
34
|
+
content_type: 'Module',
|
|
35
|
+
icon_url: '/images/badge-1.png',
|
|
36
|
+
path: '/en/content/learn/modules/salesforce-cms-basics',
|
|
37
|
+
title: 'Salesforce CMS Basics 2',
|
|
38
|
+
type: 'recent_favorite'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
color: 'var(--tds-color-brand)',
|
|
42
|
+
completion: null,
|
|
43
|
+
content_type: 'Trailmix',
|
|
44
|
+
icon_url: '/images/badge-1.png',
|
|
45
|
+
path: '/en/content/learn/modules/salesforce-cms-basics',
|
|
46
|
+
title: 'Salesforce CMS Basics 3',
|
|
47
|
+
type: 'recent_favorite'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const token = {
|
|
53
|
+
token: 'TOKEN'
|
|
54
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tds-search
|
|
3
|
+
completions={completions}
|
|
4
|
+
default-value={defaultCompletionTerms}
|
|
5
|
+
if:true={config}
|
|
6
|
+
onfocus={onFocus}
|
|
7
|
+
onchange={onChange}
|
|
8
|
+
onsearch={onSearch}
|
|
9
|
+
placeholder={config.labels.placeholder}
|
|
10
|
+
recents={recents}
|
|
11
|
+
></tds-search>
|
|
12
|
+
</template>
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { api, LightningElement, wire } from 'lwc';
|
|
2
|
+
import {
|
|
3
|
+
ContextAdapter as ThContextAdapter,
|
|
4
|
+
ContextAdapterValue as ThContextAdapterValue
|
|
5
|
+
} from 'th/contextAdapter';
|
|
6
|
+
|
|
7
|
+
import { debounce } from 'shared/debounce';
|
|
8
|
+
import { getJSON } from 'shared/fetch';
|
|
9
|
+
import { TrailheadAPIClient } from 'shared/trailhead';
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
Completion,
|
|
13
|
+
Recent,
|
|
14
|
+
RecentSection,
|
|
15
|
+
SearchEvent
|
|
16
|
+
} from '../../tds/search/types';
|
|
17
|
+
|
|
18
|
+
import { RECENTS_PATH, TOKEN_PATH } from './constants';
|
|
19
|
+
import { CoveoCompletion, Config, UserRecent } from './types';
|
|
20
|
+
|
|
21
|
+
export default class extends LightningElement {
|
|
22
|
+
@api config: Config = null!;
|
|
23
|
+
|
|
24
|
+
private accessToken: string | null = null;
|
|
25
|
+
|
|
26
|
+
private get client() {
|
|
27
|
+
return new TrailheadAPIClient({ csrfToken: this.context.csrf });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private completionTerms: string = '';
|
|
31
|
+
private completionController: AbortController | null = null;
|
|
32
|
+
private completions: Completion[] = [];
|
|
33
|
+
|
|
34
|
+
@wire(ThContextAdapter)
|
|
35
|
+
private context: ThContextAdapterValue = null!;
|
|
36
|
+
|
|
37
|
+
private defaultCompletionTerms = '';
|
|
38
|
+
|
|
39
|
+
private getCompletions = debounce(async (terms: string) => {
|
|
40
|
+
let { completionController: prevController, config } = this;
|
|
41
|
+
if (prevController) prevController.abort();
|
|
42
|
+
if (!config) return;
|
|
43
|
+
if (!terms.length) {
|
|
44
|
+
this.completions = [];
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
let controller = (this.completionController = new AbortController());
|
|
48
|
+
let accessToken = await this.getAccessToken();
|
|
49
|
+
let url = getCompletionsUrl({
|
|
50
|
+
accessToken,
|
|
51
|
+
baseUrl: config.coveo.querySuggestUrl,
|
|
52
|
+
locale: config.coveo.locale,
|
|
53
|
+
terms
|
|
54
|
+
});
|
|
55
|
+
let { completions } = await getJSON<{ completions: CoveoCompletion[] }>(
|
|
56
|
+
url,
|
|
57
|
+
{ signal: controller.signal }
|
|
58
|
+
);
|
|
59
|
+
if (this.completionTerms === terms)
|
|
60
|
+
this.completions = completions.map((c) => ({
|
|
61
|
+
value: c.expression,
|
|
62
|
+
valueHighlighted: c.highlighted
|
|
63
|
+
}));
|
|
64
|
+
}, 250);
|
|
65
|
+
|
|
66
|
+
private recents: RecentSection[] | null = null;
|
|
67
|
+
|
|
68
|
+
private async getAccessToken() {
|
|
69
|
+
if (this.accessToken) return this.accessToken;
|
|
70
|
+
let { token } = await this.client.post<{ token: string }>(TOKEN_PATH);
|
|
71
|
+
this.accessToken = token;
|
|
72
|
+
return token;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private async getRecents() {
|
|
76
|
+
let { config } = this;
|
|
77
|
+
try {
|
|
78
|
+
let { recents } = await this.client.get<{ recents: UserRecent[] }>(
|
|
79
|
+
RECENTS_PATH
|
|
80
|
+
);
|
|
81
|
+
let { recent_favorite, recent_item } = recents.reduce<
|
|
82
|
+
{
|
|
83
|
+
[type in UserRecent['type']]: UserRecent[];
|
|
84
|
+
}
|
|
85
|
+
>((a, b) => (a[b.type].push(b), a), {
|
|
86
|
+
recent_favorite: [],
|
|
87
|
+
recent_item: []
|
|
88
|
+
});
|
|
89
|
+
this.recents = [
|
|
90
|
+
{
|
|
91
|
+
items: recent_item.map(toRecent),
|
|
92
|
+
title: config.labels.recentViewed
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
items: recent_favorite.map(toRecent),
|
|
96
|
+
title: config.labels.recentFavorites
|
|
97
|
+
}
|
|
98
|
+
].filter((s) => s.items.length);
|
|
99
|
+
} catch (e) {
|
|
100
|
+
console.error(e);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private onFocus(e: FocusEvent) {
|
|
105
|
+
if (!this.recents) this.getRecents();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private onChange(e: CustomEvent<{ value: string }>) {
|
|
109
|
+
this.completionTerms = e.detail.value;
|
|
110
|
+
this.getCompletions(e.detail.value);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private onSearch(e: CustomEvent<SearchEvent>) {
|
|
114
|
+
let { config } = this;
|
|
115
|
+
switch (e.detail.type) {
|
|
116
|
+
case 'completion': {
|
|
117
|
+
let query = new URLSearchParams({
|
|
118
|
+
keywords: e.detail.value.value,
|
|
119
|
+
suggested: 'true'
|
|
120
|
+
}).toString();
|
|
121
|
+
window.location.href = `${config!.searchUrl}?${query}`;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case 'input': {
|
|
125
|
+
let query = new URLSearchParams({
|
|
126
|
+
keywords: e.detail.value
|
|
127
|
+
}).toString();
|
|
128
|
+
window.location.href = `${config!.searchUrl}?${query}`;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case 'recent': {
|
|
132
|
+
window.location.href = e.detail.value.path;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
connectedCallback() {
|
|
139
|
+
let params = new URLSearchParams(window.location.search);
|
|
140
|
+
if (params.has('keywords')) {
|
|
141
|
+
this.defaultCompletionTerms = params.get('keywords')!;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getCompletionsUrl(params: {
|
|
147
|
+
accessToken: string;
|
|
148
|
+
baseUrl: string;
|
|
149
|
+
locale: string;
|
|
150
|
+
terms: string;
|
|
151
|
+
}) {
|
|
152
|
+
let { accessToken, baseUrl, locale, terms } = { ...params };
|
|
153
|
+
if (!/^http/.test(baseUrl)) baseUrl = `${process.env.API_HOST}${baseUrl}`;
|
|
154
|
+
let query = new URLSearchParams({
|
|
155
|
+
access_token: accessToken,
|
|
156
|
+
count: '10',
|
|
157
|
+
enableWordCompletion: 'true',
|
|
158
|
+
locale,
|
|
159
|
+
q: terms
|
|
160
|
+
}).toString();
|
|
161
|
+
return `${baseUrl}?${query}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function toRecent(recent: UserRecent): Recent {
|
|
165
|
+
return {
|
|
166
|
+
icon: recent.icon_url,
|
|
167
|
+
iconBackgroundColor: recent.color ? recent.color : undefined,
|
|
168
|
+
path: recent.path,
|
|
169
|
+
pretitle: recent.content_type,
|
|
170
|
+
title: recent.title
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type Config = {
|
|
2
|
+
coveo: {
|
|
3
|
+
locale: string;
|
|
4
|
+
querySuggestUrl: string;
|
|
5
|
+
};
|
|
6
|
+
labels: {
|
|
7
|
+
placeholder: string;
|
|
8
|
+
recentViewed: string;
|
|
9
|
+
recentFavorites: string;
|
|
10
|
+
};
|
|
11
|
+
searchUrl: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type CoveoCompletion = {
|
|
15
|
+
expression: string;
|
|
16
|
+
score: number;
|
|
17
|
+
highlighted: string;
|
|
18
|
+
executableConfidence: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type UserRecent = {
|
|
22
|
+
color: string | null;
|
|
23
|
+
completion: string | null;
|
|
24
|
+
content_type: string;
|
|
25
|
+
icon_url: string;
|
|
26
|
+
path: string;
|
|
27
|
+
title: string;
|
|
28
|
+
type: 'recent_favorite' | 'recent_item';
|
|
29
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`undefined: toMatchHTMLSnapshot 1`] = `"<head><meta name="salesforce-cache-max-age" content="0"><meta name="salesforce-brand" content="trailhead"><meta name="salesforce-community" content="/tbid-community-uri"><meta name="salesforce-use-min-js" content="false"><meta name="salesforce-init-handler" content="__tbid_init"><meta name="salesforce-login-handler" content="__tbid_login"><meta name="salesforce-logout-handler" content="__tbid_logout"><meta name="salesforce-mode" content="authprovider"><meta name="salesforce-redirect-uri" content="/tbid-redirect-uri"><meta name="salesforce-authprovider-login" content="/tbid-auth-provider-login-path"><meta name="salesforce-authprovider-signup" content="/tbid-auth-provider-signup-path"><script src="/tbid-community-uri/resource/authProviderEmbeddedLogin_v1_3"></script></head>"`;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import fetchMock from 'jest-fetch-mock';
|
|
2
|
+
|
|
3
|
+
import { html, renderIntoBody, nextTick } from 'shared/testutils';
|
|
4
|
+
|
|
5
|
+
import Tbid, {
|
|
6
|
+
EVENT_LOGIN,
|
|
7
|
+
EVENT_LOGOUT,
|
|
8
|
+
TRAILHEAD_EVENT_LOGIN,
|
|
9
|
+
TRAILHEAD_EVENT_LOGOUT,
|
|
10
|
+
TRAILHEAD_EVENT_SIGNUP,
|
|
11
|
+
TBID_EVENT_INIT,
|
|
12
|
+
TBID_EVENT_LOGIN,
|
|
13
|
+
TBID_EVENT_LOGOUT,
|
|
14
|
+
TBID_INIT,
|
|
15
|
+
TBID_LOGIN,
|
|
16
|
+
TBID_LOGOUT,
|
|
17
|
+
TBID_LOGOUT_PATH,
|
|
18
|
+
Lock,
|
|
19
|
+
LOCK_KEY,
|
|
20
|
+
LOCK_TIMEOUT
|
|
21
|
+
} from '../tbid';
|
|
22
|
+
|
|
23
|
+
customElements.define('th-tbid', Tbid.CustomElementConstructor);
|
|
24
|
+
|
|
25
|
+
const render = ({
|
|
26
|
+
authenticated = 'false',
|
|
27
|
+
loginTried = 'false'
|
|
28
|
+
}: { authenticated?: string; loginTried?: string } = {}) =>
|
|
29
|
+
renderIntoBody(
|
|
30
|
+
html`
|
|
31
|
+
<th-tbid
|
|
32
|
+
authenticated=${authenticated}
|
|
33
|
+
csrf-token="token"
|
|
34
|
+
login-redirect-path="/login-redirect-path"
|
|
35
|
+
login-status-path="/login-status-path"
|
|
36
|
+
login-tried=${loginTried}
|
|
37
|
+
logout-redirect-path="/logout-redirect-path"
|
|
38
|
+
tbid-auth-provider-login-path="/tbid-auth-provider-login-path"
|
|
39
|
+
tbid-auth-provider-signup-path="/tbid-auth-provider-signup-path"
|
|
40
|
+
tbid-community-uri="/tbid-community-uri"
|
|
41
|
+
tbid-redirect-uri="/tbid-redirect-uri"
|
|
42
|
+
></th-tbid>
|
|
43
|
+
`
|
|
44
|
+
) as unknown as Tbid;
|
|
45
|
+
|
|
46
|
+
let location = {};
|
|
47
|
+
|
|
48
|
+
Object.defineProperty(window, 'location', {
|
|
49
|
+
get: () => location
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
window.location.href = '/';
|
|
54
|
+
window.sessionStorage.removeItem(LOCK_KEY);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('th-tbid', () => {
|
|
58
|
+
afterEach(() => {
|
|
59
|
+
document.head.querySelectorAll('meta').forEach((n) => n.remove());
|
|
60
|
+
});
|
|
61
|
+
it('sets the correct meta tags', () => {
|
|
62
|
+
render();
|
|
63
|
+
expect(document.head.outerHTML).toMatchHTMLSnapshot();
|
|
64
|
+
});
|
|
65
|
+
it('sets the window globals', () => {
|
|
66
|
+
render();
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
expect(window[TBID_INIT]).toBeInstanceOf(Function);
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
expect(window[TBID_LOGIN]).toBeInstanceOf(Function);
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
expect(window[TBID_LOGOUT]).toBeInstanceOf(Function);
|
|
73
|
+
});
|
|
74
|
+
it(`handles the ${TRAILHEAD_EVENT_LOGIN} event`, () => {
|
|
75
|
+
render();
|
|
76
|
+
let fn = jest.fn();
|
|
77
|
+
Object.defineProperty(window, 'SFIDWidget', {
|
|
78
|
+
value: { login: fn },
|
|
79
|
+
writable: true
|
|
80
|
+
});
|
|
81
|
+
document.dispatchEvent(new CustomEvent(TRAILHEAD_EVENT_LOGIN));
|
|
82
|
+
expect(fn).toHaveBeenCalled();
|
|
83
|
+
});
|
|
84
|
+
it(`handles the ${TRAILHEAD_EVENT_LOGOUT} event`, async () => {
|
|
85
|
+
render();
|
|
86
|
+
let fn = jest.fn();
|
|
87
|
+
Object.defineProperty(window, 'SFIDWidget', {
|
|
88
|
+
value: { logout: fn },
|
|
89
|
+
writable: true
|
|
90
|
+
});
|
|
91
|
+
document.dispatchEvent(new CustomEvent(TRAILHEAD_EVENT_LOGOUT));
|
|
92
|
+
let iframe = document.body.querySelector(
|
|
93
|
+
`iframe[src="/tbid-community-uri${TBID_LOGOUT_PATH}"]`
|
|
94
|
+
);
|
|
95
|
+
expect(iframe).toBeInTheDocument();
|
|
96
|
+
iframe!.dispatchEvent(new CustomEvent('load'));
|
|
97
|
+
await nextTick();
|
|
98
|
+
expect(fn).toHaveBeenCalled();
|
|
99
|
+
});
|
|
100
|
+
it(`handles the ${TRAILHEAD_EVENT_SIGNUP}`, () => {
|
|
101
|
+
render();
|
|
102
|
+
let fn = jest.fn();
|
|
103
|
+
Object.defineProperty(window, 'SFIDWidget', {
|
|
104
|
+
value: { signup: fn },
|
|
105
|
+
writable: true
|
|
106
|
+
});
|
|
107
|
+
document.dispatchEvent(new CustomEvent(TRAILHEAD_EVENT_SIGNUP));
|
|
108
|
+
expect(fn).toHaveBeenCalled();
|
|
109
|
+
});
|
|
110
|
+
describe('onLogin', () => {
|
|
111
|
+
it('redirects if user is not_logged_in & login-tried != true', async () => {
|
|
112
|
+
fetchMock.doMockOnceIf(
|
|
113
|
+
(r) => r.url === '/login-status-path',
|
|
114
|
+
JSON.stringify({ user: 'not_logged_in' })
|
|
115
|
+
);
|
|
116
|
+
render();
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
await window[TBID_LOGIN]();
|
|
119
|
+
expect(window.location.href).toEqual('/login-redirect-path');
|
|
120
|
+
});
|
|
121
|
+
it('retries if there is a lock', async () => {
|
|
122
|
+
jest.useFakeTimers();
|
|
123
|
+
fetchMock.doMockIf(
|
|
124
|
+
(r) => r.url === '/login-status-path',
|
|
125
|
+
JSON.stringify({ user: 'not_logged_in' })
|
|
126
|
+
);
|
|
127
|
+
let element = render();
|
|
128
|
+
let onLogin = jest.fn();
|
|
129
|
+
element.addEventListener(TBID_EVENT_LOGIN, onLogin);
|
|
130
|
+
// A: No lock
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
await window[TBID_LOGIN]();
|
|
133
|
+
expect(onLogin).toHaveBeenCalledTimes(1);
|
|
134
|
+
expect(window.location.href).toEqual('/login-redirect-path');
|
|
135
|
+
window.location.href = '/';
|
|
136
|
+
// B: Lock
|
|
137
|
+
// @ts-ignore
|
|
138
|
+
await window[TBID_LOGIN]();
|
|
139
|
+
expect(onLogin).toHaveBeenCalledTimes(2);
|
|
140
|
+
expect(window.location.href).toEqual('/');
|
|
141
|
+
// C: Lock expired
|
|
142
|
+
let now = Date.now();
|
|
143
|
+
let nowMock = jest
|
|
144
|
+
.spyOn(Date, 'now')
|
|
145
|
+
.mockImplementation(() => now + LOCK_TIMEOUT);
|
|
146
|
+
jest.runAllTimers();
|
|
147
|
+
jest.useRealTimers();
|
|
148
|
+
await nextTick();
|
|
149
|
+
expect(onLogin).toHaveBeenCalledTimes(3);
|
|
150
|
+
nowMock.mockRestore();
|
|
151
|
+
fetchMock.resetMocks();
|
|
152
|
+
});
|
|
153
|
+
it('calls onInit if user is logged_in and authenticated', async () => {
|
|
154
|
+
fetchMock.doMockOnceIf(
|
|
155
|
+
(r) => r.url === '/login-status-path',
|
|
156
|
+
JSON.stringify({ user: 'logged_in' })
|
|
157
|
+
);
|
|
158
|
+
let element = render({ authenticated: 'true' });
|
|
159
|
+
let onInit = jest.fn();
|
|
160
|
+
element.addEventListener(TBID_EVENT_INIT, onInit);
|
|
161
|
+
// @ts-ignore
|
|
162
|
+
await window[TBID_LOGIN]();
|
|
163
|
+
expect(onInit).toHaveBeenCalled();
|
|
164
|
+
expect(window.sessionStorage.getItem(LOCK_KEY)).toBeNull();
|
|
165
|
+
});
|
|
166
|
+
it('calls onInit if user is not_logged_in and login-tried', async () => {
|
|
167
|
+
fetchMock.doMockOnceIf(
|
|
168
|
+
(r) => r.url === '/login-status-path',
|
|
169
|
+
JSON.stringify({ user: 'not_logged_in' })
|
|
170
|
+
);
|
|
171
|
+
let element = render({ loginTried: 'true' });
|
|
172
|
+
let onInit = jest.fn();
|
|
173
|
+
element.addEventListener(TBID_EVENT_INIT, onInit);
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
await window[TBID_LOGIN]();
|
|
176
|
+
expect(onInit).toHaveBeenCalled();
|
|
177
|
+
expect(window.sessionStorage.getItem(LOCK_KEY)).toBeNull();
|
|
178
|
+
});
|
|
179
|
+
it('dispatches login', () => {
|
|
180
|
+
fetchMock.doMockOnceIf(
|
|
181
|
+
(r) => r.url === '/login-status-path',
|
|
182
|
+
JSON.stringify({ user: 'not_logged_in' })
|
|
183
|
+
);
|
|
184
|
+
let element = render();
|
|
185
|
+
let fn = jest.fn();
|
|
186
|
+
element.addEventListener(EVENT_LOGIN, fn);
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
window[TBID_LOGIN]();
|
|
189
|
+
expect(fn).toHaveBeenCalled();
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
describe('onLogout', () => {
|
|
193
|
+
it('calls SFIDWidget.init()', () => {
|
|
194
|
+
render();
|
|
195
|
+
let init = jest.fn();
|
|
196
|
+
Object.defineProperty(window, 'SFIDWidget', {
|
|
197
|
+
value: { init },
|
|
198
|
+
writable: true
|
|
199
|
+
});
|
|
200
|
+
// @ts-ignore
|
|
201
|
+
window[TBID_LOGOUT]();
|
|
202
|
+
expect(init).toHaveBeenCalled();
|
|
203
|
+
});
|
|
204
|
+
it('redirects', () => {
|
|
205
|
+
render();
|
|
206
|
+
// @ts-ignore
|
|
207
|
+
window[TBID_LOGOUT]();
|
|
208
|
+
expect(window.location.href).toEqual('/logout-redirect-path');
|
|
209
|
+
});
|
|
210
|
+
it('dispatches logout', () => {
|
|
211
|
+
let element = render();
|
|
212
|
+
let fn = jest.fn();
|
|
213
|
+
element.addEventListener(EVENT_LOGOUT, fn);
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
window[TBID_LOGOUT]();
|
|
216
|
+
expect(fn).toHaveBeenCalled();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe('Lock', () => {
|
|
220
|
+
afterEach(() => {
|
|
221
|
+
window.sessionStorage.removeItem('tbid');
|
|
222
|
+
});
|
|
223
|
+
it('acquire', async () => {
|
|
224
|
+
let now = Date.now();
|
|
225
|
+
let lock = new Lock('tbid', 1000);
|
|
226
|
+
expect(lock.aquire()).toBe(true);
|
|
227
|
+
expect(lock.aquire()).toBe(false);
|
|
228
|
+
let mock = jest
|
|
229
|
+
.spyOn(Date, 'now')
|
|
230
|
+
.mockImplementation(() => now + 2000);
|
|
231
|
+
expect(lock.aquire()).toBe(true);
|
|
232
|
+
mock.mockRestore();
|
|
233
|
+
});
|
|
234
|
+
it('release', async () => {
|
|
235
|
+
let lock = new Lock('tbid', 1000);
|
|
236
|
+
expect(lock.aquire()).toBe(true);
|
|
237
|
+
expect(lock.aquire()).toBe(false);
|
|
238
|
+
lock.release();
|
|
239
|
+
expect(lock.aquire()).toBe(true);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<template></template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Meta } from "@storybook/addon-docs/blocks";
|
|
2
|
+
|
|
3
|
+
<Meta title="th/th-tbid" />
|
|
4
|
+
|
|
5
|
+
# Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<th-tbid
|
|
9
|
+
authenticated="false"
|
|
10
|
+
csrf-token="token"
|
|
11
|
+
login-redirect-path="/login-redirect-path"
|
|
12
|
+
login-status-path="/login-status-path"
|
|
13
|
+
login-tried="false"
|
|
14
|
+
logout-redirect-path="/logout-path"
|
|
15
|
+
tbid-auth-provider-login-path="/tbid-auth-provider-login-path"
|
|
16
|
+
tbid-auth-provider-signup-path="/tbid-auth-provider-signup-path"
|
|
17
|
+
tbid-community-uri="/tbid-community-uri"
|
|
18
|
+
tbid-redirect-uri="/tbid-redirect-uri"
|
|
19
|
+
></th-tbid>
|
|
20
|
+
|
|
21
|
+
<script
|
|
22
|
+
src="https://trailhead.salesforce.com/ui/modules/th-tbid.js"
|
|
23
|
+
type="module"
|
|
24
|
+
></script>
|
|
25
|
+
```
|