@salesforcedevs/arch-components 1.20.17-alpha4 → 1.20.17-alpha5
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/package.json +1 -1
- package/src/modules/common/effectAdapter/__tests__/effectAdapter.test.ts +0 -12
- package/src/modules/common/effectAdapter/effectAdapter.html +0 -1
- package/src/modules/common/effectAdapter/effectAdapter.ts +0 -24
- package/src/modules/common/reflectedElement/__tests__/modules/test/select/select.html +0 -3
- package/src/modules/common/reflectedElement/__tests__/modules/test/select/select.ts +0 -7
- package/src/modules/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.html +0 -3
- package/src/modules/common/reflectedElement/__tests__/modules/test/selectTransform/selectTransform.ts +0 -18
- package/src/modules/common/reflectedElement/__tests__/reflectedElement.test.ts +0 -75
- package/src/modules/common/reflectedElement/reflectedElement.ts +0 -50
- package/src/modules/common/slot/__tests__/slot.test.ts +0 -96
- package/src/modules/common/slot/slot.ts +0 -21
- package/src/modules/sa/coverage/coverage.css +0 -35
- package/src/modules/sa/coverage/coverage.html +0 -15
- package/src/modules/sa/coverage/coverage.ts +0 -402
- package/src/modules/sa/coverage/types.d.ts +0 -26
- package/src/modules/sa/expandableSection/expandableSection.css +0 -24
- package/src/modules/sa/expandableSection/expandableSection.html +0 -20
- package/src/modules/sa/expandableSection/expandableSection.stories.ts +0 -37
- package/src/modules/sa/expandableSection/expandableSection.ts +0 -24
- package/src/modules/sa/explorer/explorer.css +0 -303
- package/src/modules/sa/explorer/explorer.html +0 -403
- package/src/modules/sa/explorer/explorer.ts +0 -664
- package/src/modules/sa/explorer/types.d.ts +0 -60
- package/src/modules/sa/gallery/gallery.css +0 -358
- package/src/modules/sa/gallery/gallery.html +0 -65
- package/src/modules/sa/gallery/gallery.ts +0 -300
- package/src/modules/sa/gallery/types.d.ts +0 -35
- package/src/modules/sa/socialShare/socialShare.css +0 -49
- package/src/modules/sa/socialShare/socialShare.html +0 -56
- package/src/modules/sa/socialShare/socialShare.ts +0 -29
- package/src/modules/shared/a11y/a11y.ts +0 -25
- package/src/modules/shared/children/children.ts +0 -29
- package/src/modules/shared/color/color.ts +0 -52
- package/src/modules/shared/debounce/debounce.ts +0 -32
- package/src/modules/shared/dialog/dialog.ts +0 -154
- package/src/modules/shared/elements/__tests__/overflow.test.ts +0 -39
- package/src/modules/shared/elements/overflow.ts +0 -71
- package/src/modules/shared/fetch/fetch.ts +0 -52
- package/src/modules/shared/helpers/helpers.ts +0 -141
- package/src/modules/shared/i18n/i18n.ts +0 -74
- package/src/modules/shared/labels/__tests__/helpers.test.ts +0 -107
- package/src/modules/shared/labels/__tests__/pointHelpers.test.ts +0 -33
- package/src/modules/shared/labels/__tests__/timeHelpers.test.ts +0 -89
- package/src/modules/shared/labels/helpers.ts +0 -23
- package/src/modules/shared/labels/pointHelpers.ts +0 -47
- package/src/modules/shared/labels/timeHelpers.ts +0 -182
- package/src/modules/shared/labels/types.d.ts +0 -5
- package/src/modules/shared/logger/logger.ts +0 -33
- package/src/modules/shared/menu/menu.ts +0 -239
- package/src/modules/shared/overflow/__tests__/overflow.test.ts +0 -39
- package/src/modules/shared/overflow/overflow.ts +0 -71
- package/src/modules/shared/polling-request.ts +0 -97
- package/src/modules/shared/testutils.ts +0 -118
- package/src/modules/shared/track/track.ts +0 -23
- package/src/modules/shared/trailhead.ts +0 -123
- package/src/modules/shared/types.d.ts +0 -1
- package/src/modules/shared/useEffectAttr.ts +0 -16
- package/src/modules/shared/withState.ts +0 -21
- package/src/modules/tds/appLauncher/__fixtures__/index.ts +0 -34
- package/src/modules/tds/appLauncher/__tests__/appLauncher.test.ts +0 -119
- package/src/modules/tds/appLauncher/appLauncher.css +0 -65
- package/src/modules/tds/appLauncher/appLauncher.html +0 -38
- package/src/modules/tds/appLauncher/appLauncher.stories.ts +0 -39
- package/src/modules/tds/appLauncher/appLauncher.ts +0 -79
- package/src/modules/tds/appLauncher/types.ts +0 -8
- package/src/modules/tds/avatar/__tests__/avatar.test.ts +0 -11
- package/src/modules/tds/avatar/avatar.css +0 -77
- package/src/modules/tds/avatar/avatar.html +0 -36
- package/src/modules/tds/avatar/avatar.stories.ts +0 -64
- package/src/modules/tds/avatar/avatar.ts +0 -50
- package/src/modules/tds/badge/__tests__/badge.test.js +0 -11
- package/src/modules/tds/badge/badge.css +0 -22
- package/src/modules/tds/badge/badge.html +0 -5
- package/src/modules/tds/badge/badge.stories.ts +0 -10
- package/src/modules/tds/badge/badge.ts +0 -9
- package/src/modules/tds/button/__tests__/button.test.ts +0 -52
- package/src/modules/tds/button/button.css +0 -1
- package/src/modules/tds/button/button.html +0 -20
- package/src/modules/tds/button/button.stories.js +0 -54
- package/src/modules/tds/button/button.ts +0 -59
- package/src/modules/tds/buttonIcon/__tests__/buttonIcon.test.ts +0 -17
- package/src/modules/tds/buttonIcon/buttonIcon.css +0 -1
- package/src/modules/tds/buttonIcon/buttonIcon.html +0 -12
- package/src/modules/tds/buttonIcon/buttonIcon.stories.js +0 -38
- package/src/modules/tds/buttonIcon/buttonIcon.ts +0 -6
- package/src/modules/tds/buttonIconLink/buttonIconLink.css +0 -1
- package/src/modules/tds/buttonIconLink/buttonIconLink.html +0 -14
- package/src/modules/tds/buttonIconLink/buttonIconLink.stories.ts +0 -32
- package/src/modules/tds/buttonIconLink/buttonIconLink.ts +0 -9
- package/src/modules/tds/buttonLink/__tests__/buttonLink.test.ts +0 -17
- package/src/modules/tds/buttonLink/buttonLink.css +0 -1
- package/src/modules/tds/buttonLink/buttonLink.html +0 -19
- package/src/modules/tds/buttonLink/buttonLink.stories.js +0 -24
- package/src/modules/tds/buttonLink/buttonLink.ts +0 -8
- package/src/modules/tds/buttonStyles/buttonStyles.css +0 -232
- package/src/modules/tds/childSummary/__tests__/childSummary.test.js +0 -99
- package/src/modules/tds/childSummary/childSummary.css +0 -74
- package/src/modules/tds/childSummary/childSummary.html +0 -38
- package/src/modules/tds/childSummary/childSummary.stories.ts +0 -40
- package/src/modules/tds/childSummary/childSummary.ts +0 -63
- package/src/modules/tds/childSummary/types.d.ts +0 -10
- package/src/modules/tds/contentChildListItem/__tests__/contentChildListItem.test.ts +0 -32
- package/src/modules/tds/contentChildListItem/contentChildListItem.css +0 -1
- package/src/modules/tds/contentChildListItem/contentChildListItem.html +0 -10
- package/src/modules/tds/contentChildListItem/contentChildListItem.stories.ts +0 -46
- package/src/modules/tds/contentChildListItem/contentChildListItem.ts +0 -34
- package/src/modules/tds/contentIcon/contentIcon.css +0 -47
- package/src/modules/tds/contentIcon/contentIcon.html +0 -15
- package/src/modules/tds/contentIcon/contentIcon.stories.js +0 -110
- package/src/modules/tds/contentIcon/contentIcon.ts +0 -66
- package/src/modules/tds/contextAdapter/__tests__/contextAdapter.test.ts +0 -76
- package/src/modules/tds/contextAdapter/constants.ts +0 -1
- package/src/modules/tds/contextAdapter/contextAdapter.html +0 -1
- package/src/modules/tds/contextAdapter/contextAdapter.ts +0 -54
- package/src/modules/tds/dialogStyles/dialogStyles.css +0 -90
- package/src/modules/tds/footerLinks/__tests__/__snapshots__/footerLinks.test.ts.snap +0 -3
- package/src/modules/tds/footerLinks/__tests__/footerLinks.test.ts +0 -142
- package/src/modules/tds/footerLinks/footerLinks.css +0 -80
- package/src/modules/tds/footerLinks/footerLinks.html +0 -30
- package/src/modules/tds/footerLinks/footerLinks.ts +0 -48
- package/src/modules/tds/footerLinks/types.ts +0 -11
- package/src/modules/tds/footerMfe/footerMfe.html +0 -3
- package/src/modules/tds/footerMfe/footerMfe.ts +0 -19
- package/src/modules/tds/headerAvatar/__tests__/headerAvatar.test.ts +0 -43
- package/src/modules/tds/headerAvatar/headerAvatar.css +0 -45
- package/src/modules/tds/headerAvatar/headerAvatar.html +0 -25
- package/src/modules/tds/headerAvatar/headerAvatar.ts +0 -15
- package/src/modules/tds/headerHelpButton/__tests__/headerHelpButton.test.ts +0 -32
- package/src/modules/tds/headerHelpButton/headerHelpButton.css +0 -14
- package/src/modules/tds/headerHelpButton/headerHelpButton.html +0 -19
- package/src/modules/tds/headerHelpButton/headerHelpButton.ts +0 -12
- package/src/modules/tds/heading/__tests__/heading.test.ts +0 -50
- package/src/modules/tds/heading/heading.css +0 -1
- package/src/modules/tds/heading/heading.html +0 -9
- package/src/modules/tds/heading/heading.stories.ts +0 -36
- package/src/modules/tds/heading/heading.ts +0 -36
- package/src/modules/tds/icon/icon.css +0 -28
- package/src/modules/tds/icon/icon.html +0 -17
- package/src/modules/tds/icon/icon.stories.js +0 -18
- package/src/modules/tds/icon/icon.ts +0 -79
- package/src/modules/tds/input/__tests__/input.test.ts +0 -41
- package/src/modules/tds/input/input.css +0 -34
- package/src/modules/tds/input/input.html +0 -12
- package/src/modules/tds/input/input.stories.ts +0 -25
- package/src/modules/tds/input/input.ts +0 -41
- package/src/modules/tds/instrumentation/instrumentation.css +0 -0
- package/src/modules/tds/instrumentation/instrumentation.html +0 -1
- package/src/modules/tds/instrumentation/instrumentation.ts +0 -113
- package/src/modules/tds/pbCard/pbCard.css +0 -28
- package/src/modules/tds/pbCard/pbCard.html +0 -21
- package/src/modules/tds/pbCard/pbCard.ts +0 -18
- package/src/modules/tds/pill/__tests__/pill.test.ts +0 -56
- package/src/modules/tds/pill/pill.css +0 -70
- package/src/modules/tds/pill/pill.html +0 -17
- package/src/modules/tds/pill/pill.stories.ts +0 -41
- package/src/modules/tds/pill/pill.ts +0 -34
- package/src/modules/tds/progressBar/__tests__/progressBar.test.js +0 -11
- package/src/modules/tds/progressBar/progressBar.css +0 -42
- package/src/modules/tds/progressBar/progressBar.html +0 -14
- package/src/modules/tds/progressBar/progressBar.stories.ts +0 -24
- package/src/modules/tds/progressBar/progressBar.ts +0 -14
- package/src/modules/tds/radio/__tests__/radio.test.ts +0 -29
- package/src/modules/tds/radio/radio.css +0 -89
- package/src/modules/tds/radio/radio.html +0 -17
- package/src/modules/tds/radio/radio.stories.ts +0 -31
- package/src/modules/tds/radio/radio.ts +0 -32
- package/src/modules/tds/reset/reset.css +0 -39
- package/src/modules/tds/search/__fixtures__/index.ts +0 -32
- package/src/modules/tds/search/__tests__/search.test.ts +0 -235
- package/src/modules/tds/search/lib/__tests__/__snapshots__/listbox.test.ts.snap +0 -115
- package/src/modules/tds/search/lib/__tests__/listbox.test.ts +0 -192
- package/src/modules/tds/search/lib/listbox.ts +0 -209
- package/src/modules/tds/search/search.css +0 -122
- package/src/modules/tds/search/search.html +0 -21
- package/src/modules/tds/search/search.stories.ts +0 -20
- package/src/modules/tds/search/search.ts +0 -107
- package/src/modules/tds/search/types.d.ts +0 -22
- package/src/modules/tds/searchList/searchList.css +0 -120
- package/src/modules/tds/searchList/searchList.html +0 -43
- package/src/modules/tds/searchList/searchList.stories.ts +0 -10
- package/src/modules/tds/searchList/searchList.ts +0 -53
- package/src/modules/tds/select/__tests__/select.test.ts +0 -150
- package/src/modules/tds/select/select.css +0 -42
- package/src/modules/tds/select/select.html +0 -24
- package/src/modules/tds/select/select.stories.ts +0 -59
- package/src/modules/tds/select/select.ts +0 -60
- package/src/modules/tds/spinner/__tests__/spinner.test.ts +0 -11
- package/src/modules/tds/spinner/spinner.css +0 -194
- package/src/modules/tds/spinner/spinner.html +0 -9
- package/src/modules/tds/spinner/spinner.stories.ts +0 -20
- package/src/modules/tds/spinner/spinner.ts +0 -15
- package/src/modules/tds/styles/styles.css +0 -24
- package/src/modules/tds/summary/__tests__/summary.test.ts +0 -135
- package/src/modules/tds/summary/summary.css +0 -135
- package/src/modules/tds/summary/summary.html +0 -69
- package/src/modules/tds/summary/summary.stories.js +0 -148
- package/src/modules/tds/summary/summary.ts +0 -95
- package/src/modules/tds/tab/__tests__/tab.test.ts +0 -25
- package/src/modules/tds/tab/tab.css +0 -3
- package/src/modules/tds/tab/tab.html +0 -5
- package/src/modules/tds/tab/tab.ts +0 -46
- package/src/modules/tds/tabset/__tests__/tabset.test.ts +0 -108
- package/src/modules/tds/tabset/tabset.css +0 -112
- package/src/modules/tds/tabset/tabset.html +0 -63
- package/src/modules/tds/tabset/tabset.stories.ts +0 -32
- package/src/modules/tds/tabset/tabset.ts +0 -232
- package/src/modules/tds/themeProvider/themeProvider.css +0 -502
- package/src/modules/tds/themeProvider/themeProvider.html +0 -3
- package/src/modules/tds/themeProvider/themeProvider.ts +0 -37
- package/src/modules/tds/tile/tile.css +0 -23
- package/src/modules/tds/tile/tile.html +0 -5
- package/src/modules/tds/tile/tile.stories.js +0 -14
- package/src/modules/tds/tile/tile.ts +0 -12
- package/src/modules/tds/xsfMfeEvents/xsfMfeEvents.html +0 -1
- package/src/modules/tds/xsfMfeEvents/xsfMfeEvents.ts +0 -47
- package/src/modules/th/contextAdapter/__tests__/contextAdapter.test.ts +0 -104
- package/src/modules/th/contextAdapter/contextAdapter.html +0 -1
- package/src/modules/th/contextAdapter/contextAdapter.ts +0 -49
- package/src/modules/th/favoriteButton/__tests__/favoriteButton.test.ts +0 -56
- package/src/modules/th/favoriteButton/favoriteButton.css +0 -3
- package/src/modules/th/favoriteButton/favoriteButton.html +0 -15
- package/src/modules/th/favoriteButton/favoriteButton.stories.js +0 -30
- package/src/modules/th/favoriteButton/favoriteButton.ts +0 -84
- package/src/modules/th/favoriteButton/mocks/index.ts +0 -12
- package/src/modules/th/search/__fixtures__/index.ts +0 -14
- package/src/modules/th/search/__tests__/search.test.ts +0 -233
- package/src/modules/th/search/constants.ts +0 -2
- package/src/modules/th/search/mocks/index.ts +0 -30
- package/src/modules/th/search/mocks/responses.ts +0 -54
- package/src/modules/th/search/search.css +0 -4
- package/src/modules/th/search/search.html +0 -12
- package/src/modules/th/search/search.ts +0 -172
- package/src/modules/th/search/types.d.ts +0 -29
- package/src/modules/tm/card/__tests__/card.test.ts +0 -65
- package/src/modules/tm/card/card.css +0 -131
- package/src/modules/tm/card/card.html +0 -81
- package/src/modules/tm/card/card.ts +0 -269
- package/src/modules/tm/cardBase/cardBase.css +0 -11
- package/src/modules/tm/cardGridA/cardGridA.css +0 -11
- package/src/modules/tm/cardGridA/cardGridA.html +0 -21
- package/src/modules/tm/cardGridA/cardGridA.stories.js +0 -107
- package/src/modules/tm/cardGridA/cardGridA.ts +0 -24
- package/src/modules/tm/cardGridB/cardGridB.css +0 -88
- package/src/modules/tm/cardGridB/cardGridB.html +0 -20
- package/src/modules/tm/cardGridB/cardGridB.stories.js +0 -58
- package/src/modules/tm/cardGridB/cardGridB.ts +0 -19
- package/src/modules/tm/cardGridC/cardGridC.css +0 -24
- package/src/modules/tm/cardGridC/cardGridC.html +0 -22
- package/src/modules/tm/cardGridC/cardGridC.stories.js +0 -42
- package/src/modules/tm/cardGridC/cardGridC.ts +0 -11
- package/src/modules/tm/cardGridD/cardGridD.css +0 -17
- package/src/modules/tm/cardGridD/cardGridD.html +0 -20
- package/src/modules/tm/cardGridD/cardGridD.stories.js +0 -34
- package/src/modules/tm/cardGridD/cardGridD.ts +0 -7
- package/src/modules/tm/cardNew/cardNew.css +0 -31
- package/src/modules/tm/cardNew/cardNew.html +0 -29
- package/src/modules/tm/cardNew/cardNew.ts +0 -66
- package/src/modules/tm/content/__fixtures__/index.ts +0 -884
- package/src/modules/tm/content/__tests__/content.test.ts +0 -95
- package/src/modules/tm/content/content.css +0 -641
- package/src/modules/tm/content/content.html +0 -53
- package/src/modules/tm/content/content.stories.js +0 -14
- package/src/modules/tm/content/content.ts +0 -171
- package/src/modules/tm/endCapA/__tests__/endCapA.test.ts +0 -52
- package/src/modules/tm/endCapA/endCapA.css +0 -64
- package/src/modules/tm/endCapA/endCapA.html +0 -21
- package/src/modules/tm/endCapA/endCapA.stories.js +0 -37
- package/src/modules/tm/endCapA/endCapA.ts +0 -23
- package/src/modules/tm/eventsA/eventsA.css +0 -107
- package/src/modules/tm/eventsA/eventsA.html +0 -26
- package/src/modules/tm/eventsA/eventsA.stories.js +0 -51
- package/src/modules/tm/eventsA/eventsA.ts +0 -48
- package/src/modules/tm/faqA/faqA.css +0 -87
- package/src/modules/tm/faqA/faqA.html +0 -27
- package/src/modules/tm/faqA/faqA.stories.js +0 -25
- package/src/modules/tm/faqA/faqA.ts +0 -40
- package/src/modules/tm/featureGridA/__tests__/featureGridA.test.ts +0 -116
- package/src/modules/tm/featureGridA/featureGridA.css +0 -95
- package/src/modules/tm/featureGridA/featureGridA.html +0 -34
- package/src/modules/tm/featureGridA/featureGridA.stories.js +0 -45
- package/src/modules/tm/featureGridA/featureGridA.ts +0 -59
- package/src/modules/tm/footnote/footnote.css +0 -28
- package/src/modules/tm/footnote/footnote.html +0 -3
- package/src/modules/tm/footnote/footnote.stories.js +0 -29
- package/src/modules/tm/footnote/footnote.ts +0 -35
- package/src/modules/tm/heroA/__tests__/heroA.test.ts +0 -51
- package/src/modules/tm/heroA/heroA.css +0 -116
- package/src/modules/tm/heroA/heroA.html +0 -27
- package/src/modules/tm/heroA/heroA.stories.js +0 -49
- package/src/modules/tm/heroA/heroA.ts +0 -56
- package/src/modules/tm/heroB/heroB.css +0 -78
- package/src/modules/tm/heroB/heroB.html +0 -26
- package/src/modules/tm/heroB/heroB.stories.js +0 -44
- package/src/modules/tm/heroB/heroB.ts +0 -26
- package/src/modules/tm/page/__tests__/page.test.ts +0 -35
- package/src/modules/tm/page/page.css +0 -3
- package/src/modules/tm/page/page.html +0 -3
- package/src/modules/tm/page/page.stories.js +0 -10
- package/src/modules/tm/page/page.ts +0 -3
- package/src/modules/tm/pageHeaderA/pageHeaderA.css +0 -82
- package/src/modules/tm/pageHeaderA/pageHeaderA.html +0 -24
- package/src/modules/tm/pageHeaderA/pageHeaderA.stories.js +0 -18
- package/src/modules/tm/pageHeaderA/pageHeaderA.ts +0 -51
- package/src/modules/tm/pageNavigationA/pageNavigationA.css +0 -41
- package/src/modules/tm/pageNavigationA/pageNavigationA.html +0 -9
- package/src/modules/tm/pageNavigationA/pageNavigationA.stories.js +0 -34
- package/src/modules/tm/pageNavigationA/pageNavigationA.ts +0 -18
- package/src/modules/tm/promoA/__tests__/promoA.test.ts +0 -89
- package/src/modules/tm/promoA/promoA.css +0 -95
- package/src/modules/tm/promoA/promoA.html +0 -22
- package/src/modules/tm/promoA/promoA.stories.js +0 -38
- package/src/modules/tm/promoA/promoA.ts +0 -62
- package/src/modules/tm/sectionA/sectionA.css +0 -64
- package/src/modules/tm/sectionA/sectionA.html +0 -21
- package/src/modules/tm/sectionA/sectionA.stories.js +0 -18
- package/src/modules/tm/sectionA/sectionA.ts +0 -27
- package/src/modules/tm/sectionSpacer/sectionSpacer.css +0 -4
- package/src/modules/tm/sectionSpacer/sectionSpacer.html +0 -1
- package/src/modules/tm/sectionSpacer/sectionSpacer.ts +0 -3
- package/src/modules/tm/skillsCardA/skillsCardA.css +0 -73
- package/src/modules/tm/skillsCardA/skillsCardA.html +0 -37
- package/src/modules/tm/skillsCardA/skillsCardA.ts +0 -38
- package/src/modules/tm/skillsGridA/skillsGridA.css +0 -12
- package/src/modules/tm/skillsGridA/skillsGridA.html +0 -5
- package/src/modules/tm/skillsGridA/skillsGridA.stories.ts +0 -65
- package/src/modules/tm/skillsGridA/skillsGridA.ts +0 -3
- package/src/modules/tm/statsA/statsA.css +0 -26
- package/src/modules/tm/statsA/statsA.html +0 -10
- package/src/modules/tm/statsA/statsA.stories.js +0 -29
- package/src/modules/tm/statsA/statsA.ts +0 -20
- package/src/modules/tm/textItem/textItem.css +0 -53
- package/src/modules/tm/textItem/textItem.html +0 -18
- package/src/modules/tm/textItem/textItem.ts +0 -32
- package/src/modules/tm/textItemGridA/textItemGridA.css +0 -11
- package/src/modules/tm/textItemGridA/textItemGridA.html +0 -15
- package/src/modules/tm/textItemGridA/textItemGridA.stories.js +0 -67
- package/src/modules/tm/textItemGridA/textItemGridA.ts +0 -20
- package/src/modules/tm/threeCardGrid/threeCardGrid.css +0 -6
- package/src/modules/tm/threeCardGrid/threeCardGrid.html +0 -5
- package/src/modules/tm/threeCardGrid/threeCardGrid.ts +0 -3
- package/src/modules/tm/trailblazersA/trailblazersA.css +0 -70
- package/src/modules/tm/trailblazersA/trailblazersA.html +0 -42
- package/src/modules/tm/trailblazersA/trailblazersA.stories.js +0 -52
- package/src/modules/tm/trailblazersA/trailblazersA.ts +0 -43
- package/src/modules/tm/utils/utils.ts +0 -18
- package/src/modules/tm/youtube/youtube.css +0 -7
- package/src/modules/tm/youtube/youtube.html +0 -10
- package/src/modules/tm/youtube/youtube.stories.js +0 -15
- package/src/modules/tm/youtube/youtube.ts +0 -27
- package/src/modules/ui/focusTrap/focusTrap.html +0 -5
- package/src/modules/ui/focusTrap/focusTrap.ts +0 -104
- package/src/modules/ui/focusVisible/__tests__/focusVisible.test.ts +0 -95
- package/src/modules/ui/focusVisible/focusVisible.html +0 -3
- package/src/modules/ui/focusVisible/focusVisible.ts +0 -46
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Instance as PopperInstance,
|
|
3
|
-
Placement as PopperPlacement
|
|
4
|
-
} from '@popperjs/core';
|
|
5
|
-
|
|
6
|
-
export type DialogState = {
|
|
7
|
-
isOpen?: boolean;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type Placement =
|
|
11
|
-
| 'top'
|
|
12
|
-
| 'top left'
|
|
13
|
-
| 'top right'
|
|
14
|
-
| 'right'
|
|
15
|
-
| 'right top'
|
|
16
|
-
| 'right bottom'
|
|
17
|
-
| 'bottom'
|
|
18
|
-
| 'bottom left'
|
|
19
|
-
| 'bottom right'
|
|
20
|
-
| 'left'
|
|
21
|
-
| 'left top'
|
|
22
|
-
| 'left bottom';
|
|
23
|
-
|
|
24
|
-
const DEFAULT_PLACEMENT = 'top';
|
|
25
|
-
const NUBBIN_SIZE = 14;
|
|
26
|
-
|
|
27
|
-
export class Dialog {
|
|
28
|
-
constructor(
|
|
29
|
-
private trigger: HTMLElement,
|
|
30
|
-
private dialog: HTMLElement,
|
|
31
|
-
private options: {
|
|
32
|
-
placement?: Placement;
|
|
33
|
-
onChange?: (Partial: DialogState) => void;
|
|
34
|
-
} = {}
|
|
35
|
-
) {
|
|
36
|
-
this.create();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
popper: PopperInstance | null = null;
|
|
40
|
-
|
|
41
|
-
private _state: DialogState = { isOpen: false };
|
|
42
|
-
|
|
43
|
-
get state(): DialogState {
|
|
44
|
-
return this._state;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
set state(nextState: DialogState) {
|
|
48
|
-
this._state = { ...this._state, ...nextState };
|
|
49
|
-
|
|
50
|
-
if (this.options.onChange) {
|
|
51
|
-
this.options.onChange(this.state);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private async create() {
|
|
56
|
-
const modifiers = [
|
|
57
|
-
{
|
|
58
|
-
name: 'flip',
|
|
59
|
-
options: {
|
|
60
|
-
padding: NUBBIN_SIZE
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'hide',
|
|
65
|
-
enabled: false
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'preventOverflow',
|
|
69
|
-
options: {
|
|
70
|
-
padding: {
|
|
71
|
-
top: 2,
|
|
72
|
-
bottom: 2,
|
|
73
|
-
left: 5,
|
|
74
|
-
right: 5
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: 'offset',
|
|
80
|
-
options: {
|
|
81
|
-
offset: ({ placement, reference }: any) => {
|
|
82
|
-
if (placement.match(/^(top|bottom)/)) {
|
|
83
|
-
return [0, NUBBIN_SIZE];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (placement.match(/end?/)) {
|
|
87
|
-
return [(reference.height / 2) * 1, NUBBIN_SIZE];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (placement.match(/start?/)) {
|
|
91
|
-
return [(reference.height / 2) * -1, NUBBIN_SIZE];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return [0, NUBBIN_SIZE];
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
];
|
|
99
|
-
const { createPopper } = await import('@popperjs/core');
|
|
100
|
-
|
|
101
|
-
this.popper = createPopper(this.trigger, this.dialog, {
|
|
102
|
-
placement: this.getPlacement(this.options.placement),
|
|
103
|
-
modifiers
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Show
|
|
107
|
-
this.trigger.addEventListener('mouseenter', this.show.bind(this));
|
|
108
|
-
this.trigger.addEventListener('focusin', this.show.bind(this));
|
|
109
|
-
|
|
110
|
-
// Hide
|
|
111
|
-
this.trigger.addEventListener('mouseleave', this.hide.bind(this));
|
|
112
|
-
this.trigger.addEventListener('focusout', this.hide.bind(this));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
destroy() {
|
|
116
|
-
this.popper!.destroy();
|
|
117
|
-
this.popper = null;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private async show() {
|
|
121
|
-
await this.popper!.update();
|
|
122
|
-
this.state = { isOpen: true };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private hide() {
|
|
126
|
-
this.state = { isOpen: false };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Map the "placement" property used by SLDS to the correct Popper "placement"
|
|
130
|
-
private getPlacement(
|
|
131
|
-
placement: Placement = DEFAULT_PLACEMENT
|
|
132
|
-
): PopperPlacement {
|
|
133
|
-
switch (placement) {
|
|
134
|
-
case 'top left':
|
|
135
|
-
return 'top-start';
|
|
136
|
-
case 'top right':
|
|
137
|
-
return 'top-end';
|
|
138
|
-
case 'right top':
|
|
139
|
-
return 'right-start';
|
|
140
|
-
case 'right bottom':
|
|
141
|
-
return 'right-end';
|
|
142
|
-
case 'bottom left':
|
|
143
|
-
return 'bottom-start';
|
|
144
|
-
case 'bottom right':
|
|
145
|
-
return 'bottom-end';
|
|
146
|
-
case 'left top':
|
|
147
|
-
return 'left-start';
|
|
148
|
-
case 'left bottom':
|
|
149
|
-
return 'left-end';
|
|
150
|
-
default:
|
|
151
|
-
return placement;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { calculateOverflow } from '../overflow';
|
|
2
|
-
|
|
3
|
-
describe('calculateOverflow()', () => {
|
|
4
|
-
const ITEMS = [
|
|
5
|
-
{ active: false, width: 100 },
|
|
6
|
-
{ active: false, width: 200 },
|
|
7
|
-
{ active: false, width: 100 }
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
it('returns visibleItems and overflowItems', () => {
|
|
11
|
-
const { visibleItems, overflowItems } = calculateOverflow(
|
|
12
|
-
ITEMS,
|
|
13
|
-
360,
|
|
14
|
-
50
|
|
15
|
-
);
|
|
16
|
-
expect(visibleItems).toHaveLength(2);
|
|
17
|
-
expect(overflowItems).toHaveLength(1);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('ensures an active item is always visible', () => {
|
|
21
|
-
const { visibleItems, overflowItems } = calculateOverflow(
|
|
22
|
-
[...ITEMS, { active: true, width: 300 }],
|
|
23
|
-
360,
|
|
24
|
-
50
|
|
25
|
-
);
|
|
26
|
-
expect(visibleItems.find((i) => i.width === 300)).toBeTruthy();
|
|
27
|
-
expect(overflowItems).toHaveLength(3);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('handles bad input', () => {
|
|
31
|
-
const badItems = calculateOverflow([], 360, 50);
|
|
32
|
-
expect(badItems.visibleItems).toHaveLength(0);
|
|
33
|
-
expect(badItems.overflowItems).toHaveLength(0);
|
|
34
|
-
|
|
35
|
-
const badWidths = calculateOverflow(ITEMS);
|
|
36
|
-
expect(badWidths.visibleItems).toHaveLength(ITEMS.length);
|
|
37
|
-
expect(badWidths.overflowItems).toHaveLength(0);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Utilities for dealing with element overflows (execeeding container width)
|
|
3
|
-
* Based on https://sfdc.co/uOYl6
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export type CalculateOverflowItem = {
|
|
7
|
-
active: boolean;
|
|
8
|
-
value?: string;
|
|
9
|
-
width: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export function calculateOverflow(
|
|
13
|
-
items: CalculateOverflowItem[],
|
|
14
|
-
containerWidth: number = 0,
|
|
15
|
-
overflowWidth: number = 0
|
|
16
|
-
) {
|
|
17
|
-
const visibleItems: CalculateOverflowItem[] = [];
|
|
18
|
-
const overflowItems: CalculateOverflowItem[] = [];
|
|
19
|
-
|
|
20
|
-
const allItemsWidth = items.reduce(
|
|
21
|
-
(totalWidth, item) => totalWidth + item.width,
|
|
22
|
-
0
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
// If total items width is less than containerwidth or if the containerwidth is
|
|
26
|
-
// less than zero in cases where container is not yet rendered and we subtract the threshold
|
|
27
|
-
// return all items as visibleItems and overflowItems empty
|
|
28
|
-
if (allItemsWidth <= containerWidth || containerWidth <= 0) {
|
|
29
|
-
return { visibleItems: items, overflowItems };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Not all items fit, an overflow is needed
|
|
33
|
-
let totalWidth = overflowWidth;
|
|
34
|
-
|
|
35
|
-
// Find the active item if it exists
|
|
36
|
-
const activeItem = items.find((i) => i.active);
|
|
37
|
-
|
|
38
|
-
// The active item is always shown, so reserve space for it
|
|
39
|
-
if (activeItem) {
|
|
40
|
-
totalWidth += activeItem.width;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let activeItemFitsWithoutRearrangement = false;
|
|
44
|
-
|
|
45
|
-
items.forEach((item) => {
|
|
46
|
-
if (item.active) {
|
|
47
|
-
activeItemFitsWithoutRearrangement = overflowItems.length === 0;
|
|
48
|
-
if (activeItemFitsWithoutRearrangement) {
|
|
49
|
-
visibleItems.push(item);
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
const itemFits = item.width + totalWidth <= containerWidth;
|
|
53
|
-
if (itemFits && overflowItems.length === 0) {
|
|
54
|
-
totalWidth += item.width;
|
|
55
|
-
visibleItems.push(item);
|
|
56
|
-
} else {
|
|
57
|
-
overflowItems.push(item);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Place the active item at the end
|
|
63
|
-
if (activeItem && !activeItemFitsWithoutRearrangement) {
|
|
64
|
-
visibleItems.push(activeItem);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
visibleItems,
|
|
69
|
-
overflowItems
|
|
70
|
-
};
|
|
71
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export function csrfHeader(token: string = '') {
|
|
2
|
-
return {
|
|
3
|
-
'X-CSRF-Token': token
|
|
4
|
-
};
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function fetch(url: string, { ...options }: globalThis.RequestInit = {}) {
|
|
8
|
-
return window.fetch(url, {
|
|
9
|
-
...options,
|
|
10
|
-
credentials: 'same-origin'
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function fetchJSON<T>(
|
|
15
|
-
url: string,
|
|
16
|
-
{ headers, ...options }: globalThis.RequestInit = {}
|
|
17
|
-
) {
|
|
18
|
-
return fetch(url, {
|
|
19
|
-
...options,
|
|
20
|
-
headers: {
|
|
21
|
-
...headers,
|
|
22
|
-
Accept: 'application/json; charset=utf-8'
|
|
23
|
-
}
|
|
24
|
-
}).then(async (response) => {
|
|
25
|
-
if (response.ok) {return response.json() as Promise<T>;}
|
|
26
|
-
if (/json/.test(String(response.headers.get('Content-Type'))))
|
|
27
|
-
{return response
|
|
28
|
-
.json()
|
|
29
|
-
.then((errorJSON) => Promise.reject(errorJSON));}
|
|
30
|
-
throw new Error(
|
|
31
|
-
`Application error code ${response.status} for "${url}"`
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { fetchJSON as getJSON };
|
|
37
|
-
|
|
38
|
-
export function postJSON<T>(
|
|
39
|
-
url: string,
|
|
40
|
-
body?: object,
|
|
41
|
-
{ headers, method = 'POST', ...options }: globalThis.RequestInit = {}
|
|
42
|
-
) {
|
|
43
|
-
return fetchJSON<T>(url, {
|
|
44
|
-
...options,
|
|
45
|
-
method,
|
|
46
|
-
headers: {
|
|
47
|
-
...headers,
|
|
48
|
-
'Content-Type': 'application/json; charset=utf-8'
|
|
49
|
-
},
|
|
50
|
-
body: typeof body === 'string' ? body : JSON.stringify(body)
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
export function attrToBool(attr: any) {
|
|
2
|
-
if (typeof attr === 'boolean') {
|
|
3
|
-
return attr;
|
|
4
|
-
}
|
|
5
|
-
if (typeof attr === 'string') {
|
|
6
|
-
return attr === 'true' || attr === '';
|
|
7
|
-
}
|
|
8
|
-
return !!attr;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function hash(value: string) {
|
|
12
|
-
let hashValue = 0;
|
|
13
|
-
for (let i = 0; i < value.length; i++) {
|
|
14
|
-
const char = value.charCodeAt(i);
|
|
15
|
-
hashValue = (hashValue << 5) - hashValue + char;
|
|
16
|
-
hashValue |= 0;
|
|
17
|
-
}
|
|
18
|
-
return hashValue;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function createImageUrl(image: string, hash: string) {
|
|
22
|
-
if (image.startsWith('/assets')) {
|
|
23
|
-
const segments = image.split('/');
|
|
24
|
-
return `/1/asset/immutable/s/${hash}/$assetsDir/images/${
|
|
25
|
-
segments[segments.length - 1]
|
|
26
|
-
}`;
|
|
27
|
-
}
|
|
28
|
-
return image;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const InteractionEventTypes = Object.freeze({
|
|
32
|
-
CLICK: 'CLICK',
|
|
33
|
-
PAGE_VIEW: 'PAGE_VIEW',
|
|
34
|
-
INPUT_CHANGE: 'INPUT_CHANGE',
|
|
35
|
-
FILE_DOWNLOAD: 'FILE_DOWNLOAD',
|
|
36
|
-
IMAGE_DOWNLOAD: 'IMAGE_DOWNLOAD', //used with CDN
|
|
37
|
-
IMAGE_CLICK: 'IMAGE_CLICK',
|
|
38
|
-
DROPDOWN_CHANGE: 'DROPDOWN_CHANGE'
|
|
39
|
-
});
|
|
40
|
-
const channelActions = Object.freeze({
|
|
41
|
-
DOWNLOAD: 'DOWNLOAD',
|
|
42
|
-
VIEW: 'VIEW'
|
|
43
|
-
});
|
|
44
|
-
const channelActionsStatus = Object.freeze({
|
|
45
|
-
SUCCESS: 'SUCCESS',
|
|
46
|
-
FAILURE: 'FAILURE'
|
|
47
|
-
});
|
|
48
|
-
export function sendInteractionEvent(name: string, type: string, event: any, target?: any) {
|
|
49
|
-
const element = target || event.currentTarget;
|
|
50
|
-
let text: string = '';
|
|
51
|
-
let eventValue: string = '';
|
|
52
|
-
let channelAction: string = '';
|
|
53
|
-
const channelActionStatus: string = channelActionsStatus.SUCCESS;
|
|
54
|
-
const pageUrl = new URL(document.location.href);
|
|
55
|
-
const searchTitle = pageUrl.searchParams.get('keywords') || '';
|
|
56
|
-
if (
|
|
57
|
-
type === InteractionEventTypes.IMAGE_CLICK ||
|
|
58
|
-
type === InteractionEventTypes.FILE_DOWNLOAD
|
|
59
|
-
) {
|
|
60
|
-
eventValue = element.href || element.src;
|
|
61
|
-
const url = new URL(
|
|
62
|
-
eventValue,
|
|
63
|
-
window.location.protocol + '//' + window.location.host
|
|
64
|
-
);
|
|
65
|
-
text = url.pathname.substr(url.pathname.lastIndexOf('/') + 1);
|
|
66
|
-
channelAction = channelActions.DOWNLOAD;
|
|
67
|
-
}
|
|
68
|
-
if (type === InteractionEventTypes.CLICK) {
|
|
69
|
-
eventValue = element.href || '';
|
|
70
|
-
|
|
71
|
-
let textNode = element;
|
|
72
|
-
if (element.firstChild.localName === 'slot') {
|
|
73
|
-
textNode = element.firstChild
|
|
74
|
-
.assignedNodes()
|
|
75
|
-
.find((child: any) => child.textContent !== '');
|
|
76
|
-
}
|
|
77
|
-
text = element.ariaLabel || textNode.textContent || textNode.innerText;
|
|
78
|
-
|
|
79
|
-
if (eventValue.includes('/view/')) {
|
|
80
|
-
type = InteractionEventTypes.IMAGE_CLICK;
|
|
81
|
-
const imgSrc = target.getElementsByTagName('img')[0].src;
|
|
82
|
-
channelAction = channelActions.VIEW;
|
|
83
|
-
|
|
84
|
-
if (imgSrc) {
|
|
85
|
-
const url = new URL(
|
|
86
|
-
imgSrc,
|
|
87
|
-
window.location.protocol + '//' + window.location.host
|
|
88
|
-
);
|
|
89
|
-
text = url.pathname.substr(url.pathname.lastIndexOf('/') + 1);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (eventValue.includes('/cms/delivery/media')) {
|
|
93
|
-
type = InteractionEventTypes.IMAGE_DOWNLOAD;
|
|
94
|
-
channelAction = channelActions.DOWNLOAD;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (type === InteractionEventTypes.DROPDOWN_CHANGE) {
|
|
98
|
-
text = element.id;
|
|
99
|
-
eventValue = element.value;
|
|
100
|
-
}
|
|
101
|
-
if (type === InteractionEventTypes.INPUT_CHANGE) {
|
|
102
|
-
text = element.ariaLabel;
|
|
103
|
-
eventValue = element.value;
|
|
104
|
-
}
|
|
105
|
-
let env = 'DEV';
|
|
106
|
-
if (window.location.host === 'architect.salesforce.com') {
|
|
107
|
-
env = 'PRD';
|
|
108
|
-
}
|
|
109
|
-
if (window.location.host.includes('site-staging')) {
|
|
110
|
-
env = 'STG';
|
|
111
|
-
}
|
|
112
|
-
text = text.replace(/^\s+|\s+$/g, '');
|
|
113
|
-
const pathNameArray = window.location.pathname.split('/');
|
|
114
|
-
const interaction = {
|
|
115
|
-
name: name,
|
|
116
|
-
eventType: 'websiteInteractionEvent',
|
|
117
|
-
topLevelLocation: pathNameArray[1] || '/',
|
|
118
|
-
secondLevelLocation: pathNameArray[2],
|
|
119
|
-
page: pathNameArray[3],
|
|
120
|
-
params: window.location.search || window.location.hash,
|
|
121
|
-
interactionType: type,
|
|
122
|
-
interactionElement: element
|
|
123
|
-
? `${element.localName}/${element.name}/${text}`
|
|
124
|
-
: '',
|
|
125
|
-
eventValue: eventValue,
|
|
126
|
-
env: env,
|
|
127
|
-
gaClientId: localStorage.getItem('ga_client_id'),
|
|
128
|
-
elementId: element.id,
|
|
129
|
-
elementLabel: text,
|
|
130
|
-
channelAction: channelAction,
|
|
131
|
-
channelActionStatus: channelActionStatus,
|
|
132
|
-
testSend: env === 'PRD' ? 'false' : 'true',
|
|
133
|
-
pageId: pathNameArray[pathNameArray.length - 1],
|
|
134
|
-
pageTitle: document.title,
|
|
135
|
-
searchTitle: pathNameArray[1] === 'search' ? searchTitle : '',
|
|
136
|
-
domainName: window.location.hostname
|
|
137
|
-
};
|
|
138
|
-
(window as any).SalesforceInteractions?.sendEvent({
|
|
139
|
-
interaction: interaction
|
|
140
|
-
});
|
|
141
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Provides a localization service
|
|
3
|
-
*/
|
|
4
|
-
import i18n from 'i18n-js';
|
|
5
|
-
|
|
6
|
-
export type Locale = 'de' | 'en' | 'es-MX' | 'fr' | 'ja' | 'pt-BR';
|
|
7
|
-
|
|
8
|
-
type Labels = {
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
type Locales = {
|
|
13
|
-
[locale in Locale]?: {
|
|
14
|
-
[key: string]: Labels | string;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type Scope = {
|
|
19
|
-
[scopeName: string]: Locales;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
i18n.defaultLocale = 'en';
|
|
23
|
-
i18n.fallbacks = true;
|
|
24
|
-
|
|
25
|
-
export function toLocaleKey(value: string) {
|
|
26
|
-
return value.replace(
|
|
27
|
-
/([a-z]{2,3})(?:[_-])?([A-Z]{2})/g,
|
|
28
|
-
(_, lang, country) => `${lang}-${country.toUpperCase()}`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let guid = 0;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @class I18n
|
|
36
|
-
* @example
|
|
37
|
-
* import { I18n } from "shared/i18n";
|
|
38
|
-
* import labels from "./locales";
|
|
39
|
-
* const i18n = new I18n({ scopeName: labels });
|
|
40
|
-
* i18n.t("en", "scopeName", "foo.bar");
|
|
41
|
-
*/
|
|
42
|
-
export class I18n {
|
|
43
|
-
private id = guid++;
|
|
44
|
-
|
|
45
|
-
constructor(scope?: Scope) {
|
|
46
|
-
if (scope) {this.addScope(scope);}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
t(
|
|
50
|
-
locale: string,
|
|
51
|
-
scope: string,
|
|
52
|
-
key: string,
|
|
53
|
-
options?: any
|
|
54
|
-
) {
|
|
55
|
-
// i18n-js is a singleton, so setting locale on each call is required to
|
|
56
|
-
// avoid overriding the locale of other components' call to this function
|
|
57
|
-
i18n.locale = locale;
|
|
58
|
-
return i18n.t(`${scope}_${this.id}.${key}`, options);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
addScope(scope: Scope) {
|
|
62
|
-
for (const [scopeName, locales] of Object.entries(scope)) {
|
|
63
|
-
for (const [locale, labels] of Object.entries(locales)) {
|
|
64
|
-
// Modules can only export indentifiers, so we transform the key
|
|
65
|
-
// "esMX" => "es-MX"
|
|
66
|
-
const localeKey = toLocaleKey(locale);
|
|
67
|
-
i18n.translations[localeKey] = {
|
|
68
|
-
...i18n.translations[localeKey],
|
|
69
|
-
[`${scopeName}_${this.id}`]: labels
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { label } from '../helpers';
|
|
2
|
-
import { LabelsDict } from '../types';
|
|
3
|
-
|
|
4
|
-
const dict: LabelsDict = {
|
|
5
|
-
en: {
|
|
6
|
-
foo: 'foon',
|
|
7
|
-
points: '%{n} points',
|
|
8
|
-
attempts: '%{n} attempts'
|
|
9
|
-
},
|
|
10
|
-
es: {
|
|
11
|
-
foo: 'fol',
|
|
12
|
-
fooNoRegion: 'fooNoRegionValue',
|
|
13
|
-
faa: 'faa'
|
|
14
|
-
},
|
|
15
|
-
'es-MX': {
|
|
16
|
-
foo: 'foll',
|
|
17
|
-
points: '%{n} puntos'
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
describe('label', () => {
|
|
22
|
-
describe('default language', () => {
|
|
23
|
-
const lang = 'en';
|
|
24
|
-
|
|
25
|
-
describe('known keys', () => {
|
|
26
|
-
it('finds key and returns the value', () => {
|
|
27
|
-
expect(label(lang, dict, 'foo')).toEqual('foon');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('finds key and substitutes values', () => {
|
|
31
|
-
expect(label(lang, dict, 'points', [300])).toEqual(
|
|
32
|
-
'300 points'
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('finds key and substitutes values, and ignores overloading', () => {
|
|
37
|
-
expect(label(lang, dict, 'points', [300, 100])).toEqual(
|
|
38
|
-
'300 points'
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('finds key and does not substitue missing values', () => {
|
|
43
|
-
expect(label(lang, dict, 'points')).toEqual('%{n} points');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('fallbacks', () => {
|
|
48
|
-
it('fails to find key and returns the label', () => {
|
|
49
|
-
expect(label(lang, dict, 'nf')).toEqual('nf');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('language with region', () => {
|
|
55
|
-
const lang = 'es-MX';
|
|
56
|
-
|
|
57
|
-
describe('known keys', () => {
|
|
58
|
-
it('finds key and returns the value', () => {
|
|
59
|
-
expect(label(lang, dict, 'foo')).toEqual('foll');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('finds key and substitutes values', () => {
|
|
63
|
-
expect(label(lang, dict, 'points', [300])).toEqual(
|
|
64
|
-
'300 puntos'
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('fallbacks', () => {
|
|
70
|
-
it('fails to find key and falls back to language', () => {
|
|
71
|
-
expect(label(lang, dict, 'fooNoRegion')).toEqual(
|
|
72
|
-
'fooNoRegionValue'
|
|
73
|
-
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('fails to find key and falls back to english', () => {
|
|
77
|
-
expect(label(lang, dict, 'attempts', [3])).toEqual(
|
|
78
|
-
'3 attempts'
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('fails to find key and returns the label', () => {
|
|
83
|
-
expect(label(lang, dict, 'nf')).toEqual('nf');
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('language not found', () => {
|
|
89
|
-
const lang = 'de';
|
|
90
|
-
|
|
91
|
-
describe('fallbacks', () => {
|
|
92
|
-
it('fails to find key and falls back to english', () => {
|
|
93
|
-
expect(label(lang, dict, 'faa')).toEqual('faa');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('fails to find key and falls back to english', () => {
|
|
97
|
-
expect(label(lang, dict, 'attempts', [3])).toEqual(
|
|
98
|
-
'3 attempts'
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('fails to find key and returns the label', () => {
|
|
103
|
-
expect(label(lang, dict, 'nf')).toEqual('nf');
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { pointLabel } from '../pointHelpers';
|
|
2
|
-
|
|
3
|
-
describe('pointLabel', () => {
|
|
4
|
-
describe('en', () => {
|
|
5
|
-
const lang = 'en';
|
|
6
|
-
|
|
7
|
-
it('returns correct values', () => {
|
|
8
|
-
expect(pointLabel(lang, 0)).toEqual('0 Points');
|
|
9
|
-
expect(pointLabel(lang, 1)).toEqual('+1 Point');
|
|
10
|
-
expect(pointLabel(lang, 10)).toEqual('+10 Points');
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
describe('es-MX', () => {
|
|
15
|
-
const lang = 'es-MX';
|
|
16
|
-
|
|
17
|
-
it('returns correct values', () => {
|
|
18
|
-
expect(pointLabel(lang, 0)).toEqual('0 puntos');
|
|
19
|
-
expect(pointLabel(lang, 1)).toEqual('+1 punto');
|
|
20
|
-
expect(pointLabel(lang, 10)).toEqual('+10 puntos');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('fj', () => {
|
|
25
|
-
const lang = 'fj';
|
|
26
|
-
|
|
27
|
-
it('returns correct values', () => {
|
|
28
|
-
expect(pointLabel(lang, 0)).toEqual('0 Points');
|
|
29
|
-
expect(pointLabel(lang, 1)).toEqual('+1 Point');
|
|
30
|
-
expect(pointLabel(lang, 10)).toEqual('+10 Points');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|