@transferwise/components 37.0.0 → 37.0.1-beta.23
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/CHANGELOG.md +264 -0
- package/build/es/no-polyfill/accordion/Accordion.js +1 -1
- package/build/es/no-polyfill/accordion/AccordionItem/AccordionItem.js +1 -1
- package/build/es/no-polyfill/actionOption/ActionOption.js +1 -1
- package/build/es/no-polyfill/actionOption/ActionOption.story.js +1 -1
- package/build/es/no-polyfill/alert/Alert.js +1 -1
- package/build/es/no-polyfill/alert/inlineMarkdown/InlineMarkdown.js +1 -1
- package/build/es/no-polyfill/alert/withArrow/withArrow.js +1 -1
- package/build/es/no-polyfill/avatar/Avatar.js +1 -1
- package/build/es/no-polyfill/avatarWrapper/AvatarWrapper.js +1 -1
- package/build/es/no-polyfill/badge/Badge.js +1 -1
- package/build/es/no-polyfill/button/Button.js +1 -2
- package/build/es/no-polyfill/card/Card.js +2 -5
- package/build/es/no-polyfill/checkbox/Checkbox.js +1 -1
- package/build/es/no-polyfill/checkboxButton/CheckboxButton.js +1 -1
- package/build/es/no-polyfill/checkboxOption/CheckboxOption.js +1 -1
- package/build/es/no-polyfill/chevron/Chevron.js +1 -1
- package/build/es/no-polyfill/chip/Chip.js +8 -2
- package/build/es/no-polyfill/circularButton/CircularButton.js +1 -1
- package/build/es/no-polyfill/common/Option/Option.js +1 -1
- package/build/es/no-polyfill/common/Option/OptionDocumentation.js +1 -0
- package/build/es/no-polyfill/common/RadioButton/RadioButton.js +1 -1
- package/build/es/no-polyfill/common/bottomSheet/BottomSheet.js +4 -6
- package/build/es/no-polyfill/common/closeButton/CloseButton.js +1 -1
- package/build/es/no-polyfill/common/focusBoundary/FocusBoundary.js +1 -1
- package/build/es/no-polyfill/common/focusBoundary/utils/getFocusableElements.js +2 -2
- package/build/es/no-polyfill/common/focusBoundary/utils/resetFocus.js +2 -2
- package/build/es/no-polyfill/common/historyNavigator/historyNavigator.js +1 -1
- package/build/es/no-polyfill/common/hooks/useClientWidth/useClientWidth.js +2 -1
- package/build/es/no-polyfill/common/hooks/useConditionalListener/useConditionalListener.js +3 -5
- package/build/es/no-polyfill/common/hooks/useHasIntersected/useHasIntersected.js +3 -2
- package/build/es/no-polyfill/common/keyCodes.js +1 -0
- package/build/es/no-polyfill/common/panel/Panel.js +2 -3
- package/build/es/no-polyfill/common/requirements.js +2 -2
- package/build/es/no-polyfill/common/responsivePanel/ResponsivePanel.js +1 -1
- package/build/es/no-polyfill/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.js +1 -1
- package/build/es/no-polyfill/common/textFormat/unformatWithPattern/unformatWithPattern.js +1 -1
- package/build/es/no-polyfill/dateInput/DateInput.js +3 -4
- package/build/es/no-polyfill/dateInput/DateInput.messages.js +1 -0
- package/build/es/no-polyfill/dateLookup/DateLookup.js +1 -1
- package/build/es/no-polyfill/dateLookup/dateTrigger/DateTrigger.js +1 -1
- package/build/es/no-polyfill/dateLookup/dayCalendar/DayCalendar.js +1 -1
- package/build/es/no-polyfill/dateLookup/dayCalendar/table/DayCalendarTable.js +3 -3
- package/build/es/no-polyfill/dateLookup/header/Header.js +1 -1
- package/build/es/no-polyfill/dateLookup/monthCalendar/MonthCalendar.js +1 -1
- package/build/es/no-polyfill/dateLookup/monthCalendar/table/MonthCalendarTable.js +1 -1
- package/build/es/no-polyfill/dateLookup/tableLink/TableLink.js +1 -1
- package/build/es/no-polyfill/dateLookup/yearCalendar/YearCalendar.js +1 -1
- package/build/es/no-polyfill/dateLookup/yearCalendar/table/YearCalendarTable.js +1 -1
- package/build/es/no-polyfill/decision/Decision.js +5 -5
- package/build/es/no-polyfill/definitionList/DefinitionList.js +1 -1
- package/build/es/no-polyfill/dimmer/Dimmer.js +3 -3
- package/build/es/no-polyfill/drawer/Drawer.js +1 -1
- package/build/es/no-polyfill/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +1 -1
- package/build/es/no-polyfill/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +2 -4
- package/build/es/no-polyfill/dynamicFieldDefinitionList/utils/text-format.js +1 -1
- package/build/es/no-polyfill/emphasis/Emphasis.js +1 -1
- package/build/es/no-polyfill/flowNavigation/FlowNavigation.js +1 -1
- package/build/es/no-polyfill/flowNavigation/animatedLabel/AnimatedLabel.js +1 -1
- package/build/es/no-polyfill/flowNavigation/backButton/BackButton.js +1 -1
- package/build/es/no-polyfill/header/Header.js +1 -1
- package/build/es/no-polyfill/i18n/en.json +3 -2
- package/build/es/no-polyfill/i18n/index.js +1 -1
- package/build/es/no-polyfill/image/Image.js +4 -5
- package/build/es/no-polyfill/info/Info.js +1 -1
- package/build/es/no-polyfill/inlineAlert/InlineAlert.js +1 -1
- package/build/es/no-polyfill/instructionsList/InstructionsList.js +1 -1
- package/build/es/no-polyfill/lab/mobileNav/MobileNav.js +2 -2
- package/build/es/no-polyfill/lab/pagination/Pagination.js +1 -1
- package/build/es/no-polyfill/lab/pagination/paginationLink/PaginationLink.js +1 -1
- package/build/es/no-polyfill/link/Link.js +4 -3
- package/build/es/no-polyfill/link/Link.spec.js +1 -0
- package/build/es/no-polyfill/link/Link.story.js +1 -0
- package/build/es/no-polyfill/loader/Loader.js +7 -3
- package/build/es/no-polyfill/logo/Logo.js +1 -1
- package/build/es/no-polyfill/markdown/Markdown.js +1 -1
- package/build/es/no-polyfill/modal/Modal.js +1 -1
- package/build/es/no-polyfill/money/Money.js +1 -1
- package/build/es/no-polyfill/moneyInput/MoneyInput.js +1 -2
- package/build/es/no-polyfill/navigationOption/NavigationOption.js +1 -1
- package/build/es/no-polyfill/navigationOptionsList/NavigationOptionsList.js +1 -1
- package/build/es/no-polyfill/nudge/Nudge.js +1 -1
- package/build/es/no-polyfill/overlayHeader/OverlayHeader.js +1 -1
- package/build/es/no-polyfill/phoneNumberInput/PhoneNumberInput.js +1 -1
- package/build/es/no-polyfill/phoneNumberInput/utils/explodeNumberModel/index.js +2 -1
- package/build/es/no-polyfill/phoneNumberInput/utils/filterOptionsForQuery/index.js +1 -0
- package/build/es/no-polyfill/phoneNumberInput/utils/findCountryByCode/index.js +1 -1
- package/build/es/no-polyfill/phoneNumberInput/utils/findCountryByPrefix/index.js +1 -1
- package/build/es/no-polyfill/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.js +1 -0
- package/build/es/no-polyfill/phoneNumberInput/utils/setDefaultPrefix/index.js +2 -0
- package/build/es/no-polyfill/popover/Popover.js +1 -1
- package/build/es/no-polyfill/processIndicator/ProcessIndicator.js +4 -1
- package/build/es/no-polyfill/provider/Provider.js +1 -1
- package/build/es/no-polyfill/provider/direction/DirectionProvider.js +1 -1
- package/build/es/no-polyfill/radio/Radio.js +1 -1
- package/build/es/no-polyfill/radioGroup/RadioGroup.js +2 -2
- package/build/es/no-polyfill/radioOption/RadioOption.js +1 -1
- package/build/es/no-polyfill/select/Select.js +3 -5
- package/build/es/no-polyfill/select/option/Option.js +1 -1
- package/build/es/no-polyfill/select/searchBox/SearchBox.js +1 -1
- package/build/es/no-polyfill/sizeSwapper/SizeSwapper.js +4 -2
- package/build/es/no-polyfill/slidingPanel/SlidingPanel.js +2 -2
- package/build/es/no-polyfill/snackbar/Snackbar.js +1 -1
- package/build/es/no-polyfill/snackbar/SnackbarProvider.js +1 -1
- package/build/es/no-polyfill/stepper/Stepper.js +1 -1
- package/build/es/no-polyfill/stepper/deviceDetection.js +2 -1
- package/build/es/no-polyfill/summary/Summary.js +1 -4
- package/build/es/no-polyfill/switch/Switch.js +1 -1
- package/build/es/no-polyfill/switch/Switch.story.js +1 -1
- package/build/es/no-polyfill/switchOption/SwitchOption.js +1 -1
- package/build/es/no-polyfill/switchOption/SwitchOption.story.js +1 -1
- package/build/es/no-polyfill/tabs/Tab.js +1 -1
- package/build/es/no-polyfill/tabs/Tabs.js +1 -1
- package/build/es/no-polyfill/tile/Tile.js +1 -1
- package/build/es/no-polyfill/tooltip/Tooltip.js +1 -1
- package/build/es/no-polyfill/typeahead/Typeahead.js +1 -2
- package/build/es/no-polyfill/typeahead/typeaheadInput/TypeaheadInput.js +1 -1
- package/build/es/no-polyfill/typeahead/typeaheadOption/TypeaheadOption.js +1 -1
- package/build/es/no-polyfill/typeahead/util/highlight.js +1 -1
- package/build/es/no-polyfill/upload/Upload.js +3 -5
- package/build/es/no-polyfill/upload/steps/completeStep/completeStep.js +1 -1
- package/build/es/no-polyfill/upload/steps/mediaUploadStep/mediaUploadStep.js +1 -1
- package/build/es/no-polyfill/upload/steps/processingStep/processingStep.js +1 -1
- package/build/es/no-polyfill/upload/steps/uploadImageStep/uploadImageStep.js +1 -1
- package/build/es/no-polyfill/upload/utils/asyncFileRead/asyncFileRead.js +1 -1
- package/build/es/no-polyfill/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.js +1 -1
- package/build/es/no-polyfill/upload/utils/index.js +1 -1
- package/build/es/no-polyfill/uploadInput/UploadInput.js +4 -6
- package/build/es/no-polyfill/uploadInput/UploadInput.spec.js +1 -1
- package/build/es/no-polyfill/uploadInput/UploadInput.story.js +1 -1
- package/build/es/no-polyfill/uploadInput/types.js +1 -0
- package/build/es/no-polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
- package/build/es/no-polyfill/uploadInput/uploadButton/UploadButton.spec.js +3 -1
- package/build/es/no-polyfill/uploadInput/uploadButton/getAllowedFileTypes.spec.js +1 -1
- package/build/es/no-polyfill/uploadInput/uploadItem/UploadItem.js +2 -2
- package/build/es/no-polyfill/uploadInput/uploadItem/UploadItem.spec.js +1 -1
- package/build/es/no-polyfill/uploadInput/uploadItem/UploadItemBody.js +1 -1
- package/build/es/no-polyfill/utilities/{deprecatedProp/deprecatedProp.js → deprecatedProperty/deprecatedProperty.js} +0 -0
- package/build/es/no-polyfill/utilities/deprecatedProperty/index.js +1 -0
- package/build/es/no-polyfill/utilities/index.js +1 -1
- package/build/es/no-polyfill/utilities/logActionRequired.js +1 -1
- package/build/es/no-polyfill/withDisplayFormat/WithDisplayFormat.js +2 -2
- package/build/es/no-polyfill/withNextPortal/withNextPortal.js +1 -1
- package/build/es/no-polyfill/withNormaliser/WithNormalizer.js +3 -0
- package/build/es/polyfill/accordion/Accordion.js +1 -1
- package/build/es/polyfill/accordion/AccordionItem/AccordionItem.js +1 -1
- package/build/es/polyfill/actionOption/ActionOption.js +1 -1
- package/build/es/polyfill/actionOption/ActionOption.story.js +1 -1
- package/build/es/polyfill/alert/Alert.js +1 -1
- package/build/es/polyfill/alert/inlineMarkdown/InlineMarkdown.js +1 -1
- package/build/es/polyfill/alert/withArrow/withArrow.js +1 -1
- package/build/es/polyfill/avatar/Avatar.js +1 -1
- package/build/es/polyfill/avatarWrapper/AvatarWrapper.js +1 -1
- package/build/es/polyfill/badge/Badge.js +1 -1
- package/build/es/polyfill/button/Button.js +1 -2
- package/build/es/polyfill/card/Card.js +2 -5
- package/build/es/polyfill/checkbox/Checkbox.js +1 -1
- package/build/es/polyfill/checkboxButton/CheckboxButton.js +1 -1
- package/build/es/polyfill/checkboxOption/CheckboxOption.js +1 -1
- package/build/es/polyfill/chevron/Chevron.js +1 -1
- package/build/es/polyfill/chip/Chip.js +8 -2
- package/build/es/polyfill/circularButton/CircularButton.js +1 -1
- package/build/es/polyfill/common/Option/Option.js +1 -1
- package/build/es/polyfill/common/Option/OptionDocumentation.js +1 -0
- package/build/es/polyfill/common/RadioButton/RadioButton.js +1 -1
- package/build/es/polyfill/common/bottomSheet/BottomSheet.js +4 -6
- package/build/es/polyfill/common/closeButton/CloseButton.js +1 -1
- package/build/es/polyfill/common/focusBoundary/FocusBoundary.js +1 -1
- package/build/es/polyfill/common/focusBoundary/utils/getFocusableElements.js +2 -2
- package/build/es/polyfill/common/focusBoundary/utils/resetFocus.js +2 -2
- package/build/es/polyfill/common/historyNavigator/historyNavigator.js +1 -1
- package/build/es/polyfill/common/hooks/useClientWidth/useClientWidth.js +2 -1
- package/build/es/polyfill/common/hooks/useConditionalListener/useConditionalListener.js +3 -5
- package/build/es/polyfill/common/hooks/useHasIntersected/useHasIntersected.js +3 -2
- package/build/es/polyfill/common/keyCodes.js +1 -0
- package/build/es/polyfill/common/panel/Panel.js +2 -3
- package/build/es/polyfill/common/requirements.js +2 -2
- package/build/es/polyfill/common/responsivePanel/ResponsivePanel.js +1 -1
- package/build/es/polyfill/common/textFormat/getCursorPositionAfterKeystroke/getCursorPositionAfterKeystroke.js +1 -1
- package/build/es/polyfill/common/textFormat/unformatWithPattern/unformatWithPattern.js +1 -1
- package/build/es/polyfill/dateInput/DateInput.js +3 -4
- package/build/es/polyfill/dateInput/DateInput.messages.js +1 -0
- package/build/es/polyfill/dateLookup/DateLookup.js +1 -1
- package/build/es/polyfill/dateLookup/dateTrigger/DateTrigger.js +1 -1
- package/build/es/polyfill/dateLookup/dayCalendar/DayCalendar.js +1 -1
- package/build/es/polyfill/dateLookup/dayCalendar/table/DayCalendarTable.js +3 -3
- package/build/es/polyfill/dateLookup/header/Header.js +1 -1
- package/build/es/polyfill/dateLookup/monthCalendar/MonthCalendar.js +1 -1
- package/build/es/polyfill/dateLookup/monthCalendar/table/MonthCalendarTable.js +1 -1
- package/build/es/polyfill/dateLookup/tableLink/TableLink.js +1 -1
- package/build/es/polyfill/dateLookup/yearCalendar/YearCalendar.js +1 -1
- package/build/es/polyfill/dateLookup/yearCalendar/table/YearCalendarTable.js +1 -1
- package/build/es/polyfill/decision/Decision.js +5 -5
- package/build/es/polyfill/definitionList/DefinitionList.js +1 -1
- package/build/es/polyfill/dimmer/Dimmer.js +3 -3
- package/build/es/polyfill/drawer/Drawer.js +1 -1
- package/build/es/polyfill/dynamicFieldDefinitionList/DynamicFieldDefinitionList.js +1 -1
- package/build/es/polyfill/dynamicFieldDefinitionList/FormattedValue/FormattedValue.js +2 -4
- package/build/es/polyfill/dynamicFieldDefinitionList/utils/text-format.js +1 -1
- package/build/es/polyfill/emphasis/Emphasis.js +1 -1
- package/build/es/polyfill/flowNavigation/FlowNavigation.js +1 -1
- package/build/es/polyfill/flowNavigation/animatedLabel/AnimatedLabel.js +1 -1
- package/build/es/polyfill/flowNavigation/backButton/BackButton.js +1 -1
- package/build/es/polyfill/header/Header.js +1 -1
- package/build/es/polyfill/i18n/en.json +3 -2
- package/build/es/polyfill/i18n/index.js +1 -1
- package/build/es/polyfill/image/Image.js +4 -5
- package/build/es/polyfill/info/Info.js +1 -1
- package/build/es/polyfill/inlineAlert/InlineAlert.js +1 -1
- package/build/es/polyfill/instructionsList/InstructionsList.js +1 -1
- package/build/es/polyfill/lab/mobileNav/MobileNav.js +2 -2
- package/build/es/polyfill/lab/pagination/Pagination.js +1 -1
- package/build/es/polyfill/lab/pagination/paginationLink/PaginationLink.js +1 -1
- package/build/es/polyfill/link/Link.js +4 -3
- package/build/es/polyfill/link/Link.spec.js +1 -0
- package/build/es/polyfill/link/Link.story.js +1 -0
- package/build/es/polyfill/loader/Loader.js +7 -3
- package/build/es/polyfill/logo/Logo.js +1 -1
- package/build/es/polyfill/markdown/Markdown.js +1 -1
- package/build/es/polyfill/modal/Modal.js +1 -1
- package/build/es/polyfill/money/Money.js +1 -1
- package/build/es/polyfill/moneyInput/MoneyInput.js +1 -2
- package/build/es/polyfill/navigationOption/NavigationOption.js +1 -1
- package/build/es/polyfill/navigationOptionsList/NavigationOptionsList.js +1 -1
- package/build/es/polyfill/nudge/Nudge.js +1 -1
- package/build/es/polyfill/overlayHeader/OverlayHeader.js +1 -1
- package/build/es/polyfill/phoneNumberInput/PhoneNumberInput.js +1 -1
- package/build/es/polyfill/phoneNumberInput/utils/explodeNumberModel/index.js +3 -2
- package/build/es/polyfill/phoneNumberInput/utils/filterOptionsForQuery/index.js +1 -0
- package/build/es/polyfill/phoneNumberInput/utils/findCountryByCode/index.js +1 -1
- package/build/es/polyfill/phoneNumberInput/utils/findCountryByPrefix/index.js +1 -1
- package/build/es/polyfill/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.js +1 -0
- package/build/es/polyfill/phoneNumberInput/utils/setDefaultPrefix/index.js +2 -0
- package/build/es/polyfill/popover/Popover.js +1 -1
- package/build/es/polyfill/processIndicator/ProcessIndicator.js +4 -1
- package/build/es/polyfill/provider/Provider.js +1 -1
- package/build/es/polyfill/provider/direction/DirectionProvider.js +1 -1
- package/build/es/polyfill/radio/Radio.js +1 -1
- package/build/es/polyfill/radioGroup/RadioGroup.js +2 -2
- package/build/es/polyfill/radioOption/RadioOption.js +1 -1
- package/build/es/polyfill/select/Select.js +3 -5
- package/build/es/polyfill/select/option/Option.js +1 -1
- package/build/es/polyfill/select/searchBox/SearchBox.js +1 -1
- package/build/es/polyfill/sizeSwapper/SizeSwapper.js +4 -2
- package/build/es/polyfill/slidingPanel/SlidingPanel.js +2 -2
- package/build/es/polyfill/snackbar/Snackbar.js +1 -1
- package/build/es/polyfill/snackbar/SnackbarProvider.js +1 -1
- package/build/es/polyfill/stepper/Stepper.js +1 -1
- package/build/es/polyfill/stepper/deviceDetection.js +2 -1
- package/build/es/polyfill/summary/Summary.js +1 -4
- package/build/es/polyfill/switch/Switch.js +1 -1
- package/build/es/polyfill/switch/Switch.story.js +1 -1
- package/build/es/polyfill/switchOption/SwitchOption.js +1 -1
- package/build/es/polyfill/switchOption/SwitchOption.story.js +1 -1
- package/build/es/polyfill/tabs/Tab.js +1 -1
- package/build/es/polyfill/tabs/Tabs.js +1 -1
- package/build/es/polyfill/tile/Tile.js +1 -1
- package/build/es/polyfill/tooltip/Tooltip.js +1 -1
- package/build/es/polyfill/typeahead/Typeahead.js +1 -2
- package/build/es/polyfill/typeahead/typeaheadInput/TypeaheadInput.js +1 -1
- package/build/es/polyfill/typeahead/typeaheadOption/TypeaheadOption.js +1 -1
- package/build/es/polyfill/typeahead/util/highlight.js +1 -1
- package/build/es/polyfill/upload/Upload.js +3 -5
- package/build/es/polyfill/upload/steps/completeStep/completeStep.js +1 -1
- package/build/es/polyfill/upload/steps/mediaUploadStep/mediaUploadStep.js +1 -1
- package/build/es/polyfill/upload/steps/processingStep/processingStep.js +1 -1
- package/build/es/polyfill/upload/steps/uploadImageStep/uploadImageStep.js +1 -1
- package/build/es/polyfill/upload/utils/asyncFileRead/asyncFileRead.js +1 -1
- package/build/es/polyfill/upload/utils/getSupportedSpotMimeTypes/getSupportedSpotMimeTypes.js +2 -2
- package/build/es/polyfill/upload/utils/index.js +1 -1
- package/build/es/polyfill/uploadInput/UploadInput.js +4 -6
- package/build/es/polyfill/uploadInput/UploadInput.spec.js +1 -1
- package/build/es/polyfill/uploadInput/UploadInput.story.js +1 -1
- package/build/es/polyfill/uploadInput/types.js +1 -0
- package/build/es/polyfill/uploadInput/uploadButton/UploadButton.js +1 -1
- package/build/es/polyfill/uploadInput/uploadButton/UploadButton.spec.js +3 -1
- package/build/es/polyfill/uploadInput/uploadButton/getAllowedFileTypes.spec.js +1 -1
- package/build/es/polyfill/uploadInput/uploadItem/UploadItem.js +2 -2
- package/build/es/polyfill/uploadInput/uploadItem/UploadItem.spec.js +1 -1
- package/build/es/polyfill/uploadInput/uploadItem/UploadItemBody.js +1 -1
- package/build/es/polyfill/utilities/{deprecatedProp/deprecatedProp.js → deprecatedProperty/deprecatedProperty.js} +0 -0
- package/build/es/polyfill/utilities/deprecatedProperty/index.js +1 -0
- package/build/es/polyfill/utilities/index.js +1 -1
- package/build/es/polyfill/utilities/logActionRequired.js +1 -1
- package/build/es/polyfill/withDisplayFormat/WithDisplayFormat.js +2 -2
- package/build/es/polyfill/withNextPortal/withNextPortal.js +1 -1
- package/build/es/polyfill/withNormaliser/WithNormalizer.js +3 -0
- package/build/i18n/en.json +3 -2
- package/build/main.css +1 -1
- package/build/styles/accordion/Accordion.css +1 -1
- package/build/styles/avatar/Avatar.css +1 -1
- package/build/styles/card/Card.css +1 -1
- package/build/styles/chip/Chip.css +1 -1
- package/build/styles/circularButton/CircularButton.css +1 -1
- package/build/styles/common/RadioButton/RadioButton.css +1 -1
- package/build/styles/common/bottomSheet/BottomSheet.css +1 -1
- package/build/styles/common/closeButton/CloseButton.css +1 -1
- package/build/styles/dateLookup/DateLookup.css +1 -1
- package/build/styles/dateLookup/dateTrigger/DateTrigger.css +1 -1
- package/build/styles/drawer/Drawer.css +1 -1
- package/build/styles/emphasis/Emphasis.css +1 -1
- package/build/styles/flowNavigation/FlowNavigation.css +1 -1
- package/build/styles/flowNavigation/backButton/BackButton.css +1 -1
- package/build/styles/info/Info.css +1 -1
- package/build/styles/instructionsList/InstructionsList.css +1 -1
- package/build/styles/lab/mobileNav/MobileNav.css +1 -1
- package/build/styles/lab/pagination/Pagination.css +1 -1
- package/build/styles/loader/Loader.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/moneyInput/MoneyInput.css +1 -1
- package/build/styles/navigationOption/NavigationOption.css +1 -1
- package/build/styles/nudge/Nudge.css +1 -1
- package/build/styles/overlayHeader/OverlayHeader.css +1 -1
- package/build/styles/popover/Popover.css +1 -1
- package/build/styles/snackbar/Snackbar.css +1 -1
- package/build/styles/stepper/Stepper.css +1 -1
- package/build/styles/summary/Summary.css +1 -1
- package/build/styles/switch/Switch.css +1 -1
- package/build/styles/tabs/Tabs.css +1 -1
- package/build/styles/tile/Tile.css +1 -1
- package/build/styles/typeahead/typeaheadOption/TypeaheadOption.css +1 -1
- package/build/styles/uploadInput/UploadInput.css +1 -1
- package/build/styles/uploadInput/uploadButton/UploadButton.css +1 -1
- package/build/styles/uploadInput/uploadItem/UploadItem.css +1 -1
- package/build/types/actionOption/ActionOption.story.d.ts +1 -1
- package/build/types/alert/Alert.d.ts +1 -1
- package/build/types/badge/Badge.d.ts +1 -1
- package/build/types/chip/Chip.d.ts +8 -2
- package/build/types/common/bottomSheet/BottomSheet.d.ts +3 -1
- package/build/types/common/commonProps.d.ts +1 -1
- package/build/types/common/focusBoundary/utils/getFocusableElements.d.ts +1 -1
- package/build/types/common/focusBoundary/utils/resetFocus.d.ts +1 -1
- package/build/types/common/hooks/useHasIntersected/useHasIntersected.d.ts +4 -1
- package/build/types/{link/Link.messages.d.ts → dateInput/DateInput.messages.d.ts} +8 -5
- package/build/types/link/Link.d.ts +5 -4
- package/build/types/link/Link.spec.d.ts +1 -0
- package/build/types/link/Link.story.d.ts +9 -0
- package/build/types/loader/Loader.d.ts +6 -1
- package/build/types/modal/Modal.d.ts +0 -1
- package/build/types/nudge/Nudge.d.ts +1 -0
- package/build/types/switch/Switch.story.d.ts +2 -1
- package/build/types/switchOption/SwitchOption.story.d.ts +1 -1
- package/build/types/test-utils/index.d.ts +17 -5
- package/build/types/upload/Upload.d.ts +1 -1
- package/build/types/upload/utils/index.d.ts +0 -1
- package/build/types/uploadInput/UploadInput.d.ts +8 -4
- package/build/types/uploadInput/UploadInput.story.d.ts +11 -10
- package/build/types/uploadInput/uploadButton/UploadButton.d.ts +1 -0
- package/build/types/uploadInput/uploadItem/UploadItem.d.ts +8 -1
- package/build/types/uploadInput/uploadItem/UploadItemBody.d.ts +3 -2
- package/build/types/utilities/{deprecatedProp/deprecatedProp.d.ts → deprecatedProperty/deprecatedProperty.d.ts} +2 -2
- package/build/types/utilities/deprecatedProperty/index.d.ts +1 -0
- package/build/types/utilities/index.d.ts +1 -1
- package/build/types/withDisplayFormat/WithDisplayFormat.d.ts +1 -1
- package/build/types/withNextPortal/withNextPortal.d.ts +1 -2
- package/build/umd/no-polyfill/main.js +1 -1
- package/build/umd/polyfill/main.js +1 -1
- package/package.json +18 -18
- package/build/es/no-polyfill/common/Option/OptionDocs.js +0 -1
- package/build/es/no-polyfill/link/Link.messages.js +0 -1
- package/build/es/no-polyfill/upload/utils/generateErrorMessage/generateErrorMessage.js +0 -1
- package/build/es/no-polyfill/upload/utils/generateErrorMessage/index.js +0 -1
- package/build/es/no-polyfill/utilities/deprecatedProp/index.js +0 -1
- package/build/es/polyfill/common/Option/OptionDocs.js +0 -1
- package/build/es/polyfill/link/Link.messages.js +0 -1
- package/build/es/polyfill/upload/utils/generateErrorMessage/generateErrorMessage.js +0 -1
- package/build/es/polyfill/upload/utils/generateErrorMessage/index.js +0 -1
- package/build/es/polyfill/utilities/deprecatedProp/index.js +0 -1
- package/build/types/upload/utils/generateErrorMessage/generateErrorMessage.d.ts +0 -1
- package/build/types/upload/utils/generateErrorMessage/index.d.ts +0 -1
- package/build/types/utilities/deprecatedProp/index.d.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.array.find.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.to-string.js";import{
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.array.find.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.to-string.js";import{isArray}from"@transferwise/neptune-validation";import classNames from"classnames";import PropTypes from"prop-types";import{useState,useEffect}from"react";import{useIntl}from"react-intl";import{Size}from"../common";import{useDirection}from"../common/hooks";import Select from"../select";import countries from"./data/countries";import{explodeNumberModel,filterOptionsForQuery,isValidPhoneNumber,cleanNumber,setDefaultPrefix,isStringNumeric,sortArrayByProperty,groupCountriesByPrefix}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var ALLOWED_PHONE_CHARS=/^$|^[\d-\s]+$/,PhoneNumberInput=function(a){var b=a.onChange,c=a.searchPlaceholder,d=a.disabled,e=a.required,f=a.size,g=a.placeholder,h=a.onFocus,i=a.onBlur,j=a.countryCode,k=useIntl(),l=k.locale,m=useDirection(),n=m.isRTL,o=function(){var b=a.initialValue,c=b?cleanNumber(b):null;return c&&isValidPhoneNumber(c)?c:null},p=useState(o()),q=_slicedToArray(p,2),r=q[0],s=q[1],t=useState(o()),u=_slicedToArray(t,2),v=u[0],w=u[1],x=useState(""),y=_slicedToArray(x,2),z=y[0],A=y[1],B=groupCountriesByPrefix(sortArrayByProperty(countries,"iso3")),C=groupCountriesByPrefix(sortArrayByProperty(countries,"phone")),D=function(a){var b=setDefaultPrefix(l,j),c="";if(a){var d=explodeNumberModel(a);b=d.prefix,c=d.suffix}return{prefix:b,suffix:c}},E=function getSelectOptions(){var a=filterOptionsForQuery(isStringNumeric(z)?C:B,z);return a.map(function(a){var b=a.phone,c=a.iso3,d=a.iso2,e="";return c?e=isArray(c)?c.join(", "):c:d&&(e=isArray(d)?d.join(", "):d),{value:b,label:b,note:e}})}();useEffect(function(){var a=isValidPhoneNumber(r)?cleanNumber(r):null;a!==v&&(b(a),w({newbroadcastValue:a}))},[r]);var F=D(r),G=F.prefix,H=F.suffix;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-telephone",{"tw-telephone--rtl":n}),children:[/*#__PURE__*/_jsx("div",{className:"tw-telephone__country-select",children:/*#__PURE__*/_jsx(Select,{options:E,selected:{value:G,label:G},placeholder:"Select an option...",searchPlaceholder:c,searchValue:z,required:e,disabled:d,size:f,onChange:function handleChangeSelect(a){var b=D(r),c=b.suffix,d=a.value;A(""),s(d+c)},onSearchChange:function onSearchChange(a){return A(a)}})}),/*#__PURE__*/_jsx("div",{className:"tw-telephone__number-input",children:/*#__PURE__*/_jsx("div",{className:"input-group input-group-".concat(f),children:/*#__PURE__*/_jsx("input",{name:"phoneNumber",inputMode:"numeric",value:H,type:"text",className:"form-control",disabled:d,required:e,placeholder:g,onChange:function handleInputChange(a){var b=a.target.value;if(ALLOWED_PHONE_CHARS.test(b)){var c=D(r),d=c.prefix;s(d+b)}},onPaste:function handlePaste(a){if(a.nativeEvent.clipboardData){var b=(a.nativeEvent.clipboardData.getData("text/plain")||"").replace(/(\s|-)+/g,""),c=E.find(function(a){var c=a.value;return new RegExp("^\\".concat(c)).test(b)});c&&ALLOWED_PHONE_CHARS.test(b.replace(c.value,""))&&s(b)}},onFocus:h,onBlur:i})})})]})};PhoneNumberInput.propTypes={required:PropTypes.bool,disabled:PropTypes.bool,initialValue:PropTypes.string,onChange:PropTypes.func.isRequired,onFocus:PropTypes.func,onBlur:PropTypes.func,countryCode:PropTypes.string,searchPlaceholder:PropTypes.string,size:PropTypes.oneOf(["sm","md","lg"]),placeholder:PropTypes.string},PhoneNumberInput.defaultProps={required:!1,disabled:!1,initialValue:null,onFocus:function onFocus(){},onBlur:function onBlur(){},countryCode:null,searchPlaceholder:"Prefix",size:Size.MEDIUM,placeholder:""};export default PhoneNumberInput;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import{findCountryByPrefix}from"../findCountryByPrefix";/**
|
|
1
|
+
import"core-js/modules/es.array.slice.js";import{findCountryByPrefix}from"../findCountryByPrefix";/**
|
|
2
2
|
* Given a sting in a valid format ex:'+447573135343' it returns an object of shape
|
|
3
3
|
* {prefix=+44 ,suffix=7573135343}
|
|
4
|
+
*
|
|
4
5
|
* @param {string} number - a string that defines a phone number.
|
|
5
6
|
* @returns {{prefix: (string|*), suffix: string, format: string}}
|
|
6
|
-
*/export var explodeNumberModel=function(a){var b="",c="",d="",e=findCountryByPrefix(a);return e?(b=e.phone,c=a.
|
|
7
|
+
*/export var explodeNumberModel=function(a){var b="",c="",d="",e=findCountryByPrefix(a);return e?(b=e.phone,c=a.slice(e.phone.length),d=e.phoneFormat||""):(b="",c=a.slice(1),d=""),{prefix:b,suffix:c,format:d}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.filter.js";import countries from"../../data/countries";import{longestMatchingPrefix}from"../longestMatchingPrefix";export var findCountryByCode=function(a){var b;return a&&2===a.length&&(b=countries.filter(function(b){return a.toUpperCase()===b.iso2})),b&&b.length?longestMatchingPrefix(b):null};
|
|
1
|
+
import"core-js/modules/es.array.filter.js";import countries from"../../data/countries";import{longestMatchingPrefix}from"../longestMatchingPrefix";export var findCountryByCode=function(a){var b;return a&&2===a.length&&(b=countries.filter(function(b){return a.toUpperCase()===b.iso2})),b&&0<b.length?longestMatchingPrefix(b):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.filter.js";import countries from"../../data/countries";import{longestMatchingPrefix}from"../longestMatchingPrefix";export var findCountryByPrefix=function(a){var b=null;return a&&1<a.length&&(b=countries.filter(function(b){return 0===a.indexOf(b.phone)})),b&&b.length?longestMatchingPrefix(b):null};
|
|
1
|
+
import"core-js/modules/es.array.filter.js";import countries from"../../data/countries";import{longestMatchingPrefix}from"../longestMatchingPrefix";export var findCountryByPrefix=function(a){var b=null;return a&&1<a.length&&(b=countries.filter(function(b){return 0===a.indexOf(b.phone)})),b&&0<b.length?longestMatchingPrefix(b):null};
|
package/build/es/polyfill/phoneNumberInput/utils/isOptionAndFitsQuery/isOptionAndFitsQuery.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import{isArray}from"@transferwise/neptune-validation";/**
|
|
2
2
|
* Checks if query is contained into object properties.
|
|
3
|
+
*
|
|
3
4
|
* @param {object} option - the select option
|
|
4
5
|
* @param {string} query - the current search query
|
|
5
6
|
* @returns {boolean}
|
|
@@ -2,7 +2,9 @@ import{getCountryFromLocale}from"../../../common/locale";import{findCountryByCod
|
|
|
2
2
|
* Default phone code, the UK one `+44`
|
|
3
3
|
*/var DEFAULT_PHONE_CODE="+44";/**
|
|
4
4
|
* Given a valid locale it returns the correspondent prefix if found or +44 otherwise.
|
|
5
|
+
*
|
|
5
6
|
* @param {string} locale - a string that represent the locale ex:'es-ES'
|
|
7
|
+
* @param countryCode
|
|
6
8
|
* @returns {string}
|
|
7
9
|
*/export var setDefaultPrefix=function(a,b){var c=findCountryByCode(b)||// when `locale` code has explicit region: `en-GB`, `en-US`, `ar-AE`
|
|
8
10
|
findCountryByCode(getCountryFromLocale(a))||// when `locale` code is only two chars value: `fr`, `es`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _deprecatedPlacements;import"core-js/modules/es.array.concat.js";import
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";var _deprecatedPlacements;import"core-js/modules/es.array.concat.js";import classnames from"classnames";import PropTypes from"prop-types";import{useRef,useState,cloneElement}from"react";import{Position}from"../common";import ResponsivePanel from"../common/responsivePanel";import{logActionRequiredIf}from"../utilities";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Popover=function(a){var b=a.children,c=a.className,d=a.content,e=a.preferredPlacement,f=a.title;logActionRequired({preferredPlacement:e});var g=useRef(null),h=useState(!1),i=_slicedToArray(h,2),j=i[0],k=i[1];return/*#__PURE__*/_jsxs("span",{className:classnames("np-popover",c),children:[/*#__PURE__*/_jsx("span",{ref:g,className:"d-inline-block",children:/*#__PURE__*/cloneElement(b,{onClick:function onClick(){var a;null!==b&&void 0!==b&&null!==(a=b.props)&&void 0!==a&&a.onClick&&b.props.onClick(),k(!j)}})}),/*#__PURE__*/_jsx(ResponsivePanel,{open:j,anchorRef:g,position:deprecatedPlacements[e]||e,arrow:!0,className:"np-popover__container",onClose:function onClose(){return k(!1)},children:/*#__PURE__*/_jsxs("div",{className:"np-popover__content","aria-hidden":!j,role:"tooltip",children:[f&&/*#__PURE__*/_jsx("div",{role:"heading","aria-level":1,className:"np-popover__title m-b-1",children:f}),d]})})]})},logActionRequired=function(a){var b=a.preferredPlacement;logActionRequiredIf("Popover has deprecated ".concat(b," value for the 'preferredPlacement' prop. Please use ").concat(deprecatedPlacements[b]," instead."),deprecatedPlacements[b])};Popover.defaultProps={className:void 0,preferredPlacement:Position.RIGHT,title:void 0},Popover.propTypes={children:PropTypes.node.isRequired,className:PropTypes.string,content:PropTypes.node.isRequired,/**
|
|
2
2
|
* `'left-top'` / `'right-top'` are deprecated use `Position.TOP` / `'top'` instead,
|
|
3
3
|
* `'bottom-right'` / `'bottom-left'` are deprecated use `Position.BOTTOM` / `'bottom'` instead
|
|
4
4
|
*/preferredPlacement:PropTypes.oneOf(["top","right","bottom","left","left-top","right-top","bottom-right","bottom-left"]),title:PropTypes.node};var deprecatedPlacements=(_deprecatedPlacements={},_defineProperty(_deprecatedPlacements,Position.BOTTOM_LEFT,Position.BOTTOM),_defineProperty(_deprecatedPlacements,Position.BOTTOM_RIGHT,Position.BOTTOM),_defineProperty(_deprecatedPlacements,Position.LEFT_TOP,Position.TOP),_defineProperty(_deprecatedPlacements,Position.RIGHT_TOP,Position.TOP),_deprecatedPlacements);export default Popover;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import
|
|
1
|
+
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import classNames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import{Status,Size}from"../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var radius={xs:11,sm:22,xl:61};export var ANIMATION_DURATION_IN_MS=1500;var ProcessIndicator=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"runCallBack",function(a){var b=d.props.onAnimationCompleted;b&&(d.timeouts=setTimeout(function(){b(a)},ANIMATION_DURATION_IN_MS))}),d.state={status:a.status,size:a.size},d.interval=null,d.timeout=null,d}/**
|
|
2
2
|
* Create interval for animation duration (1500ms)
|
|
3
3
|
* Update state only at the end of every interval
|
|
4
4
|
* (end of animation loop) if props changed before end of animation
|
|
5
5
|
*/_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentDidMount",value:function componentDidMount(){var a=this;this.interval=setInterval(function(){var b=a.state.status,c=a.state.size,d=a.props.status,e=a.props.size;b!==d&&a.setState({status:d},a.runCallBack(d)),c!==e&&a.setState({size:e})},ANIMATION_DURATION_IN_MS)}/**
|
|
6
6
|
* Only trigger render if comopnent's state got
|
|
7
7
|
* updated from interval callback
|
|
8
|
+
*
|
|
9
|
+
* @param nextProps
|
|
10
|
+
* @param nextState
|
|
8
11
|
*/},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(a,b){var c=a.status===b.status,d=a.size===b.size;return c&&d}// Clear interval before destroying component
|
|
9
12
|
},{key:"componentWillUnmount",value:function componentWillUnmount(){clearInterval(this.interval),clearTimeout(this.timeout)}},{key:"render",value:function render(){var a,b=this.props,c=b.className,d=b["data-testid"],e=this.state,f=e.size,g=e.status,h=classNames("process process-".concat(f),c,(a={},_defineProperty(a,"process-danger",g===Status.FAILED),_defineProperty(a,"process-stopped",g===Status.HIDDEN),_defineProperty(a,"process-success",g===Status.SUCCEEDED),a));return/*#__PURE__*/_jsxs("span",{className:h,"data-testid":d,children:[/*#__PURE__*/_jsxs("span",{className:"process-icon-container",children:[/*#__PURE__*/_jsx("span",{className:"process-icon-horizontal"}),/*#__PURE__*/_jsx("span",{className:"process-icon-vertical"})]}),/*#__PURE__*/_jsx("svg",{xmlns:"http://www.w3.org/2000/svg",children:/*#__PURE__*/_jsx("circle",{className:"process-circle",cx:"50%",cy:"50%",r:radius[this.state.size],fillOpacity:"0.0"})})]})}}]),b}(Component);ProcessIndicator.propTypes={status:PropTypes.oneOf(["processing","failed","succeeded","hidden"]),size:PropTypes.oneOf(["xs","sm","xl"]),onAnimationCompleted:PropTypes.func,className:PropTypes.string,"data-testid":PropTypes.string},ProcessIndicator.defaultProps={status:Status.PROCESSING,size:Size.SMALL,onAnimationCompleted:null,className:void 0,"data-testid":null};export default ProcessIndicator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.concat.js";import PropTypes from"prop-types";import{IntlProvider}from"react-intl";import{
|
|
1
|
+
import"core-js/modules/es.array.concat.js";import PropTypes from"prop-types";import{IntlProvider}from"react-intl";import{DEFAULT_LOCALE,adjustLocale}from"../common/locale";import en from"../i18n/en.json";import{DirectionProvider}from"./direction";import{jsx as _jsx}from"react/jsx-runtime";var Provider=function(a){var b,c=a.i18n,d=a.children,e=c.locale,f=c.messages,g=c.defaultRichTextElements,h=adjustLocale(e);return null===h?(console.warn("Unsupported locale value was provided: '".concat(e,"', defaulting to '").concat(DEFAULT_LOCALE,"'")),b={locale:DEFAULT_LOCALE,messages:en}):b={locale:h,messages:f},/*#__PURE__*/_jsx(DirectionProvider,{locale:b.locale,children:/*#__PURE__*/_jsx(IntlProvider,{defaultLocale:DEFAULT_LOCALE,locale:b.locale,messages:b.messages,defaultRichTextElements:g,children:d})})};Provider.propTypes={i18n:PropTypes.shape({locale:PropTypes.string.isRequired,messages:PropTypes.shape({}).isRequired,defaultRichTextElements:PropTypes.shape({})}).isRequired,children:PropTypes.node},Provider.defaultProps={children:void 0};export default Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import PropTypes from"prop-types";import{createContext}from"react";import{DEFAULT_LOCALE,SUPPORTED_RTL}from"../../common/locale";import{jsx as _jsx}from"react/jsx-runtime";export var DirectionContext=/*#__PURE__*/createContext("ltr");export var DirectionProvider=function(a){var b=a.locale,c=a.children;return/*#__PURE__*/_jsx(DirectionContext.Provider,{value:SUPPORTED_RTL.includes(b)?"rtl":"ltr",children:c})};DirectionProvider.propTypes={children:PropTypes.node,locale:PropTypes.string},DirectionProvider.defaultProps={children:null,locale:DEFAULT_LOCALE};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","id","disabled","avatar","secondary"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["label","id","disabled","avatar","secondary"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import classNames from"classnames";import PropTypes from"prop-types";import RadioButton from"../common/RadioButton";import{useDirection}from"../common/hooks";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Radio=function(a){var b=a.label,c=a.id,d=a.disabled,e=a.avatar,f=a.secondary,g=_objectWithoutProperties(a,_excluded),h=useDirection(),i=h.isRTL;return/*#__PURE__*/_jsx("div",{className:classNames("radio np-radio",{"radio-lg":f,disabled:d}),disabled:d,children:/*#__PURE__*/_jsxs("label",{htmlFor:c,children:[/*#__PURE__*/_jsx("span",{className:classNames("np-radio-button",{"p-r-2":!i,"p-l-2":i}),children:/*#__PURE__*/_jsx(RadioButton,_objectSpread({id:c,disabled:d},g))}),/*#__PURE__*/_jsxs("span",{className:"np-radio__text",children:[b,f&&/*#__PURE__*/_jsx("small",{children:f})]}),e&&/*#__PURE__*/_jsx("span",{className:classNames("np-radio__avatar",{"m-l-auto":!i,"m-r-auto":i}),children:e})]})})};Radio.propTypes={avatar:PropTypes.element,checked:PropTypes.bool,disabled:PropTypes.bool,id:PropTypes.string,label:PropTypes.string.isRequired,name:PropTypes.string.isRequired,onChange:PropTypes.func.isRequired,secondary:PropTypes.string,value:PropTypes.oneOfType([PropTypes.number,PropTypes.string])},Radio.defaultProps={avatar:void 0,checked:!1,disabled:!1,id:null,secondary:null,value:""};export default Radio;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.map.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import
|
|
2
|
-
,label:i,name:d,disabled:j,checked:e===h,secondary:k,onChange:function onChange(b){return a.handleOnChange(b)}
|
|
1
|
+
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.map.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import PropTypes from"prop-types";import{Component}from"react";import Radio from"../radio";import{jsx as _jsx}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";var RadioGroup=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"handleOnChange",function(a){var b=d.props.onChange;d.setState({selectedValue:a},b&&b(a))}),d.state={selectedValue:a.selectedValue},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"render",value:function render(){var a=this,b=this.props,c=b.radios,d=b.name,e=this.state.selectedValue;return c&&1<c.length?/*#__PURE__*/_jsx(_Fragment,{children:c.map(function(b,c){var f=b.id,g=b.avatar,h=b.value,i=b.label,j=b.disabled,k=b.secondary,l=b.readOnly;return/*#__PURE__*/_jsx(Radio// eslint-disable-next-line react/no-array-index-key
|
|
2
|
+
,{id:f,value:h,label:i,name:d,disabled:j,checked:e===h,secondary:k,readOnly:l,avatar:g,onChange:function onChange(b){return a.handleOnChange(b)}},c)})}):null}}]),b}(Component);RadioGroup.propTypes={radios:PropTypes.arrayOf(PropTypes.shape({id:PropTypes.string,avatar:PropTypes.element,value:PropTypes.oneOfType([PropTypes.number,PropTypes.string]),secondary:PropTypes.string,label:PropTypes.string.isRequired,disabled:PropTypes.bool,readOnly:PropTypes.bool})).isRequired,onChange:PropTypes.func.isRequired,selectedValue:PropTypes.oneOfType([PropTypes.number,PropTypes.string]),name:PropTypes.string.isRequired},RadioGroup.defaultProps={selectedValue:null};export default RadioGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.function.name.js";import PropTypes from"prop-types";import Option from"../common/Option";import RadioButton from"../common/RadioButton";import{jsx as _jsx}from"react/jsx-runtime";var RadioOption=function(a){var b=a.media,c=a.title,d=a.content,e=a.id,f=a.name,g=a.checked,h=a.onChange,i=a.complex,j=a.disabled,k=a.value,l=a.showMediaAtAllSizes;return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},{media:b,title:c,content:d,name:f,complex:i,disabled:j,showMediaAtAllSizes:l}),{},{button:/*#__PURE__*/_jsx(RadioButton,{id:e,name:f,checked:g,
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.function.name.js";import PropTypes from"prop-types";import Option from"../common/Option";import RadioButton from"../common/RadioButton";import{jsx as _jsx}from"react/jsx-runtime";var RadioOption=function(a){var b=a.media,c=a.title,d=a.content,e=a.id,f=a.name,g=a.checked,h=a.onChange,i=a.complex,j=a.disabled,k=a.value,l=a.showMediaAtAllSizes;return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},{media:b,title:c,content:d,name:f,complex:i,disabled:j,showMediaAtAllSizes:l}),{},{button:/*#__PURE__*/_jsx(RadioButton,{id:e,name:f,checked:g,disabled:j,value:k,onChange:h})}))};RadioOption.propTypes={media:PropTypes.node,id:PropTypes.string.isRequired,name:PropTypes.string.isRequired,title:PropTypes.node.isRequired,content:PropTypes.node,checked:PropTypes.bool,onChange:PropTypes.func.isRequired,complex:PropTypes.bool,disabled:PropTypes.bool,value:PropTypes.string,showMediaAtAllSizes:PropTypes.bool},RadioOption.defaultProps={media:null,content:null,checked:!1,complex:!1,disabled:!1,showMediaAtAllSizes:!1,value:""};export default RadioOption;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.search.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.reduce.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.concat.js";import{Component,createRef}from"react";import PropTypes from"prop-types";import classNames from"classnames";import Transition from"react-transition-group/Transition";import Option from"./option";import Chevron from"../chevron";import KeyCodes from"../common/keyCodes";import{Breakpoint}from"../common";import{addClickClassToDocumentOnIos,removeClickClassFromDocumentOnIos}from"../common/domHelpers";import{addClassAndTriggerReflow,removeClass}from"./domHelpers";import Dimmer from"../dimmer";import SlidingPanel from"../slidingPanel";import SearchBox from"./searchBox";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";function clamp(a,b,c){return Math.max(Math.min(b,c),a)}function actionableOption(a){return!a.header&&!a.separator&&!a.disabled}var isFunction=function(a){return a&&"[object Function]"==={}.toString.call(a)};function stopPropagation(a){a.stopPropagation(),a.preventDefault(),a.nativeEvent&&a.nativeEvent.stopImmediatePropagation&&a.nativeEvent.stopImmediatePropagation()}function getShouldRenderWithPortal(){return"undefined"!=typeof document&&"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(max-width: ".concat(Breakpoint.SMALL,"px)")).matches}var BOOTSTRAP_DROPDOWN_ANIMATION_TIME=200,defer=function(a){return setTimeout(a,0)},includesString=function(a,b){return-1<a.toLowerCase().indexOf(b.toLowerCase())},arrayIncludesString=function(a,b){return a.some(function(a){return includesString(a,b)})},defaultFilterFunction=function(a,b){return a.label&&includesString(a.label,b)||a.note&&includesString(a.note,b)||a.secondary&&includesString(a.secondary,b)||a.currency&&includesString(a.currency,b)||a.searchStrings&&arrayIncludesString(a.searchStrings,b)},Select=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setState({shouldRenderWithPortal:getShouldRenderWithPortal()})}),_defineProperty(_assertThisInitialized(d),"handleOnFocus",function(a){return d.props.onFocus&&d.props.onFocus(a)}),_defineProperty(_assertThisInitialized(d),"handleOnBlur",function(a){var b=d.props.onBlur,c=a.nativeEvent;if(c){var e=c.relatedTarget,f=a.currentTarget;if(f&&e&&f.contains(e))return}b&&b(a)}),_defineProperty(_assertThisInitialized(d),"getOptions",function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:d.props.options,b=d.props.search;if(!b||!d.state.searchValue)return a;var c=isFunction(b)?b:defaultFilterFunction;return a.filter(function(a){return c(a,d.state.searchValue)})}),_defineProperty(_assertThisInitialized(d),"handleSearchChange",function(a){d.props.onSearchChange?d.props.onSearchChange(a.target.value):d.setState({searchValue:a.target.value})}),_defineProperty(_assertThisInitialized(d),"handleKeyDown",function(a){var b=d.state.open;switch(a.keyCode){case KeyCodes.UP:b?d.moveFocusWithDifference(-1):d.open(),a.preventDefault();break;case KeyCodes.DOWN:b?d.moveFocusWithDifference(1):d.open(),a.preventDefault();break;case KeyCodes.SPACE:a.target!==d.searchBoxRef.current&&(b?d.selectKeyboardFocusedOption():d.open(),a.preventDefault());break;case KeyCodes.ENTER:b?d.selectKeyboardFocusedOption():d.open(),a.preventDefault();break;case KeyCodes.ESCAPE:d.close(),a.preventDefault();break;case KeyCodes.TAB:b&&d.selectKeyboardFocusedOption();break;default:}}),_defineProperty(_assertThisInitialized(d),"handleButtonClick",function(){d.props.disabled||d.open()}),_defineProperty(_assertThisInitialized(d),"handleDocumentClick",function(){d.state.open&&d.close()}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){a.currentTarget===a.target&&d.state.open&&d.close()}),_defineProperty(_assertThisInitialized(d),"style",function(a){return d.props.classNames[a]||a}),_defineProperty(_assertThisInitialized(d),"renderOption",function(a,b){var c;if(a.separator)return/*#__PURE__*/_jsx("li",{className:d.style("divider")},b);if(a.header)return/*#__PURE__*/_jsx("li",{onClick:stopPropagation,onKeyPress:stopPropagation,className:d.style("dropdown-header"),children:a.header},b);var e=d.props.selected&&d.props.selected.value===a.value,f=d.state.keyboardFocusedOptionIndex===d.getIndexWithoutHeadersForIndexWithHeaders(b),g=classNames(d.style("tw-dropdown-item"),d.style("tw-dropdown-item--clickable"),(c={},_defineProperty(c,d.style("active"),e),_defineProperty(c,d.style("tw-dropdown-item--focused"),f&&!a.disabled),_defineProperty(c,d.style("disabled"),a.disabled),c));return/*#__PURE__*/_jsx("li",{onClick:a.disabled?stopPropagation:d.createSelectHandlerForOption(a),onKeyPress:a.disabled?stopPropagation:d.createSelectHandlerForOption(a),className:g,children:/*#__PURE__*/_jsx("a",{disabled:a.disabled,children:/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},a),{},{classNames:d.props.classNames}))})},b)}),d.state={open:!1,searchValue:"",keyboardFocusedOptionIndex:null},d.searchBoxRef=/*#__PURE__*/createRef(),d.dropdownMenuRef=/*#__PURE__*/createRef(),d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentDidMount",value:function componentDidMount(){this.setState({shouldRenderWithPortal:getShouldRenderWithPortal()}),window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.close(),window.removeEventListener("resize",this.handleResize)}},{key:"getIndexWithoutHeadersForIndexWithHeaders",value:function getIndexWithoutHeadersForIndexWithHeaders(a){return this.getOptions().reduce(function(b,c,d){return d<a&&actionableOption(c)?b+1:b},0)}},{key:"selectKeyboardFocusedOption",value:function selectKeyboardFocusedOption(){if(null!==this.state.keyboardFocusedOptionIndex){var a=this.state.keyboardFocusedOptionIndex;this.selectOption(this.getOptions().filter(actionableOption)[a])}}},{key:"moveFocusWithDifference",value:function moveFocusWithDifference(a){var b=this;this.setState(function(c,d){var e=b.getOptions(d.options).filter(actionableOption),f=e.reduce(function(a,b,c){return null===a?d.selected&&d.selected.value===b.value?c:null:a},null),g=c.keyboardFocusedOptionIndex,h=g;if(null===g&&null===f)return{keyboardFocusedOptionIndex:0};null===g&&null!==f&&(h=f);var i=h+a,j=clamp(0,e.length-1,i);return{keyboardFocusedOptionIndex:j}})}},{key:"open",value:function open(){var a=this;this.setState({open:!0},function(){var b="undefined"!=typeof window&&window.matchMedia&&!!window.matchMedia("(pointer: coarse)").matches,c=!!a.props.onSearchChange||!!a.props.search;defer(function(){!b&&c&&a.searchBoxRef.current&&a.searchBoxRef.current.focus(),addClickClassToDocumentOnIos(),document.addEventListener("click",a.handleDocumentClick,!1)})})}},{key:"close",value:function close(){var a=this;this.setState({open:!1,keyboardFocusedOptionIndex:null},function(){defer(function(){removeClickClassFromDocumentOnIos(),document.removeEventListener("click",a.handleDocumentClick,!1)})})}},{key:"createSelectHandlerForOption",value:function createSelectHandlerForOption(a){var b=this;return function(c){stopPropagation(c),b.selectOption(a)}}},{key:"selectOption",value:function selectOption(a){a&&!a.placeholder?this.props.onChange(a):this.props.onChange(null),this.close()}},{key:"renderOptionsList",value:function renderOptionsList(){var a,b=this.props,c=b.dropdownRight,d=b.dropdownWidth,e=b.onSearchChange,f=b.placeholder,g=b.required,h=b.search,i=b.searchValue,j=b.searchPlaceholder,k=this.state.open,l=this.style,m=!!e||!!h,n=classNames(l("tw-select"),l("dropdown-menu"),(a={},_defineProperty(a,l("dropdown-menu-".concat(c,"-right")),c),_defineProperty(a,l("dropdown-menu-".concat(d)),d),_defineProperty(a,l("dropdown-menu--open"),k),a)),o=/*#__PURE__*/_jsxs("ul",{className:n,children:[g||m||!f?"":this.renderPlaceHolderOption(),m&&/*#__PURE__*/_jsx(SearchBox,{classNames:this.props.classNames,onChange:this.handleSearchChange,onClick:stopPropagation,value:i||this.state.searchValue,ref:this.searchBoxRef,placeholder:j}),this.renderOptions()]});return o}},{key:"renderOptions",value:function renderOptions(){return this.getOptions().map(this.renderOption)}},{key:"renderPlaceHolderOption",value:function renderPlaceHolderOption(){var a=this.props.placeholder;return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{onClick:this.createSelectHandlerForOption({placeholder:a}),onKeyPress:this.createSelectHandlerForOption({placeholder:a}),className:classNames(this.style("tw-dropdown-item--clickable"),this.style("tw-dropdown-item--divider")),children:/*#__PURE__*/_jsx("a",{children:a})}))}},{key:"renderButtonInternals",value:function renderButtonInternals(){var a=this.props,b=a.selected,c=a.placeholder;return b?/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},b),{},{classNames:this.props.classNames,selected:!0})):/*#__PURE__*/_jsx("span",{className:this.style("form-control-placeholder"),children:c})}},{key:"render",value:function render(){var a,b,c=this,d=this.props,e=d.disabled,f=d.size,g=d.block,h=d.id,i=d.dropdownUp,j=d.inverse,k=this.state,l=k.open,m=k.shouldRenderWithPortal,n=this.style,o=classNames(n("tw-select"),n("btn-group"),(a={},_defineProperty(a,n("btn-block"),g),_defineProperty(a,n("dropup"),i),_defineProperty(a,n("dropdown"),!i),a)),p=classNames(n("btn"),n("btn-input"),(b={},_defineProperty(b,"".concat(n("btn-input-inverse")," ").concat(n("btn-addon")),j),_defineProperty(b,n("btn-xs"),"xs"===f),_defineProperty(b,n("btn-sm"),"sm"===f),_defineProperty(b,n("btn-md"),"md"===f),_defineProperty(b,n("btn-lg"),"lg"===f),b),n("dropdown-toggle")),q=n("open");return/*#__PURE__*/ (// A transition is used here in order to mount and unmount the dropdown menu while retaining animations
|
|
1
|
+
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.string.includes.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.search.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.reduce.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.array.concat.js";import classNames from"classnames";import PropTypes from"prop-types";import{Component,createRef}from"react";import Transition from"react-transition-group/Transition";import Chevron from"../chevron";import{Breakpoint}from"../common";import{addClickClassToDocumentOnIos,removeClickClassFromDocumentOnIos}from"../common/domHelpers";import KeyCodes from"../common/keyCodes";import Dimmer from"../dimmer";import SlidingPanel from"../slidingPanel";import{addClassAndTriggerReflow,removeClass}from"./domHelpers";import Option from"./option";import SearchBox from"./searchBox";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";import{Fragment as _Fragment}from"react/jsx-runtime";function clamp(a,b,c){return Math.max(Math.min(b,c),a)}function actionableOption(a){return!a.header&&!a.separator&&!a.disabled}var isFunction=function(a){return a&&"[object Function]"==={}.toString.call(a)};function stopPropagation(a){a.stopPropagation(),a.preventDefault(),a.nativeEvent&&a.nativeEvent.stopImmediatePropagation&&a.nativeEvent.stopImmediatePropagation()}function getShouldRenderWithPortal(){return"undefined"!=typeof document&&"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(max-width: ".concat(Breakpoint.SMALL,"px)")).matches}var OPTIONS_PAGE_SIZE=50,BOOTSTRAP_DROPDOWN_ANIMATION_TIME=200,defer=function(a){return setTimeout(a,0)},includesString=function(a,b){return a.toLowerCase().includes(b.toLowerCase())},arrayIncludesString=function(a,b){return a.some(function(a){return includesString(a,b)})},defaultFilterFunction=function(a,b){return a.label&&includesString(a.label,b)||a.note&&includesString(a.note,b)||a.secondary&&includesString(a.secondary,b)||a.currency&&includesString(a.currency,b)||a.searchStrings&&arrayIncludesString(a.searchStrings,b)},Select=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setState({shouldRenderWithPortal:getShouldRenderWithPortal()})}),_defineProperty(_assertThisInitialized(d),"handleOnFocus",function(a){return d.props.onFocus&&d.props.onFocus(a)}),_defineProperty(_assertThisInitialized(d),"handleOnBlur",function(a){var b=d.props.onBlur,c=a.nativeEvent;if(c){var e=c.relatedTarget,f=a.currentTarget;if(f&&e&&f.contains(e))return}b&&b(a)}),_defineProperty(_assertThisInitialized(d),"getOptions",function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:d.props.options,b=d.props.search;if(!b||!d.state.searchValue)return a;var c=isFunction(b)?b:defaultFilterFunction;return a.filter(function(a){return c(a,d.state.searchValue)})}),_defineProperty(_assertThisInitialized(d),"handleSearchChange",function(a){d.setState({numberOfOptionsShown:OPTIONS_PAGE_SIZE}),d.props.onSearchChange?d.props.onSearchChange(a.target.value):d.setState({searchValue:a.target.value})}),_defineProperty(_assertThisInitialized(d),"handleKeyDown",function(a){var b=d.state.open;switch(a.keyCode){case KeyCodes.UP:b?d.moveFocusWithDifference(-1):d.open(),a.preventDefault();break;case KeyCodes.DOWN:b?d.moveFocusWithDifference(1):d.open(),a.preventDefault();break;case KeyCodes.SPACE:a.target!==d.searchBoxRef.current&&(b?d.selectKeyboardFocusedOption():d.open(),a.preventDefault());break;case KeyCodes.ENTER:b?d.selectKeyboardFocusedOption():d.open(),a.preventDefault();break;case KeyCodes.ESCAPE:d.close(),a.preventDefault();break;case KeyCodes.TAB:b&&d.selectKeyboardFocusedOption();break;default:}}),_defineProperty(_assertThisInitialized(d),"handleButtonClick",function(){d.props.disabled||d.open()}),_defineProperty(_assertThisInitialized(d),"handleDocumentClick",function(){d.state.open&&d.close()}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){a.currentTarget===a.target&&d.state.open&&d.close()}),_defineProperty(_assertThisInitialized(d),"style",function(a){return d.props.classNames[a]||a}),_defineProperty(_assertThisInitialized(d),"renderOption",function(a,b){var c;if(a.separator)return/*#__PURE__*/_jsx("li",{className:d.style("divider")},b);if(a.header)return/*#__PURE__*/_jsx("li",{className:d.style("dropdown-header"),onClick:stopPropagation,onKeyPress:stopPropagation,children:a.header},b);var e=d.props.selected&&d.props.selected.value===a.value,f=d.state.keyboardFocusedOptionIndex===d.getIndexWithoutHeadersForIndexWithHeaders(b),g=classNames(d.style("tw-dropdown-item"),d.style("tw-dropdown-item--clickable"),(c={},_defineProperty(c,d.style("active"),e),_defineProperty(c,d.style("tw-dropdown-item--focused"),f&&!a.disabled),_defineProperty(c,d.style("disabled"),a.disabled),c));return/*#__PURE__*/_jsx("li",{className:g,onClick:a.disabled?stopPropagation:d.createSelectHandlerForOption(a),onKeyPress:a.disabled?stopPropagation:d.createSelectHandlerForOption(a),children:/*#__PURE__*/_jsx("a",{disabled:a.disabled,children:/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},a),{},{classNames:d.props.classNames}))})},b)}),d.state={open:!1,searchValue:"",keyboardFocusedOptionIndex:null,numberOfOptionsShown:OPTIONS_PAGE_SIZE},d.searchBoxRef=/*#__PURE__*/createRef(),d.dropdownMenuRef=/*#__PURE__*/createRef(),d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentDidMount",value:function componentDidMount(){this.setState({shouldRenderWithPortal:getShouldRenderWithPortal()}),window.addEventListener("resize",this.handleResize)}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.close(),window.removeEventListener("resize",this.handleResize)}},{key:"getIndexWithoutHeadersForIndexWithHeaders",value:function getIndexWithoutHeadersForIndexWithHeaders(a){return this.getOptions().reduce(function(b,c,d){return d<a&&actionableOption(c)?b+1:b},0)}},{key:"selectKeyboardFocusedOption",value:function selectKeyboardFocusedOption(){if(null!==this.state.keyboardFocusedOptionIndex){var a=this.state.keyboardFocusedOptionIndex;this.selectOption(this.getOptions().filter(actionableOption)[a])}}},{key:"moveFocusWithDifference",value:function moveFocusWithDifference(a){var b=this;this.setState(function(c,d){var e=b.getOptions(d.options).filter(actionableOption),f=e.reduce(function(a,b,c){return null===a?d.selected&&d.selected.value===b.value?c:null:a},null),g=c.keyboardFocusedOptionIndex,h=g;if(null===g&&null===f)return{keyboardFocusedOptionIndex:0};null===g&&null!==f&&(h=f);var i=h+a,j=clamp(0,e.length-1,i);return{keyboardFocusedOptionIndex:j}})}},{key:"open",value:function open(){var a=this;this.setState({open:!0},function(){var b="undefined"!=typeof window&&window.matchMedia&&!!window.matchMedia("(pointer: coarse)").matches,c=!!a.props.onSearchChange||!!a.props.search;defer(function(){!b&&c&&a.searchBoxRef.current&&a.searchBoxRef.current.focus(),addClickClassToDocumentOnIos(),document.addEventListener("click",a.handleDocumentClick,!1)})})}},{key:"close",value:function close(){var a=this;this.setState({open:!1,keyboardFocusedOptionIndex:null},function(){defer(function(){removeClickClassFromDocumentOnIos(),document.removeEventListener("click",a.handleDocumentClick,!1)})})}},{key:"createSelectHandlerForOption",value:function createSelectHandlerForOption(a){var b=this;return function(c){stopPropagation(c),b.selectOption(a)}}},{key:"selectOption",value:function selectOption(a){a&&!a.placeholder?this.props.onChange(a):this.props.onChange(null),this.close()}},{key:"renderOptionsList",value:function renderOptionsList(){var a,b=this.props,c=b.dropdownRight,d=b.dropdownWidth,e=b.onSearchChange,f=b.placeholder,g=b.required,h=b.search,i=b.searchValue,j=b.searchPlaceholder,k=this.state.open,l=this.style,m=!!e||!!h,n=classNames(l("tw-select"),l("dropdown-menu"),(a={},_defineProperty(a,l("dropdown-menu-".concat(c,"-right")),c),_defineProperty(a,l("dropdown-menu-".concat(d)),d),_defineProperty(a,l("dropdown-menu--open"),k),a));return/*#__PURE__*/_jsxs("ul",{className:n,children:[g||m||!f?"":this.renderPlaceHolderOption(),m&&/*#__PURE__*/_jsx(SearchBox,{ref:this.searchBoxRef,classNames:this.props.classNames,value:i||this.state.searchValue,placeholder:j,onChange:this.handleSearchChange,onClick:stopPropagation}),this.renderOptions(),this.state.numberOfOptionsShown<this.getOptions().length?this.renderShowMore():""]})}},{key:"renderOptions",value:function renderOptions(){return this.getOptions().slice(0,this.state.numberOfOptionsShown).map(this.renderOption)}},{key:"renderShowMore",value:function renderShowMore(){return/*#__PURE__*/ (/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */_jsx("li",{className:classNames(this.style("tw-dropdown-item--clickable"),this.style("tw-dropdown-item--divider"),this.style("show-more")),onClick:this.showMore.bind(this),onKeyPress:this.showMore.bind(this),children:/*#__PURE__*/_jsx("a",{children:"..."})}))}},{key:"showMore",value:function showMore(a){stopPropagation(a),this.setState(function(a){return{numberOfOptionsShown:a.numberOfOptionsShown+OPTIONS_PAGE_SIZE}})}},{key:"renderPlaceHolderOption",value:function renderPlaceHolderOption(){var a=this.props.placeholder;return/*#__PURE__*/_jsx("li",{className:classNames(this.style("tw-dropdown-item--clickable"),this.style("tw-dropdown-item--divider")),onClick:this.createSelectHandlerForOption({placeholder:a}),onKeyPress:this.createSelectHandlerForOption({placeholder:a}),children:/*#__PURE__*/_jsx("a",{children:a})})}},{key:"renderButtonInternals",value:function renderButtonInternals(){var a=this.props,b=a.selected,c=a.placeholder;return b?/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},b),{},{classNames:this.props.classNames,selected:!0})):/*#__PURE__*/_jsx("span",{className:this.style("form-control-placeholder"),children:c})}},{key:"render",value:function render(){var a,b,c=this,d=this.props,e=d.disabled,f=d.size,g=d.block,h=d.id,i=d.dropdownUp,j=d.inverse,k=this.state,l=k.open,m=k.shouldRenderWithPortal,n=this.style,o=classNames(n("tw-select"),n("btn-group"),(a={},_defineProperty(a,n("btn-block"),g),_defineProperty(a,n("dropup"),i),_defineProperty(a,n("dropdown"),!i),a)),p=classNames(n("btn"),n("btn-input"),(b={},_defineProperty(b,"".concat(n("btn-input-inverse")," ").concat(n("btn-addon")),j),_defineProperty(b,n("btn-xs"),"xs"===f),_defineProperty(b,n("btn-sm"),"sm"===f),_defineProperty(b,n("btn-md"),"md"===f),_defineProperty(b,n("btn-lg"),"lg"===f),b),n("dropdown-toggle")),q=n("open");return/*#__PURE__*/ (// A transition is used here in order to mount and unmount the dropdown menu while retaining animations
|
|
2
2
|
_jsx(_Fragment,{children:/*#__PURE__*/_jsxs("div",{// eslint-disable-line jsx-a11y/no-static-element-interactions
|
|
3
|
-
|
|
4
|
-
value:PropTypes.any.isRequired,label:PropTypes.node,icon:PropTypes.node,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node}),/**
|
|
3
|
+
ref:this.dropdownMenuRef,className:o,onKeyDown:this.handleKeyDown,onTouchMove:this.handleTouchStart,onFocus:this.handleOnFocus,onBlur:this.handleOnBlur,children:[/*#__PURE__*/_jsxs("button",{disabled:e,className:p,type:"button",id:h,"aria-expanded":l,onClick:this.handleButtonClick,children:[this.renderButtonInternals(),/*#__PURE__*/_jsx(Chevron,{disabled:e,className:"".concat(n("tw-icon")," ").concat(n("tw-chevron-up-icon")," ").concat(n("tw-chevron")," ").concat(n("bottom")," ").concat(n("tw-select-chevron"))})]}),m?/*#__PURE__*/_jsx(Dimmer,{open:l,children:/*#__PURE__*/_jsx(SlidingPanel,{open:l,position:"bottom",children:this.renderOptionsList()})}):/*#__PURE__*/_jsx(Transition,{in:l,timeout:BOOTSTRAP_DROPDOWN_ANIMATION_TIME,onEntering:function onEntering(){c.dropdownMenuRef.current&&addClassAndTriggerReflow(c.dropdownMenuRef.current,q)},onExit:function onExit(){c.dropdownMenuRef.current&&removeClass(c.dropdownMenuRef.current,q)},children:function children(a){return"exited"!==a&&c.renderOptionsList()}})]})}))}}],[{key:"getDerivedStateFromProps",value:function getDerivedStateFromProps(a,b){var c=!!a.options.length;if(b.open&&(""!==a.searchValue||""!==b.searchValue)){if(c&&null===b.keyboardFocusedOptionIndex)return{keyboardFocusedOptionIndex:0};if(!c&&null!==b.keyboardFocusedOptionIndex)return{keyboardFocusedOptionIndex:null}}return null}}]),b}(Component);export{Select as default};Select.propTypes={placeholder:PropTypes.string,id:PropTypes.string,required:PropTypes.bool,disabled:PropTypes.bool,inverse:PropTypes.bool,dropdownRight:PropTypes.oneOf(["xs","sm","md","lg","xl"]),dropdownWidth:PropTypes.oneOf(["sm","md","lg"]),size:PropTypes.oneOf(["sm","md","lg"]),block:PropTypes.bool,selected:PropTypes.shape({value:PropTypes.any.isRequired,label:PropTypes.node,icon:PropTypes.node,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node}),/**
|
|
5
4
|
* Search toggle
|
|
6
5
|
* if `true` default search functionality being enabled (not case sensitive search in option labels & currency props)
|
|
7
6
|
* if `function` you can define your own search function to implement custom search experience. This search function used while filtering the options array. The custom search function takes two parameters. First is the option the second is the keyword.
|
|
8
|
-
*/search:PropTypes.oneOfType([PropTypes.bool,PropTypes.func]),onChange:PropTypes.func.isRequired,onFocus:PropTypes.func,onBlur:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({
|
|
9
|
-
value:PropTypes.any,label:PropTypes.node,header:PropTypes.node,icon:PropTypes.node,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node,separator:PropTypes.bool,disabled:PropTypes.bool,searchStrings:PropTypes.arrayOf(PropTypes.string)})).isRequired,/**
|
|
7
|
+
*/search:PropTypes.oneOfType([PropTypes.bool,PropTypes.func]),onChange:PropTypes.func.isRequired,onFocus:PropTypes.func,onBlur:PropTypes.func,options:PropTypes.arrayOf(PropTypes.shape({value:PropTypes.any,label:PropTypes.node,header:PropTypes.node,icon:PropTypes.node,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node,separator:PropTypes.bool,disabled:PropTypes.bool,searchStrings:PropTypes.arrayOf(PropTypes.string)})).isRequired,/**
|
|
10
8
|
* To have full control of your search value and response use `onSearchChange` function combined with `searchValue` and custom filtering on the options array.
|
|
11
9
|
* DO NOT USE TOGETHER WITH `search` PROPERTY
|
|
12
10
|
*/onSearchChange:PropTypes.func,searchValue:PropTypes.string,searchPlaceholder:PropTypes.string,classNames:PropTypes.objectOf(PropTypes.string),dropdownUp:PropTypes.bool},Select.defaultProps={id:void 0,placeholder:void 0,size:"md",dropdownRight:null,dropdownWidth:null,inverse:!1,required:!1,disabled:!1,block:!0,selected:null,onFocus:null,onBlur:null,onSearchChange:void 0,search:!1,searchValue:"",searchPlaceholder:"Search...",classNames:{},dropdownUp:!1};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.map.js";import
|
|
1
|
+
import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.map.js";import PropTypes from"prop-types";import{cloneElement}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Option=function(a){var b=a.currency,c=a.label,d=a.note,e=a.secondary,f=a.icon,g=a.classNames,h=a.selected,i=function(a){return a.map(function(a){return g[a]||a}).join(" ")},j=b?"".concat(i(["currency-flag","currency-flag-".concat(b.toLowerCase()),"".concat(h?"hidden-xs":"")])):null;return/*#__PURE__*/_jsxs("span",{children:[b?/*#__PURE__*/_jsx("i",{className:j}):f&&/*#__PURE__*/cloneElement(f,{size:24,className:"".concat(i(["tw-icon"]))}),c,d&&/*#__PURE__*/_jsx("span",{className:"small m-l-1",children:d}),e&&/*#__PURE__*/_jsx("span",{className:"small text-ellipsis",children:e})]})};Option.propTypes={label:PropTypes.node.isRequired,currency:PropTypes.string,note:PropTypes.node,secondary:PropTypes.node,icon:PropTypes.node,classNames:PropTypes.objectOf(PropTypes.string),selected:PropTypes.bool},Option.defaultProps={currency:"",note:"",secondary:"",icon:null,classNames:{},selected:!1};export default Option;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.concat.js";import{
|
|
1
|
+
import"core-js/modules/es.array.concat.js";import{Search as SearchIcon}from"@transferwise/icons";import classnames from"classnames";import PropTypes from"prop-types";import{forwardRef}from"react";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var SearchBox=/*#__PURE__*/forwardRef(function(a,b){var c=a.classNames,d=a.onChange,e=a.onClick,f=a.placeholder,g=a.value,h=function(a){return c[a]||a};return/*#__PURE__*/_jsx("li",{className:h("tw-dropdown-item--divider"),children:/*#__PURE__*/_jsx("a",{className:"".concat(h("tw-select-filter-link")," ").concat(h("p-a-0")),children:/*#__PURE__*/_jsxs("div",{className:h("input-group"),children:[/*#__PURE__*/_jsx("span",{className:h("input-group-addon"),children:/*#__PURE__*/_jsx(SearchIcon,{className:classnames(h("tw-icon"),h("tw-icon-search"))})}),/*#__PURE__*/_jsx("input",{ref:b,type:"text",className:classnames(h("tw-select-filter"),h("form-control")),placeholder:f,value:g,spellCheck:"false",onChange:d,onClick:e})]})})})});SearchBox.propTypes={classNames:PropTypes.objectOf(PropTypes.string),onChange:PropTypes.func.isRequired,onClick:PropTypes.func.isRequired,placeholder:PropTypes.string,value:PropTypes.string},SearchBox.defaultProps={classNames:{},value:"",placeholder:void 0};export default SearchBox;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.object.values.js";import
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.object.values.js";import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef,useRef}from"react";import{Breakpoint}from"../common";import{useClientWidth}from"../common/hooks";import{jsx as _jsx}from"react/jsx-runtime";var Layout={COLUMN:"COLUMN"},SizeSwapper=/*#__PURE__*/forwardRef(function(a,b){var c=a.items,d=a.inline,e=useRef(null),f=useClientWidth({ref:b||e}),g=_slicedToArray(f,1),h=g[0];if(!c||0===c.length)return null;// If all breakpoints are specified and clientWidth never > breakpoint itemsToRender can be undefined.
|
|
2
|
+
// Do not use deconstruct here to get items and layout.
|
|
3
|
+
var i=[];// Always return parent container even if there are no items to display to
|
|
2
4
|
// keep the ref on DOM and let clientWidth be calculated properly.
|
|
3
|
-
return h?i=c.filter(function(a){var b=a.breakpoint,c=void 0===b?0:b;return h>=c}).pop():i.items=c.map(function(a){var b=a.items;return Object.values(b)}),/*#__PURE__*/_jsx("div",{className:classNames("np-size-swapper",{"d-flex":!d,"d-inline-flex":d,"flex-column":i&&i.layout===Layout.COLUMN,"flex-wrap":i&&i.wrap}),style:{visibility:h?"visible":"hidden"},
|
|
5
|
+
return h?i=c.filter(function(a){var b=a.breakpoint,c=void 0===b?0:b;return h>=c}).pop():i.items=c.map(function(a){var b=a.items;return Object.values(b)}),/*#__PURE__*/_jsx("div",{ref:e,className:classNames("np-size-swapper",{"d-flex":!d,"d-inline-flex":d,"flex-column":i&&i.layout===Layout.COLUMN,"flex-wrap":i&&i.wrap}),style:{visibility:h?"visible":"hidden"},children:i&&i.items})});SizeSwapper.Breakpoint=Breakpoint,SizeSwapper.Layout=Layout,SizeSwapper.propTypes={inline:PropTypes.bool,/** List of items that will appear at the specified breakpoint and presented in row or columns depending on layout */items:PropTypes.arrayOf(PropTypes.shape({items:PropTypes.arrayOf(PropTypes.element),breakpoint:PropTypes.number,layout:PropTypes.oneOf([SizeSwapper.Layout.COLUMN]),wrap:PropTypes.bool})).isRequired},SizeSwapper.defaultProps={inline:!1};export default SizeSwapper;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["children","className","open","position","showSlidingPanelBorder","slidingPanelPositionFixed"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import
|
|
2
|
-
,timeout:{enter:0,exit:EXIT_ANIMATION},classNames:classNames("sliding-panel--open-".concat(f),g&&"sliding-panel--border-".concat(f),{"sliding-panel--fixed":h},"sliding-panel"),appear:!0,unmountOnExit:!0,children:/*#__PURE__*/_jsx("div",{className:classNames("sliding-panel",d),
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from"@babel/runtime/helpers/objectWithoutProperties";var _excluded=["children","className","open","position","showSlidingPanelBorder","slidingPanelPositionFixed"];import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef}from"react";import CSSTransition from"react-transition-group/CSSTransition";import{jsx as _jsx}from"react/jsx-runtime";export var EXIT_ANIMATION=350;var SlidingPanel=/*#__PURE__*/forwardRef(function(a,b){var c=a.children,d=a.className,e=a.open,f=a.position,g=a.showSlidingPanelBorder,h=a.slidingPanelPositionFixed,i=_objectWithoutProperties(a,_excluded);return/*#__PURE__*/_jsx(CSSTransition,_objectSpread(_objectSpread({},i),{},{in:e// Wait for animation to finish before unmount.
|
|
2
|
+
,timeout:{enter:0,exit:EXIT_ANIMATION},classNames:classNames("sliding-panel--open-".concat(f),g&&"sliding-panel--border-".concat(f),{"sliding-panel--fixed":h},"sliding-panel"),appear:!0,unmountOnExit:!0,children:/*#__PURE__*/_jsx("div",{ref:b,className:classNames("sliding-panel",d),children:c})}))});SlidingPanel.propTypes={children:PropTypes.node,className:PropTypes.string,open:PropTypes.bool,position:PropTypes.oneOf(["top","bottom","left","right"]),showSlidingPanelBorder:PropTypes.bool,slidingPanelPositionFixed:PropTypes.bool},SlidingPanel.defaultProps={children:null,className:void 0,open:!1,position:"left",showSlidingPanelBorder:!1,slidingPanelPositionFixed:!1};export default SlidingPanel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import
|
|
1
|
+
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import classNames from"classnames";import PropTypes from"prop-types";import{Component}from"react";import CSSTransition from"react-transition-group/CSSTransition";import{Theme}from"../common";import{DirectionContext}from"../provider/direction";import withNextPortal from"../withNextPortal/withNextPortal";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export var CSS_TRANSITION_DURATION=400;export var Snackbar=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"setLeaveTimeout",function(){var b=a.props.timeout;a.timeout=setTimeout(function(){a.setState({visible:!1})},b)}),a.state={visible:!1,text:""},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"componentWillUnmount",value:function componentWillUnmount(){clearTimeout(this.timeout),clearTimeout(this.transitionTimeout)}},{key:"shouldComponentUpdate",value:function shouldComponentUpdate(a,b){return!!a.text&&(a.timestamp!==this.props.timestamp||b.visible!==this.state.visible||b.text!==this.state.text)}},{key:"componentDidUpdate",value:function componentDidUpdate(a){var b=this,c=this.props,d=c.action,e=c.text,f=c.theme,g=c.timestamp;a.text?a.timestamp!==g&&(clearTimeout(this.timeout),this.state.visible?this.setState({visible:!1},function(){b.transitionTimeout=setTimeout(function(){b.setState({visible:!0,action:d,text:e,theme:f}),b.setLeaveTimeout()},CSS_TRANSITION_DURATION)}):(this.setState({visible:!0,action:d,text:e,theme:f}),this.setLeaveTimeout())):this.setState({visible:!0,action:d,text:e,theme:f},function(){b.setLeaveTimeout()})}},{key:"render",value:function render(){var a="rtl"===this.context,b=this.state,c=b.action,d=b.text,e=b.theme,f=b.visible,g=this.props.timeout;return/*#__PURE__*/_jsx("div",{className:classNames("snackbar",{"snackbar--rtl":a}),children:/*#__PURE__*/_jsx(CSSTransition,{in:f,classNames:"snackbar__text-container",timeout:{appear:0,enter:g,exit:CSS_TRANSITION_DURATION},unmountOnExit:!0,children:/*#__PURE__*/_jsxs("span",{className:"snackbar__text snackbar__text--".concat(e),children:[d,c?/*#__PURE__*/_jsx("button",{type:"button",className:"snackbar__text__action",onClick:c.onClick,children:c.label}):null]})})})}}]),b}(Component);Snackbar.contextType=DirectionContext,Snackbar.propTypes={action:PropTypes.shape({label:PropTypes.string.isRequired,onClick:PropTypes.func.isRequired}),text:PropTypes.node.isRequired,theme:PropTypes.oneOf(["light","dark"]),timeout:PropTypes.number.isRequired,timestamp:PropTypes.number.isRequired},Snackbar.defaultProps={action:null,theme:Theme.LIGHT};export default withNextPortal(Snackbar);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import
|
|
1
|
+
import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import PropTypes from"prop-types";import{Component}from"react";import SnackbarPortal from"./Snackbar";import{SnackbarContext}from"./SnackbarContext";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var SnackbarProvider=/*#__PURE__*/function(a){function b(){var a;return _classCallCheck(this,b),a=c.call(this),_defineProperty(_assertThisInitialized(a),"create",function(b){var c=b.action,d=b.text,e=b.theme;a.setState({action:c,text:d,theme:e,timestamp:Date.now()})}),a.state={text:"",timestamp:0},a}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"render",value:function render(){var a=this.state,b=a.action,c=a.text,d=a.theme,e=a.timestamp;return/*#__PURE__*/_jsxs(SnackbarContext.Provider,{value:{createSnackbar:this.create},children:[/*#__PURE__*/_jsx(SnackbarPortal,{action:b,text:c,timestamp:e,timeout:this.props.timeout,theme:d}),this.props.children]})}}]),b}(Component);SnackbarProvider.propTypes={children:PropTypes.node.isRequired,timeout:PropTypes.number},SnackbarProvider.defaultProps={timeout:4500};export default SnackbarProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.map.js";import PropTypes from"prop-types";import
|
|
1
|
+
import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.map.js";import classNames from"classnames";import PropTypes from"prop-types";import{Position}from"../common";import Tooltip from"../tooltip";import{isTouchDevice}from"./deviceDetection";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";function clamp(a,b,c){return Math.max(Math.min(b,c),a)}/* eslint-disable react/no-array-index-key */var Stepper=function(a){var b=a.steps,c=a.activeStep,d=a.className;if(0===b.length)return null;var e=clamp(0,b.length-1,c),f=1/(b.length-1),g=e/(b.length-1),h=Math.max(g-f,0),i=Math.min(e,1)*f;return/*#__PURE__*/_jsxs("div",{className:classNames("tw-stepper",d),children:[/*#__PURE__*/_jsxs("div",{className:"progress",children:[/*#__PURE__*/_jsx("div",{className:"progress-bar-filler",style:{width:"".concat(100*h,"%")}}),/*#__PURE__*/_jsx("div",{className:"progress-bar-ending",style:{width:"".concat(100*i,"%")}})]}),/*#__PURE__*/_jsx("ul",{className:"tw-stepper-steps p-t-1 m-b-0",children:b.map(function renderStep(a,b){var c=b===e,d=a.onClick&&!c,g=/*#__PURE__*/_jsx("button",{type:"button",className:"btn-unstyled tw-stepper__step-label",disabled:!d,onClick:function onClick(){return d&&a.onClick()},children:/*#__PURE__*/_jsx("small",{children:a.label})});return/*#__PURE__*/_jsx("li",{style:{left:"".concat(100*(b*f),"%")},className:"\n hidden-xs\n tw-stepper__step\n ".concat(c?"tw-stepper__step--active":"","\n ").concat(d?"tw-stepper__step--clickable":"","\n "),children:a.hoverLabel&&!isTouchDevice()?/*#__PURE__*/_jsx(Tooltip,{position:Position.BOTTOM,label:a.hoverLabel,children:g}):g},b)})})]})};/* eslint-enable react/no-array-index-key */Stepper.propTypes={steps:PropTypes.arrayOf(PropTypes.shape({label:PropTypes.node.isRequired,onClick:PropTypes.func,hoverLabel:PropTypes.node})).isRequired,activeStep:PropTypes.number,className:PropTypes.string},Stepper.defaultProps={activeStep:0,className:void 0};export default Stepper;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.string.match.js";function supportsTouchEvents(){var a="undefined"!=typeof window&&window.ontouchstart!==void 0,b="undefined"!=typeof navigator&&navigator.maxTouchPoints,c="undefined"!=typeof window&&window.DocumentTouch&&document instanceof window.DocumentTouch
|
|
1
|
+
import"core-js/modules/es.array.join.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.string.match.js";function supportsTouchEvents(){var a="undefined"!=typeof window&&window.ontouchstart!==void 0,b="undefined"!=typeof navigator&&navigator.maxTouchPoints,c="undefined"!=typeof window&&window.DocumentTouch&&document instanceof window.DocumentTouch;// eslint-disable-next-line compat/compat
|
|
2
|
+
return!!(a||b||c)}function userAgentSuggestsTouchDevice(){var a=["android","iemobile","iphone","ipad","ipod","blackberry","bada"].map(function(a){return"(".concat(a,")")}).join("|"),b=new RegExp(a,"ig");return"undefined"!=typeof navigator&&!!navigator.userAgent.match(b)}// Important: this is not fool-proof! It gives false positives and negatives, and will be outdated.
|
|
2
3
|
// Only use this for small vanity changes where it still works either way.
|
|
3
4
|
export function isTouchDevice(){return supportsTouchEvents()||userAgentSuggestsTouchDevice()}
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";var _statusLabels;import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import classNames from"classnames";import{cloneElement}from"react";import{useIntl}from"react-intl";import
|
|
2
|
-
description:PropTypes.node,/** @deprecated please use info instead */help:deprecated(PropTypes.shape({content:PropTypes.node.isRequired,title:PropTypes.node}),{component:"Summary",newProp:"info",expiryDate:expiryDate}),/** Infos displayed on help Icon click inside Popover or Modal */ // eslint-disable-next-line
|
|
3
|
-
info:PropTypes.shape({"aria-label":PropTypes.string.isRequired,content:PropTypes.node.isRequired,onClick:PropTypes.func,presentation:PropTypes.oneOf(["POPOVER","MODAL"]),title:PropTypes.node}),/** @deprecated please use icon instead */illustration:deprecated(PropTypes.node,{component:"Summary",newProp:"icon",expiryDate:expiryDate}),/** Main Summary Icon */ // eslint-disable-next-line
|
|
4
|
-
icon:requiredIf(PropTypes.node,function(a){var b=a.illustration;return!b}),/** Decides the badge applied to Icon */status:PropTypes.oneOf(["notDone","done","pending"]),/** Summary title */title:PropTypes.node.isRequired},Summary.defaultProps={action:null,as:"div",className:null,content:null,help:null,illustration:null,status:null};export default Summary;
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";var _statusLabels;import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import{CheckCircle as CheckCircleIcon,PendingCircle as PendingCircleIcon}from"@transferwise/icons";import classNames from"classnames";import PropTypes from"prop-types";import{cloneElement}from"react";import{useIntl}from"react-intl";import requiredIf from"react-required-if";import{Status,Size}from"../common";import{useDirection}from"../common/hooks";import Info from"../info";import{deprecated}from"../utilities";import messages from"./Summary.messages";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var BadgeIcons={done:CheckCircleIcon,pending:PendingCircleIcon},statusLabels=(_statusLabels={},_defineProperty(_statusLabels,Status.NOT_DONE,"statusNotDone"),_defineProperty(_statusLabels,Status.DONE,"statusDone"),_defineProperty(_statusLabels,Status.PENDING,"statusPending"),_statusLabels),expiryDate=new Date("03-01-2021"),Summary=function(a){var b=a.action,c=a.as,d=a.className,e=a.content,f=a.description,g=void 0===f?e:f,h=a.help,i=a.icon,j=a.illustration,k=a.info,l=void 0===k?h:k,m=a.status,n=a.title,o=useIntl(),p=useDirection(),q=p.isRTL,r=j;if(i){var s,t=null===i||void 0===i||null===(s=i.props)||void 0===s?void 0:s.size;r=24===t?i:/*#__PURE__*/cloneElement(i,{size:24})}var u=m&&BadgeIcons[m];return/*#__PURE__*/_jsxs(c,{className:classNames("np-summary d-flex align-items-start",d),"aria-label":m&&o.formatMessage(messages[statusLabels[m]]),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__icon",children:[r,u&&/*#__PURE__*/_jsx(u,{size:16,filled:!0,className:"np-summary-icon__".concat(m)})]}),/*#__PURE__*/_jsxs("div",{className:classNames("np-summary__body",{"m-l-2":!q,"m-r-2":q}),children:[/*#__PURE__*/_jsxs("div",{className:"np-summary__title d-flex",children:[/*#__PURE__*/_jsx("strong",{children:n}),l&&/*#__PURE__*/_jsx(Info,{"aria-label":l["aria-label"],className:classNames({"m-l-1":!q,"m-r-1":q},"hidden-xs"),content:l.content,presentation:l.presentation,title:l.title,onClick:l.onClick})]}),g&&/*#__PURE__*/_jsx("div",{className:"np-summary__description",children:g}),b&&/*#__PURE__*/_jsx("a",{href:b.href,target:b.target,className:"np-summary__action","aria-label":b["aria-label"],onClick:b.onClick,children:b.text})]}),l&&/*#__PURE__*/_jsx(Info,{"aria-label":l["aria-label"],className:"m-l-2 hidden-sm hidden-md hidden-lg hidden-xl",content:l.content,presentation:l.presentation,size:Size.LARGE,title:l.title,onClick:l.onClick})]})};Summary.propTypes={/** Action displayed at the bottom of the Summary */action:PropTypes.shape({text:PropTypes.node.isRequired,href:PropTypes.string.isRequired,"aria-label":PropTypes.string,target:PropTypes.string,onClick:PropTypes.func}),/** Decides which html element should wrap the Summary */as:PropTypes.string,/** Extra classes applied to Summary */className:PropTypes.string,/** @deprecated please use description instead */content:deprecated(PropTypes.node,{component:"Summary",newProp:"description",expiryDate:expiryDate}),/** Summary description */description:PropTypes.node,/** @deprecated please use info instead */help:deprecated(PropTypes.shape({content:PropTypes.node.isRequired,title:PropTypes.node}),{component:"Summary",newProp:"info",expiryDate:expiryDate}),/** Infos displayed on help Icon click inside Popover or Modal */info:PropTypes.shape({"aria-label":PropTypes.string.isRequired,content:PropTypes.node.isRequired,onClick:PropTypes.func,presentation:PropTypes.oneOf(["POPOVER","MODAL"]),title:PropTypes.node}),/** @deprecated please use icon instead */illustration:deprecated(PropTypes.node,{component:"Summary",newProp:"icon",expiryDate:expiryDate}),/** Main Summary Icon */icon:requiredIf(PropTypes.node,function(a){var b=a.illustration;return!b}),/** Decides the badge applied to Icon */status:PropTypes.oneOf(["notDone","done","pending"]),/** Summary title */title:PropTypes.node.isRequired},Summary.defaultProps={action:null,as:"div",className:null,content:null,help:null,illustration:null,status:null};export default Summary;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{CheckCircle,CrossCircle}from"@transferwise/icons";import classnames from"classnames";import{useDirection}from"../common/hooks";import KeyCodes from"../common/keyCodes";import{logActionRequiredIf}from"../utilities";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var Switch=function(a){var b=useDirection(),c=b.isRTL,d=a.checked,e=a.className,f=a.id,g=a.onClick,h=a.disabled,i=a["aria-label"],j=i?void 0:a["aria-labelledby"];return logActionRequiredIf("Switch now expects either `aria-label` or `aria-labelledby`, and will soon make these props required. Please update your usage to provide one or the other.",!i&&!j),/*#__PURE__*/_jsxs("span",{className:classnames("np-switch",{"np-switch--rtl":c,"np-switch--unchecked":!d,"np-switch--checked":d,"np-switch--disabled":h},e),tabIndex:0,role:"switch","aria-checked":d,"aria-label":i,"aria-labelledby":j,id:f,"aria-disabled":h,onClick:h?void 0:g,onKeyDown:h?void 0:function handleKeyDown(a){("32"===a.code||a.keyCode===KeyCodes.SPACE)&&(a.preventDefault(),g())},children:[/*#__PURE__*/_jsx("span",{className:"np-switch--thumb",children:d?/*#__PURE__*/_jsx(CheckCircle,{filled:!0,size:24}):/*#__PURE__*/_jsx(CrossCircle,{filled:!0,size:24})}),/*#__PURE__*/_jsx("input",{type:"checkbox",checked:d,readOnly:!0})]})};export default Switch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useState}from"react";import Switch from"./Switch";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export default{component:Switch,title:"Switch"};export var
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useState}from"react";import Switch from"./Switch";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";export default{component:Switch,title:"Switch"};export var Basic=function(){var a=useState(!0),b=_slicedToArray(a,2),c=b[0],d=b[1];return/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column",children:[/*#__PURE__*/_jsx("label",{id:"labelID",htmlFor:"switchId",children:"A switch with a label"}),/*#__PURE__*/_jsx(Switch,{checked:c,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:!0,disabled:!0,className:"a-class-name m-t-4","aria-label":"I'm a switch without label",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:!1,disabled:!1,className:"a-class-name m-t-4","aria-label":"I'm a switch without label",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:!1,disabled:!0,className:"a-class-name m-t-4","aria-label":"I'm a switch without label",onClick:function onClick(){return d(!c)}})]})};export var Disabled=function(){var a=useState(!1),b=_slicedToArray(a,2),c=b[0],d=b[1];return/*#__PURE__*/_jsxs("div",{className:"d-flex flex-column",children:[/*#__PURE__*/_jsx(Switch,{checked:c,disabled:!0,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}}),/*#__PURE__*/_jsx(Switch,{checked:!c,disabled:!0,className:"a-class-name","aria-labelledby":"labelID",id:"switchId",onClick:function onClick(){return d(!c)}})]})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import Option from"../common/Option";import Switch from"../switch";import{jsx as _jsx}from"react/jsx-runtime";var SwitchOption=function(a){var b=a.checked,c=a.complex,d=a.content,e=a.disabled,f=a.id,g=a.media,h=a.onChange,i=a.title,j=a.showMediaAtAllSizes,k=a["aria-label"],l=function(a){
|
|
1
|
+
import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import Option from"../common/Option";import Switch from"../switch";import{jsx as _jsx}from"react/jsx-runtime";var stopPropagation=function(a){a&&(a.stopPropagation(),a.preventDefault(),a.nativeEvent&&a.nativeEvent.stopImmediatePropagation&&a.nativeEvent.stopImmediatePropagation())},SwitchOption=function(a){var b=a.checked,c=a.complex,d=a.content,e=a.disabled,f=a.id,g=a.media,h=a.onChange,i=a.title,j=a.showMediaAtAllSizes,k=a["aria-label"],l=function(a){stopPropagation(a);e||h(!b)};return/*#__PURE__*/_jsx(Option,_objectSpread(_objectSpread({},{media:g,title:i,content:d,complex:c,disabled:e,showMediaAtAllSizes:j}),{},{button:/*#__PURE__*/_jsx(Switch,{id:f,checked:b,disabled:e,"aria-label":k,onClick:l}),onClick:l}))};export default SwitchOption;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{
|
|
1
|
+
import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{text,boolean}from"@storybook/addon-knobs";import{FastFlag as FastFlagIcon}from"@transferwise/icons";import{useState}from"react";import SwitchOption from"./SwitchOption";import{jsx as _jsx}from"react/jsx-runtime";export default{component:SwitchOption,title:"SwitchOption"};export var Basic=function(){var a=useState(!1),b=_slicedToArray(a,2),c=b[0],d=b[1],e=text("title","Switch option"),f=text("content","Normally, the button and icon are vertically centered."),g=boolean("disabled",!1),h=boolean("showMediaAtAllSizes",!1);return/*#__PURE__*/_jsx(SwitchOption,{media:/*#__PURE__*/_jsx(FastFlagIcon,{}),title:e,content:f,id:"id",checked:c,complex:!1,disabled:g,showMediaAtAllSizes:h,"aria-label":e,onChange:d})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import classNames from"classnames";import PropTypes from"prop-types";import{forwardRef,useEffect,useRef}from"react";import{jsx as _jsx}from"react/jsx-runtime";var Tab=/*#__PURE__*/forwardRef(function(a,b){var c=a.children,d=a.id,e=a.disabled,f=a.panelId,g=a.selected,h=a.onKeyDown,i=a.onClick,j=a.style,k=a.focusTab,l=useRef(!0),m=function(){return l.current?void(l.current=!1):void(g&&k&&k())};return useEffect(function(){m()},[g]),/*#__PURE__*/_jsx("li",{ref:b,className:classNames("tabs__tab",{"tabs__tab--selected":g,"tabs__tab--disabled":e}),role:"tab",id:d,"aria-selected":g?"true":"false","aria-disabled":e?"true":"false","aria-controls":e?null:f,tabIndex:"0",style:j,onKeyDown:e?null:h,onClick:i,children:c})});Tab.defaultProps={disabled:!1,selected:!1,onClick:null,style:null,focusTab:null},Tab.propTypes={children:PropTypes.node.isRequired,disabled:PropTypes.bool,selected:PropTypes.bool,id:PropTypes.string.isRequired,panelId:PropTypes.string.isRequired,onKeyDown:PropTypes.func.isRequired,onClick:PropTypes.func,style:PropTypes.shape({width:PropTypes.string}),focusTab:PropTypes.func};export default Tab;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.reduce.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.number.is-nan.js";import"core-js/modules/es.number.constructor.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import{Component,Fragment}from"react";import PropTypes from"prop-types";import classNames from"classnames";import clamp from"lodash.clamp";import{Spring}from"react-spring/renderprops.cjs";import Tab from"./Tab";import TabList from"./TabList";import TabPanel from"./TabPanel";import KeyCodes from"../common/keyCodes";import{getElasticDragDifference,getSwipeDifference,swipedLeftToRight,swipedRightToLeft,swipeShouldChangeTab,getVelocity}from"./utils";import{Size,Width}from"../common";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MIN_INDEX=0,enabledTabsFilter=function(a){return!a.disabled},SpacerWidth={default:0,xs:8,sm:16,md:24,lg:32},Tabs=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"container",null),_defineProperty(_assertThisInitialized(d),"containerWidth",0),_defineProperty(_assertThisInitialized(d),"tabRefs",[]),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setContainerWidth(d.container),d.setState(function(a){var b=a.selectedTabIndex;return{translateTo:-(d.containerWidth*b)}})}),_defineProperty(_assertThisInitialized(d),"setContainerRefAndWidth",function(a){d.container=a,d.setContainerWidth(a)}),_defineProperty(_assertThisInitialized(d),"setContainerWidth",function(a){if(a){var b=a.getBoundingClientRect(),c=b.width;d.containerWidth=c}}),_defineProperty(_assertThisInitialized(d),"isTabDisabled",function(a){var b=d.props.tabs;return b[a]&&b[a].disabled}),_defineProperty(_assertThisInitialized(d),"getAllTabsWidth",function(){return d.tabRefs.map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"getDistanceToSelectedTab",function(a){return d.tabRefs.filter(function(b,c){return c<a}).map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"setTabWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.headerWidth,e=b.selected,f=d.getAllTabsWidth();!a&&(c===Width.BLOCK||d.containerWidth<f)&&d.setState({fullWidthTabs:!0,translateLineX:"".concat(100*e,"%")}),a&&c===Width.AUTO&&d.containerWidth>=f&&d.setState({fullWidthTabs:!1,translateLineX:"".concat(d.getDistanceToSelectedTab(e),"px")})}),_defineProperty(_assertThisInitialized(d),"getTabLineWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.selected,e=b.tabs;if(a)return"".concat(100*(1/e.length),"%");var f=d.tabRefs[c]||d.tabRefs[d.tabRefs.length-1],g=f?f.getBoundingClientRect().width:0;return"".concat(g,"px")}),_defineProperty(_assertThisInitialized(d),"getTabToSelect",function(a,b,c){var e=a;if(swipedLeftToRight(b,c)){if(e-=1,e>MIN_INDEX&&d.isTabDisabled(e))return d.getTabToSelect(e,b,c);}else if(swipedRightToLeft(b,c)&&(e+=1,e<d.MAX_INDEX&&d.isTabDisabled(e)))return d.getTabToSelect(e,b,c);return e=clamp(e,Math.max(a-1,MIN_INDEX),Math.min(a+1,d.MAX_INDEX)),d.isTabDisabled(e)?a:e}),_defineProperty(_assertThisInitialized(d),"swipedOverHalfOfContainer",function(a){return .5<=a/d.containerWidth}),_defineProperty(_assertThisInitialized(d),"calculateApplicableDragDifference",function(a){var b=a.currentSelected,c=a.nextSelected,e=a.start,f=a.end,g=getSwipeDifference(e,f),h=getElasticDragDifference(g);return swipedLeftToRight(e,f)?b>MIN_INDEX&&b!==c?Math.min(g,d.containerWidth):h:!!swipedRightToLeft(e,f)&&(b<d.MAX_INDEX&&b!==c?-Math.min(g,d.containerWidth):-h)}),_defineProperty(_assertThisInitialized(d),"switchTab",function(a){var b=d.props.onTabSelect;b(a)}),_defineProperty(_assertThisInitialized(d),"animateToTab",function(a,b){d.animateLine(a),d.animatePanel(d.getTabIndexWithoutDisabledTabs(a),b)}),_defineProperty(_assertThisInitialized(d),"animateLine",function(a){d.setState(function(b){return{translateLineX:b.fullWidthTabs?"".concat(100*a,"%"):"".concat(d.getDistanceToSelectedTab(a),"px")}})}),_defineProperty(_assertThisInitialized(d),"animatePanel",function(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=d.state.translateTo,e=c,f=-(d.containerWidth*a);d.setState({selectedTabIndex:a,isAnimating:!b&&e!==f,translateFrom:e,translateTo:f})}),_defineProperty(_assertThisInitialized(d),"disableScroll",function(a){var b=d.state.isSwiping;b&&a.preventDefault()}),_defineProperty(_assertThisInitialized(d),"handleTabClick",function(a){return function(){d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"onKeyDown",function(a){return function(b){b&&b.keyCode===KeyCodes.ENTER&&d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){var b={x:a.nativeEvent.touches[0].clientX,y:a.nativeEvent.touches[0].clientY,time:Date.now()};d.setState({start:b,currentSwipe:[b]}),a.persist()}),_defineProperty(_assertThisInitialized(d),"handleTouchMove",function(a){var b=d.state.start,c=d.props.selected,e=d.getTabIndexWithoutDisabledTabs(c),f={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},g=getSwipeDifference(b,f),h=getSwipeDifference(b,f,"y"),i=d.state,j=i.isScrolling,k=i.isSwiping;if(a.persist(),j||k||(g>h?k=!0:j=!0),d.setState({isScrolling:j,isSwiping:k}),k){var n=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?n:c);var l=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:n,start:b,end:f}),m=!!l&&-(d.containerWidth*e)+l;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:m||a.translateFrom,translateTo:m||a.translateTo}})}}),_defineProperty(_assertThisInitialized(d),"handleTouchEnd",function(a){var b=d.state,c=b.start,e=b.isSwiping,f=d.props.selected,g={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},h=getSwipeDifference(c,g),i=getVelocity([].concat(_toConsumableArray(d.state.currentSwipe),[g]));d.setState({currentSwipe:[]});var j=f;a.persist(),e&&((swipeShouldChangeTab(c,g)||d.swipedOverHalfOfContainer(h))&&(j=d.getTabToSelect(j,c,g)),j===f?d.animateToTab(j):(d.switchTab(j),d.setState({lastSwipeVelocity:i}))),d.setState({isSwiping:!1,isScrolling:!1})}),d.state={start:null,translateX:0,translateFrom:0,translateTo:0,translateLineX:null,isAnimating:!1,isSwiping:!1,isScrolling:!1,lastSwipeVelocity:0,fullWidthTabs:a.headerWidth===Width.BLOCK},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"filteredTabsLength",get:function get(){return this.props.tabs.filter(enabledTabsFilter).length}},{key:"MAX_INDEX",get:function get(){return this.props.tabs.length-1}},{key:"componentDidMount",value:function componentDidMount(){var a=this.props.selected;this.setTabWidth(),this.switchTab(clamp(a,MIN_INDEX,this.MAX_INDEX)),this.animateToTab(clamp(a,MIN_INDEX,this.MAX_INDEX),!0),document.body.addEventListener("touchmove",this.disableScroll,{passive:!1}),document.body.addEventListener("touchforcechange",this.disableScroll,{passive:!1}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function componentDidUpdate(a,b){var c=this.props.selected,d=a.selected,e=this.props.tabs[c],f=e&&e.disabled,g=a.tabs[d],h=g&&g.disabled,i=this.props.tabs.length,j=a.tabs.length,k=this.props.tabs.filter(enabledTabsFilter).length,l=a.tabs.filter(enabledTabsFilter).length,m=this.props.headerWidth,n=a.headerWidth,o=this.props.animatePanelsOnClick,p=!o&&!b.isSwiping;(m!==n||i!==j)&&this.setTabWidth(),(c!==d||k!==l||f!==h)&&this.animateToTab(clamp(c,MIN_INDEX,this.MAX_INDEX),c===d||p)}},{key:"componentWillUnmount",value:function componentWillUnmount(){document.body.removeEventListener("touchmove",this.disableScroll),document.body.removeEventListener("touchforcechange",this.disableScroll),window.removeEventListener("resize",this.handleResize)}},{key:"getTabIndexWithoutDisabledTabs",value:function getTabIndexWithoutDisabledTabs(a){return a-this.props.tabs.slice(0,a).filter(function(a){return!enabledTabsFilter(a)}).length}},{key:"render",value:function render(){var a=this,b=this.props,c=b.tabs,d=b.changeTabOnSwipe,e=b.name,f=b.selected,g=b.className,h=b.transitionSpacing,i=this.state,j=i.isSwiping,k=i.translateLineX,l=i.isAnimating,m=i.translateFrom,n=i.translateTo,o=i.lastSwipeVelocity,p=i.fullWidthTabs,q=SpacerWidth[h],r=this.filteredTabsLength,s=Math.abs(-m-this.containerWidth*f),t=j?1-s/this.containerWidth:1-Math.abs(s/this.containerWidth-1),u=(Number.isNaN(t)?0:t)*Math.min(10*Math.E,10*o*Math.E),v=l||j,w=r*this.containerWidth+2*q,x=function(a){var b=a.id;return 0<q&&/*#__PURE__*/_jsx("div",{style:{width:q,display:v?"block":"none"}},b)};return/*#__PURE__*/_jsxs("div",{onTouchStart:d?this.handleTouchStart:void 0,onTouchEnd:d?this.handleTouchEnd:void 0,onTouchMove:d?this.handleTouchMove:void 0,className:classNames("tabs",g),children:[/*#__PURE__*/_jsxs(TabList,{children:[c.map(function(b,d){var g=b.title,h=b.disabled;return/*#__PURE__*/_jsx(Tab,_objectSpread(_objectSpread({id:"".concat(e,"-tab-").concat(d),panelId:"".concat(e,"-panel-").concat(d),selected:f===d,disabled:h,onClick:h?null:a.handleTabClick(d),onKeyDown:a.onKeyDown(d),ref:function ref(b){a.tabRefs[d]=b},focusTab:function focusTab(){a.tabRefs[d].focus()}},p?{style:{width:"".concat(100*(1/c.length),"%")}}:{}),{},{children:g}),g)}),k?/*#__PURE__*/_jsx("div",{className:classNames("tabs__line"),style:{width:this.getTabLineWidth(),transform:"translateX(".concat(k,")")}}):null]}),/*#__PURE__*/_jsx("div",{className:"tabs__panel-container",ref:this.setContainerRefAndWidth,style:{overflow:v?"hidden":"visible"},children:/*#__PURE__*/_jsx(Spring,{from:{transform:"translateX(".concat(m-q,"px)")},to:{transform:"translateX(".concat(n-q,"px)")},config:{precision:j?1:.01,velocity:j?0:u,clamp:!0},onRest:function onRest(){l&&a.setState({isAnimating:!1,lastSwipeVelocity:0})},children:function children(b){return/*#__PURE__*/_jsx("div",{className:"tabs__slider",style:{width:v?"".concat(w,"px"):"100%",transform:v?b.transform:"translateX(0px)"},children:c.map(function(b,d){var g=b.content,h=b.disabled;return h?null:/*#__PURE__*/_jsxs(Fragment,{children:[d===f&&/*#__PURE__*/_jsx(x,{id:"left-spacer"}),/*#__PURE__*/_jsx(TabPanel,{tabId:"".concat(e,"-tab-").concat(d),id:"".concat(e,"-panel-").concat(d),style:{width:v?"".concat(a.containerWidth,"px"):"100%",display:v||d===f?"block":"none"},children:g},c[d].title),d===f&&/*#__PURE__*/_jsx(x,{id:"right-spacer"})]},"".concat(c[d].title,"-fragment"))})})}})})]})}}]),b}(Component),SpacerSizes=_objectSpread(_objectSpread({},Size),{},{NONE:"default"});Tabs.propTypes={tabs:PropTypes.arrayOf(PropTypes.shape({title:PropTypes.string.isRequired,content:PropTypes.node.isRequired,disabled:PropTypes.bool.isRequired})).isRequired,selected:PropTypes.number.isRequired,onTabSelect:PropTypes.func.isRequired,name:PropTypes.string.isRequired,animatePanelsOnClick:PropTypes.bool,changeTabOnSwipe:PropTypes.bool,className:PropTypes.string,transitionSpacing:PropTypes.oneOf(["default","xs","sm","md","lg"]),headerWidth:PropTypes.oneOf(["auto","block"])},Tabs.defaultProps={animatePanelsOnClick:!1,changeTabOnSwipe:!0,className:"",transitionSpacing:SpacerSizes.NONE,headerWidth:Width.BLOCK};export default Tabs;
|
|
1
|
+
import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _assertThisInitialized from"@babel/runtime/helpers/assertThisInitialized";import _inherits from"@babel/runtime/helpers/inherits";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _defineProperty from"@babel/runtime/helpers/defineProperty";import"core-js/modules/es.reflect.construct.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.object.get-own-property-descriptors.js";function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}import"core-js/modules/es.array.reduce.js";import"core-js/modules/es.array.map.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.concat.js";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.number.is-nan.js";import"core-js/modules/es.number.constructor.js";function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}import classNames from"classnames";import clamp from"lodash.clamp";import PropTypes from"prop-types";import{Component,Fragment}from"react";import{Spring}from"react-spring/renderprops.cjs";import{Size,Width}from"../common";import KeyCodes from"../common/keyCodes";import Tab from"./Tab";import TabList from"./TabList";import TabPanel from"./TabPanel";import{getElasticDragDifference,getSwipeDifference,swipedLeftToRight,swipedRightToLeft,swipeShouldChangeTab,getVelocity}from"./utils";import{jsx as _jsx}from"react/jsx-runtime";import{jsxs as _jsxs}from"react/jsx-runtime";var MIN_INDEX=0,enabledTabsFilter=function(a){return!a.disabled},SpacerWidth={default:0,xs:8,sm:16,md:24,lg:32},Tabs=/*#__PURE__*/function(a){function b(a){var d;return _classCallCheck(this,b),d=c.call(this,a),_defineProperty(_assertThisInitialized(d),"container",null),_defineProperty(_assertThisInitialized(d),"containerWidth",0),_defineProperty(_assertThisInitialized(d),"tabRefs",[]),_defineProperty(_assertThisInitialized(d),"handleResize",function(){d.setContainerWidth(d.container),d.setState(function(a){var b=a.selectedTabIndex;return{translateTo:-(d.containerWidth*b)}})}),_defineProperty(_assertThisInitialized(d),"setContainerRefAndWidth",function(a){d.container=a,d.setContainerWidth(a)}),_defineProperty(_assertThisInitialized(d),"setContainerWidth",function(a){if(a){var b=a.getBoundingClientRect(),c=b.width;d.containerWidth=c}}),_defineProperty(_assertThisInitialized(d),"isTabDisabled",function(a){var b=d.props.tabs;return b[a]&&b[a].disabled}),_defineProperty(_assertThisInitialized(d),"getAllTabsWidth",function(){return d.tabRefs.map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"getDistanceToSelectedTab",function(a){return d.tabRefs.filter(function(b,c){return c<a}).map(function(a){return a?a.getBoundingClientRect().width:0}).reduce(function(c,a){return c+a},0)}),_defineProperty(_assertThisInitialized(d),"setTabWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.headerWidth,e=b.selected,f=d.getAllTabsWidth();!a&&(c===Width.BLOCK||d.containerWidth<f)&&d.setState({fullWidthTabs:!0,translateLineX:"".concat(100*e,"%")}),a&&c===Width.AUTO&&d.containerWidth>=f&&d.setState({fullWidthTabs:!1,translateLineX:"".concat(d.getDistanceToSelectedTab(e),"px")})}),_defineProperty(_assertThisInitialized(d),"getTabLineWidth",function(){var a=d.state.fullWidthTabs,b=d.props,c=b.selected,e=b.tabs;if(a)return"".concat(100*(1/e.length),"%");var f=d.tabRefs[c]||d.tabRefs[d.tabRefs.length-1],g=f?f.getBoundingClientRect().width:0;return"".concat(g,"px")}),_defineProperty(_assertThisInitialized(d),"getTabToSelect",function(a,b,c){var e=a;if(swipedLeftToRight(b,c)){if(e-=1,e>MIN_INDEX&&d.isTabDisabled(e))return d.getTabToSelect(e,b,c);}else if(swipedRightToLeft(b,c)&&(e+=1,e<d.MAX_INDEX&&d.isTabDisabled(e)))return d.getTabToSelect(e,b,c);return e=clamp(e,Math.max(a-1,MIN_INDEX),Math.min(a+1,d.MAX_INDEX)),d.isTabDisabled(e)?a:e}),_defineProperty(_assertThisInitialized(d),"swipedOverHalfOfContainer",function(a){return .5<=a/d.containerWidth}),_defineProperty(_assertThisInitialized(d),"calculateApplicableDragDifference",function(a){var b=a.currentSelected,c=a.nextSelected,e=a.start,f=a.end,g=getSwipeDifference(e,f),h=getElasticDragDifference(g);return swipedLeftToRight(e,f)?b>MIN_INDEX&&b!==c?Math.min(g,d.containerWidth):h:!!swipedRightToLeft(e,f)&&(b<d.MAX_INDEX&&b!==c?-Math.min(g,d.containerWidth):-h)}),_defineProperty(_assertThisInitialized(d),"switchTab",function(a){var b=d.props.onTabSelect;b(a)}),_defineProperty(_assertThisInitialized(d),"animateToTab",function(a,b){d.animateLine(a),d.animatePanel(d.getTabIndexWithoutDisabledTabs(a),b)}),_defineProperty(_assertThisInitialized(d),"animateLine",function(a){d.setState(function(b){return{translateLineX:b.fullWidthTabs?"".concat(100*a,"%"):"".concat(d.getDistanceToSelectedTab(a),"px")}})}),_defineProperty(_assertThisInitialized(d),"animatePanel",function(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c=d.state.translateTo,e=c,f=-(d.containerWidth*a);d.setState({selectedTabIndex:a,isAnimating:!b&&e!==f,translateFrom:e,translateTo:f})}),_defineProperty(_assertThisInitialized(d),"disableScroll",function(a){var b=d.state.isSwiping;b&&a.preventDefault()}),_defineProperty(_assertThisInitialized(d),"handleTabClick",function(a){return function(){d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"onKeyDown",function(a){return function(b){b&&b.keyCode===KeyCodes.ENTER&&d.switchTab(a)}}),_defineProperty(_assertThisInitialized(d),"handleTouchStart",function(a){var b={x:a.nativeEvent.touches[0].clientX,y:a.nativeEvent.touches[0].clientY,time:Date.now()};d.setState({start:b,currentSwipe:[b]}),a.persist()}),_defineProperty(_assertThisInitialized(d),"handleTouchMove",function(a){var b=d.state.start,c=d.props.selected,e=d.getTabIndexWithoutDisabledTabs(c),f={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},g=getSwipeDifference(b,f),h=getSwipeDifference(b,f,"y"),i=d.state,j=i.isScrolling,k=i.isSwiping;if(a.persist(),j||k||(g>h?k=!0:j=!0),d.setState({isScrolling:j,isSwiping:k}),k){var n=d.getTabToSelect(c,b,f);d.animateLine(d.swipedOverHalfOfContainer(g)?n:c);var l=d.calculateApplicableDragDifference({currentSelected:c,nextSelected:n,start:b,end:f}),m=!!l&&-(d.containerWidth*e)+l;d.setState(function(a){return{currentSwipe:[].concat(_toConsumableArray(a.currentSwipe),[f]),translateFrom:m||a.translateFrom,translateTo:m||a.translateTo}})}}),_defineProperty(_assertThisInitialized(d),"handleTouchEnd",function(a){var b=d.state,c=b.start,e=b.isSwiping,f=d.props.selected,g={x:a.nativeEvent.changedTouches[0].clientX,y:a.nativeEvent.changedTouches[0].clientY,time:Date.now()},h=getSwipeDifference(c,g),i=getVelocity([].concat(_toConsumableArray(d.state.currentSwipe),[g]));d.setState({currentSwipe:[]});var j=f;a.persist(),e&&((swipeShouldChangeTab(c,g)||d.swipedOverHalfOfContainer(h))&&(j=d.getTabToSelect(j,c,g)),j===f?d.animateToTab(j):(d.switchTab(j),d.setState({lastSwipeVelocity:i}))),d.setState({isSwiping:!1,isScrolling:!1})}),d.state={start:null,translateX:0,translateFrom:0,translateTo:0,translateLineX:null,isAnimating:!1,isSwiping:!1,isScrolling:!1,lastSwipeVelocity:0,fullWidthTabs:a.headerWidth===Width.BLOCK},d}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"filteredTabsLength",get:function get(){return this.props.tabs.filter(enabledTabsFilter).length}},{key:"MAX_INDEX",get:function get(){return this.props.tabs.length-1}},{key:"componentDidMount",value:function componentDidMount(){var a=this.props.selected;this.setTabWidth(),this.switchTab(clamp(a,MIN_INDEX,this.MAX_INDEX)),this.animateToTab(clamp(a,MIN_INDEX,this.MAX_INDEX),!0),document.body.addEventListener("touchmove",this.disableScroll,{passive:!1}),document.body.addEventListener("touchforcechange",this.disableScroll,{passive:!1}),window.addEventListener("resize",this.handleResize)}},{key:"componentDidUpdate",value:function componentDidUpdate(a,b){var c=this.props.selected,d=a.selected,e=this.props.tabs[c],f=e&&e.disabled,g=a.tabs[d],h=g&&g.disabled,i=this.props.tabs.length,j=a.tabs.length,k=this.props.tabs.filter(enabledTabsFilter).length,l=a.tabs.filter(enabledTabsFilter).length,m=this.props.headerWidth,n=a.headerWidth,o=this.props.animatePanelsOnClick,p=!o&&!b.isSwiping;(m!==n||i!==j)&&this.setTabWidth(),(c!==d||k!==l||f!==h)&&this.animateToTab(clamp(c,MIN_INDEX,this.MAX_INDEX),c===d||p)}},{key:"componentWillUnmount",value:function componentWillUnmount(){document.body.removeEventListener("touchmove",this.disableScroll),document.body.removeEventListener("touchforcechange",this.disableScroll),window.removeEventListener("resize",this.handleResize)}},{key:"getTabIndexWithoutDisabledTabs",value:function getTabIndexWithoutDisabledTabs(a){return a-this.props.tabs.slice(0,a).filter(function(a){return!enabledTabsFilter(a)}).length}},{key:"render",value:function render(){var a=this,b=this.props,c=b.tabs,d=b.changeTabOnSwipe,e=b.name,f=b.selected,g=b.className,h=b.transitionSpacing,i=b.headerWidth,j=this.state,k=j.isSwiping,l=j.translateLineX,m=j.isAnimating,n=j.translateFrom,o=j.translateTo,p=j.lastSwipeVelocity,q=j.fullWidthTabs,r=SpacerWidth[h],s=this.filteredTabsLength,t=Math.abs(-n-this.containerWidth*f),u=k?1-t/this.containerWidth:1-Math.abs(t/this.containerWidth-1),v=(Number.isNaN(u)?0:u)*Math.min(10*Math.E,10*p*Math.E),w=m||k,x=s*this.containerWidth+2*r,y=function(a){var b=a.id;return 0<r&&/*#__PURE__*/_jsx("div",{style:{width:r,display:w?"block":"none"}},b)};return/*#__PURE__*/_jsxs("div",{className:classNames("tabs",g,{"tabs--auto-width":i===Width.AUTO}),onTouchStart:d?this.handleTouchStart:void 0,onTouchEnd:d?this.handleTouchEnd:void 0,onTouchMove:d?this.handleTouchMove:void 0,children:[/*#__PURE__*/_jsxs(TabList,{children:[c.map(function(b,d){var g=b.title,h=b.disabled;return/*#__PURE__*/_jsx(Tab,_objectSpread(_objectSpread({ref:function ref(b){a.tabRefs[d]=b},id:"".concat(e,"-tab-").concat(d),panelId:"".concat(e,"-panel-").concat(d),selected:f===d,disabled:h,focusTab:function focusTab(){a.tabRefs[d].focus()},onClick:h?null:a.handleTabClick(d),onKeyDown:a.onKeyDown(d)},q?{style:{width:"".concat(100*(1/c.length),"%")}}:{}),{},{children:g}),g)}),l?/*#__PURE__*/_jsx("div",{className:classNames("tabs__line"),style:{width:this.getTabLineWidth(),transform:"translateX(".concat(l,")")}}):null]}),/*#__PURE__*/_jsx("div",{ref:this.setContainerRefAndWidth,className:"tabs__panel-container",style:{overflow:w?"hidden":"visible"},children:/*#__PURE__*/_jsx(Spring,{from:{transform:"translateX(".concat(n-r,"px)")},to:{transform:"translateX(".concat(o-r,"px)")},config:{precision:k?1:.01,velocity:k?0:v,clamp:!0},onRest:function onRest(){m&&a.setState({isAnimating:!1,lastSwipeVelocity:0})},children:function children(b){return/*#__PURE__*/_jsx("div",{className:"tabs__slider",style:{width:w?"".concat(x,"px"):"100%",transform:w?b.transform:"translateX(0px)"},children:c.map(function(b,d){var g=b.content,h=b.disabled;return h?null:/*#__PURE__*/_jsxs(Fragment,{children:[d===f&&/*#__PURE__*/_jsx(y,{id:"left-spacer"}),/*#__PURE__*/_jsx(TabPanel,{tabId:"".concat(e,"-tab-").concat(d),id:"".concat(e,"-panel-").concat(d),style:{width:w?"".concat(a.containerWidth,"px"):"100%",display:w||d===f?"block":"none"},children:g},c[d].title),d===f&&/*#__PURE__*/_jsx(y,{id:"right-spacer"})]},"".concat(c[d].title,"-fragment"))})})}})})]})}}]),b}(Component),SpacerSizes=_objectSpread(_objectSpread({},Size),{},{NONE:"default"});Tabs.propTypes={tabs:PropTypes.arrayOf(PropTypes.shape({title:PropTypes.string.isRequired,content:PropTypes.node.isRequired,disabled:PropTypes.bool.isRequired})).isRequired,selected:PropTypes.number.isRequired,onTabSelect:PropTypes.func.isRequired,name:PropTypes.string.isRequired,animatePanelsOnClick:PropTypes.bool,changeTabOnSwipe:PropTypes.bool,className:PropTypes.string,transitionSpacing:PropTypes.oneOf(["default","xs","sm","md","lg"]),headerWidth:PropTypes.oneOf(["auto","block"])},Tabs.defaultProps={animatePanelsOnClick:!1,changeTabOnSwipe:!0,className:"",transitionSpacing:SpacerSizes.NONE,headerWidth:Width.BLOCK};export default Tabs;
|