@transferwise/components 46.124.1 → 46.125.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/field/Field.js +10 -0
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +10 -0
- package/build/field/Field.mjs.map +1 -1
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/index.mjs +1 -0
- package/build/index.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +10 -0
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +10 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/main.css +32 -2
- package/build/prompt/ActionPrompt/ActionPrompt.js +123 -0
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -0
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +118 -0
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -0
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js +13 -11
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.js.map +1 -1
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs +14 -12
- package/build/prompt/PrimitivePrompt/PrimitivePrompt.mjs.map +1 -1
- package/build/styles/main.css +32 -2
- package/build/styles/prompt/ActionPrompt/ActionPrompt.css +21 -0
- package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +11 -2
- package/build/tabs/Tabs.js +14 -171
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs +16 -173
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/tabs/utils.js +0 -18
- package/build/tabs/utils.js.map +1 -1
- package/build/tabs/utils.mjs +1 -17
- package/build/tabs/utils.mjs.map +1 -1
- package/build/typeahead/Typeahead.js +10 -0
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +10 -0
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts +26 -0
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -0
- package/build/types/prompt/ActionPrompt/index.d.ts +3 -0
- package/build/types/prompt/ActionPrompt/index.d.ts.map +1 -0
- package/build/types/prompt/PrimitivePrompt/PrimitivePrompt.d.ts.map +1 -1
- package/build/types/prompt/index.d.ts +2 -0
- package/build/types/prompt/index.d.ts.map +1 -1
- package/build/types/tabs/Tabs.d.ts +2 -24
- package/build/types/tabs/Tabs.d.ts.map +1 -1
- package/build/types/tabs/utils.d.ts +0 -2
- package/build/types/tabs/utils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/actionButton/ActionButton.story.tsx +2 -9
- package/src/avatar/Avatar.story.tsx +2 -8
- package/src/button/_stories/{Button.tests.story.tsx → Button.test.story.tsx} +5 -10
- package/src/checkbox/Checkbox.story.tsx +3 -16
- package/src/circularButton/CircularButton.story.tsx +2 -7
- package/src/common/bottomSheet/BottomSheet.story.tsx +6 -32
- package/src/common/circle/Circle.story.tsx +3 -14
- package/src/criticalBanner/CriticalCommsBanner.story.tsx +3 -16
- package/src/dateInput/{DateInput.tests.story.tsx → DateInput.test.story.tsx} +3 -13
- package/src/dateLookup/DateLookup.story.tsx +9 -7
- package/src/header/{Header.tests.story.tsx → Header.test.story.tsx} +5 -10
- package/src/index.ts +2 -2
- package/src/info/Info.story.tsx +4 -20
- package/src/listItem/_stories/variants/ListItem.brightGreen.test.story.tsx +2 -7
- package/src/listItem/_stories/variants/ListItem.dark.test.story.tsx +2 -7
- package/src/listItem/_stories/variants/ListItem.forestGreen.test.story.tsx +2 -7
- package/src/listItem/_stories/variants/ListItem.rtl.test.story.tsx +2 -7
- package/src/main.css +32 -2
- package/src/main.less +1 -0
- package/src/modal/Modal.story.tsx +6 -31
- package/src/prompt/ActionPrompt/ActionPrompt.css +21 -0
- package/src/prompt/ActionPrompt/ActionPrompt.less +23 -0
- package/src/prompt/ActionPrompt/ActionPrompt.story.tsx +184 -0
- package/src/prompt/ActionPrompt/ActionPrompt.test.tsx +256 -0
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +129 -0
- package/src/prompt/ActionPrompt/index.ts +2 -0
- package/src/prompt/InlinePrompt/{InlinePrompt.spec.tsx → InlinePrompt.test.tsx} +3 -38
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +11 -2
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +12 -2
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.test.tsx +161 -0
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.tsx +15 -11
- package/src/prompt/index.ts +3 -0
- package/src/snackbar/{Snackbar.tests.story.tsx → Snackbar.test.story.tsx} +6 -32
- package/src/{ssr.spec.tsx → ssr.test.tsx} +1 -0
- package/src/statusIcon/StatusIcon.story.tsx +5 -9
- package/src/tabs/Tabs.story.tsx +1 -45
- package/src/tabs/{Tabs.spec.tsx → Tabs.test.tsx} +0 -22
- package/src/tabs/Tabs.tsx +23 -240
- package/src/tabs/utils.test.ts +68 -0
- package/src/tabs/utils.ts +0 -20
- package/src/tooltip/Tooltip.story.tsx +2 -7
- package/src/tabs/utils.spec.ts +0 -126
- /package/src/accordion/{Accordion.spec.js → Accordion.test.js} +0 -0
- /package/src/accordion/AccordionItem/{AccordionItem.spec.js → AccordionItem.test.js} +0 -0
- /package/src/accordion/AccordionItem/__snapshots__/{AccordionItem.spec.js.snap → AccordionItem.test.js.snap} +0 -0
- /package/src/accordion/__snapshots__/{Accordion.spec.js.snap → Accordion.test.js.snap} +0 -0
- /package/src/actionButton/{ActionButton.spec.tsx → ActionButton.test.tsx} +0 -0
- /package/src/actionButton/__snapshots__/{ActionButton.spec.tsx.snap → ActionButton.test.tsx.snap} +0 -0
- /package/src/actionOption/{ActionOption.spec.tsx → ActionOption.test.tsx} +0 -0
- /package/src/alert/{Alert.tests.story.tsx → Alert.test.story.tsx} +0 -0
- /package/src/alert/{Alert.spec.tsx → Alert.test.tsx} +0 -0
- /package/src/avatar/{Avatar.spec.tsx → Avatar.test.tsx} +0 -0
- /package/src/avatarWrapper/{AvatarWrapper.spec.tsx → AvatarWrapper.test.tsx} +0 -0
- /package/src/avatarWrapper/__snapshots__/{AvatarWrapper.spec.tsx.snap → AvatarWrapper.test.tsx.snap} +0 -0
- /package/src/badge/{Badge.spec.tsx → Badge.test.tsx} +0 -0
- /package/src/body/{Body.spec.tsx → Body.test.tsx} +0 -0
- /package/src/button/{Button.spec.tsx → Button.test.tsx} +0 -0
- /package/src/button/{LegacyButton.spec.tsx → LegacyButton.test.tsx} +0 -0
- /package/src/button/_stories/{Button.brightGreen.tests.story.tsx → Button.brightGreen.test.story.tsx} +0 -0
- /package/src/button/_stories/{Button.dark.tests.story.tsx → Button.dark.test.story.tsx} +0 -0
- /package/src/button/_stories/{Button.default.tests.story.tsx → Button.default.test.story.tsx} +0 -0
- /package/src/button/_stories/{Button.forestGreen.tests.story.tsx → Button.forestGreen.test.story.tsx} +0 -0
- /package/src/button/legacyUtils/{legacyUtils.spec.tsx → legacyUtils.test.tsx} +0 -0
- /package/src/card/{Card.spec.tsx → Card.test.tsx} +0 -0
- /package/src/carousel/{Carousel.spec.tsx → Carousel.test.tsx} +0 -0
- /package/src/checkbox/{Checkbox.spec.tsx → Checkbox.test.tsx} +0 -0
- /package/src/checkbox/__snapshots__/{Checkbox.spec.tsx.snap → Checkbox.test.tsx.snap} +0 -0
- /package/src/checkboxButton/{CheckboxButton.spec.tsx → CheckboxButton.test.tsx} +0 -0
- /package/src/checkboxOption/{CheckboxOption.spec.tsx → CheckboxOption.test.tsx} +0 -0
- /package/src/chevron/{Chevron.spec.tsx → Chevron.test.tsx} +0 -0
- /package/src/chevron/__snapshots__/{Chevron.spec.tsx.snap → Chevron.test.tsx.snap} +0 -0
- /package/src/chips/{Chips.spec.tsx → Chips.test.tsx} +0 -0
- /package/src/chips/__snapshots__/{Chips.spec.tsx.snap → Chips.test.tsx.snap} +0 -0
- /package/src/circularButton/{CircularButton.tests.story.tsx → CircularButton.test.story.tsx} +0 -0
- /package/src/circularButton/{CircularButton.spec.tsx → CircularButton.test.tsx} +0 -0
- /package/src/common/DOMOperations/{DOMOperations.spec.tsx → DOMOperations.test.tsx} +0 -0
- /package/src/common/Option/{Option.spec.tsx → Option.test.tsx} +0 -0
- /package/src/common/RadioButton/{RadioButton.spec.tsx → RadioButton.test.tsx} +0 -0
- /package/src/common/RadioButton/__snapshots__/{RadioButton.spec.tsx.snap → RadioButton.test.tsx.snap} +0 -0
- /package/src/common/bottomSheet/{BottomSheet.spec.tsx → BottomSheet.test.tsx} +0 -0
- /package/src/common/bottomSheet/__snapshots__/{BottomSheet.spec.tsx.snap → BottomSheet.test.tsx.snap} +0 -0
- /package/src/common/card/{Card.spec.tsx → Card.test.tsx} +0 -0
- /package/src/common/card/__snapshots__/{Card.spec.tsx.snap → Card.test.tsx.snap} +0 -0
- /package/src/common/closeButton/{CloseButton.spec.tsx → CloseButton.test.tsx} +0 -0
- /package/src/common/closeButton/__snapshots__/{CloseButton.spec.tsx.snap → CloseButton.test.tsx.snap} +0 -0
- /package/src/common/dateUtils/getDayNames/{getDayNames.spec.js → getDayNames.test.js} +0 -0
- /package/src/common/dateUtils/getMonthNames/{getMonthNames.spec.js → getMonthNames.test.js} +0 -0
- /package/src/common/dateUtils/isDateValid/{isDateValid.spec.ts → isDateValid.test.ts} +0 -0
- /package/src/common/dateUtils/isMonthAndYearFormat/{isMonthAndYearFormat.spec.js → isMonthAndYearFormat.test.js} +0 -0
- /package/src/common/dateUtils/isWithinRange/{isWithinRange.spec.ts → isWithinRange.test.ts} +0 -0
- /package/src/common/dateUtils/moveToWithinRange/{moveToWithinRange.spec.js → moveToWithinRange.test.js} +0 -0
- /package/src/common/deviceDetection/{deviceDetection.spec.ts → deviceDetection.test.ts} +0 -0
- /package/src/common/domHelpers/{documentIosClick.spec.ts → documentIosClick.test.ts} +0 -0
- /package/src/common/flowHeader/{FlowHeader.spec.tsx → FlowHeader.test.tsx} +0 -0
- /package/src/common/flowHeader/__snapshots__/{FlowHeader.spec.tsx.snap → FlowHeader.test.tsx.snap} +0 -0
- /package/src/common/historyNavigator/{historyNavigator.spec.ts → historyNavigator.test.ts} +0 -0
- /package/src/common/hooks/useConditionalListener/{useConditionalListener.spec.js → useConditionalListener.test.js} +0 -0
- /package/src/common/hooks/useDirection/{useDirection.spec.js → useDirection.test.js} +0 -0
- /package/src/common/hooks/useHasIntersected/{useHasIntersected.spec.js → useHasIntersected.test.js} +0 -0
- /package/src/common/hooks/{useMedia.spec.ts → useMedia.test.ts} +0 -0
- /package/src/common/{initials.spec.tsx → initials.test.tsx} +0 -0
- /package/src/common/locale/{index.spec.ts → index.test.ts} +0 -0
- /package/src/common/panel/{Panel.spec.tsx → Panel.test.tsx} +0 -0
- /package/src/common/panel/__snapshots__/{Panel.spec.tsx.snap → Panel.test.tsx.snap} +0 -0
- /package/src/common/responsivePanel/{ResponsivePanel.spec.js → ResponsivePanel.test.js} +0 -0
- /package/src/common/textFormat/formatWithPattern/{formatWithPattern.spec.ts → formatWithPattern.test.ts} +0 -0
- /package/src/common/textFormat/getCountOfSymbolsInSelection/{getCountOfSymbolsInSelection.spec.ts → getCountOfSymbolsInSelection.test.ts} +0 -0
- /package/src/common/textFormat/getCursorPositionAfterKeystroke/{getCursorPositionAfterKeystroke.spec.ts → getCursorPositionAfterKeystroke.test.ts} +0 -0
- /package/src/common/textFormat/getDistanceToSymbol/{getDistanceToSymbol.spec.ts → getDistanceToSymbol.test.ts} +0 -0
- /package/src/common/textFormat/getSymbolsInPatternWithPosition/{getSymbolsInPatternWithPosition.spec.ts → getSymbolsInPatternWithPosition.test.ts} +0 -0
- /package/src/common/textFormat/unformatWithPattern/{unformatWithPattern.spec.ts → unformatWithPattern.test.ts} +0 -0
- /package/src/dateInput/{DateInput.spec.tsx → DateInput.test.tsx} +0 -0
- /package/src/dateInput/utils/convertToLocalMidnight/{convertToLocalMidnight.spec.ts → convertToLocalMidnight.test.ts} +0 -0
- /package/src/dateLookup/{DateLookup.tests.story.tsx → DateLookup.test.story.tsx} +0 -0
- /package/src/dateLookup/{DateLookup.spec.tsx → DateLookup.test.tsx} +0 -0
- /package/src/dateLookup/getFocusableTime/{getFocusable.spec.ts → getFocusable.test.ts} +0 -0
- /package/src/dateLookup/getStartOfDay/{getStartOfDay.spec.js → getStartOfDay.test.js} +0 -0
- /package/src/decision/{Decision.spec.tsx → Decision.test.tsx} +0 -0
- /package/src/dimmer/{Dimmer.spec.tsx → Dimmer.test.tsx} +0 -0
- /package/src/divider/{Divider.spec.tsx → Divider.test.tsx} +0 -0
- /package/src/drawer/{Drawer.spec.tsx → Drawer.test.tsx} +0 -0
- /package/src/emphasis/{Emphasis.spec.tsx → Emphasis.test.tsx} +0 -0
- /package/src/emphasis/{EmphasisHtmlTransformer.spec.tsx → EmphasisHtmlTransformer.test.tsx} +0 -0
- /package/src/expressiveMoneyInput/{ExpressiveMoneyInput.spec.tsx → ExpressiveMoneyInput.test.tsx} +0 -0
- /package/src/expressiveMoneyInput/amountInput/{AmountInput.spec.tsx → AmountInput.test.tsx} +0 -0
- /package/src/expressiveMoneyInput/amountInput/{utils.spec.ts → utils.test.ts} +0 -0
- /package/src/expressiveMoneyInput/currencySelector/{CurrencySelector.spec.tsx → CurrencySelector.test.tsx} +0 -0
- /package/src/field/{Field.spec.tsx → Field.test.tsx} +0 -0
- /package/src/flowNavigation/{FlowNavigation.spec.js → FlowNavigation.test.js} +0 -0
- /package/src/flowNavigation/__snapshots__/{FlowNavigation.spec.js.snap → FlowNavigation.test.js.snap} +0 -0
- /package/src/flowNavigation/animatedLabel/{AnimatedLabel.spec.js → AnimatedLabel.test.js} +0 -0
- /package/src/header/{Header.spec.tsx → Header.test.tsx} +0 -0
- /package/src/iconButton/{iconButton.spec.tsx → iconButton.test.tsx} +0 -0
- /package/src/image/{Image.spec.tsx → Image.test.tsx} +0 -0
- /package/src/info/{Info.spec.jsx → Info.test.jsx} +0 -0
- /package/src/inlineAlert/{InlineAlert.spec.tsx → InlineAlert.test.tsx} +0 -0
- /package/src/inputWithDisplayFormat/{InputWithDisplayFormat.spec.js → InputWithDisplayFormat.test.js} +0 -0
- /package/src/inputs/{InputGroup.spec.tsx → InputGroup.test.tsx} +0 -0
- /package/src/inputs/{SearchInput.spec.tsx → SearchInput.test.tsx} +0 -0
- /package/src/inputs/{SelectInput.spec.tsx → SelectInput.test.tsx} +0 -0
- /package/src/instructionsList/{InstructionsList.spec.tsx → InstructionsList.test.tsx} +0 -0
- /package/src/label/{Label.spec.tsx → Label.test.tsx} +0 -0
- /package/src/legacylistItem/{LegacyListItem.tests.story.tsx → LegacyListItem.test.story.tsx} +0 -0
- /package/src/legacylistItem/{LegacyListItem.spec.tsx → LegacyListItem.test.tsx} +0 -0
- /package/src/link/{Link.spec.tsx → Link.test.tsx} +0 -0
- /package/src/list/{List.spec.tsx → List.test.tsx} +0 -0
- /package/src/listItem/AdditionalInfo/{ListItemAdditionalInfo.spec.tsx → ListItemAdditionalInfo.test.tsx} +0 -0
- /package/src/listItem/AvatarLayout/{ListItemAvatarLayout.spec.tsx → ListItemAvatarLayout.test.tsx} +0 -0
- /package/src/listItem/AvatarView/{ListItemAvatarView.spec.tsx → ListItemAvatarView.test.tsx} +0 -0
- /package/src/listItem/Button/{ListItemButton.spec.tsx → ListItemButton.test.tsx} +0 -0
- /package/src/listItem/Checkbox/{ListItemCheckbox.spec.tsx → ListItemCheckbox.test.tsx} +0 -0
- /package/src/listItem/IconButton/{ListItemIconButton.spec.tsx → ListItemIconButton.test.tsx} +0 -0
- /package/src/listItem/Image/{ListItemImage.spec.tsx → ListItemImage.test.tsx} +0 -0
- /package/src/listItem/{ListItem.spec.tsx → ListItem.test.tsx} +0 -0
- /package/src/listItem/Navigation/{ListItemNavigation.spec.tsx → ListItemNavigation.test.tsx} +0 -0
- /package/src/listItem/Prompt/{ListItemPrompt.spec.tsx → ListItemPrompt.test.tsx} +0 -0
- /package/src/listItem/Radio/{ListItemRadio.spec.tsx → ListItemRadio.test.tsx} +0 -0
- /package/src/listItem/Switch/{ListItemSwitch.spec.tsx → ListItemSwitch.test.tsx} +0 -0
- /package/src/loader/{Loader.spec.tsx → Loader.test.tsx} +0 -0
- /package/src/logo/{Logo.spec.tsx → Logo.test.tsx} +0 -0
- /package/src/logo/__snapshots__/{Logo.spec.tsx.snap → Logo.test.tsx.snap} +0 -0
- /package/src/markdown/{Markdown.spec.tsx → Markdown.test.tsx} +0 -0
- /package/src/modal/{Modal.spec.tsx → Modal.test.tsx} +0 -0
- /package/src/money/{Money.spec.tsx → Money.test.tsx} +0 -0
- /package/src/moneyInput/{MoneyInput.spec.tsx → MoneyInput.test.tsx} +0 -0
- /package/src/moneyInput/{currencyFormatting.spec.ts → currencyFormatting.test.ts} +0 -0
- /package/src/navigationOption/{NavigationOption.spec.tsx → NavigationOption.test.tsx} +0 -0
- /package/src/navigationOptionsList/{NavigationOptionsList.spec.tsx → NavigationOptionsList.test.tsx} +0 -0
- /package/src/nudge/{Nudge.spec.tsx → Nudge.test.tsx} +0 -0
- /package/src/overlayHeader/{OverlayHeader.spec.tsx → OverlayHeader.test.tsx} +0 -0
- /package/src/overlayHeader/__snapshots__/{OverlayHeader.spec.tsx.snap → OverlayHeader.test.tsx.snap} +0 -0
- /package/src/phoneNumberInput/{PhoneNumberInput.spec.tsx → PhoneNumberInput.test.tsx} +0 -0
- /package/src/phoneNumberInput/utils/cleanNumber/{cleanNumber.spec.ts → cleanNumber.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/excludeCountries/{excludeCountries.spec.ts → excludeCountries.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/explodeNumberModel/{explodeNumberModel.spec.ts → explodeNumberModel.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/findCountryByCode/{findCountryByCode.spec.ts → findCountryByCode.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/findCountryByPrefix/{findCountryByPrefix.spec.ts → findCountryByPrefix.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/groupCountriesByPrefix/{groupCountriesByPrefix.spec.ts → groupCountriesByPrefix.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/isStringNumeric/{isStringNumeric.spec.ts → isStringNumeric.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/isValidPhoneNumber/{isValidPhoneNumber.spec.ts → isValidPhoneNumber.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/longestMatchingPrefix/{longestMatchingPrefix.spec.ts → longestMatchingPrefix.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/setDefaultPrefix/{setDefaultPrefix.spec.ts → setDefaultPrefix.test.ts} +0 -0
- /package/src/phoneNumberInput/utils/sortArrayByProperty/{sortArrayByProperty.spec.ts → sortArrayByProperty.test.ts} +0 -0
- /package/src/popover/{Popover.spec.tsx → Popover.test.tsx} +0 -0
- /package/src/popover/__snapshots__/{Popover.spec.tsx.snap → Popover.test.tsx.snap} +0 -0
- /package/src/primitives/PrimitiveAnchor/stories/{PrimitiveAnchor.tests.story.tsx → PrimitiveAnchor.test.story.tsx} +0 -0
- /package/src/primitives/PrimitiveAnchor/test/{PrimitiveAnchor.spec.tsx → PrimitiveAnchor.test.tsx} +0 -0
- /package/src/primitives/PrimitiveButton/stories/{PrimitiveButton.tests.story.tsx → PrimitiveButton.test.story.tsx} +0 -0
- /package/src/primitives/PrimitiveButton/test/{PrimitiveButton.spec.tsx → PrimitiveButton.test.tsx} +0 -0
- /package/src/processIndicator/{ProcessIndicator.rtl.spec.tsx → ProcessIndicator.rtl.test.tsx} +0 -0
- /package/src/progress/{Progress.spec.tsx → Progress.test.tsx} +0 -0
- /package/src/progressBar/{ProgressBar.spec.tsx → ProgressBar.test.tsx} +0 -0
- /package/src/promoCard/{PromoCard.spec.tsx → PromoCard.test.tsx} +0 -0
- /package/src/promoCard/{PromoCardContext.spec.tsx → PromoCardContext.test.tsx} +0 -0
- /package/src/promoCard/{PromoCardGroup.spec.tsx → PromoCardGroup.test.tsx} +0 -0
- /package/src/promoCard/__snapshots__/{PromoCard.spec.tsx.snap → PromoCard.test.tsx.snap} +0 -0
- /package/src/promoCard/__snapshots__/{PromoCardGroup.spec.tsx.snap → PromoCardGroup.test.tsx.snap} +0 -0
- /package/src/provider/{Provider.spec.tsx → Provider.test.tsx} +0 -0
- /package/src/provider/direction/{DirectionProvider.spec.tsx → DirectionProvider.test.tsx} +0 -0
- /package/src/provider/language/{LanguageProvider.spec.tsx → LanguageProvider.test.tsx} +0 -0
- /package/src/radio/{Radio.spec.tsx → Radio.test.tsx} +0 -0
- /package/src/radioGroup/{RadioGroup.spec.tsx → RadioGroup.test.tsx} +0 -0
- /package/src/radioOption/{RadioOption.spec.tsx → RadioOption.test.tsx} +0 -0
- /package/src/section/{Section.spec.tsx → Section.test.tsx} +0 -0
- /package/src/segmentedControl/{SegmentedControl.spec.tsx → SegmentedControl.test.tsx} +0 -0
- /package/src/select/{Select.rtl.spec.tsx → Select.rtl.test.tsx} +0 -0
- /package/src/select/{Select.spec.tsx → Select.test.tsx} +0 -0
- /package/src/select/option/{Option.spec.tsx → Option.test.tsx} +0 -0
- /package/src/select/searchBox/{SearchBox.spec.tsx → SearchBox.test.tsx} +0 -0
- /package/src/sentimentSurface/{SentimentSurface.tests.story.tsx → SentimentSurface.test.story.tsx} +0 -0
- /package/src/sentimentSurface/{SentimentSurface.spec.tsx → SentimentSurface.test.tsx} +0 -0
- /package/src/slidingPanel/{SlidingPanel.spec.tsx → SlidingPanel.test.tsx} +0 -0
- /package/src/statusIcon/{StatusIcon.spec.tsx → StatusIcon.test.tsx} +0 -0
- /package/src/stepper/{Stepper.tests.story.tsx → Stepper.test.story.tsx} +0 -0
- /package/src/stepper/{Stepper.spec.tsx → Stepper.test.tsx} +0 -0
- /package/src/stepper/{deviceDetection.spec.ts → deviceDetection.test.ts} +0 -0
- /package/src/sticky/{Sticky.spec.tsx → Sticky.test.tsx} +0 -0
- /package/src/summary/{Summary.tests.story.tsx → Summary.test.story.tsx} +0 -0
- /package/src/summary/{Summary.spec.tsx → Summary.test.tsx} +0 -0
- /package/src/switch/{Switch.spec.tsx → Switch.test.tsx} +0 -0
- /package/src/switchOption/{SwitchOption.spec.tsx → SwitchOption.test.tsx} +0 -0
- /package/src/table/{Table.spec.tsx → Table.test.tsx} +0 -0
- /package/src/table/{TableCell.spec.tsx → TableCell.test.tsx} +0 -0
- /package/src/table/{TableHeader.spec.tsx → TableHeader.test.tsx} +0 -0
- /package/src/table/{TableRow.spec.tsx → TableRow.test.tsx} +0 -0
- /package/src/table/{TableStatusText.spec.tsx → TableStatusText.test.tsx} +0 -0
- /package/src/textareaWithDisplayFormat/{TextareaWithDisplayFormat.spec.js → TextareaWithDisplayFormat.test.js} +0 -0
- /package/src/tile/{Tile.spec.tsx → Tile.test.tsx} +0 -0
- /package/src/tile/__snapshots__/{Tile.spec.tsx.snap → Tile.test.tsx.snap} +0 -0
- /package/src/title/{Title.spec.tsx → Title.test.tsx} +0 -0
- /package/src/tooltip/{Tooltip.spec.tsx → Tooltip.test.tsx} +0 -0
- /package/src/tooltip/__snapshots__/{Tooltip.spec.tsx.snap → Tooltip.test.tsx.snap} +0 -0
- /package/src/typeahead/{Typeahead.spec.tsx → Typeahead.test.tsx} +0 -0
- /package/src/typeahead/typeaheadInput/{TypeaheadInput.spec.tsx → TypeaheadInput.test.tsx} +0 -0
- /package/src/typeahead/util/{highlight.spec.tsx → highlight.test.tsx} +0 -0
- /package/src/upload/{Upload.tests.story.tsx → Upload.test.story.tsx} +0 -0
- /package/src/upload/{Upload.spec.tsx → Upload.test.tsx} +0 -0
- /package/src/upload/steps/completeStep/{completeStep.spec.tsx → completeStep.test.tsx} +0 -0
- /package/src/upload/steps/processingStep/{processingStep.spec.tsx → processingStep.test.tsx} +0 -0
- /package/src/upload/steps/uploadImageStep/{uploadImageStep.spec.tsx → uploadImageStep.test.tsx} +0 -0
- /package/src/upload/utils/asyncFileRead/{asyncFileRead.spec.ts → asyncFileRead.test.ts} +0 -0
- /package/src/upload/utils/getFileType/{getFileType.spec.ts → getFileType.test.ts} +0 -0
- /package/src/upload/utils/isSizeValid/{isSizeValid.spec.ts → isSizeValid.test.ts} +0 -0
- /package/src/upload/utils/isTypeValid/{isTypeValid.spec.ts → isTypeValid.test.ts} +0 -0
- /package/src/upload/utils/postData/{postData.spec.ts → postData.test.ts} +0 -0
- /package/src/uploadInput/{UploadInput.tests.story.tsx → UploadInput.test.story.tsx} +0 -0
- /package/src/uploadInput/{UploadInput.spec.tsx → UploadInput.test.tsx} +0 -0
- /package/src/uploadInput/uploadButton/{UploadButton.spec.tsx → UploadButton.test.tsx} +0 -0
- /package/src/uploadInput/uploadButton/{getAllowedFileTypes.spec.ts → getAllowedFileTypes.test.ts} +0 -0
- /package/src/uploadInput/uploadItem/{UploadItem.spec.tsx → UploadItem.test.tsx} +0 -0
- /package/src/utilities/deprecatedProperty/{deprecatedProperty.spec.ts → deprecatedProperty.test.ts} +0 -0
- /package/src/withDisplayFormat/{WithDisplayFormat.spec.js → WithDisplayFormat.test.js} +0 -0
- /package/src/withId/{withId.spec.tsx → withId.test.tsx} +0 -0
- /package/src/withNextPortal/{withNextPortal.spec.tsx → withNextPortal.test.tsx} +0 -0
package/src/tabs/Tabs.tsx
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { Spring, animated } from '@react-spring/web';
|
|
2
1
|
import { clsx } from 'clsx';
|
|
3
2
|
import clamp from 'lodash.clamp';
|
|
4
|
-
import { Component, createRef
|
|
3
|
+
import { Component, createRef } from 'react';
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import { Width, Direction } from '../common';
|
|
7
6
|
import { DirectionContext } from '../provider/direction';
|
|
8
7
|
|
|
9
8
|
import Tab from './Tab';
|
|
10
9
|
import TabList from './TabList';
|
|
11
10
|
import TabPanel from './TabPanel';
|
|
12
11
|
import {
|
|
13
|
-
getElasticDragDifference,
|
|
14
12
|
getSwipeDifference,
|
|
15
13
|
swipedLeftToRight,
|
|
16
14
|
swipedRightToLeft,
|
|
17
15
|
swipeShouldChangeTab,
|
|
18
|
-
getVelocity,
|
|
19
16
|
Swipe,
|
|
20
17
|
} from './utils';
|
|
21
18
|
|
|
@@ -27,52 +24,29 @@ export interface TabItem {
|
|
|
27
24
|
disabled: boolean;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
type TabsTransitionSpacing =
|
|
31
|
-
| 'default'
|
|
32
|
-
| `${Size.EXTRA_SMALL | Size.SMALL | Size.MEDIUM | Size.LARGE}`;
|
|
33
|
-
|
|
34
27
|
export interface TabsProps {
|
|
35
28
|
tabs: TabItem[];
|
|
36
29
|
selected: number;
|
|
37
30
|
name: string;
|
|
38
|
-
animatePanelsOnClick?: boolean;
|
|
39
31
|
changeTabOnSwipe?: boolean;
|
|
40
32
|
className?: string;
|
|
41
|
-
transitionSpacing?: TabsTransitionSpacing;
|
|
42
33
|
headerWidth?: `${Width}`;
|
|
43
|
-
id?: string;
|
|
44
34
|
onTabSelect: (index: number) => void;
|
|
45
35
|
}
|
|
46
36
|
|
|
47
37
|
interface TabsState {
|
|
48
38
|
start: Swipe | null;
|
|
49
|
-
translateX: number;
|
|
50
|
-
translateFrom: number;
|
|
51
|
-
translateTo: number;
|
|
52
39
|
translateLineX: string | null;
|
|
53
|
-
isAnimating: boolean;
|
|
54
40
|
isSwiping: boolean;
|
|
55
41
|
isScrolling: boolean;
|
|
56
|
-
lastSwipeVelocity: number;
|
|
57
42
|
fullWidthTabs: boolean;
|
|
58
|
-
currentSwipe: Swipe[];
|
|
59
|
-
selectedTabIndex: number;
|
|
60
43
|
}
|
|
61
44
|
|
|
62
|
-
const SpacerWidth = {
|
|
63
|
-
default: 0,
|
|
64
|
-
xs: 8,
|
|
65
|
-
sm: 16,
|
|
66
|
-
md: 24,
|
|
67
|
-
lg: 32,
|
|
68
|
-
} satisfies Record<TabsTransitionSpacing, number>;
|
|
69
|
-
|
|
70
45
|
export default class Tabs extends Component<TabsProps, TabsState> {
|
|
71
46
|
declare props: TabsProps & Required<Pick<TabsProps, keyof typeof Tabs.defaultProps>>;
|
|
72
47
|
|
|
73
48
|
static defaultProps = {
|
|
74
49
|
changeTabOnSwipe: true,
|
|
75
|
-
transitionSpacing: 'default',
|
|
76
50
|
headerWidth: Width.BLOCK,
|
|
77
51
|
} satisfies Partial<TabsProps>;
|
|
78
52
|
|
|
@@ -82,17 +56,10 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
82
56
|
super(props);
|
|
83
57
|
this.state = {
|
|
84
58
|
start: null,
|
|
85
|
-
translateX: 0,
|
|
86
|
-
translateFrom: 0,
|
|
87
|
-
translateTo: 0,
|
|
88
59
|
translateLineX: null,
|
|
89
|
-
isAnimating: false,
|
|
90
60
|
isSwiping: false,
|
|
91
61
|
isScrolling: false,
|
|
92
|
-
lastSwipeVelocity: 0,
|
|
93
62
|
fullWidthTabs: props.headerWidth === Width.BLOCK,
|
|
94
|
-
currentSwipe: [],
|
|
95
|
-
selectedTabIndex: props.selected,
|
|
96
63
|
};
|
|
97
64
|
}
|
|
98
65
|
|
|
@@ -102,10 +69,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
102
69
|
|
|
103
70
|
tabRefs: (HTMLLIElement | null)[] = [];
|
|
104
71
|
|
|
105
|
-
get filteredTabsLength() {
|
|
106
|
-
return this.props.tabs.filter((tab) => !tab.disabled).length;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
72
|
get MAX_INDEX() {
|
|
110
73
|
return this.props.tabs.length - 1;
|
|
111
74
|
}
|
|
@@ -115,13 +78,13 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
115
78
|
|
|
116
79
|
this.setTabWidth();
|
|
117
80
|
this.switchTab(clamp(selected, MIN_INDEX, this.MAX_INDEX));
|
|
118
|
-
this.
|
|
81
|
+
this.animateLine(clamp(selected, MIN_INDEX, this.MAX_INDEX));
|
|
119
82
|
document.body.addEventListener('touchmove', this.disableScroll, { passive: false });
|
|
120
83
|
document.body.addEventListener('touchforcechange', this.disableScroll, { passive: false });
|
|
121
84
|
window.addEventListener('resize', this.handleResize);
|
|
122
85
|
}
|
|
123
86
|
|
|
124
|
-
componentDidUpdate(previousProps: TabsProps
|
|
87
|
+
componentDidUpdate(previousProps: TabsProps) {
|
|
125
88
|
const currentSelected = this.props.selected;
|
|
126
89
|
const previousSelected = previousProps.selected;
|
|
127
90
|
const currentSelectedTab = this.props.tabs[currentSelected];
|
|
@@ -134,8 +97,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
134
97
|
const previousDisabledTabsLength = previousProps.tabs.filter((tab) => !tab.disabled).length;
|
|
135
98
|
const currentHeaderWidth = this.props.headerWidth;
|
|
136
99
|
const previousFullHeaderWidth = previousProps.headerWidth;
|
|
137
|
-
const { animatePanelsOnClick } = this.props;
|
|
138
|
-
const instantOnClick = !animatePanelsOnClick && !previousState.isSwiping;
|
|
139
100
|
|
|
140
101
|
if (
|
|
141
102
|
currentHeaderWidth !== previousFullHeaderWidth ||
|
|
@@ -149,10 +110,7 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
149
110
|
currentDisabledTabsLength !== previousDisabledTabsLength ||
|
|
150
111
|
currentSelectedTabIsDisabled !== previousSelectedTabIsDisabled
|
|
151
112
|
) {
|
|
152
|
-
this.
|
|
153
|
-
clamp(currentSelected, MIN_INDEX, this.MAX_INDEX),
|
|
154
|
-
currentSelected === previousSelected || instantOnClick,
|
|
155
|
-
);
|
|
113
|
+
this.animateLine(clamp(currentSelected, MIN_INDEX, this.MAX_INDEX));
|
|
156
114
|
}
|
|
157
115
|
}
|
|
158
116
|
|
|
@@ -164,10 +122,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
164
122
|
|
|
165
123
|
handleResize = () => {
|
|
166
124
|
this.setContainerWidth(this.container);
|
|
167
|
-
|
|
168
|
-
this.setState(({ selectedTabIndex }) => ({
|
|
169
|
-
translateTo: -(this.containerWidth * selectedTabIndex),
|
|
170
|
-
}));
|
|
171
125
|
};
|
|
172
126
|
|
|
173
127
|
setContainerRefAndWidth = (node: HTMLDivElement | null) => {
|
|
@@ -272,51 +226,11 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
272
226
|
|
|
273
227
|
swipedOverHalfOfContainer = (difference: number) => difference / this.containerWidth >= 0.5;
|
|
274
228
|
|
|
275
|
-
calculateApplicableDragDifference = ({
|
|
276
|
-
currentSelected,
|
|
277
|
-
nextSelected,
|
|
278
|
-
start,
|
|
279
|
-
end,
|
|
280
|
-
}: {
|
|
281
|
-
currentSelected: number;
|
|
282
|
-
nextSelected: number;
|
|
283
|
-
start: Swipe;
|
|
284
|
-
end: Swipe;
|
|
285
|
-
}) => {
|
|
286
|
-
const difference = getSwipeDifference(start, end);
|
|
287
|
-
const elasticDrag = getElasticDragDifference(difference);
|
|
288
|
-
|
|
289
|
-
if (swipedLeftToRight(start, end)) {
|
|
290
|
-
if (currentSelected > MIN_INDEX && currentSelected !== nextSelected) {
|
|
291
|
-
return Math.min(difference, this.containerWidth);
|
|
292
|
-
}
|
|
293
|
-
return elasticDrag;
|
|
294
|
-
}
|
|
295
|
-
if (swipedRightToLeft(start, end)) {
|
|
296
|
-
if (currentSelected < this.MAX_INDEX && currentSelected !== nextSelected) {
|
|
297
|
-
return -Math.min(difference, this.containerWidth);
|
|
298
|
-
}
|
|
299
|
-
return -elasticDrag;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return false;
|
|
303
|
-
};
|
|
304
|
-
|
|
305
229
|
switchTab = (index: number) => {
|
|
306
230
|
const { onTabSelect } = this.props;
|
|
307
231
|
onTabSelect(index);
|
|
308
232
|
};
|
|
309
233
|
|
|
310
|
-
getTabIndexWithoutDisabledTabs(index: number) {
|
|
311
|
-
return index - this.props.tabs.slice(0, index).filter((tab) => tab.disabled).length;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
animateToTab = (index: number, instant?: boolean) => {
|
|
315
|
-
this.animateLine(index);
|
|
316
|
-
|
|
317
|
-
this.animatePanel(this.getTabIndexWithoutDisabledTabs(index), instant);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
234
|
animateLine = (index: number) => {
|
|
321
235
|
this.setState((previousState) => ({
|
|
322
236
|
translateLineX: previousState.fullWidthTabs
|
|
@@ -325,21 +239,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
325
239
|
}));
|
|
326
240
|
};
|
|
327
241
|
|
|
328
|
-
// Pass `instant` to set the `translateX` to the new panel with no transition
|
|
329
|
-
animatePanel = (index: number, instant = false) => {
|
|
330
|
-
const { translateTo: currentTranslateTo } = this.state;
|
|
331
|
-
|
|
332
|
-
const translateFrom = currentTranslateTo;
|
|
333
|
-
const translateTo = -(this.containerWidth * index);
|
|
334
|
-
|
|
335
|
-
this.setState({
|
|
336
|
-
selectedTabIndex: index,
|
|
337
|
-
isAnimating: !instant && translateFrom !== translateTo,
|
|
338
|
-
translateFrom,
|
|
339
|
-
translateTo,
|
|
340
|
-
});
|
|
341
|
-
};
|
|
342
|
-
|
|
343
242
|
disableScroll = (event: Event) => {
|
|
344
243
|
const { isSwiping } = this.state;
|
|
345
244
|
|
|
@@ -366,10 +265,7 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
366
265
|
};
|
|
367
266
|
this.setState({
|
|
368
267
|
start,
|
|
369
|
-
currentSwipe: [start],
|
|
370
268
|
});
|
|
371
|
-
|
|
372
|
-
event.persist();
|
|
373
269
|
};
|
|
374
270
|
|
|
375
271
|
handleTouchMove: React.TouchEventHandler<HTMLDivElement> = (event) => {
|
|
@@ -379,7 +275,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
379
275
|
}
|
|
380
276
|
|
|
381
277
|
const { selected: currentSelectedFromProps } = this.props;
|
|
382
|
-
const selected = this.getTabIndexWithoutDisabledTabs(currentSelectedFromProps);
|
|
383
278
|
const end: Swipe = {
|
|
384
279
|
x: event.nativeEvent.changedTouches[0].clientX,
|
|
385
280
|
y: event.nativeEvent.changedTouches[0].clientY,
|
|
@@ -389,8 +284,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
389
284
|
const yAxisDifference = getSwipeDifference(start, end, 'y');
|
|
390
285
|
let { isScrolling, isSwiping } = this.state;
|
|
391
286
|
|
|
392
|
-
event.persist();
|
|
393
|
-
|
|
394
287
|
if (!isScrolling && !isSwiping) {
|
|
395
288
|
if (difference > yAxisDifference) {
|
|
396
289
|
isSwiping = true;
|
|
@@ -406,23 +299,6 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
406
299
|
this.animateLine(
|
|
407
300
|
this.swipedOverHalfOfContainer(difference) ? nextSelected : currentSelectedFromProps,
|
|
408
301
|
);
|
|
409
|
-
|
|
410
|
-
const dragDifference = this.calculateApplicableDragDifference({
|
|
411
|
-
currentSelected: currentSelectedFromProps,
|
|
412
|
-
nextSelected,
|
|
413
|
-
start,
|
|
414
|
-
end,
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
const translateX = dragDifference
|
|
418
|
-
? -(this.containerWidth * selected) + dragDifference
|
|
419
|
-
: false;
|
|
420
|
-
|
|
421
|
-
this.setState((state) => ({
|
|
422
|
-
currentSwipe: [...state.currentSwipe, end],
|
|
423
|
-
translateFrom: translateX || state.translateFrom,
|
|
424
|
-
translateTo: translateX || state.translateTo,
|
|
425
|
-
}));
|
|
426
302
|
}
|
|
427
303
|
};
|
|
428
304
|
|
|
@@ -439,16 +315,9 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
439
315
|
time: Date.now(),
|
|
440
316
|
};
|
|
441
317
|
const difference = getSwipeDifference(start, end);
|
|
442
|
-
const velocity = getVelocity([...this.state.currentSwipe, end]);
|
|
443
|
-
|
|
444
|
-
this.setState({
|
|
445
|
-
currentSwipe: [],
|
|
446
|
-
});
|
|
447
318
|
|
|
448
319
|
let nextSelected = selected;
|
|
449
320
|
|
|
450
|
-
event.persist();
|
|
451
|
-
|
|
452
321
|
if (isSwiping) {
|
|
453
322
|
if (swipeShouldChangeTab(start, end) || this.swipedOverHalfOfContainer(difference)) {
|
|
454
323
|
nextSelected = this.getTabToSelect(nextSelected, start, end);
|
|
@@ -456,12 +325,8 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
456
325
|
|
|
457
326
|
if (nextSelected !== selected) {
|
|
458
327
|
this.switchTab(nextSelected);
|
|
459
|
-
|
|
460
|
-
this.setState({
|
|
461
|
-
lastSwipeVelocity: velocity,
|
|
462
|
-
});
|
|
463
328
|
} else {
|
|
464
|
-
this.
|
|
329
|
+
this.animateLine(nextSelected);
|
|
465
330
|
}
|
|
466
331
|
}
|
|
467
332
|
|
|
@@ -469,47 +334,10 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
469
334
|
};
|
|
470
335
|
|
|
471
336
|
render() {
|
|
472
|
-
const { tabs, changeTabOnSwipe, name, selected, className,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
translateLineX,
|
|
477
|
-
isAnimating,
|
|
478
|
-
translateFrom,
|
|
479
|
-
translateTo,
|
|
480
|
-
lastSwipeVelocity,
|
|
481
|
-
fullWidthTabs,
|
|
482
|
-
} = this.state;
|
|
483
|
-
|
|
484
|
-
const spacer = SpacerWidth[transitionSpacing];
|
|
485
|
-
|
|
486
|
-
const tabsLength = this.filteredTabsLength;
|
|
487
|
-
|
|
488
|
-
const distanceSwiped = Math.abs(-translateFrom - this.containerWidth * selected);
|
|
489
|
-
|
|
490
|
-
const remainingContainerToTravel = isSwiping
|
|
491
|
-
? 1 - distanceSwiped / this.containerWidth
|
|
492
|
-
: 1 - Math.abs(distanceSwiped / this.containerWidth - 1);
|
|
493
|
-
|
|
494
|
-
const restrictedVelocity =
|
|
495
|
-
(Number.isNaN(remainingContainerToTravel) ? 0 : remainingContainerToTravel) *
|
|
496
|
-
Math.min(10 * Math.E, lastSwipeVelocity * 10 * Math.E);
|
|
497
|
-
|
|
498
|
-
const hidePanelOverflow = isAnimating || isSwiping;
|
|
499
|
-
|
|
500
|
-
const sliderWidth = tabsLength * this.containerWidth + spacer * 2;
|
|
501
|
-
|
|
502
|
-
// Uses `props.panelTransitionSpacing` to add a spacer in-between the `TabPanel` you're transitioning to/from
|
|
503
|
-
const Spacer = ({ id }: { id: string }) =>
|
|
504
|
-
spacer > 0 && (
|
|
505
|
-
<div
|
|
506
|
-
key={id}
|
|
507
|
-
style={{
|
|
508
|
-
width: spacer,
|
|
509
|
-
display: hidePanelOverflow ? 'block' : 'none',
|
|
510
|
-
}}
|
|
511
|
-
/>
|
|
512
|
-
);
|
|
337
|
+
const { tabs, changeTabOnSwipe, name, selected, className, headerWidth } = this.props;
|
|
338
|
+
const { translateLineX, fullWidthTabs } = this.state;
|
|
339
|
+
|
|
340
|
+
const selectedTab = tabs[selected];
|
|
513
341
|
|
|
514
342
|
return (
|
|
515
343
|
<DirectionContext.Consumer>
|
|
@@ -565,64 +393,19 @@ export default class Tabs extends Component<TabsProps, TabsState> {
|
|
|
565
393
|
/>
|
|
566
394
|
) : null}
|
|
567
395
|
</TabList>
|
|
568
|
-
<div
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}}
|
|
582
|
-
config={{
|
|
583
|
-
precision: isSwiping ? 1 : 0.01,
|
|
584
|
-
velocity: !isSwiping ? restrictedVelocity : 0,
|
|
585
|
-
clamp: true,
|
|
586
|
-
}}
|
|
587
|
-
onRest={() => {
|
|
588
|
-
if (isAnimating) {
|
|
589
|
-
this.setState({
|
|
590
|
-
isAnimating: false,
|
|
591
|
-
lastSwipeVelocity: 0,
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
}}
|
|
595
|
-
>
|
|
596
|
-
{(props) => (
|
|
597
|
-
<animated.div
|
|
598
|
-
className="tabs__slider"
|
|
599
|
-
style={{
|
|
600
|
-
width: hidePanelOverflow ? `${sliderWidth}px` : '100%',
|
|
601
|
-
transform: hidePanelOverflow ? props.transform : 'translateX(0px)',
|
|
602
|
-
}}
|
|
603
|
-
>
|
|
604
|
-
{tabs.map(({ content, disabled }, index) =>
|
|
605
|
-
!disabled ? (
|
|
606
|
-
<Fragment key={`${tabs[index].title}-fragment`}>
|
|
607
|
-
{index === selected && <Spacer id="left-spacer" />}
|
|
608
|
-
<TabPanel
|
|
609
|
-
key={tabs[index].title}
|
|
610
|
-
tabId={`${name}-tab-${index}`}
|
|
611
|
-
id={`${name}-panel-${index}`}
|
|
612
|
-
style={{
|
|
613
|
-
width: hidePanelOverflow ? `${this.containerWidth}px` : '100%',
|
|
614
|
-
display: hidePanelOverflow || index === selected ? 'block' : 'none',
|
|
615
|
-
}}
|
|
616
|
-
>
|
|
617
|
-
{content}
|
|
618
|
-
</TabPanel>
|
|
619
|
-
{index === selected && <Spacer id="right-spacer" />}
|
|
620
|
-
</Fragment>
|
|
621
|
-
) : null,
|
|
622
|
-
)}
|
|
623
|
-
</animated.div>
|
|
624
|
-
)}
|
|
625
|
-
</Spring>
|
|
396
|
+
<div ref={this.setContainerRefAndWidth} className="tabs__panel-container">
|
|
397
|
+
{selectedTab && !selectedTab.disabled ? (
|
|
398
|
+
<TabPanel
|
|
399
|
+
key={selectedTab.title}
|
|
400
|
+
tabId={`${name}-tab-${selected}`}
|
|
401
|
+
id={`${name}-panel-${selected}`}
|
|
402
|
+
style={{
|
|
403
|
+
width: '100%',
|
|
404
|
+
}}
|
|
405
|
+
>
|
|
406
|
+
{selectedTab.content}
|
|
407
|
+
</TabPanel>
|
|
408
|
+
) : null}
|
|
626
409
|
</div>
|
|
627
410
|
</div>
|
|
628
411
|
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
swipedLeftToRight,
|
|
3
|
+
swipedRightToLeft,
|
|
4
|
+
getSwipeDifference,
|
|
5
|
+
swipeShouldChangeTab,
|
|
6
|
+
Swipe,
|
|
7
|
+
} from './utils';
|
|
8
|
+
|
|
9
|
+
describe('Tabs Utility', () => {
|
|
10
|
+
let start: Swipe;
|
|
11
|
+
let end: Swipe;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
jest.clearAllMocks();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('when the ending x axis is greater than the starting x axis', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
start = { x: 0, y: 0, time: 1569538800000 };
|
|
20
|
+
end = { x: 50, y: 0, time: 1569538800300 };
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('determines that the swipe was left to right', () => {
|
|
24
|
+
expect(swipedLeftToRight(start, end)).toBe(true);
|
|
25
|
+
expect(swipedRightToLeft(start, end)).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('calculates the correct swipe difference', () => {
|
|
29
|
+
expect(getSwipeDifference(start, end)).toBe(50);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('when the ending x axis is less than the starting x axis', () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
start = { x: 50, y: 0, time: 1569538800000 };
|
|
36
|
+
end = { x: 0, y: 0, time: 1569538800300 };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('determines that the swipe was right to left', () => {
|
|
40
|
+
expect(swipedRightToLeft(start, end)).toBe(true);
|
|
41
|
+
expect(swipedLeftToRight(start, end)).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('calculates the correct swipe difference', () => {
|
|
45
|
+
expect(getSwipeDifference(start, end)).toBe(50);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('checking if a swipe should change tabs', () => {
|
|
50
|
+
it('should change tab when the difference and velocity are significant', () => {
|
|
51
|
+
start = { x: 0, y: 0, time: 1569538800000 };
|
|
52
|
+
end = { x: 100, y: 0, time: 1569538800001 };
|
|
53
|
+
expect(swipeShouldChangeTab(start, end)).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('should not change tab when the difference is small', () => {
|
|
57
|
+
start = { x: 0, y: 0, time: 1569538800000 };
|
|
58
|
+
end = { x: 1, y: 0, time: 1569538800001 };
|
|
59
|
+
expect(swipeShouldChangeTab(start, end)).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should not change tab when the velocity is small', () => {
|
|
63
|
+
start = { x: 0, y: 0, time: 1569538800000 };
|
|
64
|
+
end = { x: 100, y: 0, time: 1569538900000 };
|
|
65
|
+
expect(swipeShouldChangeTab(start, end)).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
package/src/tabs/utils.ts
CHANGED
|
@@ -35,23 +35,3 @@ export const swipeShouldChangeTab = (start: Swipe, end: Swipe) => {
|
|
|
35
35
|
|
|
36
36
|
return swipedSignificantDistance(difference) && swipedWithSignificantVelocity(velocity);
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
export function getVelocity(coords: Swipe[]) {
|
|
40
|
-
try {
|
|
41
|
-
const relevant = coords.slice(Math.max(coords.length - 5, 1));
|
|
42
|
-
const first = relevant[0];
|
|
43
|
-
const last = relevant[relevant.length - 1];
|
|
44
|
-
|
|
45
|
-
return Math.abs(first.x - last.x) / (last.time - first.time);
|
|
46
|
-
} catch {
|
|
47
|
-
return 0;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/*
|
|
52
|
-
`elasticDrag` is the translateX value, which slows down as the difference increases
|
|
53
|
-
`1 - Math.E ** (-0.005 * difference)` provides a % value of how far we want to translate (0.005 being the rate)
|
|
54
|
-
`Math.min(150, window.innerWidth / 3)` provides the maximum translate value
|
|
55
|
-
*/
|
|
56
|
-
export const getElasticDragDifference = (difference: number) =>
|
|
57
|
-
Math.min(150, window.innerWidth / 3) * (1 - Math.E ** (-0.005 * difference));
|
|
@@ -4,7 +4,7 @@ import { userEvent, within } from 'storybook/test';
|
|
|
4
4
|
import Button from '../button';
|
|
5
5
|
|
|
6
6
|
import Tooltip from './Tooltip';
|
|
7
|
-
import {
|
|
7
|
+
import { withVariantConfig } from '../../.storybook/helpers';
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
component: Tooltip,
|
|
@@ -40,10 +40,5 @@ export const OpenedTooltip: Story = {
|
|
|
40
40
|
|
|
41
41
|
export const OpenedTooltipDark: Story = {
|
|
42
42
|
...OpenedTooltip,
|
|
43
|
-
|
|
44
|
-
variants: ['dark'],
|
|
45
|
-
chromatic: {
|
|
46
|
-
dark: allModes.dark,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
43
|
+
...withVariantConfig(['dark'], OpenedTooltip),
|
|
49
44
|
};
|
package/src/tabs/utils.spec.ts
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getElasticDragDifference,
|
|
3
|
-
swipedLeftToRight,
|
|
4
|
-
swipedRightToLeft,
|
|
5
|
-
getSwipeDifference,
|
|
6
|
-
swipeShouldChangeTab,
|
|
7
|
-
getVelocity,
|
|
8
|
-
Swipe,
|
|
9
|
-
} from './utils';
|
|
10
|
-
|
|
11
|
-
describe('Tabs Utility', () => {
|
|
12
|
-
let start: Swipe;
|
|
13
|
-
let end: Swipe;
|
|
14
|
-
let coords: Swipe[];
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
jest.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('when the ending x axis is greater than the starting x axis', () => {
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
start = { x: 0, y: 0, time: 1569538800000 };
|
|
23
|
-
end = { x: 50, y: 0, time: 1569538800300 };
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('determines that the swipe was left to right', () => {
|
|
27
|
-
expect(swipedLeftToRight(start, end)).toBe(true);
|
|
28
|
-
expect(swipedRightToLeft(start, end)).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('calculates the correct swipe difference', () => {
|
|
32
|
-
expect(getSwipeDifference(start, end)).toBe(50);
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
describe('when the ending x axis is less than the starting x axis', () => {
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
start = { x: 50, y: 0, time: 1569538800000 };
|
|
39
|
-
end = { x: 0, y: 0, time: 1569538800300 };
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('determines that the swipe was right to left', () => {
|
|
43
|
-
expect(swipedRightToLeft(start, end)).toBe(true);
|
|
44
|
-
expect(swipedLeftToRight(start, end)).toBe(false);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('calculates the correct swipe difference', () => {
|
|
48
|
-
expect(getSwipeDifference(start, end)).toBe(50);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('checking if a swipe should change tabs', () => {
|
|
53
|
-
it('should change tab when the difference and velocity are significant', () => {
|
|
54
|
-
start = { x: 0, y: 0, time: 1569538800000 };
|
|
55
|
-
end = { x: 100, y: 0, time: 1569538800001 };
|
|
56
|
-
expect(swipeShouldChangeTab(start, end)).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should not change tab when the difference is small', () => {
|
|
60
|
-
start = { x: 0, y: 0, time: 1569538800000 };
|
|
61
|
-
end = { x: 1, y: 0, time: 1569538800001 };
|
|
62
|
-
expect(swipeShouldChangeTab(start, end)).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should not change tab when the velocity is small', () => {
|
|
66
|
-
start = { x: 0, y: 0, time: 1569538800000 };
|
|
67
|
-
end = { x: 100, y: 0, time: 1569538900000 };
|
|
68
|
-
expect(swipeShouldChangeTab(start, end)).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('checking for velocity against an array of touches', () => {
|
|
73
|
-
beforeEach(() => {
|
|
74
|
-
coords = [
|
|
75
|
-
{ x: 0, y: 0, time: 1569538800000 },
|
|
76
|
-
{ x: 100, y: 0, time: 1569538825000 },
|
|
77
|
-
{ x: 200, y: 0, time: 1569538850000 },
|
|
78
|
-
{ x: 300, y: 0, time: 1569538875000 },
|
|
79
|
-
{ x: 400, y: 0, time: 1569538900000 },
|
|
80
|
-
];
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should return the difference in velocity between the first and last touch in an array', () => {
|
|
84
|
-
expect(getVelocity(coords)).toBe(0.004);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should only take into account the last 5 coordinates', () => {
|
|
88
|
-
coords.unshift(
|
|
89
|
-
{ x: 10000, y: 0, time: 1569538800000 },
|
|
90
|
-
{ x: 100000, y: 0, time: 1569538800000 },
|
|
91
|
-
);
|
|
92
|
-
expect(getVelocity(coords)).toBe(0.004);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('returns a default 0 if there are any issues with the touches passed in', () => {
|
|
96
|
-
expect(getVelocity([])).toBe(0);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('applying elasticity to a drag event', () => {
|
|
101
|
-
it('gradually reduces the amount of difference returned toward a maximum distance', () => {
|
|
102
|
-
global.innerWidth = 375;
|
|
103
|
-
const maximumDraggableDistance = 125;
|
|
104
|
-
|
|
105
|
-
expect(getElasticDragDifference(0)).toBe(0);
|
|
106
|
-
expect(getApproximateElasticDragDifference(50)).toBe(28);
|
|
107
|
-
expect(getApproximateElasticDragDifference(100)).toBe(49);
|
|
108
|
-
expect(getApproximateElasticDragDifference(150)).toBe(66);
|
|
109
|
-
expect(getApproximateElasticDragDifference(200)).toBe(79);
|
|
110
|
-
expect(getApproximateElasticDragDifference(250)).toBe(89);
|
|
111
|
-
expect(getApproximateElasticDragDifference(300)).toBe(97);
|
|
112
|
-
expect(getApproximateElasticDragDifference(350)).toBe(103);
|
|
113
|
-
|
|
114
|
-
expect(getElasticDragDifference(10000)).toBe(maximumDraggableDistance);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('limits the maximum dragable distance on larger screens', () => {
|
|
118
|
-
global.innerWidth = 1024;
|
|
119
|
-
const maximumDraggableDistance = 150;
|
|
120
|
-
expect(getElasticDragDifference(10000)).toBe(maximumDraggableDistance);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const getApproximateElasticDragDifference = (difference: number) =>
|
|
126
|
-
Math.round(getElasticDragDifference(difference));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/actionButton/__snapshots__/{ActionButton.spec.tsx.snap → ActionButton.test.tsx.snap}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|