@transferwise/components 46.141.0 → 46.143.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/accordion/AccordionItem/AccordionItem.js +1 -1
- package/build/accordion/AccordionItem/AccordionItem.mjs +1 -1
- package/build/actionButton/ActionButton.js +1 -1
- package/build/actionButton/ActionButton.mjs +1 -1
- package/build/actionOption/ActionOption.js +1 -1
- package/build/actionOption/ActionOption.mjs +1 -1
- package/build/alert/Alert.js +1 -1
- package/build/alert/Alert.mjs +1 -1
- package/build/alert/inlineMarkdown/InlineMarkdown.js +1 -1
- package/build/alert/inlineMarkdown/InlineMarkdown.mjs +1 -1
- package/build/avatar/Avatar.js +1 -1
- package/build/avatar/Avatar.mjs +1 -1
- package/build/avatarLayout/AvatarLayout.js +16 -2
- package/build/avatarLayout/AvatarLayout.js.map +1 -1
- package/build/avatarLayout/AvatarLayout.mjs +16 -2
- package/build/avatarLayout/AvatarLayout.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +7 -3
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +7 -3
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/avatarView/Dot.js +8 -0
- package/build/avatarView/Dot.js.map +1 -1
- package/build/avatarView/Dot.mjs +8 -0
- package/build/avatarView/Dot.mjs.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.js +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +1 -1
- package/build/badge/Badge.js +1 -1
- package/build/badge/Badge.mjs +1 -1
- package/build/button/Button.js +1 -1
- package/build/button/Button.mjs +1 -1
- package/build/button/LegacyButton.js +1 -1
- package/build/button/LegacyButton.mjs +1 -1
- package/build/button/classMap.js +1 -1
- package/build/button/classMap.mjs +1 -1
- package/build/button/legacyUtils/legacyUtils.js +1 -1
- package/build/button/legacyUtils/legacyUtils.mjs +1 -1
- package/build/card/Card.js +1 -1
- package/build/card/Card.mjs +1 -1
- package/build/checkbox/Checkbox.js +1 -1
- package/build/checkbox/Checkbox.mjs +1 -1
- package/build/chevron/Chevron.js +1 -1
- package/build/chevron/Chevron.mjs +1 -1
- package/build/chips/Chip.js +1 -1
- package/build/chips/Chip.mjs +1 -1
- package/build/circularButton/CircularButton.js +2 -2
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +2 -2
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/bottomSheet/BottomSheet.js +2 -2
- package/build/common/bottomSheet/BottomSheet.js.map +1 -1
- package/build/common/bottomSheet/BottomSheet.mjs +2 -2
- package/build/common/bottomSheet/BottomSheet.mjs.map +1 -1
- package/build/common/circle/Circle.js +8 -4
- package/build/common/circle/Circle.js.map +1 -1
- package/build/common/circle/Circle.mjs +8 -4
- package/build/common/circle/Circle.mjs.map +1 -1
- package/build/common/hooks/useLayout/useLayout.js +6 -6
- package/build/common/hooks/useLayout/useLayout.js.map +1 -1
- package/build/common/hooks/useLayout/useLayout.mjs +1 -1
- package/build/common/hooks/useLayout/useLayout.mjs.map +1 -1
- package/build/common/hooks/useScreenSize.js.map +1 -1
- package/build/common/hooks/useScreenSize.mjs.map +1 -1
- package/build/common/panel/Panel.js +1 -1
- package/build/common/panel/Panel.mjs +1 -1
- package/build/common/responsivePanel/ResponsivePanel.js +1 -1
- package/build/common/responsivePanel/ResponsivePanel.mjs +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -1
- package/build/dateInput/DateInput.js +1 -1
- package/build/dateInput/DateInput.mjs +1 -1
- package/build/dateLookup/DateLookup.js +2 -2
- package/build/dateLookup/DateLookup.js.map +1 -1
- package/build/dateLookup/DateLookup.mjs +1 -1
- package/build/dateLookup/DateLookup.mjs.map +1 -1
- package/build/dateLookup/dateHeader/DateHeader.js +1 -1
- package/build/dateLookup/dateHeader/DateHeader.mjs +1 -1
- package/build/dateLookup/dateTrigger/DateTrigger.js +1 -1
- package/build/dateLookup/dateTrigger/DateTrigger.mjs +1 -1
- package/build/decision/Decision.js +3 -3
- package/build/decision/Decision.js.map +1 -1
- package/build/decision/Decision.mjs +1 -1
- package/build/decision/Decision.mjs.map +1 -1
- package/build/definitionList/DefinitionList.js +1 -1
- package/build/definitionList/DefinitionList.mjs +1 -1
- package/build/dimmer/Dimmer.js +1 -1
- package/build/dimmer/Dimmer.mjs +1 -1
- package/build/display/Display.js +1 -1
- package/build/display/Display.mjs +1 -1
- package/build/drawer/Drawer.js +1 -1
- package/build/drawer/Drawer.mjs +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.js +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.js.map +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs +1 -1
- package/build/expressiveMoneyInput/amountInput/AmountInput.mjs.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +1 -1
- package/build/field/Field.js +64 -33
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.messages.js +14 -0
- package/build/field/Field.messages.js.map +1 -0
- package/build/field/Field.messages.mjs +10 -0
- package/build/field/Field.messages.mjs.map +1 -0
- package/build/field/Field.mjs +66 -35
- package/build/field/Field.mjs.map +1 -1
- package/build/flowNavigation/FlowNavigation.js +3 -3
- package/build/flowNavigation/FlowNavigation.js.map +1 -1
- package/build/flowNavigation/FlowNavigation.mjs +1 -1
- package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/header/Header.js +1 -1
- package/build/header/Header.mjs +1 -1
- package/build/i18n/en.json +1 -0
- package/build/i18n/en.json.js +1 -0
- package/build/i18n/en.json.js.map +1 -1
- package/build/i18n/en.json.mjs +1 -0
- package/build/i18n/en.json.mjs.map +1 -1
- package/build/image/Image.js +1 -1
- package/build/image/Image.mjs +1 -1
- package/build/index.js +2 -2
- package/build/index.mjs +1 -1
- package/build/info/Info.js +1 -1
- package/build/info/Info.mjs +1 -1
- package/build/inlineAlert/InlineAlert.js +1 -1
- package/build/inlineAlert/InlineAlert.mjs +1 -1
- package/build/inputs/SearchInput.js +1 -1
- package/build/inputs/SearchInput.mjs +1 -1
- package/build/inputs/SelectInput/SelectInput.js +2 -2
- package/build/inputs/SelectInput/SelectInput.js.map +1 -1
- package/build/inputs/SelectInput/SelectInput.mjs +1 -1
- package/build/inputs/SelectInput/SelectInput.mjs.map +1 -1
- package/build/inputs/TextArea.js +5 -0
- package/build/inputs/TextArea.js.map +1 -1
- package/build/inputs/TextArea.mjs +6 -1
- package/build/inputs/TextArea.mjs.map +1 -1
- package/build/inputs/contexts.js +16 -0
- package/build/inputs/contexts.js.map +1 -1
- package/build/inputs/contexts.mjs +16 -2
- package/build/inputs/contexts.mjs.map +1 -1
- package/build/instructionsList/InstructionsList.js +1 -1
- package/build/instructionsList/InstructionsList.mjs +1 -1
- package/build/link/Link.js +1 -1
- package/build/link/Link.mjs +1 -1
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +1 -1
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +1 -1
- package/build/listItem/ListItem.js +1 -1
- package/build/listItem/ListItem.mjs +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +1 -1
- package/build/loader/Loader.js +1 -1
- package/build/loader/Loader.mjs +1 -1
- package/build/logo/Logo.js +3 -3
- package/build/logo/Logo.js.map +1 -1
- package/build/logo/Logo.mjs +2 -2
- package/build/logo/Logo.mjs.map +1 -1
- package/build/main.css +350 -402
- package/build/markdown/Markdown.js +1 -1
- package/build/markdown/Markdown.mjs +1 -1
- package/build/modal/Modal.js +3 -3
- package/build/modal/Modal.js.map +1 -1
- package/build/modal/Modal.mjs +3 -3
- package/build/modal/Modal.mjs.map +1 -1
- package/build/moneyInput/MoneyInput.js +1 -1
- package/build/moneyInput/MoneyInput.mjs +1 -1
- package/build/navigationOption/NavigationOption.js +1 -1
- package/build/navigationOption/NavigationOption.mjs +1 -1
- package/build/nudge/Nudge.js +1 -1
- package/build/nudge/Nudge.mjs +1 -1
- package/build/overlayHeader/OverlayHeader.js +1 -1
- package/build/overlayHeader/OverlayHeader.mjs +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -1
- package/build/popover/Popover.js +1 -1
- package/build/popover/Popover.mjs +1 -1
- package/build/processIndicator/ProcessIndicator.js +1 -1
- package/build/processIndicator/ProcessIndicator.mjs +1 -1
- package/build/progressBar/ProgressBar.js +1 -1
- package/build/progressBar/ProgressBar.mjs +1 -1
- package/build/promoCard/PromoCard.js +1 -1
- package/build/promoCard/PromoCard.mjs +1 -1
- package/build/promoCard/PromoCardIndicator.js +1 -1
- package/build/promoCard/PromoCardIndicator.mjs +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js +2 -2
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +2 -2
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/CriticalBanner/CriticalBanner.js +2 -2
- package/build/prompt/CriticalBanner/CriticalBanner.js.map +1 -1
- package/build/prompt/CriticalBanner/CriticalBanner.mjs +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.js +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.mjs +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -1
- package/build/provider/Provider.js +1 -1
- package/build/provider/Provider.mjs +1 -1
- package/build/radio/Radio.js +1 -1
- package/build/radio/Radio.mjs +1 -1
- package/build/segmentedControl/SegmentedControl.js +1 -1
- package/build/segmentedControl/SegmentedControl.mjs +1 -1
- package/build/select/Select.js +1 -1
- package/build/select/Select.mjs +1 -1
- package/build/select/option/Option.js +1 -1
- package/build/select/option/Option.mjs +1 -1
- package/build/statusIcon/StatusIcon.js +2 -2
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +2 -2
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/stepper/Stepper.js +1 -1
- package/build/stepper/Stepper.mjs +1 -1
- package/build/sticky/Sticky.js +1 -1
- package/build/sticky/Sticky.mjs +1 -1
- package/build/styles/accordion/Accordion.css +1 -1
- package/build/styles/avatarView/AvatarView.css +4 -4
- package/build/styles/avatarView/Dot.css +4 -4
- package/build/styles/card/Card.css +2 -2
- package/build/styles/carousel/Carousel.css +5 -5
- package/build/styles/common/Option/Option.css +2 -4
- package/build/styles/common/baseCard/BaseCard.css +1 -1
- package/build/styles/container/Container.css +3 -3
- package/build/styles/criticalBanner/CriticalCommsBanner.css +1 -1
- package/build/styles/css/accordion.css +4 -4
- package/build/styles/css/button-groups.css +6 -6
- package/build/styles/css/buttons.css +1 -1
- package/build/styles/css/circles.css +1 -1
- package/build/styles/css/column-layout.css +4 -4
- package/build/styles/css/decision.css +4 -4
- package/build/styles/css/dropdowns.css +10 -10
- package/build/styles/css/droppable.css +8 -8
- package/build/styles/css/flex.css +13 -15
- package/build/styles/css/footer.css +3 -3
- package/build/styles/css/grid.css +19 -19
- package/build/styles/css/input-groups.css +12 -12
- package/build/styles/css/list-group.css +8 -8
- package/build/styles/css/modals.css +6 -6
- package/build/styles/css/navbar.css +62 -62
- package/build/styles/css/navs.css +2 -2
- package/build/styles/css/neptune.css +274 -328
- package/build/styles/css/panels.css +9 -9
- package/build/styles/css/popovers.css +13 -13
- package/build/styles/css/select.css +1 -1
- package/build/styles/css/sequences.css +6 -6
- package/build/styles/css/table.css +6 -6
- package/build/styles/css/utilities.css +8 -20
- package/build/styles/css/wells.css +4 -18
- package/build/styles/dateInput/DateInput.css +1 -1
- package/build/styles/definitionList/DefinitionList.css +2 -2
- package/build/styles/drawer/Drawer.css +2 -2
- package/build/styles/expressiveMoneyInput/ExpressiveMoneyInput.css +2 -0
- package/build/styles/expressiveMoneyInput/amountInput/AmountInput.css +2 -0
- package/build/styles/field/Field.css +19 -3
- package/build/styles/flowNavigation/FlowNavigation.css +1 -1
- package/build/styles/inputs/Input.css +3 -3
- package/build/styles/inputs/SelectInput/Options/SelectInputOptions.css +2 -2
- package/build/styles/inputs/SelectInput/SelectInput.css +2 -2
- package/build/styles/inputs/TextArea.css +3 -3
- package/build/styles/less/legacy-variables.less +34 -47
- package/build/styles/main.css +350 -402
- package/build/styles/modal/Modal.css +7 -20
- package/build/styles/overlayHeader/OverlayHeader.css +1 -1
- package/build/styles/popover/Popover.css +3 -3
- package/build/styles/promoCard/PromoCard.css +1 -1
- package/build/styles/prompt/ActionPrompt/ActionPrompt.css +1 -1
- package/build/styles/prompt/CriticalBanner/CriticalBanner.css +1 -1
- package/build/styles/prompt/PrimitivePrompt/PrimitivePrompt.css +1 -1
- package/build/styles/props/custom-media.css +23 -11
- package/build/styles/snackbar/Snackbar.css +2 -2
- package/build/styles/stepper/Stepper.css +2 -2
- package/build/styles/styles/less/accordion.css +4 -4
- package/build/styles/styles/less/button-groups.css +6 -6
- package/build/styles/styles/less/buttons.css +1 -1
- package/build/styles/styles/less/circles.css +1 -1
- package/build/styles/styles/less/column-layout.css +4 -4
- package/build/styles/styles/less/decision.css +4 -4
- package/build/styles/styles/less/dropdowns.css +10 -10
- package/build/styles/styles/less/droppable.css +8 -8
- package/build/styles/styles/less/flex.css +13 -15
- package/build/styles/styles/less/footer.css +3 -3
- package/build/styles/styles/less/forms/bootstrap-forms.css +9 -9
- package/build/styles/styles/less/grid.css +19 -19
- package/build/styles/styles/less/input-groups.css +12 -12
- package/build/styles/styles/less/list-group.css +8 -8
- package/build/styles/styles/less/modals.css +6 -6
- package/build/styles/styles/less/navbar.css +62 -62
- package/build/styles/styles/less/navs.css +2 -2
- package/build/styles/styles/less/neptune.css +274 -328
- package/build/styles/styles/less/panels.css +9 -9
- package/build/styles/styles/less/popovers.css +13 -13
- package/build/styles/styles/less/select.css +1 -1
- package/build/styles/styles/less/sequences.css +6 -6
- package/build/styles/styles/less/table.css +6 -6
- package/build/styles/styles/less/utilities.css +8 -20
- package/build/styles/styles/less/wells.css +4 -18
- package/build/styles/styles/props/custom-media.css +1 -11
- package/build/styles/table/Table.css +1 -1
- package/build/styles/tabs/Tabs.css +2 -2
- package/build/styles/typeahead/Typeahead.css +1 -1
- package/build/summary/Summary.js +1 -1
- package/build/summary/Summary.mjs +1 -1
- package/build/table/Table.js +1 -1
- package/build/table/Table.mjs +1 -1
- package/build/table/TableRow.js +1 -1
- package/build/table/TableRow.mjs +1 -1
- package/build/table/TableStatusText.js +1 -1
- package/build/table/TableStatusText.mjs +1 -1
- package/build/tabs/Tabs.js +1 -1
- package/build/tabs/Tabs.mjs +1 -1
- package/build/tile/Tile.js +1 -1
- package/build/tile/Tile.mjs +1 -1
- package/build/title/Title.js +1 -1
- package/build/title/Title.mjs +1 -1
- package/build/tooltip/Tooltip.js +1 -1
- package/build/tooltip/Tooltip.mjs +1 -1
- package/build/typeahead/Typeahead.js +1 -1
- package/build/typeahead/Typeahead.mjs +1 -1
- package/build/types/avatarView/AvatarView.d.ts +1 -1
- package/build/types/avatarView/AvatarView.d.ts.map +1 -1
- package/build/types/avatarView/Dot.d.ts.map +1 -1
- package/build/types/circularButton/CircularButton.d.ts.map +1 -1
- package/build/types/common/bottomSheet/BottomSheet.d.ts.map +1 -1
- package/build/types/common/circle/Circle.d.ts +1 -1
- package/build/types/common/circle/Circle.d.ts.map +1 -1
- package/build/types/common/hooks/useScreenSize.d.ts +1 -1
- package/build/types/common/hooks/useScreenSize.d.ts.map +1 -1
- package/build/types/common/index.d.ts +1 -1
- package/build/types/common/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/decision/Decision.d.ts.map +1 -1
- package/build/types/field/Field.d.ts.map +1 -1
- package/build/types/field/Field.messages.d.ts +8 -0
- package/build/types/field/Field.messages.d.ts.map +1 -0
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/TextArea.d.ts.map +1 -1
- package/build/types/inputs/contexts.d.ts +6 -0
- package/build/types/inputs/contexts.d.ts.map +1 -1
- package/build/types/logo/Logo.d.ts +1 -1
- package/build/types/prompt/ActionPrompt/ActionPrompt.d.ts.map +1 -1
- package/build/types/statusIcon/StatusIcon.d.ts.map +1 -1
- package/build/types/test-utils/index.d.ts +2 -0
- package/build/types/test-utils/index.d.ts.map +1 -1
- package/build/upload/Upload.js +1 -1
- package/build/upload/Upload.mjs +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.js +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +1 -1
- package/build/uploadInput/UploadInput.js +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -1
- package/build/uploadInput/uploadButton/UploadButton.js +1 -1
- package/build/uploadInput/uploadButton/UploadButton.mjs +1 -1
- package/build/uploadInput/uploadButton/defaults.js +1 -1
- package/build/uploadInput/uploadButton/defaults.mjs +1 -1
- package/build/uploadInput/uploadItem/UploadItem.js +1 -1
- package/build/uploadInput/uploadItem/UploadItem.mjs +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.js +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.css +1 -1
- package/src/avatarLayout/AvatarLayout.story.tsx +1 -1
- package/src/avatarLayout/AvatarLayout.tsx +4 -0
- package/src/avatarView/AvatarView.css +4 -4
- package/src/avatarView/AvatarView.story.tsx +17 -13
- package/src/avatarView/AvatarView.tsx +5 -1
- package/src/avatarView/Dot.css +4 -4
- package/src/avatarView/Dot.less +6 -6
- package/src/avatarView/Dot.tsx +2 -0
- package/src/card/Card.css +2 -2
- package/src/carousel/Carousel.css +5 -5
- package/src/carousel/Carousel.less +3 -3
- package/src/circularButton/CircularButton.tsx +3 -2
- package/src/common/Option/Option.css +2 -4
- package/src/common/Option/Option.less +2 -4
- package/src/common/baseCard/BaseCard.css +1 -1
- package/src/common/bottomSheet/BottomSheet.tsx +2 -2
- package/src/common/circle/Circle.tsx +7 -3
- package/src/common/hooks/useLayout/useLayout.ts +1 -1
- package/src/common/hooks/useScreenSize.ts +1 -1
- package/src/common/index.ts +1 -1
- package/src/common/responsivePanel/ResponsivePanel.test.js +3 -2
- package/src/container/Container.css +3 -3
- package/src/criticalBanner/CriticalCommsBanner.css +1 -1
- package/src/dateInput/DateInput.css +1 -1
- package/src/dateLookup/DateLookup.tsx +1 -1
- package/src/decision/Decision.test.tsx +2 -1
- package/src/decision/Decision.tsx +2 -1
- package/src/definitionList/DefinitionList.css +2 -2
- package/src/definitionList/DefinitionList.less +2 -2
- package/src/drawer/Drawer.css +2 -2
- package/src/drawer/Drawer.less +4 -3
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.css +2 -0
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.test.story.tsx +43 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.css +2 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.less +2 -0
- package/src/expressiveMoneyInput/amountInput/AmountInput.tsx +1 -1
- package/src/field/Field.css +19 -3
- package/src/field/Field.less +17 -3
- package/src/field/Field.messages.ts +8 -0
- package/src/field/Field.story.tsx +5 -1
- package/src/field/Field.test.tsx +90 -0
- package/src/field/Field.tsx +84 -37
- package/src/flowNavigation/FlowNavigation.css +1 -1
- package/src/flowNavigation/FlowNavigation.less +2 -1
- package/src/flowNavigation/FlowNavigation.story.tsx +6 -3
- package/src/flowNavigation/FlowNavigation.test.js +1 -1
- package/src/flowNavigation/FlowNavigation.tsx +2 -1
- package/src/i18n/en.json +1 -0
- package/src/index.ts +1 -1
- package/src/inputs/Input.css +3 -3
- package/src/inputs/SelectInput/Options/SelectInputOptions.css +2 -2
- package/src/inputs/SelectInput/SelectInput.css +2 -2
- package/src/inputs/SelectInput/SelectInput.tsx +1 -1
- package/src/inputs/TextArea.css +3 -3
- package/src/inputs/TextArea.story.tsx +97 -0
- package/src/inputs/TextArea.test.story.tsx +142 -0
- package/src/inputs/TextArea.tsx +7 -2
- package/src/inputs/contexts.tsx +18 -1
- package/src/logo/Logo.tsx +1 -1
- package/src/main.css +350 -402
- package/src/modal/Modal.css +7 -20
- package/src/modal/Modal.less +7 -19
- package/src/modal/Modal.tsx +2 -2
- package/src/overlayHeader/OverlayHeader.css +1 -1
- package/src/overlayHeader/OverlayHeader.less +3 -2
- package/src/popover/Popover.css +3 -3
- package/src/popover/Popover.test.tsx +2 -1
- package/src/promoCard/PromoCard.css +1 -1
- package/src/prompt/ActionPrompt/ActionPrompt.css +1 -1
- package/src/prompt/ActionPrompt/ActionPrompt.less +1 -1
- package/src/prompt/ActionPrompt/ActionPrompt.test.tsx +37 -6
- package/src/prompt/ActionPrompt/ActionPrompt.tsx +3 -2
- package/src/prompt/CriticalBanner/CriticalBanner.css +1 -1
- package/src/prompt/CriticalBanner/CriticalBanner.less +2 -2
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.css +1 -1
- package/src/prompt/PrimitivePrompt/PrimitivePrompt.less +1 -1
- package/src/select/Select.test.tsx +1 -1
- package/src/snackbar/Snackbar.css +2 -2
- package/src/statusIcon/StatusIcon.tsx +3 -2
- package/src/stepper/Stepper.css +2 -2
- package/src/styles/less/accordion.css +4 -4
- package/src/styles/less/addons/_display-utilities.less +13 -27
- package/src/styles/less/button-groups.css +6 -6
- package/src/styles/less/buttons.css +1 -1
- package/src/styles/less/circles.css +1 -1
- package/src/styles/less/column-layout.css +4 -4
- package/src/styles/less/core/_typography-utilities.less +10 -22
- package/src/styles/less/core/_typography.less +28 -6
- package/src/styles/less/decision.css +4 -4
- package/src/styles/less/dropdowns.css +10 -10
- package/src/styles/less/droppable.css +8 -8
- package/src/styles/less/flex.css +13 -15
- package/src/styles/less/flex.less +1 -3
- package/src/styles/less/footer.css +3 -3
- package/src/styles/less/forms/bootstrap-forms.css +9 -9
- package/src/styles/less/forms/bootstrap-forms.less +1 -1
- package/src/styles/less/grid.css +19 -19
- package/src/styles/less/input-groups.css +12 -12
- package/src/styles/less/list-group.css +8 -8
- package/src/styles/less/modals.css +6 -6
- package/src/styles/less/modals.less +4 -4
- package/src/styles/less/navbar.css +62 -62
- package/src/styles/less/navbar.less +2 -2
- package/src/styles/less/navs.css +2 -2
- package/src/styles/less/neptune.bundle.less +1 -0
- package/src/styles/less/neptune.css +274 -328
- package/src/styles/less/panels.css +9 -9
- package/src/styles/less/popovers.css +13 -13
- package/src/styles/less/popovers.less +6 -6
- package/src/styles/less/select.css +1 -1
- package/src/styles/less/sequences.css +6 -6
- package/src/styles/less/table.css +6 -6
- package/src/styles/less/table.less +1 -1
- package/src/styles/less/utilities.css +8 -20
- package/src/styles/less/utilities.less +6 -14
- package/src/styles/less/wells.css +4 -18
- package/src/styles/less/wells.less +3 -5
- package/src/styles/props/custom-media.css +1 -11
- package/src/styles/variables/legacy-variables.less +4 -47
- package/src/table/Table.css +1 -1
- package/src/tabs/Tabs.css +2 -2
- package/src/textareaWithDisplayFormat/TextareaWithDisplayFormat.story.tsx +1 -0
- package/src/typeahead/Typeahead.css +1 -1
- package/src/uploadInput/uploadItem/UploadItem.less +2 -2
- package/build/common/propsValues/breakpoint.js +0 -12
- package/build/common/propsValues/breakpoint.js.map +0 -1
- package/build/common/propsValues/breakpoint.mjs +0 -12
- package/build/common/propsValues/breakpoint.mjs.map +0 -1
- package/build/types/common/propsValues/breakpoint.d.ts +0 -9
- package/build/types/common/propsValues/breakpoint.d.ts.map +0 -1
- package/src/common/propsValues/breakpoint.ts +0 -8
package/build/field/Field.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
|
-
import { useRef, useId } from 'react';
|
|
2
|
+
import { useRef, useId, useState, useCallback } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import Body from '../body/Body.mjs';
|
|
3
5
|
import '../common/theme.mjs';
|
|
4
6
|
import '../common/direction.mjs';
|
|
7
|
+
import '@transferwise/neptune-tokens';
|
|
5
8
|
import '../common/propsValues/control.mjs';
|
|
6
|
-
import '../common/propsValues/breakpoint.mjs';
|
|
7
9
|
import '../common/propsValues/size.mjs';
|
|
8
10
|
import '../common/propsValues/typography.mjs';
|
|
9
11
|
import '../common/propsValues/width.mjs';
|
|
@@ -21,11 +23,10 @@ import '../common/propsValues/markdownNodeType.mjs';
|
|
|
21
23
|
import '../common/fileType.mjs';
|
|
22
24
|
import '@transferwise/formatting';
|
|
23
25
|
import '@transferwise/icons';
|
|
24
|
-
import 'react-intl';
|
|
25
26
|
import '../common/closeButton/CloseButton.messages.mjs';
|
|
26
27
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
28
|
+
import messages from './Field.messages.mjs';
|
|
27
29
|
import { InlinePrompt } from '../prompt/InlinePrompt/InlinePrompt.mjs';
|
|
28
|
-
import '../body/Body.mjs';
|
|
29
30
|
import '../button/Button.resolver.mjs';
|
|
30
31
|
import '../prompt/PrimitivePrompt/PrimitivePrompt.mjs';
|
|
31
32
|
import '../badge/Badge.mjs';
|
|
@@ -37,7 +38,7 @@ import '../primitives/PrimitiveButton/PrimitiveButton.mjs';
|
|
|
37
38
|
import '../primitives/PrimitiveAnchor/PrimitiveAnchor.mjs';
|
|
38
39
|
import '../link/Link.messages.mjs';
|
|
39
40
|
import '../prompt/common/Expander/Expander.messages.mjs';
|
|
40
|
-
import { FieldLabelContextProvider, InputIdContextProvider, InputDescribedByProvider, InputInvalidProvider } from '../inputs/contexts.mjs';
|
|
41
|
+
import { FieldLabelContextProvider, InputIdContextProvider, InputDescribedByProvider, InputInvalidProvider, TextareaCharacterCountProvider } from '../inputs/contexts.mjs';
|
|
41
42
|
import { Label as LabelNamespace } from '../label/Label.mjs';
|
|
42
43
|
|
|
43
44
|
const Field = ({
|
|
@@ -54,6 +55,9 @@ const Field = ({
|
|
|
54
55
|
children,
|
|
55
56
|
...props
|
|
56
57
|
}) => {
|
|
58
|
+
const {
|
|
59
|
+
formatMessage
|
|
60
|
+
} = useIntl();
|
|
57
61
|
const labelRef = useRef(null);
|
|
58
62
|
const sentiment = props.error ? Sentiment.NEGATIVE : propType;
|
|
59
63
|
const message = propMessage || props.error;
|
|
@@ -63,6 +67,10 @@ const Field = ({
|
|
|
63
67
|
const inputId = id !== null ? id ?? fallbackInputId : undefined;
|
|
64
68
|
const messageId = useId();
|
|
65
69
|
const descriptionId = useId();
|
|
70
|
+
const textareaCharCounterId = useId();
|
|
71
|
+
const [textareaCharacterCount, setTextareaCharacterCount] = useState(null);
|
|
72
|
+
const handleTextareaCharacterCount = useCallback(state => setTextareaCharacterCount(state), []);
|
|
73
|
+
const isNearCharLimit = textareaCharacterCount != null && textareaCharacterCount.current >= textareaCharacterCount.max * 0.8;
|
|
66
74
|
/**
|
|
67
75
|
* form control can have multiple messages to describe it,
|
|
68
76
|
* e.g the description underneath the label and inline alert
|
|
@@ -75,6 +83,9 @@ const Field = ({
|
|
|
75
83
|
if (message) {
|
|
76
84
|
messageIds.push(messageId);
|
|
77
85
|
}
|
|
86
|
+
if (textareaCharacterCount) {
|
|
87
|
+
messageIds.push(textareaCharCounterId);
|
|
88
|
+
}
|
|
78
89
|
return messageIds.length > 0 ? messageIds.join(' ') : undefined;
|
|
79
90
|
}
|
|
80
91
|
return /*#__PURE__*/jsx(FieldLabelContextProvider, {
|
|
@@ -88,37 +99,57 @@ const Field = ({
|
|
|
88
99
|
value: ariaDescribedbyByIds(),
|
|
89
100
|
children: /*#__PURE__*/jsx(InputInvalidProvider, {
|
|
90
101
|
value: hasError,
|
|
91
|
-
children: /*#__PURE__*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
'
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
children: /*#__PURE__*/jsx(TextareaCharacterCountProvider, {
|
|
103
|
+
value: handleTextareaCharacterCount,
|
|
104
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
105
|
+
className: clsx('np-field form-group d-block', {
|
|
106
|
+
'has-success': sentiment === Sentiment.POSITIVE,
|
|
107
|
+
'has-warning': sentiment === Sentiment.WARNING,
|
|
108
|
+
'has-error': hasError,
|
|
109
|
+
'has-info': sentiment === Sentiment.NEUTRAL
|
|
110
|
+
}, className),
|
|
111
|
+
children: [label != null ? /*#__PURE__*/jsxs(Fragment, {
|
|
112
|
+
children: [/*#__PURE__*/jsx(LabelNamespace, {
|
|
113
|
+
ref: labelRef,
|
|
114
|
+
id: labelId,
|
|
115
|
+
htmlFor: inputId,
|
|
116
|
+
children: required ? label : /*#__PURE__*/jsx(LabelNamespace.Optional, {
|
|
117
|
+
children: label
|
|
118
|
+
})
|
|
119
|
+
}), /*#__PURE__*/jsx(LabelNamespace.Description, {
|
|
120
|
+
id: descriptionId,
|
|
121
|
+
children: description
|
|
122
|
+
}), /*#__PURE__*/jsx("div", {
|
|
123
|
+
className: "np-field-control",
|
|
124
|
+
children: children
|
|
125
|
+
})]
|
|
126
|
+
}) : children, (message || textareaCharacterCount) && /*#__PURE__*/jsxs("div", {
|
|
127
|
+
className: "np-field-validation",
|
|
128
|
+
children: [message && /*#__PURE__*/jsx(InlinePrompt, {
|
|
129
|
+
sentiment: sentiment,
|
|
130
|
+
id: messageId,
|
|
131
|
+
mediaLabel: messageIconLabel,
|
|
132
|
+
className: "np-field__prompt",
|
|
133
|
+
loading: messageLoading,
|
|
134
|
+
width: "full",
|
|
135
|
+
children: message
|
|
136
|
+
}), textareaCharacterCount && /*#__PURE__*/jsxs(Body, {
|
|
137
|
+
as: "span",
|
|
138
|
+
id: textareaCharCounterId,
|
|
139
|
+
...(isNearCharLimit ? {
|
|
140
|
+
role: 'status',
|
|
141
|
+
'aria-live': 'polite',
|
|
142
|
+
'aria-atomic': 'true'
|
|
143
|
+
} : {}),
|
|
144
|
+
"aria-label": formatMessage(messages.characterCount, {
|
|
145
|
+
current: textareaCharacterCount.current,
|
|
146
|
+
max: textareaCharacterCount.max
|
|
147
|
+
}),
|
|
148
|
+
className: "np-field-textarea-char-counter",
|
|
149
|
+
children: [textareaCharacterCount.current, "/", textareaCharacterCount.max]
|
|
150
|
+
})]
|
|
112
151
|
})]
|
|
113
|
-
})
|
|
114
|
-
sentiment: sentiment,
|
|
115
|
-
id: messageId,
|
|
116
|
-
mediaLabel: messageIconLabel,
|
|
117
|
-
className: "np-field__prompt",
|
|
118
|
-
loading: messageLoading,
|
|
119
|
-
width: "full",
|
|
120
|
-
children: message
|
|
121
|
-
})]
|
|
152
|
+
})
|
|
122
153
|
})
|
|
123
154
|
})
|
|
124
155
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.mjs","sources":["../../src/field/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useId, useRef } from 'react';\n\nimport { Sentiment } from '../common';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt';\nimport {\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @default true */\n required?: boolean;\n /** @deprecated Use `description` prop instead. */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n /**\n * If true, shows a loading spinner in place of the message icon of the InlinePrompt\n * @default false\n */\n messageLoading?: boolean;\n description?: React.ReactNode;\n /** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */\n error?: React.ReactNode;\n /** @default Sentiment.NEUTRAL */\n sentiment?: InlinePromptProps['sentiment'];\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n messageLoading,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {message && (\n <InlinePrompt\n sentiment={sentiment}\n id={messageId}\n mediaLabel={messageIconLabel}\n className=\"np-field__prompt\"\n loading={messageLoading}\n width=\"full\"\n >\n {message}\n </InlinePrompt>\n )}\n </div>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","messageLoading","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","mediaLabel","loading","width"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,SAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;AACf,EAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAmB,IAAI,CAAC;EAC/C,MAAMR,SAAS,GAAGM,KAAK,CAACG,KAAK,GAAGP,SAAS,CAACQ,QAAQ,GAAGT,QAAQ;AAC7D,EAAA,MAAMP,OAAO,GAAGC,WAAW,IAAIW,KAAK,CAACG,KAAK;AAC1C,EAAA,MAAME,QAAQ,GAA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/Field.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useCallback, useId, useRef, useState } from 'react';\nimport { useIntl } from 'react-intl';\n\nimport Body from '../body';\nimport { Sentiment } from '../common';\nimport messages from './Field.messages';\nimport { InlinePrompt, type InlinePromptProps } from '../prompt';\nimport {\n TextareaCharacterCountProvider,\n type TextareaCharacterCountState,\n FieldLabelContextProvider,\n InputDescribedByProvider,\n InputIdContextProvider,\n InputInvalidProvider,\n} from '../inputs/contexts';\nimport { Label } from '../label';\n\nexport type FieldProps = {\n /** `null` disables auto-generating the `id` attribute, falling back to nesting-based label association over setting `htmlFor` explicitly. */\n id?: string | null;\n /** Should be specified unless the wrapped control has its own labeling mechanism, e.g. `Checkbox`. */\n label?: React.ReactNode;\n /** @default true */\n required?: boolean;\n /** @deprecated Use `description` prop instead. */\n hint?: React.ReactNode;\n message?: React.ReactNode;\n /**\n * Override for the [InlinePrompt icon's default, accessible name](/?path=/docs/other-statusicon-accessibility--docs)\n * announced by the screen readers\n * */\n messageIconLabel?: string;\n /**\n * If true, shows a loading spinner in place of the message icon of the InlinePrompt\n * @default false\n */\n messageLoading?: boolean;\n description?: React.ReactNode;\n /** @deprecated Use `message` and `type={Sentiment.NEGATIVE}` prop instead. */\n error?: React.ReactNode;\n /** @default Sentiment.NEUTRAL */\n sentiment?: InlinePromptProps['sentiment'];\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const Field = ({\n id,\n label,\n required = true,\n message: propMessage,\n messageIconLabel,\n messageLoading,\n hint,\n description = hint,\n sentiment: propType = Sentiment.NEUTRAL,\n className,\n children,\n ...props\n}: FieldProps) => {\n const { formatMessage } = useIntl();\n const labelRef = useRef<HTMLLabelElement>(null);\n const sentiment = props.error ? Sentiment.NEGATIVE : propType;\n const message = propMessage || props.error;\n const hasError = sentiment === Sentiment.NEGATIVE;\n\n const labelId = useId();\n\n const fallbackInputId = useId();\n const inputId = id !== null ? (id ?? fallbackInputId) : undefined;\n\n const messageId = useId();\n const descriptionId = useId();\n const textareaCharCounterId = useId();\n\n const [textareaCharacterCount, setTextareaCharacterCount] =\n useState<TextareaCharacterCountState>(null);\n const handleTextareaCharacterCount = useCallback(\n (state: TextareaCharacterCountState) => setTextareaCharacterCount(state),\n [],\n );\n\n const isNearCharLimit =\n textareaCharacterCount != null &&\n textareaCharacterCount.current >= textareaCharacterCount.max * 0.8;\n\n /**\n * form control can have multiple messages to describe it,\n * e.g the description underneath the label and inline alert\n */\n function ariaDescribedbyByIds() {\n const messageIds = [];\n if (description) {\n messageIds.push(descriptionId);\n }\n if (message) {\n messageIds.push(messageId);\n }\n if (textareaCharacterCount) {\n messageIds.push(textareaCharCounterId);\n }\n return messageIds.length > 0 ? messageIds.join(' ') : undefined;\n }\n\n return (\n <FieldLabelContextProvider value={{ id: labelId, ref: labelRef }}>\n <InputIdContextProvider value={inputId}>\n <InputDescribedByProvider value={ariaDescribedbyByIds()}>\n <InputInvalidProvider value={hasError}>\n <TextareaCharacterCountProvider value={handleTextareaCharacterCount}>\n <div\n className={clsx(\n 'np-field form-group d-block',\n {\n 'has-success': sentiment === Sentiment.POSITIVE,\n 'has-warning': sentiment === Sentiment.WARNING,\n 'has-error': hasError,\n 'has-info': sentiment === Sentiment.NEUTRAL,\n },\n className,\n )}\n >\n {label != null ? (\n <>\n <Label ref={labelRef} id={labelId} htmlFor={inputId}>\n {required ? label : <Label.Optional>{label}</Label.Optional>}\n </Label>\n <Label.Description id={descriptionId}>{description}</Label.Description>\n <div className=\"np-field-control\">{children}</div>\n </>\n ) : (\n children\n )}\n\n {(message || textareaCharacterCount) && (\n <div className=\"np-field-validation\">\n {message && (\n <InlinePrompt\n sentiment={sentiment}\n id={messageId}\n mediaLabel={messageIconLabel}\n className=\"np-field__prompt\"\n loading={messageLoading}\n width=\"full\"\n >\n {message}\n </InlinePrompt>\n )}\n {textareaCharacterCount && (\n <Body\n as=\"span\"\n id={textareaCharCounterId}\n {...(isNearCharLimit\n ? {\n role: 'status' as const,\n 'aria-live': 'polite' as const,\n 'aria-atomic': 'true' as const,\n }\n : {})}\n aria-label={formatMessage(messages.characterCount, {\n current: textareaCharacterCount.current,\n max: textareaCharacterCount.max,\n })}\n className=\"np-field-textarea-char-counter\"\n >\n {textareaCharacterCount.current}/{textareaCharacterCount.max}\n </Body>\n )}\n </div>\n )}\n </div>\n </TextareaCharacterCountProvider>\n </InputInvalidProvider>\n </InputDescribedByProvider>\n </InputIdContextProvider>\n </FieldLabelContextProvider>\n );\n};\n"],"names":["Field","id","label","required","message","propMessage","messageIconLabel","messageLoading","hint","description","sentiment","propType","Sentiment","NEUTRAL","className","children","props","formatMessage","useIntl","labelRef","useRef","error","NEGATIVE","hasError","labelId","useId","fallbackInputId","inputId","undefined","messageId","descriptionId","textareaCharCounterId","textareaCharacterCount","setTextareaCharacterCount","useState","handleTextareaCharacterCount","useCallback","state","isNearCharLimit","current","max","ariaDescribedbyByIds","messageIds","push","length","join","_jsx","FieldLabelContextProvider","value","ref","InputIdContextProvider","InputDescribedByProvider","InputInvalidProvider","TextareaCharacterCountProvider","_jsxs","clsx","POSITIVE","WARNING","_Fragment","Label","htmlFor","Optional","Description","InlinePrompt","mediaLabel","loading","width","Body","as","role","messages","characterCount"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CO,MAAMA,KAAK,GAAGA,CAAC;EACpBC,EAAE;EACFC,KAAK;AACLC,EAAAA,QAAQ,GAAG,IAAI;AACfC,EAAAA,OAAO,EAAEC,WAAW;EACpBC,gBAAgB;EAChBC,cAAc;EACdC,IAAI;AACJC,EAAAA,WAAW,GAAGD,IAAI;AAClBE,EAAAA,SAAS,EAAEC,QAAQ,GAAGC,SAAS,CAACC,OAAO;EACvCC,SAAS;EACTC,QAAQ;EACR,GAAGC;AAAK,CACG,KAAI;EACf,MAAM;AAAEC,IAAAA;GAAe,GAAGC,OAAO,EAAE;AACnC,EAAA,MAAMC,QAAQ,GAAGC,MAAM,CAAmB,IAAI,CAAC;EAC/C,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AS,EAAC,gCAAgC;kBAAAC,QAAA,EAAA,CAEzCiB,sBAAsB,CAACO,OAAO,EAAC,GAAC,EAACP,sBAAsB,CAACQ,GAAG;AAAA,iBACxD,CACP;AAAA,eACE,CACN;aACE;WACyB;SACZ;OACE;KACJ;AAC1B,GAA2B,CAAC;AAEhC;;;;"}
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
var reactIntl = require('react-intl');
|
|
7
|
+
var neptuneTokens = require('@transferwise/neptune-tokens');
|
|
7
8
|
require('../common/theme.js');
|
|
8
9
|
require('../common/direction.js');
|
|
9
10
|
require('../common/propsValues/control.js');
|
|
10
|
-
var breakpoint = require('../common/propsValues/breakpoint.js');
|
|
11
11
|
require('../common/propsValues/size.js');
|
|
12
12
|
require('../common/propsValues/typography.js');
|
|
13
13
|
require('../common/propsValues/width.js');
|
|
@@ -50,8 +50,8 @@ const FlowNavigation = ({
|
|
|
50
50
|
size: "lg",
|
|
51
51
|
onClick: onClose
|
|
52
52
|
});
|
|
53
|
-
const screenSm = useScreenSize.useScreenSize(
|
|
54
|
-
const screenLg = useScreenSize.useScreenSize(
|
|
53
|
+
const screenSm = useScreenSize.useScreenSize(neptuneTokens.Breakpoint.SMALL);
|
|
54
|
+
const screenLg = useScreenSize.useScreenSize(neptuneTokens.Breakpoint.LARGE);
|
|
55
55
|
const newAvatar = done ? null : avatar;
|
|
56
56
|
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
57
57
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowNavigation.js","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport {
|
|
1
|
+
{"version":3,"file":"FlowNavigation.js","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\n\nimport { Layout } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport FlowHeader from '../common/flowHeader/FlowHeader';\nimport Logo from '../logo';\nimport Stepper, { type Step } from '../stepper/Stepper';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './animatedLabel';\nimport IconButton from '../iconButton';\nimport { ArrowLeft } from '@transferwise/icons';\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: () => void;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */\n steps: readonly Step[];\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = <Logo />,\n done = false,\n onClose,\n onGoBack,\n steps,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const newAvatar = done ? null : avatar;\n\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n return (\n <div\n className={clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {\n 'np-flow-navigation--border-bottom': !done,\n })}\n >\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content p-x-3',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done && steps.length > 0 ? (\n <Stepper\n activeStep={activeStep}\n steps={steps}\n className={clsx('np-flow-navigation__stepper')}\n />\n ) : null\n }\n layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}\n />\n </div>\n );\n};\n\nexport default FlowNavigation;\n"],"names":["FlowNavigation","activeStep","avatar","logo","_jsx","Logo","done","onClose","onGoBack","steps","intl","useIntl","closeButton","CloseButton","size","onClick","screenSm","useScreenSize","Breakpoint","SMALL","screenLg","LARGE","newAvatar","displayGoBack","className","clsx","children","FlowHeader","leftContent","_jsxs","_Fragment","IconButton","priority","type","formatMessage","messages","back","ArrowLeft","AnimatedLabel","activeLabel","rightContent","bottomContent","length","Stepper","layout","Layout","VERTICAL","HORIZONTAL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,cAAc,GAAGA,CAAC;AACtBC,EAAAA,UAAU,GAAG,CAAC;EACdC,MAAM;AACNC,EAAAA,IAAI,gBAAGC,cAAA,CAACC,YAAI,IAAA,CAAG;AACfC,EAAAA,IAAI,GAAG,KAAK;EACZC,OAAO;EACPC,QAAQ;AACRC,EAAAA;AAAK,CACe,KAAI;AACxB,EAAA,MAAMC,IAAI,GAAGC,iBAAO,EAAE;EAEtB,MAAMC,WAAW,GAAGL,OAAO,IAAI,IAAI,iBAAIH,cAAA,CAACS,uBAAW,EAAA;AAACC,IAAAA,IAA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AAAE,UAAAA,QAAA,EAAEvB;SAAU,CAClD,EACA,CAACa,QAAQ,IAAI,CAACV,IAAI,iBACjBF,cAAA,CAACkC,qBAAa,EAAA;AAACd,UAAAA,SAAS,EAAC,OAAO;AAACf,UAAAA,KAAK,EAAEA,KAAM;AAAC8B,UAAAA,WAAW,EAAEtC;AAAW,SAAA,CACxE;AAAA,OACH,CACD;AACDuC,MAAAA,YAAY,eACVX,eAAA,CAAA,KAAA,EAAA;AAAKL,QAAAA,SAAS,EAAC,iFAAiF;AAAAE,QAAAA,QAAA,GAC7FJ,SAAS,EACTA,SAAS,IAAIV,WAAW,iBAAIR,cAAA,CAAA,MAAA,EAAA;AAAMoB,UAAAA,SAAS,EAAC;SAAO,CAAG,EACtDZ,WAAW;AAAA,OACT,CACN;AACD6B,MAAAA,aAAa,EACX,CAACnC,IAAI,IAAIG,KAAK,CAACiC,MAAM,GAAG,CAAC,gBACvBtC,cAAA,CAACuC,eAAO,EAAA;AACN1C,QAAAA,UAAU,EAAEA,UAAW;AACvBQ,QAAAA,KAAK,EAAEA,KAAM;QACbe,SAAS,EAAEC,SAAI,CAAC,6BAA6B;OAAE,CAC/C,GACA,IACL;MACDmB,MAAM,EAAE,CAACxB,QAAQ,GAAGyB,cAAM,CAACC,QAAQ,GAAGD,cAAM,CAACE;KAAW;AAE5D,GAAK,CAAC;AAEV;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
|
+
import { Breakpoint } from '@transferwise/neptune-tokens';
|
|
3
4
|
import '../common/theme.mjs';
|
|
4
5
|
import '../common/direction.mjs';
|
|
5
6
|
import '../common/propsValues/control.mjs';
|
|
6
|
-
import { Breakpoint } from '../common/propsValues/breakpoint.mjs';
|
|
7
7
|
import '../common/propsValues/size.mjs';
|
|
8
8
|
import '../common/propsValues/typography.mjs';
|
|
9
9
|
import '../common/propsValues/width.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlowNavigation.mjs","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\n\nimport {
|
|
1
|
+
{"version":3,"file":"FlowNavigation.mjs","sources":["../../src/flowNavigation/FlowNavigation.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useIntl } from 'react-intl';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\n\nimport { Layout } from '../common';\nimport { CloseButton } from '../common/closeButton';\nimport FlowHeader from '../common/flowHeader/FlowHeader';\nimport Logo from '../logo';\nimport Stepper, { type Step } from '../stepper/Stepper';\n\nimport { useScreenSize } from '../common/hooks/useScreenSize';\nimport messages from './FlowNavigation.messages';\nimport AnimatedLabel from './animatedLabel';\nimport IconButton from '../iconButton';\nimport { ArrowLeft } from '@transferwise/icons';\n\nexport interface FlowNavigationProps {\n /** @default 0 */\n activeStep?: number;\n avatar?: React.ReactNode;\n /** @default <Logo /> */\n logo?: React.ReactNode;\n /** @default false */\n done?: boolean;\n /** Called when the close button is clicked. If not provided the close button won't show */\n onClose?: () => void;\n /** Called when the back button is clicked. If not provided the back button won't show. The back button only shows on small screens */\n onGoBack?: () => void;\n /** Steps to be displayed in stepper. If you don't need the stepper, please use OverlayHeader instead */\n steps: readonly Step[];\n}\n\nconst FlowNavigation = ({\n activeStep = 0,\n avatar,\n logo = <Logo />,\n done = false,\n onClose,\n onGoBack,\n steps,\n}: FlowNavigationProps) => {\n const intl = useIntl();\n\n const closeButton = onClose != null && <CloseButton size=\"lg\" onClick={onClose} />;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const screenLg = useScreenSize(Breakpoint.LARGE);\n\n const newAvatar = done ? null : avatar;\n\n const displayGoBack = onGoBack != null && activeStep > 0;\n\n return (\n <div\n className={clsx('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {\n 'np-flow-navigation--border-bottom': !done,\n })}\n >\n <FlowHeader\n className={clsx(\n 'np-flow-navigation__content p-x-3',\n screenSm == null\n ? 'np-flow-navigation--hidden'\n : {\n 'np-flow-navigation--xs-max': !screenSm,\n // Size switches on parent container which may or may not have the same size as the window.\n 'np-flow-navigation--sm': screenSm,\n 'np-flow-navigation--lg': screenLg,\n },\n )}\n leftContent={\n <>\n {!screenSm && displayGoBack ? (\n <IconButton\n size={40}\n priority=\"tertiary\"\n type=\"default\"\n aria-label={intl.formatMessage(messages.back)}\n onClick={onGoBack}\n >\n <ArrowLeft />\n </IconButton>\n ) : (\n <div className=\"np-flow-header__left\">{logo}</div>\n )}\n {!screenSm && !done && (\n <AnimatedLabel className=\"m-x-1\" steps={steps} activeLabel={activeStep} />\n )}\n </>\n }\n rightContent={\n <div className=\"np-flow-header__right d-flex align-items-center justify-content-end order-2--lg\">\n {newAvatar}\n {newAvatar && closeButton && <span className=\"m-x-1\" />}\n {closeButton}\n </div>\n }\n bottomContent={\n !done && steps.length > 0 ? (\n <Stepper\n activeStep={activeStep}\n steps={steps}\n className={clsx('np-flow-navigation__stepper')}\n />\n ) : null\n }\n layout={!screenLg ? Layout.VERTICAL : Layout.HORIZONTAL}\n />\n </div>\n );\n};\n\nexport default FlowNavigation;\n"],"names":["FlowNavigation","activeStep","avatar","logo","_jsx","Logo","done","onClose","onGoBack","steps","intl","useIntl","closeButton","CloseButton","size","onClick","screenSm","useScreenSize","Breakpoint","SMALL","screenLg","LARGE","newAvatar","displayGoBack","className","clsx","children","FlowHeader","leftContent","_jsxs","_Fragment","IconButton","priority","type","formatMessage","messages","back","ArrowLeft","AnimatedLabel","activeLabel","rightContent","bottomContent","length","Stepper","layout","Layout","VERTICAL","HORIZONTAL"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,cAAc,GAAGA,CAAC;AACtBC,EAAAA,UAAU,GAAG,CAAC;EACdC,MAAM;AACNC,EAAAA,IAAI,gBAAGC,GAAA,CAACC,IAAI,IAAA,CAAG;AACfC,EAAAA,IA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Q,CAACC,IAAI,CAAE;AAC9CrB,UAAAA,OAAO,EAAEP,QAAS;AAAAkB,UAAAA,QAAA,eAElBtB,GAAA,CAACiC,SAAS,EAAA,EAAA;SACA,CAAC,gBAEbjC,GAAA,CAAA,KAAA,EAAA;AAAKoB,UAAAA,SAAS,EAAC,sBAAsB;AAAAE,UAAAA,QAAA,EAAEvB;SAAU,CAClD,EACA,CAACa,QAAQ,IAAI,CAACV,IAAI,iBACjBF,GAAA,CAACkC,aAAa,EAAA;AAACd,UAAAA,SAAS,EAAC,OAAO;AAACf,UAAAA,KAAK,EAAEA,KAAM;AAAC8B,UAAAA,WAAW,EAAEtC;AAAW,SAAA,CACxE;AAAA,OACH,CACD;AACDuC,MAAAA,YAAY,eACVX,IAAA,CAAA,KAAA,EAAA;AAAKL,QAAAA,SAAS,EAAC,iFAAiF;AAAAE,QAAAA,QAAA,GAC7FJ,SAAS,EACTA,SAAS,IAAIV,WAAW,iBAAIR,GAAA,CAAA,MAAA,EAAA;AAAMoB,UAAAA,SAAS,EAAC;SAAO,CAAG,EACtDZ,WAAW;AAAA,OACT,CACN;AACD6B,MAAAA,aAAa,EACX,CAACnC,IAAI,IAAIG,KAAK,CAACiC,MAAM,GAAG,CAAC,gBACvBtC,GAAA,CAACuC,OAAO,EAAA;AACN1C,QAAAA,UAAU,EAAEA,UAAW;AACvBQ,QAAAA,KAAK,EAAEA,KAAM;QACbe,SAAS,EAAEC,IAAI,CAAC,6BAA6B;OAAE,CAC/C,GACA,IACL;MACDmB,MAAM,EAAE,CAACxB,QAAQ,GAAGyB,MAAM,CAACC,QAAQ,GAAGD,MAAM,CAACE;KAAW;AAE5D,GAAK,CAAC;AAEV;;;;"}
|
package/build/header/Header.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
require('../common/theme.js');
|
|
7
7
|
require('../common/direction.js');
|
|
8
|
+
require('@transferwise/neptune-tokens');
|
|
8
9
|
require('../common/propsValues/control.js');
|
|
9
|
-
require('../common/propsValues/breakpoint.js');
|
|
10
10
|
require('../common/propsValues/size.js');
|
|
11
11
|
var typography = require('../common/propsValues/typography.js');
|
|
12
12
|
require('../common/propsValues/width.js');
|
package/build/header/Header.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import '../common/theme.mjs';
|
|
3
3
|
import '../common/direction.mjs';
|
|
4
|
+
import '@transferwise/neptune-tokens';
|
|
4
5
|
import '../common/propsValues/control.mjs';
|
|
5
|
-
import '../common/propsValues/breakpoint.mjs';
|
|
6
6
|
import '../common/propsValues/size.mjs';
|
|
7
7
|
import { Typography } from '../common/propsValues/typography.mjs';
|
|
8
8
|
import '../common/propsValues/width.mjs';
|
package/build/i18n/en.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"neptune.Expander.expandAriaLabel": "Expand",
|
|
21
21
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": "Type a currency / country",
|
|
22
22
|
"neptune.ExpressiveMoneyInput.currency.select.currency": "Select currency",
|
|
23
|
+
"neptune.Field.characterCount": "{current} of {max} characters used",
|
|
23
24
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
24
25
|
"neptune.Info.ariaLabel": "More information",
|
|
25
26
|
"neptune.Label.optional": "(Optional)",
|
package/build/i18n/en.json.js
CHANGED
|
@@ -24,6 +24,7 @@ var en = {
|
|
|
24
24
|
"neptune.Expander.expandAriaLabel": "Expand",
|
|
25
25
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": "Type a currency / country",
|
|
26
26
|
"neptune.ExpressiveMoneyInput.currency.select.currency": "Select currency",
|
|
27
|
+
"neptune.Field.characterCount": "{current} of {max} characters used",
|
|
27
28
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
28
29
|
"neptune.Info.ariaLabel": "More information",
|
|
29
30
|
"neptune.Label.optional": "(Optional)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/i18n/en.json.mjs
CHANGED
|
@@ -20,6 +20,7 @@ var en = {
|
|
|
20
20
|
"neptune.Expander.expandAriaLabel": "Expand",
|
|
21
21
|
"neptune.ExpressiveMoneyInput.currency.search.placeholder": "Type a currency / country",
|
|
22
22
|
"neptune.ExpressiveMoneyInput.currency.select.currency": "Select currency",
|
|
23
|
+
"neptune.Field.characterCount": "{current} of {max} characters used",
|
|
23
24
|
"neptune.FlowNavigation.back": "back to previous step",
|
|
24
25
|
"neptune.Info.ariaLabel": "More information",
|
|
25
26
|
"neptune.Label.optional": "(Optional)",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/image/Image.js
CHANGED
|
@@ -7,7 +7,7 @@ var React = require('react');
|
|
|
7
7
|
require('@transferwise/neptune-validation');
|
|
8
8
|
require('../provider/direction/DirectionProvider.js');
|
|
9
9
|
var useHasIntersected = require('../common/hooks/useHasIntersected/useHasIntersected.js');
|
|
10
|
-
require('
|
|
10
|
+
require('@transferwise/neptune-tokens');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
12
|
|
|
13
13
|
const Image = ({
|
package/build/image/Image.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { useRef, useCallback } from 'react';
|
|
|
3
3
|
import '@transferwise/neptune-validation';
|
|
4
4
|
import '../provider/direction/DirectionProvider.mjs';
|
|
5
5
|
import { useHasIntersected } from '../common/hooks/useHasIntersected/useHasIntersected.mjs';
|
|
6
|
-
import '
|
|
6
|
+
import '@transferwise/neptune-tokens';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
const Image = ({
|
package/build/index.js
CHANGED
|
@@ -16,7 +16,7 @@ require('@wise/art');
|
|
|
16
16
|
var StatusIcon = require('./statusIcon/StatusIcon.js');
|
|
17
17
|
require('react');
|
|
18
18
|
require('clsx');
|
|
19
|
-
var
|
|
19
|
+
var neptuneTokens = require('@transferwise/neptune-tokens');
|
|
20
20
|
require('react/jsx-runtime');
|
|
21
21
|
var Image = require('./image/Image.js');
|
|
22
22
|
var Body = require('./body/Body.js');
|
|
@@ -174,7 +174,7 @@ exports.Badge = Badge.default;
|
|
|
174
174
|
exports.StatusIcon = StatusIcon.default;
|
|
175
175
|
Object.defineProperty(exports, "Breakpoint", {
|
|
176
176
|
enumerable: true,
|
|
177
|
-
get: function () { return
|
|
177
|
+
get: function () { return neptuneTokens.Breakpoint; }
|
|
178
178
|
});
|
|
179
179
|
exports.Image = Image.default;
|
|
180
180
|
exports.Body = Body.default;
|
package/build/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import '@wise/art';
|
|
|
14
14
|
export { default as StatusIcon } from './statusIcon/StatusIcon.mjs';
|
|
15
15
|
import 'react';
|
|
16
16
|
import 'clsx';
|
|
17
|
-
export { Breakpoint } from '
|
|
17
|
+
export { Breakpoint } from '@transferwise/neptune-tokens';
|
|
18
18
|
import 'react/jsx-runtime';
|
|
19
19
|
export { default as Image } from './image/Image.mjs';
|
|
20
20
|
export { default as Body } from './body/Body.mjs';
|
package/build/info/Info.js
CHANGED
|
@@ -8,8 +8,8 @@ var React = require('react');
|
|
|
8
8
|
var reactIntl = require('react-intl');
|
|
9
9
|
require('../common/theme.js');
|
|
10
10
|
require('../common/direction.js');
|
|
11
|
+
require('@transferwise/neptune-tokens');
|
|
11
12
|
require('../common/propsValues/control.js');
|
|
12
|
-
require('../common/propsValues/breakpoint.js');
|
|
13
13
|
var size = require('../common/propsValues/size.js');
|
|
14
14
|
require('../common/propsValues/typography.js');
|
|
15
15
|
require('../common/propsValues/width.js');
|
package/build/info/Info.mjs
CHANGED
|
@@ -4,8 +4,8 @@ import { useState } from 'react';
|
|
|
4
4
|
import { useIntl } from 'react-intl';
|
|
5
5
|
import '../common/theme.mjs';
|
|
6
6
|
import '../common/direction.mjs';
|
|
7
|
+
import '@transferwise/neptune-tokens';
|
|
7
8
|
import '../common/propsValues/control.mjs';
|
|
8
|
-
import '../common/propsValues/breakpoint.mjs';
|
|
9
9
|
import { Size } from '../common/propsValues/size.mjs';
|
|
10
10
|
import '../common/propsValues/typography.mjs';
|
|
11
11
|
import '../common/propsValues/width.mjs';
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var clsx = require('clsx');
|
|
6
6
|
require('../common/theme.js');
|
|
7
7
|
require('../common/direction.js');
|
|
8
|
+
require('@transferwise/neptune-tokens');
|
|
8
9
|
require('../common/propsValues/control.js');
|
|
9
|
-
require('../common/propsValues/breakpoint.js');
|
|
10
10
|
var size = require('../common/propsValues/size.js');
|
|
11
11
|
require('../common/propsValues/typography.js');
|
|
12
12
|
require('../common/propsValues/width.js');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { clsx } from 'clsx';
|
|
2
2
|
import '../common/theme.mjs';
|
|
3
3
|
import '../common/direction.mjs';
|
|
4
|
+
import '@transferwise/neptune-tokens';
|
|
4
5
|
import '../common/propsValues/control.mjs';
|
|
5
|
-
import '../common/propsValues/breakpoint.mjs';
|
|
6
6
|
import { Size } from '../common/propsValues/size.mjs';
|
|
7
7
|
import '../common/propsValues/typography.mjs';
|
|
8
8
|
import '../common/propsValues/width.mjs';
|
|
@@ -4,8 +4,8 @@ var icons = require('@transferwise/icons');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
require('../common/theme.js');
|
|
6
6
|
require('../common/direction.js');
|
|
7
|
+
require('@transferwise/neptune-tokens');
|
|
7
8
|
require('../common/propsValues/control.js');
|
|
8
|
-
require('../common/propsValues/breakpoint.js');
|
|
9
9
|
var size = require('../common/propsValues/size.js');
|
|
10
10
|
require('../common/propsValues/typography.js');
|
|
11
11
|
require('../common/propsValues/width.js');
|
|
@@ -2,8 +2,8 @@ import { Search } from '@transferwise/icons';
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import '../common/theme.mjs';
|
|
4
4
|
import '../common/direction.mjs';
|
|
5
|
+
import '@transferwise/neptune-tokens';
|
|
5
6
|
import '../common/propsValues/control.mjs';
|
|
6
|
-
import '../common/propsValues/breakpoint.mjs';
|
|
7
7
|
import { Size } from '../common/propsValues/size.mjs';
|
|
8
8
|
import '../common/propsValues/typography.mjs';
|
|
9
9
|
import '../common/propsValues/width.mjs';
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var mergeProps = require('merge-props');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var react = require('@headlessui/react');
|
|
6
|
+
var neptuneTokens = require('@transferwise/neptune-tokens');
|
|
6
7
|
var useScreenSize = require('../../common/hooks/useScreenSize.js');
|
|
7
|
-
var breakpoint = require('../../common/propsValues/breakpoint.js');
|
|
8
8
|
var useEffectEvent = require('../../common/hooks/useEffectEvent.js');
|
|
9
9
|
var contexts = require('../contexts.js');
|
|
10
10
|
var SelectInputBottomSheet = require('./BottomSheet/SelectInputBottomSheet.js');
|
|
@@ -88,7 +88,7 @@ function SelectInput({
|
|
|
88
88
|
const searchInputRef = React.useRef(null);
|
|
89
89
|
const listboxRef = React.useRef(null);
|
|
90
90
|
const controllerRef = filterable ? searchInputRef : listboxRef;
|
|
91
|
-
const screenSm = useScreenSize.useScreenSize(
|
|
91
|
+
const screenSm = useScreenSize.useScreenSize(neptuneTokens.Breakpoint.SMALL);
|
|
92
92
|
const OptionsOverlay = screenSm ? SelectInputPopover.SelectInputPopover : SelectInputBottomSheet.SelectInputBottomSheet;
|
|
93
93
|
/**
|
|
94
94
|
* Attempts to resolve the `listbox` label
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInput.js","sources":["../../../src/inputs/SelectInput/SelectInput.tsx"],"sourcesContent":["import mergeProps from 'merge-props';\nimport { useCallback, useEffect, useRef, useState, useDeferredValue } from 'react';\nimport { Listbox as ListboxBase } from '@headlessui/react';\nimport { useScreenSize } from '../../common/hooks/useScreenSize';\nimport { Breakpoint } from '../../common/propsValues/breakpoint';\nimport { useEffectEvent } from '../../common/hooks/useEffectEvent';\nimport { useInputAttributes } from '../contexts';\n\nimport { SelectInputBottomSheet } from './BottomSheet';\nimport { SelectInputPopover } from './Popover';\nimport { SelectInputOptions } from './Options';\nimport { DefaultRenderTrigger } from './DefaultRenderTrigger';\n\nimport {\n SelectInputOptionContentWithinTriggerContext,\n SelectInputTriggerButtonPropsContext,\n} from './SelectInput.contexts';\nimport { searchableString, sortByRelevance } from './SelectInput.utils';\nimport { SelectInputProps } from './SelectInput.types';\n\nconst noop = () => {};\n\n/**\n * SelectInput component allows users to select an option from a dropdown list.\n * Supports filtering, multiple selection, and customization.\n */\nexport function SelectInput<T = string, M extends boolean = false>({\n id: idProp,\n parentId,\n name,\n multiple,\n placeholder,\n autocomplete,\n items,\n defaultValue,\n value: controlledValue,\n compareValues,\n renderValue = String,\n renderFooter,\n renderTrigger = DefaultRenderTrigger,\n filterable,\n filterPlaceholder,\n sortFilteredOptions,\n disabled,\n size = 'md',\n className,\n UNSAFE_triggerButtonProps,\n triggerRef: externalTriggerRef,\n onFilterChange = noop,\n onChange,\n onOpen,\n onClose,\n onClear,\n}: SelectInputProps<T, M>) {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const id = idProp ?? inputAttributes.id;\n\n const [open, setOpen] = useState(false);\n\n const initialized = useRef(false);\n const handleClose = useEffectEvent(onClose ?? (() => {}));\n const handleOpen = useEffectEvent(onOpen ?? (() => {}));\n\n useEffect(() => {\n if (initialized.current) {\n if (open) {\n handleOpen?.();\n } else {\n handleClose?.();\n }\n } else {\n initialized.current = true;\n }\n }, [open]);\n\n const [filterQuery, _setFilterQuery] = useState('');\n const deferredFilterQuery = useDeferredValue(filterQuery);\n const previousFilterQueryRef = useRef(filterQuery);\n\n const setFilterQuery = useCallback(\n (query: string) => {\n _setFilterQuery(query);\n if (query !== previousFilterQueryRef.current) {\n onFilterChange({\n query,\n queryNormalized: query ? searchableString(query) : null,\n });\n previousFilterQueryRef.current = query;\n }\n },\n [onFilterChange],\n );\n\n const internalTriggerRef = useRef<HTMLButtonElement | null>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const listboxRef = useRef<HTMLDivElement>(null);\n const controllerRef = filterable ? searchInputRef : listboxRef;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const OptionsOverlay = screenSm ? SelectInputPopover : SelectInputBottomSheet;\n\n /**\n * Attempts to resolve the `listbox` label\n * @see https://storybook.wise.design/?path=/docs/forms-selectinput-accessibility--docs#labelling\n */\n const getListBoxLabelProps = (): {\n listBoxLabel?: string;\n listBoxLabelledBy?: string;\n } => {\n if (UNSAFE_triggerButtonProps?.['aria-label']) {\n return {\n listBoxLabel: UNSAFE_triggerButtonProps['aria-label'],\n };\n }\n\n if (UNSAFE_triggerButtonProps?.['aria-labelledby']) {\n return {\n listBoxLabelledBy: UNSAFE_triggerButtonProps['aria-labelledby'],\n };\n }\n\n if (inputAttributes['aria-labelledby']) {\n return {\n listBoxLabelledBy: inputAttributes['aria-labelledby'],\n };\n }\n\n return {};\n };\n\n return (\n <ListboxBase\n name={name}\n multiple={multiple}\n defaultValue={defaultValue as M extends true ? T[] : T}\n value={controlledValue as M extends true ? T[] : T}\n by={compareValues}\n disabled={disabled}\n onChange={\n ((value) => {\n if (!multiple) {\n setOpen(false);\n }\n onChange?.(value);\n }) satisfies SelectInputProps<T, M>['onChange']\n }\n >\n {({ disabled: uiDisabled, value }) => {\n const placeholderShown =\n multiple && Array.isArray(value) ? value.length === 0 : value == null;\n return (\n <OptionsOverlay\n placement=\"bottom-start\"\n open={open}\n renderTrigger={({ ref, getInteractionProps }) => (\n <SelectInputTriggerButtonPropsContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n ref: (node) => {\n ref(node);\n if (externalTriggerRef) {\n // eslint-disable-next-line no-param-reassign\n externalTriggerRef.current = node;\n } else {\n internalTriggerRef.current = node;\n }\n },\n size,\n ...inputAttributes,\n ...UNSAFE_triggerButtonProps,\n id,\n ...mergeProps(\n {\n onClick: () => {\n setOpen((prev) => !prev);\n },\n onKeyDown: (event: React.KeyboardEvent) => {\n if (\n event.key === ' ' ||\n event.key === 'Enter' ||\n event.key === 'ArrowDown' ||\n event.key === 'ArrowUp'\n ) {\n setOpen((prev) => !prev);\n }\n },\n },\n getInteractionProps(),\n ),\n }}\n >\n {renderTrigger({\n content: !placeholderShown ? (\n <SelectInputOptionContentWithinTriggerContext.Provider value>\n {multiple && Array.isArray(value)\n ? (value as readonly NonNullable<T>[])\n .map((option) => renderValue(option, true))\n .filter((node) => node != null)\n .join(', ')\n : renderValue(value as NonNullable<T>, true)}\n </SelectInputOptionContentWithinTriggerContext.Provider>\n ) : (\n placeholder\n ),\n placeholderShown,\n clear:\n onClear != null\n ? () => {\n onClear();\n (externalTriggerRef?.current ?? internalTriggerRef.current)?.focus({\n preventScroll: true,\n });\n }\n : undefined,\n disabled: uiDisabled,\n size,\n className,\n })}\n </SelectInputTriggerButtonPropsContext.Provider>\n )}\n initialFocusRef={controllerRef}\n size={filterable ? 'lg' : 'md'}\n padding=\"none\"\n onClose={() => {\n setOpen(false);\n }}\n onCloseEnd={() => {\n setFilterQuery('');\n }}\n >\n <SelectInputOptions\n id={id ? `${id}Search` : undefined}\n parentId={parentId}\n items={items}\n compareValues={compareValues}\n renderValue={renderValue}\n renderFooter={renderFooter}\n filterable={filterable}\n filterPlaceholder={filterPlaceholder}\n sortFilteredOptions={sortFilteredOptions}\n searchInputRef={searchInputRef}\n listboxRef={listboxRef}\n filterQuery={deferredFilterQuery}\n autocomplete={autocomplete}\n name={name}\n onFilterChange={setFilterQuery}\n onAutocompleteSelect={(matchedValue) => {\n onChange?.(matchedValue as M extends true ? T[] : T);\n if (!multiple) {\n setOpen(false);\n }\n }}\n {...getListBoxLabelProps()}\n />\n </OptionsOverlay>\n );\n }}\n </ListboxBase>\n );\n}\n\n// Attach sortByRelevance to the component for convenience\nSelectInput.sortByRelevance = sortByRelevance;\n"],"names":["noop","SelectInput","id","idProp","parentId","name","multiple","placeholder","autocomplete","items","defaultValue","value","controlledValue","compareValues","renderValue","String","renderFooter","renderTrigger","DefaultRenderTrigger","filterable","filterPlaceholder","sortFilteredOptions","disabled","size","className","UNSAFE_triggerButtonProps","triggerRef","externalTriggerRef","onFilterChange","onChange","onOpen","onClose","onClear","inputAttributes","useInputAttributes","nonLabelable","open","setOpen","useState","initialized","useRef","handleClose","useEffectEvent","handleOpen","useEffect","current","filterQuery","_setFilterQuery","deferredFilterQuery","useDeferredValue","previousFilterQueryRef","setFilterQuery","useCallback","query","queryNormalized","searchableString","internalTriggerRef","searchInputRef","listboxRef","controllerRef","screenSm","useScreenSize","Breakpoint","SMALL","OptionsOverlay","SelectInputPopover","SelectInputBottomSheet","getListBoxLabelProps","listBoxLabel","listBoxLabelledBy","_jsx","ListboxBase","by","children","uiDisabled","placeholderShown","Array","isArray","length","placement","ref","getInteractionProps","SelectInputTriggerButtonPropsContext","Provider","node","mergeProps","onClick","prev","onKeyDown","event","key","content","SelectInputOptionContentWithinTriggerContext","map","option","filter","join","clear","focus","preventScroll","undefined","initialFocusRef","padding","onCloseEnd","SelectInputOptions","onAutocompleteSelect","matchedValue","sortByRelevance"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA,MAAMA,IAAI,GAAGA,MAAK,CAAE,CAAC;AAErB;;;AAGG;A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AAY,IAAI;YACrC7E,QAAQ,GAAG6E,YAAwC,CAAC;YACpD,IAAI,CAACpG,QAAQ,EAAE;cACb+B,OAAO,CAAC,KAAK,CAAC;AAChB,YAAA;UACF,CAAE;AAAA,UAAA,GACE8B,oBAAoB;SAAG;AAE/B,OAAgB,CAAC;AAErB,IAAA;AAAC,GACU,CAAC;AAElB;AAEA;AACAlE,WAAW,CAAC0G,eAAe,GAAGA,iCAAe;;;;"}
|
|
1
|
+
{"version":3,"file":"SelectInput.js","sources":["../../../src/inputs/SelectInput/SelectInput.tsx"],"sourcesContent":["import mergeProps from 'merge-props';\nimport { useCallback, useEffect, useRef, useState, useDeferredValue } from 'react';\nimport { Listbox as ListboxBase } from '@headlessui/react';\nimport { Breakpoint } from '@transferwise/neptune-tokens';\nimport { useScreenSize } from '../../common/hooks/useScreenSize';\nimport { useEffectEvent } from '../../common/hooks/useEffectEvent';\nimport { useInputAttributes } from '../contexts';\n\nimport { SelectInputBottomSheet } from './BottomSheet';\nimport { SelectInputPopover } from './Popover';\nimport { SelectInputOptions } from './Options';\nimport { DefaultRenderTrigger } from './DefaultRenderTrigger';\n\nimport {\n SelectInputOptionContentWithinTriggerContext,\n SelectInputTriggerButtonPropsContext,\n} from './SelectInput.contexts';\nimport { searchableString, sortByRelevance } from './SelectInput.utils';\nimport { SelectInputProps } from './SelectInput.types';\n\nconst noop = () => {};\n\n/**\n * SelectInput component allows users to select an option from a dropdown list.\n * Supports filtering, multiple selection, and customization.\n */\nexport function SelectInput<T = string, M extends boolean = false>({\n id: idProp,\n parentId,\n name,\n multiple,\n placeholder,\n autocomplete,\n items,\n defaultValue,\n value: controlledValue,\n compareValues,\n renderValue = String,\n renderFooter,\n renderTrigger = DefaultRenderTrigger,\n filterable,\n filterPlaceholder,\n sortFilteredOptions,\n disabled,\n size = 'md',\n className,\n UNSAFE_triggerButtonProps,\n triggerRef: externalTriggerRef,\n onFilterChange = noop,\n onChange,\n onOpen,\n onClose,\n onClear,\n}: SelectInputProps<T, M>) {\n const inputAttributes = useInputAttributes({ nonLabelable: true });\n const id = idProp ?? inputAttributes.id;\n\n const [open, setOpen] = useState(false);\n\n const initialized = useRef(false);\n const handleClose = useEffectEvent(onClose ?? (() => {}));\n const handleOpen = useEffectEvent(onOpen ?? (() => {}));\n\n useEffect(() => {\n if (initialized.current) {\n if (open) {\n handleOpen?.();\n } else {\n handleClose?.();\n }\n } else {\n initialized.current = true;\n }\n }, [open]);\n\n const [filterQuery, _setFilterQuery] = useState('');\n const deferredFilterQuery = useDeferredValue(filterQuery);\n const previousFilterQueryRef = useRef(filterQuery);\n\n const setFilterQuery = useCallback(\n (query: string) => {\n _setFilterQuery(query);\n if (query !== previousFilterQueryRef.current) {\n onFilterChange({\n query,\n queryNormalized: query ? searchableString(query) : null,\n });\n previousFilterQueryRef.current = query;\n }\n },\n [onFilterChange],\n );\n\n const internalTriggerRef = useRef<HTMLButtonElement | null>(null);\n const searchInputRef = useRef<HTMLInputElement>(null);\n const listboxRef = useRef<HTMLDivElement>(null);\n const controllerRef = filterable ? searchInputRef : listboxRef;\n\n const screenSm = useScreenSize(Breakpoint.SMALL);\n const OptionsOverlay = screenSm ? SelectInputPopover : SelectInputBottomSheet;\n\n /**\n * Attempts to resolve the `listbox` label\n * @see https://storybook.wise.design/?path=/docs/forms-selectinput-accessibility--docs#labelling\n */\n const getListBoxLabelProps = (): {\n listBoxLabel?: string;\n listBoxLabelledBy?: string;\n } => {\n if (UNSAFE_triggerButtonProps?.['aria-label']) {\n return {\n listBoxLabel: UNSAFE_triggerButtonProps['aria-label'],\n };\n }\n\n if (UNSAFE_triggerButtonProps?.['aria-labelledby']) {\n return {\n listBoxLabelledBy: UNSAFE_triggerButtonProps['aria-labelledby'],\n };\n }\n\n if (inputAttributes['aria-labelledby']) {\n return {\n listBoxLabelledBy: inputAttributes['aria-labelledby'],\n };\n }\n\n return {};\n };\n\n return (\n <ListboxBase\n name={name}\n multiple={multiple}\n defaultValue={defaultValue as M extends true ? T[] : T}\n value={controlledValue as M extends true ? T[] : T}\n by={compareValues}\n disabled={disabled}\n onChange={\n ((value) => {\n if (!multiple) {\n setOpen(false);\n }\n onChange?.(value);\n }) satisfies SelectInputProps<T, M>['onChange']\n }\n >\n {({ disabled: uiDisabled, value }) => {\n const placeholderShown =\n multiple && Array.isArray(value) ? value.length === 0 : value == null;\n return (\n <OptionsOverlay\n placement=\"bottom-start\"\n open={open}\n renderTrigger={({ ref, getInteractionProps }) => (\n <SelectInputTriggerButtonPropsContext.Provider\n // eslint-disable-next-line react/jsx-no-constructed-context-values\n value={{\n ref: (node) => {\n ref(node);\n if (externalTriggerRef) {\n // eslint-disable-next-line no-param-reassign\n externalTriggerRef.current = node;\n } else {\n internalTriggerRef.current = node;\n }\n },\n size,\n ...inputAttributes,\n ...UNSAFE_triggerButtonProps,\n id,\n ...mergeProps(\n {\n onClick: () => {\n setOpen((prev) => !prev);\n },\n onKeyDown: (event: React.KeyboardEvent) => {\n if (\n event.key === ' ' ||\n event.key === 'Enter' ||\n event.key === 'ArrowDown' ||\n event.key === 'ArrowUp'\n ) {\n setOpen((prev) => !prev);\n }\n },\n },\n getInteractionProps(),\n ),\n }}\n >\n {renderTrigger({\n content: !placeholderShown ? (\n <SelectInputOptionContentWithinTriggerContext.Provider value>\n {multiple && Array.isArray(value)\n ? (value as readonly NonNullable<T>[])\n .map((option) => renderValue(option, true))\n .filter((node) => node != null)\n .join(', ')\n : renderValue(value as NonNullable<T>, true)}\n </SelectInputOptionContentWithinTriggerContext.Provider>\n ) : (\n placeholder\n ),\n placeholderShown,\n clear:\n onClear != null\n ? () => {\n onClear();\n (externalTriggerRef?.current ?? internalTriggerRef.current)?.focus({\n preventScroll: true,\n });\n }\n : undefined,\n disabled: uiDisabled,\n size,\n className,\n })}\n </SelectInputTriggerButtonPropsContext.Provider>\n )}\n initialFocusRef={controllerRef}\n size={filterable ? 'lg' : 'md'}\n padding=\"none\"\n onClose={() => {\n setOpen(false);\n }}\n onCloseEnd={() => {\n setFilterQuery('');\n }}\n >\n <SelectInputOptions\n id={id ? `${id}Search` : undefined}\n parentId={parentId}\n items={items}\n compareValues={compareValues}\n renderValue={renderValue}\n renderFooter={renderFooter}\n filterable={filterable}\n filterPlaceholder={filterPlaceholder}\n sortFilteredOptions={sortFilteredOptions}\n searchInputRef={searchInputRef}\n listboxRef={listboxRef}\n filterQuery={deferredFilterQuery}\n autocomplete={autocomplete}\n name={name}\n onFilterChange={setFilterQuery}\n onAutocompleteSelect={(matchedValue) => {\n onChange?.(matchedValue as M extends true ? T[] : T);\n if (!multiple) {\n setOpen(false);\n }\n }}\n {...getListBoxLabelProps()}\n />\n </OptionsOverlay>\n );\n }}\n </ListboxBase>\n );\n}\n\n// Attach sortByRelevance to the component for convenience\nSelectInput.sortByRelevance = sortByRelevance;\n"],"names":["noop","SelectInput","id","idProp","parentId","name","multiple","placeholder","autocomplete","items","defaultValue","value","controlledValue","compareValues","renderValue","String","renderFooter","renderTrigger","DefaultRenderTrigger","filterable","filterPlaceholder","sortFilteredOptions","disabled","size","className","UNSAFE_triggerButtonProps","triggerRef","externalTriggerRef","onFilterChange","onChange","onOpen","onClose","onClear","inputAttributes","useInputAttributes","nonLabelable","open","setOpen","useState","initialized","useRef","handleClose","useEffectEvent","handleOpen","useEffect","current","filterQuery","_setFilterQuery","deferredFilterQuery","useDeferredValue","previousFilterQueryRef","setFilterQuery","useCallback","query","queryNormalized","searchableString","internalTriggerRef","searchInputRef","listboxRef","controllerRef","screenSm","useScreenSize","Breakpoint","SMALL","OptionsOverlay","SelectInputPopover","SelectInputBottomSheet","getListBoxLabelProps","listBoxLabel","listBoxLabelledBy","_jsx","ListboxBase","by","children","uiDisabled","placeholderShown","Array","isArray","length","placement","ref","getInteractionProps","SelectInputTriggerButtonPropsContext","Provider","node","mergeProps","onClick","prev","onKeyDown","event","key","content","SelectInputOptionContentWithinTriggerContext","map","option","filter","join","clear","focus","preventScroll","undefined","initialFocusRef","padding","onCloseEnd","SelectInputOptions","onAutocompleteS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AAY,EAAEA,YAAa;AAC3BH,UAAAA,IAAI,EAAEA,IAAK;AACXuB,UAAAA,cAAc,EAAEuB,cAAe;UAC/BsD,oBAAoB,EAAGC,YAAY,IAAI;YACrC7E,QAAQ,GAAG6E,YAAwC,CAAC;YACpD,IAAI,CAACpG,QAAQ,EAAE;cACb+B,OAAO,CAAC,KAAK,CAAC;AAChB,YAAA;UACF,CAAE;AAAA,UAAA,GACE8B,oBAAoB;SAAG;AAE/B,OAAgB,CAAC;AAErB,IAAA;AAAC,GACU,CAAC;AAElB;AAEA;AACAlE,WAAW,CAAC0G,eAAe,GAAGA,iCAAe;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import mergeProps from 'merge-props';
|
|
2
2
|
import { useState, useRef, useEffect, useDeferredValue, useCallback } from 'react';
|
|
3
3
|
import { Listbox } from '@headlessui/react';
|
|
4
|
+
import { Breakpoint } from '@transferwise/neptune-tokens';
|
|
4
5
|
import { useScreenSize } from '../../common/hooks/useScreenSize.mjs';
|
|
5
|
-
import { Breakpoint } from '../../common/propsValues/breakpoint.mjs';
|
|
6
6
|
import { useEffectEvent } from '../../common/hooks/useEffectEvent.mjs';
|
|
7
7
|
import { useInputAttributes } from '../contexts.mjs';
|
|
8
8
|
import { SelectInputBottomSheet } from './BottomSheet/SelectInputBottomSheet.mjs';
|