@razorpay/blade 11.37.0 → 11.38.1
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/lib/native/components/Accordion/Accordion.js +2 -1
- package/build/lib/native/components/Accordion/Accordion.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionItem.js +3 -1
- package/build/lib/native/components/Accordion/AccordionItem.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionItemBody.js +3 -2
- package/build/lib/native/components/Accordion/AccordionItemBody.js.map +1 -1
- package/build/lib/native/components/Accordion/AccordionItemHeader.js +3 -2
- package/build/lib/native/components/Accordion/AccordionItemHeader.js.map +1 -1
- package/build/lib/native/components/ActionList/ActionList.js +3 -1
- package/build/lib/native/components/ActionList/ActionList.js.map +1 -1
- package/build/lib/native/components/ActionList/ActionListItem.js +3 -2
- package/build/lib/native/components/ActionList/ActionListItem.js.map +1 -1
- package/build/lib/native/components/Alert/Alert.js +2 -1
- package/build/lib/native/components/Alert/Alert.js.map +1 -1
- package/build/lib/native/components/Amount/Amount.js +2 -1
- package/build/lib/native/components/Amount/Amount.js.map +1 -1
- package/build/lib/native/components/Badge/Badge.js +2 -1
- package/build/lib/native/components/Badge/Badge.js.map +1 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseFooter.js +3 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseFooter.js.map +1 -1
- package/build/lib/native/components/BaseHeaderFooter/BaseHeader.js +3 -2
- package/build/lib/native/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/native/components/Box/BaseBox/types/propsTypes.js.map +1 -1
- package/build/lib/native/components/Box/Box.js +2 -1
- package/build/lib/native/components/Box/Box.js.map +1 -1
- package/build/lib/native/components/Button/BaseButton/BaseButton.js +2 -1
- package/build/lib/native/components/Button/BaseButton/BaseButton.js.map +1 -1
- package/build/lib/native/components/Button/Button/Button.js +2 -1
- package/build/lib/native/components/Button/Button/Button.js.map +1 -1
- package/build/lib/native/components/Button/IconButton/IconButton.js +3 -1
- package/build/lib/native/components/Button/IconButton/IconButton.js.map +1 -1
- package/build/lib/native/components/Card/Card.js +2 -1
- package/build/lib/native/components/Card/Card.js.map +1 -1
- package/build/lib/native/components/Card/CardFooter.js +3 -2
- package/build/lib/native/components/Card/CardFooter.js.map +1 -1
- package/build/lib/native/components/Card/CardHeader.js +3 -2
- package/build/lib/native/components/Card/CardHeader.js.map +1 -1
- package/build/lib/native/components/Checkbox/Checkbox.js +3 -2
- package/build/lib/native/components/Checkbox/Checkbox.js.map +1 -1
- package/build/lib/native/components/Checkbox/CheckboxGroup/CheckboxGroup.js +2 -1
- package/build/lib/native/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/build/lib/native/components/Chip/Chip.js +2 -1
- package/build/lib/native/components/Chip/Chip.js.map +1 -1
- package/build/lib/native/components/Chip/ChipGroup.js +2 -1
- package/build/lib/native/components/Chip/ChipGroup.js.map +1 -1
- package/build/lib/native/components/Collapsible/Collapsible.js +2 -1
- package/build/lib/native/components/Collapsible/Collapsible.js.map +1 -1
- package/build/lib/native/components/Collapsible/CollapsibleBody.js +3 -1
- package/build/lib/native/components/Collapsible/CollapsibleBody.js.map +1 -1
- package/build/lib/native/components/Collapsible/CollapsibleButton.js +3 -1
- package/build/lib/native/components/Collapsible/CollapsibleButton.js.map +1 -1
- package/build/lib/native/components/Collapsible/CollapsibleLink.js +2 -1
- package/build/lib/native/components/Collapsible/CollapsibleLink.js.map +1 -1
- package/build/lib/native/components/Counter/Counter.js +2 -1
- package/build/lib/native/components/Counter/Counter.js.map +1 -1
- package/build/lib/native/components/Dropdown/Dropdown.js +2 -1
- package/build/lib/native/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/native/components/Dropdown/DropdownButton.js +1 -1
- package/build/lib/native/components/Dropdown/DropdownButton.js.map +1 -1
- package/build/lib/native/components/Dropdown/DropdownHeaderFooter.js +3 -1
- package/build/lib/native/components/Dropdown/DropdownHeaderFooter.js.map +1 -1
- package/build/lib/native/components/Dropdown/DropdownLink.js +2 -1
- package/build/lib/native/components/Dropdown/DropdownLink.js.map +1 -1
- package/build/lib/native/components/Form/Selector/SelectorGroupField.js +3 -1
- package/build/lib/native/components/Form/Selector/SelectorGroupField.js.map +1 -1
- package/build/lib/native/components/Indicator/Indicator.js +2 -1
- package/build/lib/native/components/Indicator/Indicator.js.map +1 -1
- package/build/lib/native/components/Input/BaseInput/BaseInput.js +2 -1
- package/build/lib/native/components/Input/BaseInput/BaseInput.js.map +1 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js +2 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js.map +1 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/SelectInput.js +2 -1
- package/build/lib/native/components/Input/DropdownInputTriggers/SelectInput.js.map +1 -1
- package/build/lib/native/components/Input/OTPInput/OTPInput.js +2 -1
- package/build/lib/native/components/Input/OTPInput/OTPInput.js.map +1 -1
- package/build/lib/native/components/Input/PasswordInput/PasswordInput.js +1 -1
- package/build/lib/native/components/Input/PasswordInput/PasswordInput.js.map +1 -1
- package/build/lib/native/components/Input/SearchInput/SearchInput.js +1 -1
- package/build/lib/native/components/Input/SearchInput/SearchInput.js.map +1 -1
- package/build/lib/native/components/Input/TextArea/TextArea.js +1 -1
- package/build/lib/native/components/Input/TextArea/TextArea.js.map +1 -1
- package/build/lib/native/components/Input/TextInput/TextInput.js +1 -1
- package/build/lib/native/components/Input/TextInput/TextInput.js.map +1 -1
- package/build/lib/native/components/Link/BaseLink/BaseLink.js +2 -1
- package/build/lib/native/components/Link/BaseLink/BaseLink.js.map +1 -1
- package/build/lib/native/components/Link/Link/Link.js +2 -1
- package/build/lib/native/components/Link/Link/Link.js.map +1 -1
- package/build/lib/native/components/ProgressBar/ProgressBar.js +2 -1
- package/build/lib/native/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/native/components/Radio/Radio.js +2 -1
- package/build/lib/native/components/Radio/Radio.js.map +1 -1
- package/build/lib/native/components/Radio/RadioGroup/RadioGroup.js +2 -1
- package/build/lib/native/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
- package/build/lib/native/components/StepGroup/tokens.js +1 -1
- package/build/lib/native/components/StepGroup/tokens.js.map +1 -1
- package/build/lib/native/components/Switch/Switch.js +2 -1
- package/build/lib/native/components/Switch/Switch.js.map +1 -1
- package/build/lib/native/components/Tag/Tag.js +2 -1
- package/build/lib/native/components/Tag/Tag.js.map +1 -1
- package/build/lib/native/tokens/global/size.js +1 -1
- package/build/lib/native/tokens/global/size.js.map +1 -1
- package/build/lib/native/utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js +7 -0
- package/build/lib/native/utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js.map +1 -0
- package/build/lib/web/development/components/Accordion/Accordion.js +5 -3
- package/build/lib/web/development/components/Accordion/Accordion.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionButton.web.js +8 -3
- package/build/lib/web/development/components/Accordion/AccordionButton.web.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionItem.js +8 -3
- package/build/lib/web/development/components/Accordion/AccordionItem.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionItemBody.js +8 -3
- package/build/lib/web/development/components/Accordion/AccordionItemBody.js.map +1 -1
- package/build/lib/web/development/components/Accordion/AccordionItemHeader.js +10 -4
- package/build/lib/web/development/components/Accordion/AccordionItemHeader.js.map +1 -1
- package/build/lib/web/development/components/ActionList/ActionList.js +9 -4
- package/build/lib/web/development/components/ActionList/ActionList.js.map +1 -1
- package/build/lib/web/development/components/ActionList/ActionListBox.web.js +8 -3
- package/build/lib/web/development/components/ActionList/ActionListBox.web.js.map +1 -1
- package/build/lib/web/development/components/ActionList/ActionListItem.js +10 -5
- package/build/lib/web/development/components/ActionList/ActionListItem.js.map +1 -1
- package/build/lib/web/development/components/Alert/Alert.js +5 -3
- package/build/lib/web/development/components/Alert/Alert.js.map +1 -1
- package/build/lib/web/development/components/Amount/Amount.js +5 -8
- package/build/lib/web/development/components/Amount/Amount.js.map +1 -1
- package/build/lib/web/development/components/Avatar/Avatar.web.js +5 -3
- package/build/lib/web/development/components/Avatar/Avatar.web.js.map +1 -1
- package/build/lib/web/development/components/Avatar/AvatarGroup.web.js +5 -3
- package/build/lib/web/development/components/Avatar/AvatarGroup.web.js.map +1 -1
- package/build/lib/web/development/components/Badge/Badge.js +5 -3
- package/build/lib/web/development/components/Badge/Badge.js.map +1 -1
- package/build/lib/web/development/components/BaseHeaderFooter/BaseFooter.js +8 -3
- package/build/lib/web/development/components/BaseHeaderFooter/BaseFooter.js.map +1 -1
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js +8 -3
- package/build/lib/web/development/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/development/components/BottomNav/BottomNav.web.js +12 -8
- package/build/lib/web/development/components/BottomNav/BottomNav.web.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheet.web.js +9 -3
- package/build/lib/web/development/components/BottomSheet/BottomSheet.web.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheetBody.web.js +8 -3
- package/build/lib/web/development/components/BottomSheet/BottomSheetBody.web.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheetFooter.web.js +8 -3
- package/build/lib/web/development/components/BottomSheet/BottomSheetFooter.web.js.map +1 -1
- package/build/lib/web/development/components/BottomSheet/BottomSheetHeader.web.js +8 -3
- package/build/lib/web/development/components/BottomSheet/BottomSheetHeader.web.js.map +1 -1
- package/build/lib/web/development/components/Box/BaseBox/BaseBox.web.js +4 -2
- package/build/lib/web/development/components/Box/BaseBox/BaseBox.web.js.map +1 -1
- package/build/lib/web/development/components/Box/BaseBox/types/propsTypes.js.map +1 -1
- package/build/lib/web/development/components/Box/Box.js +4 -2
- package/build/lib/web/development/components/Box/Box.js.map +1 -1
- package/build/lib/web/development/components/Breadcrumb/Breadcrumb.web.js +6 -4
- package/build/lib/web/development/components/Breadcrumb/Breadcrumb.web.js.map +1 -1
- package/build/lib/web/development/components/Breadcrumb/BreadcrumbItem.web.js +13 -4
- package/build/lib/web/development/components/Breadcrumb/BreadcrumbItem.web.js.map +1 -1
- package/build/lib/web/development/components/Button/BaseButton/BaseButton.js +4 -2
- package/build/lib/web/development/components/Button/BaseButton/BaseButton.js.map +1 -1
- package/build/lib/web/development/components/Button/Button/Button.js +4 -2
- package/build/lib/web/development/components/Button/Button/Button.js.map +1 -1
- package/build/lib/web/development/components/Button/IconButton/IconButton.js +11 -5
- package/build/lib/web/development/components/Button/IconButton/IconButton.js.map +1 -1
- package/build/lib/web/development/components/Button/IconButton/StyledIconButton.web.js +8 -3
- package/build/lib/web/development/components/Button/IconButton/StyledIconButton.web.js.map +1 -1
- package/build/lib/web/development/components/ButtonGroup/ButtonGroup.web.js +5 -3
- package/build/lib/web/development/components/ButtonGroup/ButtonGroup.web.js.map +1 -1
- package/build/lib/web/development/components/Card/Card.js +11 -7
- package/build/lib/web/development/components/Card/Card.js.map +1 -1
- package/build/lib/web/development/components/Card/CardFooter.js +22 -11
- package/build/lib/web/development/components/Card/CardFooter.js.map +1 -1
- package/build/lib/web/development/components/Card/CardHeader.js +13 -6
- package/build/lib/web/development/components/Card/CardHeader.js.map +1 -1
- package/build/lib/web/development/components/Carousel/Carousel.web.js +5 -3
- package/build/lib/web/development/components/Carousel/Carousel.web.js.map +1 -1
- package/build/lib/web/development/components/Carousel/CarouselItem.web.js +9 -3
- package/build/lib/web/development/components/Carousel/CarouselItem.web.js.map +1 -1
- package/build/lib/web/development/components/Checkbox/Checkbox.js +6 -4
- package/build/lib/web/development/components/Checkbox/Checkbox.js.map +1 -1
- package/build/lib/web/development/components/Checkbox/CheckboxGroup/CheckboxGroup.js +8 -5
- package/build/lib/web/development/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/build/lib/web/development/components/Chip/Chip.js +5 -3
- package/build/lib/web/development/components/Chip/Chip.js.map +1 -1
- package/build/lib/web/development/components/Chip/ChipGroup.js +8 -5
- package/build/lib/web/development/components/Chip/ChipGroup.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/Collapsible.js +5 -3
- package/build/lib/web/development/components/Collapsible/Collapsible.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleBody.js +8 -3
- package/build/lib/web/development/components/Collapsible/CollapsibleBody.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleButton.js +13 -4
- package/build/lib/web/development/components/Collapsible/CollapsibleButton.js.map +1 -1
- package/build/lib/web/development/components/Collapsible/CollapsibleLink.js +5 -3
- package/build/lib/web/development/components/Collapsible/CollapsibleLink.js.map +1 -1
- package/build/lib/web/development/components/Counter/Counter.js +5 -3
- package/build/lib/web/development/components/Counter/Counter.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/DateInput.web.js +11 -7
- package/build/lib/web/development/components/DatePicker/DateInput.web.js.map +1 -1
- package/build/lib/web/development/components/DatePicker/DatePicker.web.js +4 -2
- package/build/lib/web/development/components/DatePicker/DatePicker.web.js.map +1 -1
- package/build/lib/web/development/components/Drawer/Drawer.web.js +8 -3
- package/build/lib/web/development/components/Drawer/Drawer.web.js.map +1 -1
- package/build/lib/web/development/components/Drawer/DrawerSubcomponents.web.js +11 -3
- package/build/lib/web/development/components/Drawer/DrawerSubcomponents.web.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/Dropdown.js +5 -3
- package/build/lib/web/development/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/DropdownButton.js +2 -2
- package/build/lib/web/development/components/Dropdown/DropdownButton.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/DropdownHeaderFooter.js +8 -3
- package/build/lib/web/development/components/Dropdown/DropdownHeaderFooter.js.map +1 -1
- package/build/lib/web/development/components/Dropdown/DropdownLink.js +5 -3
- package/build/lib/web/development/components/Dropdown/DropdownLink.js.map +1 -1
- package/build/lib/web/development/components/FileUpload/FileUpload.web.js +6 -4
- package/build/lib/web/development/components/FileUpload/FileUpload.web.js.map +1 -1
- package/build/lib/web/development/components/Form/Selector/SelectorGroupField.js +8 -3
- package/build/lib/web/development/components/Form/Selector/SelectorGroupField.js.map +1 -1
- package/build/lib/web/development/components/Form/Selector/SelectorInput.web.js +8 -3
- package/build/lib/web/development/components/Form/Selector/SelectorInput.web.js.map +1 -1
- package/build/lib/web/development/components/Indicator/Indicator.js +5 -3
- package/build/lib/web/development/components/Indicator/Indicator.js.map +1 -1
- package/build/lib/web/development/components/Input/BaseInput/BaseInput.js +6 -4
- package/build/lib/web/development/components/Input/BaseInput/BaseInput.js.map +1 -1
- package/build/lib/web/development/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js +5 -2
- package/build/lib/web/development/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js.map +1 -1
- package/build/lib/web/development/components/Input/DropdownInputTriggers/SelectInput.js +5 -3
- package/build/lib/web/development/components/Input/DropdownInputTriggers/SelectInput.js.map +1 -1
- package/build/lib/web/development/components/Input/OTPInput/OTPInput.js +6 -4
- package/build/lib/web/development/components/Input/OTPInput/OTPInput.js.map +1 -1
- package/build/lib/web/development/components/Input/PasswordInput/PasswordInput.js +2 -2
- package/build/lib/web/development/components/Input/PasswordInput/PasswordInput.js.map +1 -1
- package/build/lib/web/development/components/Input/PhoneNumberInput/PhoneNumberInput.web.js +2 -2
- package/build/lib/web/development/components/Input/PhoneNumberInput/PhoneNumberInput.web.js.map +1 -1
- package/build/lib/web/development/components/Input/SearchInput/SearchInput.js +2 -2
- package/build/lib/web/development/components/Input/SearchInput/SearchInput.js.map +1 -1
- package/build/lib/web/development/components/Input/TextArea/TextArea.js +2 -2
- package/build/lib/web/development/components/Input/TextArea/TextArea.js.map +1 -1
- package/build/lib/web/development/components/Input/TextInput/TextInput.js +2 -2
- package/build/lib/web/development/components/Input/TextInput/TextInput.js.map +1 -1
- package/build/lib/web/development/components/Link/BaseLink/BaseLink.js +5 -3
- package/build/lib/web/development/components/Link/BaseLink/BaseLink.js.map +1 -1
- package/build/lib/web/development/components/Link/Link/Link.js +4 -2
- package/build/lib/web/development/components/Link/Link/Link.js.map +1 -1
- package/build/lib/web/development/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js +18 -8
- package/build/lib/web/development/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js.map +1 -1
- package/build/lib/web/development/components/Modal/Modal.web.js +10 -4
- package/build/lib/web/development/components/Modal/Modal.web.js.map +1 -1
- package/build/lib/web/development/components/Modal/ModalBody.web.js +9 -3
- package/build/lib/web/development/components/Modal/ModalBody.web.js.map +1 -1
- package/build/lib/web/development/components/Modal/ModalFooter.web.js +7 -2
- package/build/lib/web/development/components/Modal/ModalFooter.web.js.map +1 -1
- package/build/lib/web/development/components/Modal/ModalHeader.web.js +14 -6
- package/build/lib/web/development/components/Modal/ModalHeader.web.js.map +1 -1
- package/build/lib/web/development/components/Popover/Popover.web.js +8 -3
- package/build/lib/web/development/components/Popover/Popover.web.js.map +1 -1
- package/build/lib/web/development/components/Popover/PopoverInteractiveWrapper.web.js.map +1 -1
- package/build/lib/web/development/components/ProgressBar/ProgressBar.js +5 -3
- package/build/lib/web/development/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/web/development/components/Radio/Radio.js +6 -4
- package/build/lib/web/development/components/Radio/Radio.js.map +1 -1
- package/build/lib/web/development/components/Radio/RadioGroup/RadioGroup.js +8 -5
- package/build/lib/web/development/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNav.web.js +5 -3
- package/build/lib/web/development/components/SideNav/SideNav.web.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavItem.web.js +13 -4
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavItem.web.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavLink.web.js +10 -4
- package/build/lib/web/development/components/SideNav/SideNavItems/SideNavLink.web.js.map +1 -1
- package/build/lib/web/development/components/SideNav/SideNavSection.web.js +10 -4
- package/build/lib/web/development/components/SideNav/SideNavSection.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepGroup.web.js +5 -3
- package/build/lib/web/development/components/StepGroup/StepGroup.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepItem.web.js +13 -7
- package/build/lib/web/development/components/StepGroup/StepItem.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/StepLine.web.js +79 -42
- package/build/lib/web/development/components/StepGroup/StepLine.web.js.map +1 -1
- package/build/lib/web/development/components/StepGroup/tokens.js +6 -6
- package/build/lib/web/development/components/StepGroup/tokens.js.map +1 -1
- package/build/lib/web/development/components/Switch/Switch.js +5 -3
- package/build/lib/web/development/components/Switch/Switch.js.map +1 -1
- package/build/lib/web/development/components/Table/Table.web.js +9 -7
- package/build/lib/web/development/components/Table/Table.web.js.map +1 -1
- package/build/lib/web/development/components/Table/TableBody.web.js +18 -9
- package/build/lib/web/development/components/Table/TableBody.web.js.map +1 -1
- package/build/lib/web/development/components/Table/TableFooter.web.js +18 -9
- package/build/lib/web/development/components/Table/TableFooter.web.js.map +1 -1
- package/build/lib/web/development/components/Table/TableHeader.web.js +18 -9
- package/build/lib/web/development/components/Table/TableHeader.web.js.map +1 -1
- package/build/lib/web/development/components/Table/TablePagination.web.js +10 -4
- package/build/lib/web/development/components/Table/TablePagination.web.js.map +1 -1
- package/build/lib/web/development/components/Table/TableToolbar.web.js +13 -8
- package/build/lib/web/development/components/Table/TableToolbar.web.js.map +1 -1
- package/build/lib/web/development/components/Tabs/TabItem.web.js +9 -5
- package/build/lib/web/development/components/Tabs/TabItem.web.js.map +1 -1
- package/build/lib/web/development/components/Tabs/TabList.web.js +5 -3
- package/build/lib/web/development/components/Tabs/TabList.web.js.map +1 -1
- package/build/lib/web/development/components/Tabs/TabPanel.web.js +10 -5
- package/build/lib/web/development/components/Tabs/TabPanel.web.js.map +1 -1
- package/build/lib/web/development/components/Tabs/Tabs.web.js +8 -3
- package/build/lib/web/development/components/Tabs/Tabs.web.js.map +1 -1
- package/build/lib/web/development/components/Tag/Tag.js +6 -4
- package/build/lib/web/development/components/Tag/Tag.js.map +1 -1
- package/build/lib/web/development/components/Toast/ToastContainer.web.js +8 -3
- package/build/lib/web/development/components/Toast/ToastContainer.web.js.map +1 -1
- package/build/lib/web/development/components/Tooltip/Tooltip.web.js +8 -3
- package/build/lib/web/development/components/Tooltip/Tooltip.web.js.map +1 -1
- package/build/lib/web/development/components/TopNav/TabNav/TabNav.web.js +6 -3
- package/build/lib/web/development/components/TopNav/TabNav/TabNav.web.js.map +1 -1
- package/build/lib/web/development/components/TopNav/TopNav.web.js +8 -5
- package/build/lib/web/development/components/TopNav/TopNav.web.js.map +1 -1
- package/build/lib/web/development/tokens/global/size.js +3 -1
- package/build/lib/web/development/tokens/global/size.js.map +1 -1
- package/build/lib/web/development/utils/makeAnalyticsAttribute/index.js +2 -0
- package/build/lib/web/development/utils/makeAnalyticsAttribute/index.js.map +1 -0
- package/build/lib/web/development/utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js +20 -0
- package/build/lib/web/development/utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js.map +1 -0
- package/build/lib/web/production/components/Accordion/Accordion.js +5 -3
- package/build/lib/web/production/components/Accordion/Accordion.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionButton.web.js +8 -3
- package/build/lib/web/production/components/Accordion/AccordionButton.web.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionItem.js +8 -3
- package/build/lib/web/production/components/Accordion/AccordionItem.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionItemBody.js +8 -3
- package/build/lib/web/production/components/Accordion/AccordionItemBody.js.map +1 -1
- package/build/lib/web/production/components/Accordion/AccordionItemHeader.js +10 -4
- package/build/lib/web/production/components/Accordion/AccordionItemHeader.js.map +1 -1
- package/build/lib/web/production/components/ActionList/ActionList.js +9 -4
- package/build/lib/web/production/components/ActionList/ActionList.js.map +1 -1
- package/build/lib/web/production/components/ActionList/ActionListBox.web.js +8 -3
- package/build/lib/web/production/components/ActionList/ActionListBox.web.js.map +1 -1
- package/build/lib/web/production/components/ActionList/ActionListItem.js +10 -5
- package/build/lib/web/production/components/ActionList/ActionListItem.js.map +1 -1
- package/build/lib/web/production/components/Alert/Alert.js +5 -3
- package/build/lib/web/production/components/Alert/Alert.js.map +1 -1
- package/build/lib/web/production/components/Amount/Amount.js +5 -8
- package/build/lib/web/production/components/Amount/Amount.js.map +1 -1
- package/build/lib/web/production/components/Avatar/Avatar.web.js +5 -3
- package/build/lib/web/production/components/Avatar/Avatar.web.js.map +1 -1
- package/build/lib/web/production/components/Avatar/AvatarGroup.web.js +5 -3
- package/build/lib/web/production/components/Avatar/AvatarGroup.web.js.map +1 -1
- package/build/lib/web/production/components/Badge/Badge.js +5 -3
- package/build/lib/web/production/components/Badge/Badge.js.map +1 -1
- package/build/lib/web/production/components/BaseHeaderFooter/BaseFooter.js +8 -3
- package/build/lib/web/production/components/BaseHeaderFooter/BaseFooter.js.map +1 -1
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js +8 -3
- package/build/lib/web/production/components/BaseHeaderFooter/BaseHeader.js.map +1 -1
- package/build/lib/web/production/components/BottomNav/BottomNav.web.js +12 -8
- package/build/lib/web/production/components/BottomNav/BottomNav.web.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheet.web.js +9 -3
- package/build/lib/web/production/components/BottomSheet/BottomSheet.web.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheetBody.web.js +8 -3
- package/build/lib/web/production/components/BottomSheet/BottomSheetBody.web.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheetFooter.web.js +8 -3
- package/build/lib/web/production/components/BottomSheet/BottomSheetFooter.web.js.map +1 -1
- package/build/lib/web/production/components/BottomSheet/BottomSheetHeader.web.js +8 -3
- package/build/lib/web/production/components/BottomSheet/BottomSheetHeader.web.js.map +1 -1
- package/build/lib/web/production/components/Box/BaseBox/BaseBox.web.js +4 -2
- package/build/lib/web/production/components/Box/BaseBox/BaseBox.web.js.map +1 -1
- package/build/lib/web/production/components/Box/BaseBox/types/propsTypes.js.map +1 -1
- package/build/lib/web/production/components/Box/Box.js +4 -2
- package/build/lib/web/production/components/Box/Box.js.map +1 -1
- package/build/lib/web/production/components/Breadcrumb/Breadcrumb.web.js +6 -4
- package/build/lib/web/production/components/Breadcrumb/Breadcrumb.web.js.map +1 -1
- package/build/lib/web/production/components/Breadcrumb/BreadcrumbItem.web.js +13 -4
- package/build/lib/web/production/components/Breadcrumb/BreadcrumbItem.web.js.map +1 -1
- package/build/lib/web/production/components/Button/BaseButton/BaseButton.js +4 -2
- package/build/lib/web/production/components/Button/BaseButton/BaseButton.js.map +1 -1
- package/build/lib/web/production/components/Button/Button/Button.js +4 -2
- package/build/lib/web/production/components/Button/Button/Button.js.map +1 -1
- package/build/lib/web/production/components/Button/IconButton/IconButton.js +11 -5
- package/build/lib/web/production/components/Button/IconButton/IconButton.js.map +1 -1
- package/build/lib/web/production/components/Button/IconButton/StyledIconButton.web.js +8 -3
- package/build/lib/web/production/components/Button/IconButton/StyledIconButton.web.js.map +1 -1
- package/build/lib/web/production/components/ButtonGroup/ButtonGroup.web.js +5 -3
- package/build/lib/web/production/components/ButtonGroup/ButtonGroup.web.js.map +1 -1
- package/build/lib/web/production/components/Card/Card.js +11 -7
- package/build/lib/web/production/components/Card/Card.js.map +1 -1
- package/build/lib/web/production/components/Card/CardFooter.js +22 -11
- package/build/lib/web/production/components/Card/CardFooter.js.map +1 -1
- package/build/lib/web/production/components/Card/CardHeader.js +13 -6
- package/build/lib/web/production/components/Card/CardHeader.js.map +1 -1
- package/build/lib/web/production/components/Carousel/Carousel.web.js +5 -3
- package/build/lib/web/production/components/Carousel/Carousel.web.js.map +1 -1
- package/build/lib/web/production/components/Carousel/CarouselItem.web.js +9 -3
- package/build/lib/web/production/components/Carousel/CarouselItem.web.js.map +1 -1
- package/build/lib/web/production/components/Checkbox/Checkbox.js +6 -4
- package/build/lib/web/production/components/Checkbox/Checkbox.js.map +1 -1
- package/build/lib/web/production/components/Checkbox/CheckboxGroup/CheckboxGroup.js +8 -5
- package/build/lib/web/production/components/Checkbox/CheckboxGroup/CheckboxGroup.js.map +1 -1
- package/build/lib/web/production/components/Chip/Chip.js +5 -3
- package/build/lib/web/production/components/Chip/Chip.js.map +1 -1
- package/build/lib/web/production/components/Chip/ChipGroup.js +8 -5
- package/build/lib/web/production/components/Chip/ChipGroup.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/Collapsible.js +5 -3
- package/build/lib/web/production/components/Collapsible/Collapsible.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleBody.js +8 -3
- package/build/lib/web/production/components/Collapsible/CollapsibleBody.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleButton.js +13 -4
- package/build/lib/web/production/components/Collapsible/CollapsibleButton.js.map +1 -1
- package/build/lib/web/production/components/Collapsible/CollapsibleLink.js +5 -3
- package/build/lib/web/production/components/Collapsible/CollapsibleLink.js.map +1 -1
- package/build/lib/web/production/components/Counter/Counter.js +5 -3
- package/build/lib/web/production/components/Counter/Counter.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/DateInput.web.js +11 -7
- package/build/lib/web/production/components/DatePicker/DateInput.web.js.map +1 -1
- package/build/lib/web/production/components/DatePicker/DatePicker.web.js +4 -2
- package/build/lib/web/production/components/DatePicker/DatePicker.web.js.map +1 -1
- package/build/lib/web/production/components/Drawer/Drawer.web.js +8 -3
- package/build/lib/web/production/components/Drawer/Drawer.web.js.map +1 -1
- package/build/lib/web/production/components/Drawer/DrawerSubcomponents.web.js +11 -3
- package/build/lib/web/production/components/Drawer/DrawerSubcomponents.web.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/Dropdown.js +5 -3
- package/build/lib/web/production/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/DropdownButton.js +2 -2
- package/build/lib/web/production/components/Dropdown/DropdownButton.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/DropdownHeaderFooter.js +8 -3
- package/build/lib/web/production/components/Dropdown/DropdownHeaderFooter.js.map +1 -1
- package/build/lib/web/production/components/Dropdown/DropdownLink.js +5 -3
- package/build/lib/web/production/components/Dropdown/DropdownLink.js.map +1 -1
- package/build/lib/web/production/components/FileUpload/FileUpload.web.js +6 -4
- package/build/lib/web/production/components/FileUpload/FileUpload.web.js.map +1 -1
- package/build/lib/web/production/components/Form/Selector/SelectorGroupField.js +8 -3
- package/build/lib/web/production/components/Form/Selector/SelectorGroupField.js.map +1 -1
- package/build/lib/web/production/components/Form/Selector/SelectorInput.web.js +8 -3
- package/build/lib/web/production/components/Form/Selector/SelectorInput.web.js.map +1 -1
- package/build/lib/web/production/components/Indicator/Indicator.js +5 -3
- package/build/lib/web/production/components/Indicator/Indicator.js.map +1 -1
- package/build/lib/web/production/components/Input/BaseInput/BaseInput.js +6 -4
- package/build/lib/web/production/components/Input/BaseInput/BaseInput.js.map +1 -1
- package/build/lib/web/production/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js +5 -2
- package/build/lib/web/production/components/Input/DropdownInputTriggers/BaseDropdownInputTrigger.js.map +1 -1
- package/build/lib/web/production/components/Input/DropdownInputTriggers/SelectInput.js +5 -3
- package/build/lib/web/production/components/Input/DropdownInputTriggers/SelectInput.js.map +1 -1
- package/build/lib/web/production/components/Input/OTPInput/OTPInput.js +6 -4
- package/build/lib/web/production/components/Input/OTPInput/OTPInput.js.map +1 -1
- package/build/lib/web/production/components/Input/PasswordInput/PasswordInput.js +2 -2
- package/build/lib/web/production/components/Input/PasswordInput/PasswordInput.js.map +1 -1
- package/build/lib/web/production/components/Input/PhoneNumberInput/PhoneNumberInput.web.js +2 -2
- package/build/lib/web/production/components/Input/PhoneNumberInput/PhoneNumberInput.web.js.map +1 -1
- package/build/lib/web/production/components/Input/SearchInput/SearchInput.js +2 -2
- package/build/lib/web/production/components/Input/SearchInput/SearchInput.js.map +1 -1
- package/build/lib/web/production/components/Input/TextArea/TextArea.js +2 -2
- package/build/lib/web/production/components/Input/TextArea/TextArea.js.map +1 -1
- package/build/lib/web/production/components/Input/TextInput/TextInput.js +2 -2
- package/build/lib/web/production/components/Input/TextInput/TextInput.js.map +1 -1
- package/build/lib/web/production/components/Link/BaseLink/BaseLink.js +5 -3
- package/build/lib/web/production/components/Link/BaseLink/BaseLink.js.map +1 -1
- package/build/lib/web/production/components/Link/Link/Link.js +4 -2
- package/build/lib/web/production/components/Link/Link/Link.js.map +1 -1
- package/build/lib/web/production/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js +18 -8
- package/build/lib/web/production/components/Menu/VisualSubComponents/MenuHeaderFooter.web.js.map +1 -1
- package/build/lib/web/production/components/Modal/Modal.web.js +10 -4
- package/build/lib/web/production/components/Modal/Modal.web.js.map +1 -1
- package/build/lib/web/production/components/Modal/ModalBody.web.js +9 -3
- package/build/lib/web/production/components/Modal/ModalBody.web.js.map +1 -1
- package/build/lib/web/production/components/Modal/ModalFooter.web.js +7 -2
- package/build/lib/web/production/components/Modal/ModalFooter.web.js.map +1 -1
- package/build/lib/web/production/components/Modal/ModalHeader.web.js +14 -6
- package/build/lib/web/production/components/Modal/ModalHeader.web.js.map +1 -1
- package/build/lib/web/production/components/Popover/Popover.web.js +8 -3
- package/build/lib/web/production/components/Popover/Popover.web.js.map +1 -1
- package/build/lib/web/production/components/Popover/PopoverInteractiveWrapper.web.js.map +1 -1
- package/build/lib/web/production/components/ProgressBar/ProgressBar.js +5 -3
- package/build/lib/web/production/components/ProgressBar/ProgressBar.js.map +1 -1
- package/build/lib/web/production/components/Radio/Radio.js +6 -4
- package/build/lib/web/production/components/Radio/Radio.js.map +1 -1
- package/build/lib/web/production/components/Radio/RadioGroup/RadioGroup.js +8 -5
- package/build/lib/web/production/components/Radio/RadioGroup/RadioGroup.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNav.web.js +5 -3
- package/build/lib/web/production/components/SideNav/SideNav.web.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavItem.web.js +13 -4
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavItem.web.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavLink.web.js +10 -4
- package/build/lib/web/production/components/SideNav/SideNavItems/SideNavLink.web.js.map +1 -1
- package/build/lib/web/production/components/SideNav/SideNavSection.web.js +10 -4
- package/build/lib/web/production/components/SideNav/SideNavSection.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepGroup.web.js +5 -3
- package/build/lib/web/production/components/StepGroup/StepGroup.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepItem.web.js +13 -7
- package/build/lib/web/production/components/StepGroup/StepItem.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/StepLine.web.js +79 -42
- package/build/lib/web/production/components/StepGroup/StepLine.web.js.map +1 -1
- package/build/lib/web/production/components/StepGroup/tokens.js +6 -6
- package/build/lib/web/production/components/StepGroup/tokens.js.map +1 -1
- package/build/lib/web/production/components/Switch/Switch.js +5 -3
- package/build/lib/web/production/components/Switch/Switch.js.map +1 -1
- package/build/lib/web/production/components/Table/Table.web.js +9 -7
- package/build/lib/web/production/components/Table/Table.web.js.map +1 -1
- package/build/lib/web/production/components/Table/TableBody.web.js +18 -9
- package/build/lib/web/production/components/Table/TableBody.web.js.map +1 -1
- package/build/lib/web/production/components/Table/TableFooter.web.js +18 -9
- package/build/lib/web/production/components/Table/TableFooter.web.js.map +1 -1
- package/build/lib/web/production/components/Table/TableHeader.web.js +18 -9
- package/build/lib/web/production/components/Table/TableHeader.web.js.map +1 -1
- package/build/lib/web/production/components/Table/TablePagination.web.js +10 -4
- package/build/lib/web/production/components/Table/TablePagination.web.js.map +1 -1
- package/build/lib/web/production/components/Table/TableToolbar.web.js +13 -8
- package/build/lib/web/production/components/Table/TableToolbar.web.js.map +1 -1
- package/build/lib/web/production/components/Tabs/TabItem.web.js +9 -5
- package/build/lib/web/production/components/Tabs/TabItem.web.js.map +1 -1
- package/build/lib/web/production/components/Tabs/TabList.web.js +5 -3
- package/build/lib/web/production/components/Tabs/TabList.web.js.map +1 -1
- package/build/lib/web/production/components/Tabs/TabPanel.web.js +10 -5
- package/build/lib/web/production/components/Tabs/TabPanel.web.js.map +1 -1
- package/build/lib/web/production/components/Tabs/Tabs.web.js +8 -3
- package/build/lib/web/production/components/Tabs/Tabs.web.js.map +1 -1
- package/build/lib/web/production/components/Tag/Tag.js +6 -4
- package/build/lib/web/production/components/Tag/Tag.js.map +1 -1
- package/build/lib/web/production/components/Toast/ToastContainer.web.js +8 -3
- package/build/lib/web/production/components/Toast/ToastContainer.web.js.map +1 -1
- package/build/lib/web/production/components/Tooltip/Tooltip.web.js +8 -3
- package/build/lib/web/production/components/Tooltip/Tooltip.web.js.map +1 -1
- package/build/lib/web/production/components/TopNav/TabNav/TabNav.web.js +6 -3
- package/build/lib/web/production/components/TopNav/TabNav/TabNav.web.js.map +1 -1
- package/build/lib/web/production/components/TopNav/TopNav.web.js +8 -5
- package/build/lib/web/production/components/TopNav/TopNav.web.js.map +1 -1
- package/build/lib/web/production/tokens/global/size.js +3 -1
- package/build/lib/web/production/tokens/global/size.js.map +1 -1
- package/build/lib/web/production/utils/makeAnalyticsAttribute/index.js +2 -0
- package/build/lib/web/production/utils/makeAnalyticsAttribute/index.js.map +1 -0
- package/build/lib/web/production/utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js +20 -0
- package/build/lib/web/production/utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js.map +1 -0
- package/build/types/components/index.d.ts +221 -189
- package/build/types/components/index.native.d.ts +145 -131
- package/build/types/tokens/index.d.ts +3 -1
- package/build/types/tokens/index.native.d.ts +3 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","sources":["../../../../../../src/components/Input/TextInput/TextInput.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport type { TextInput as TextInputReactNative } from 'react-native';\nimport type { BaseInputProps } from '../BaseInput';\nimport { BaseInput } from '../BaseInput';\nimport { getKeyboardAndAutocompleteProps } from '../BaseInput/utils';\nimport type { TaggedInputProps } from '../BaseInput/useTaggedInput';\nimport { useTaggedInput } from '../BaseInput/useTaggedInput';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport type { IconComponent } from '~components/Icons';\nimport { CloseIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { CharacterCounter } from '~components/Form/CharacterCounter';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Spinner } from '~components/Spinner';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType } from '~utils';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type { BladeElementRef, BladeElementRefWithValue } from '~utils/types';\nimport { hintMarginTop } from '~components/Form/formTokens';\n\n// Users should use PasswordInput for input type password\ntype Type = Exclude<BaseInputProps['type'], 'password'>;\n\ntype TextInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'necessityIndicator'\n | 'validationState'\n | 'helpText'\n | 'errorText'\n | 'successText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'isRequired'\n | 'prefix'\n | 'suffix'\n | 'maxCharacters'\n | 'autoFocus'\n | 'keyboardReturnKeyType'\n | 'autoCompleteSuggestionType'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | 'leadingIcon'\n | 'trailingButton'\n | 'trailingIcon'\n | 'textAlign'\n> & {\n /**\n * Decides whether to render a clear icon button\n */\n showClearButton?: boolean;\n\n /**\n * Event handler to handle the onClick event for clear button. Used when `showClearButton` is `true`\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n\n /**\n * Icon that will be rendered at the beginning of the input field\n * @deprecated Use `leadingIcon` instead. This prop will be removed in the next major version.\n */\n icon?: IconComponent;\n /**\n * Type of Input Field to be rendered. Use `PasswordInput` for type `password`\n *\n *\n * **Note on number type**\n *\n * `type=\"number\"` internally uses `inputMode=\"numeric\"` instead of HTML's `type=\"number\"` which also allows text characters.\n * If you have a usecase where you only want to support number input, you can handle it on validations end.\n *\n * Check out [Why the GOV.UK Design System team changed the input type for numbers](https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/) for reasoning\n *\n * @default text\n */\n type?: Type;\n} & TaggedInputProps &\n StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype TextInputPropsWithA11yLabel = {\n /**\n * Label to be shown for the input field\n */\n label?: undefined;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel: string;\n};\n\n/*\n Optional accessibilityLabel prop when label is provided\n*/\ntype TextInputPropsWithLabel = {\n /**\n * Label to be shown for the input field\n */\n label: string;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel?: string;\n};\n\ntype TextInputProps = (TextInputPropsWithA11yLabel | TextInputPropsWithLabel) &\n TextInputCommonProps;\n\n// need to do this to tell TS to infer type as TextInput of React Native and make it believe that `ref.current.clear()` exists\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isReactNative = (_textInputRef: any): _textInputRef is TextInputReactNative => {\n return getPlatformType() === 'react-native';\n};\n\nconst _TextInput: React.ForwardRefRenderFunction<BladeElementRef, TextInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n type = 'text',\n defaultValue,\n name,\n value,\n maxCharacters,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n necessityIndicator,\n validationState,\n errorText,\n helpText,\n successText,\n isRequired,\n icon,\n prefix,\n showClearButton,\n onClearButtonClick,\n isLoading,\n suffix,\n autoFocus,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n testID,\n size = 'medium',\n leadingIcon,\n trailingIcon,\n isTaggedInput,\n tags,\n onTagChange,\n ...styledProps\n },\n ref,\n): ReactElement => {\n const textInputRef = React.useRef<BladeElementRefWithValue>(null);\n const mergedRef = useMergeRefs(ref, textInputRef);\n const [shouldShowClearButton, setShouldShowClearButton] = useState(false);\n const [isInputFocussed, setIsInputFocussed] = useState(autoFocus ?? false);\n const {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n } = useTaggedInput({\n isTaggedInput,\n tags,\n onTagChange,\n isDisabled,\n onChange,\n name,\n value,\n inputRef: textInputRef,\n });\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(showClearButton && (defaultValue ?? value)));\n }, [showClearButton, defaultValue, value]);\n\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton) {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && textInputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (isReactNative(textInputRef.current)) {\n textInputRef.current.clear();\n textInputRef.current.focus();\n } else if (textInputRef.current instanceof HTMLInputElement) {\n textInputRef.current.value = '';\n textInputRef.current.focus();\n }\n }\n handleTagsClear();\n // if the input field is controlled just call the click handler and the value change shall be left upto the consumer\n onClearButtonClick?.();\n textInputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n }\n\n return null;\n };\n\n return (\n <BaseInput\n id=\"textinput\"\n componentName={MetaConstants.TextInput}\n ref={mergedRef}\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n maxCharacters={maxCharacters}\n isDropdownTrigger={isTaggedInput}\n tags={isTaggedInput ? getTags({ size }) : undefined}\n showAllTags={isInputFocussed}\n maxTagRows=\"single\"\n activeTagIndex={activeTagIndex}\n setActiveTagIndex={setActiveTagIndex}\n onChange={({ name, value }) => {\n if (showClearButton && value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n\n handleTaggedInputChange({ name, value });\n onChange?.({ name, value });\n }}\n onClick={onClick}\n onFocus={(e) => {\n setIsInputFocussed(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsInputFocussed(false);\n onBlur?.(e);\n }}\n onKeyDown={(e) => {\n handleTaggedInputKeydown(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n leadingIcon={leadingIcon ?? icon}\n prefix={prefix}\n trailingInteractionElement={renderInteractionElement()}\n trailingIcon={trailingIcon}\n suffix={suffix}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n trailingFooterSlot={(value) => {\n return maxCharacters ? (\n <BaseBox marginTop={hintMarginTop[size]} marginRight=\"spacing.1\">\n <CharacterCounter\n currentCount={value?.length ?? 0}\n maxCount={maxCharacters}\n size={size}\n />\n </BaseBox>\n ) : null;\n }}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n })}\n size={size}\n {...styledProps}\n />\n );\n};\n\nconst TextInput = assignWithoutSideEffects(React.forwardRef(_TextInput), {\n displayName: 'TextInput',\n});\n\nexport type { TextInputProps };\nexport { TextInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_TextInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","_ref$type","type","defaultValue","name","value","maxCharacters","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","necessityIndicator","validationState","errorText","helpText","successText","isRequired","icon","prefix","showClearButton","onClearButtonClick","isLoading","suffix","autoFocus","keyboardReturnKeyType","autoCompleteSuggestionType","autoCapitalize","testID","_ref$size","size","leadingIcon","trailingIcon","isTaggedInput","tags","onTagChange","styledProps","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isInputFocussed","setIsInputFocussed","_useTaggedInput","useTaggedInput","inputRef","activeTagIndex","setActiveTagIndex","getTags","handleTaggedInputKeydown","handleTaggedInputChange","handleTagsClear","useEffect","Boolean","renderInteractionElement","_jsx","Spinner","color","IconButton","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","BaseInput","Object","assign","id","componentName","MetaConstants","TextInput","hideLabelText","isDropdownTrigger","undefined","showAllTags","maxTagRows","_ref2","length","e","onKeyDown","trailingInteractionElement","trailingFooterSlot","_value$length","BaseBox","marginTop","hintMarginTop","marginRight","children","CharacterCounter","currentCount","maxCount","getKeyboardAndAutocompleteProps","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,eAAA,CAAA,aAAA,CAAA,MAAA,CAAA,cAAA,CAAA,MAAA,CAAA,OAAA,CAAA,eAAA,CAAA,UAAA,CAAA,SAAA,CAAA,SAAA,CAAA,QAAA,CAAA,UAAA,CAAA,YAAA,CAAA,oBAAA,CAAA,iBAAA,CAAA,WAAA,CAAA,UAAA,CAAA,aAAA,C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AC,CACK,CAAC,CACR,IAAI,CACV,CAAE,CAEFN,SAAS,CAAEA,SAAU,CACrBI,MAAM,CAAEA,MAAO,CAAA,CACX4E,+BAA+B,CAAC,CAClCvG,IAAI,CAAJA,IAAI,CACJwB,qBAAqB,CAArBA,qBAAqB,CACrBC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,cAAc,CAAdA,cACF,CAAC,CAAC,CACFG,CAAAA,IAAI,CAAEA,IAAK,EACPM,WAAW,CAChB,CAAC,CAEN,CAAC,CAEK,IAAA+C,SAAS,CAAGsB,wBAAwB,CAACjE,cAAK,CAACkE,UAAU,CAAClH,UAAU,CAAC,CAAE,CACvEmH,WAAW,CAAE,WACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"TextInput.js","sources":["../../../../../../src/components/Input/TextInput/TextInput.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { ReactElement, ReactNode } from 'react';\nimport type { TextInput as TextInputReactNative } from 'react-native';\nimport type { BaseInputProps } from '../BaseInput';\nimport { BaseInput } from '../BaseInput';\nimport { getKeyboardAndAutocompleteProps } from '../BaseInput/utils';\nimport type { TaggedInputProps } from '../BaseInput/useTaggedInput';\nimport { useTaggedInput } from '../BaseInput/useTaggedInput';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport type { IconComponent } from '~components/Icons';\nimport { CloseIcon } from '~components/Icons';\nimport { IconButton } from '~components/Button/IconButton';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { CharacterCounter } from '~components/Form/CharacterCounter';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Spinner } from '~components/Spinner';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType } from '~utils';\nimport { useMergeRefs } from '~utils/useMergeRefs';\nimport type {\n BladeElementRef,\n BladeElementRefWithValue,\n DataAnalyticsAttribute,\n} from '~utils/types';\nimport { hintMarginTop } from '~components/Form/formTokens';\n\n// Users should use PasswordInput for input type password\ntype Type = Exclude<BaseInputProps['type'], 'password'>;\n\ntype TextInputCommonProps = Pick<\n BaseInputProps,\n | 'label'\n | 'accessibilityLabel'\n | 'labelPosition'\n | 'necessityIndicator'\n | 'validationState'\n | 'helpText'\n | 'errorText'\n | 'successText'\n | 'placeholder'\n | 'defaultValue'\n | 'name'\n | 'onChange'\n | 'onFocus'\n | 'onBlur'\n | 'value'\n | 'isDisabled'\n | 'isRequired'\n | 'prefix'\n | 'suffix'\n | 'maxCharacters'\n | 'autoFocus'\n | 'keyboardReturnKeyType'\n | 'autoCompleteSuggestionType'\n | 'onSubmit'\n | 'autoCapitalize'\n | 'testID'\n | 'onClick'\n | 'size'\n | 'leadingIcon'\n | 'trailingButton'\n | 'trailingIcon'\n | 'textAlign'\n | keyof DataAnalyticsAttribute\n> & {\n /**\n * Decides whether to render a clear icon button\n */\n showClearButton?: boolean;\n\n /**\n * Event handler to handle the onClick event for clear button. Used when `showClearButton` is `true`\n */\n onClearButtonClick?: () => void;\n\n /**\n * Decides whether to show a loading spinner for the input field.\n */\n isLoading?: boolean;\n\n /**\n * Icon that will be rendered at the beginning of the input field\n * @deprecated Use `leadingIcon` instead. This prop will be removed in the next major version.\n */\n icon?: IconComponent;\n /**\n * Type of Input Field to be rendered. Use `PasswordInput` for type `password`\n *\n *\n * **Note on number type**\n *\n * `type=\"number\"` internally uses `inputMode=\"numeric\"` instead of HTML's `type=\"number\"` which also allows text characters.\n * If you have a usecase where you only want to support number input, you can handle it on validations end.\n *\n * Check out [Why the GOV.UK Design System team changed the input type for numbers](https://technology.blog.gov.uk/2020/02/24/why-the-gov-uk-design-system-team-changed-the-input-type-for-numbers/) for reasoning\n *\n * @default text\n */\n type?: Type;\n} & TaggedInputProps &\n StyledPropsBlade;\n\n/*\n Mandatory accessibilityLabel prop when label is not provided\n*/\ntype TextInputPropsWithA11yLabel = {\n /**\n * Label to be shown for the input field\n */\n label?: undefined;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel: string;\n};\n\n/*\n Optional accessibilityLabel prop when label is provided\n*/\ntype TextInputPropsWithLabel = {\n /**\n * Label to be shown for the input field\n */\n label: string;\n /**\n * Accessibility label for the input\n */\n accessibilityLabel?: string;\n};\n\ntype TextInputProps = (TextInputPropsWithA11yLabel | TextInputPropsWithLabel) &\n TextInputCommonProps;\n\n// need to do this to tell TS to infer type as TextInput of React Native and make it believe that `ref.current.clear()` exists\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isReactNative = (_textInputRef: any): _textInputRef is TextInputReactNative => {\n return getPlatformType() === 'react-native';\n};\n\nconst _TextInput: React.ForwardRefRenderFunction<BladeElementRef, TextInputProps> = (\n {\n label,\n accessibilityLabel,\n labelPosition = 'top',\n placeholder,\n type = 'text',\n defaultValue,\n name,\n value,\n maxCharacters,\n onChange,\n onClick,\n onFocus,\n onBlur,\n onSubmit,\n isDisabled,\n necessityIndicator,\n validationState,\n errorText,\n helpText,\n successText,\n isRequired,\n icon,\n prefix,\n showClearButton,\n onClearButtonClick,\n isLoading,\n suffix,\n autoFocus,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n testID,\n size = 'medium',\n leadingIcon,\n trailingIcon,\n isTaggedInput,\n tags,\n onTagChange,\n ...rest\n },\n ref,\n): ReactElement => {\n const textInputRef = React.useRef<BladeElementRefWithValue>(null);\n const mergedRef = useMergeRefs(ref, textInputRef);\n const [shouldShowClearButton, setShouldShowClearButton] = useState(false);\n const [isInputFocussed, setIsInputFocussed] = useState(autoFocus ?? false);\n const {\n activeTagIndex,\n setActiveTagIndex,\n getTags,\n handleTaggedInputKeydown,\n handleTaggedInputChange,\n handleTagsClear,\n } = useTaggedInput({\n isTaggedInput,\n tags,\n onTagChange,\n isDisabled,\n onChange,\n name,\n value,\n inputRef: textInputRef,\n });\n\n React.useEffect(() => {\n setShouldShowClearButton(Boolean(showClearButton && (defaultValue ?? value)));\n }, [showClearButton, defaultValue, value]);\n\n const renderInteractionElement = (): ReactNode => {\n if (isLoading) {\n return <Spinner accessibilityLabel=\"Loading Content\" color=\"primary\" />;\n }\n\n if (shouldShowClearButton) {\n return (\n <IconButton\n size=\"medium\"\n icon={CloseIcon}\n onClick={() => {\n if (isEmpty(value) && textInputRef.current) {\n // when the input field is uncontrolled take the ref and clear the input and then call the onClearButtonClick function\n if (isReactNative(textInputRef.current)) {\n textInputRef.current.clear();\n textInputRef.current.focus();\n } else if (textInputRef.current instanceof HTMLInputElement) {\n textInputRef.current.value = '';\n textInputRef.current.focus();\n }\n }\n handleTagsClear();\n // if the input field is controlled just call the click handler and the value change shall be left upto the consumer\n onClearButtonClick?.();\n textInputRef?.current?.focus();\n setShouldShowClearButton(false);\n }}\n isDisabled={isDisabled}\n accessibilityLabel=\"Clear Input Content\"\n />\n );\n }\n\n return null;\n };\n\n return (\n <BaseInput\n id=\"textinput\"\n componentName={MetaConstants.TextInput}\n ref={mergedRef}\n label={label as string}\n accessibilityLabel={accessibilityLabel}\n hideLabelText={!Boolean(label)}\n labelPosition={labelPosition}\n placeholder={placeholder}\n defaultValue={defaultValue}\n value={value}\n name={name}\n maxCharacters={maxCharacters}\n isDropdownTrigger={isTaggedInput}\n tags={isTaggedInput ? getTags({ size }) : undefined}\n showAllTags={isInputFocussed}\n maxTagRows=\"single\"\n activeTagIndex={activeTagIndex}\n setActiveTagIndex={setActiveTagIndex}\n onChange={({ name, value }) => {\n if (showClearButton && value?.length) {\n // show the clear button when the user starts typing in\n setShouldShowClearButton(true);\n }\n\n if (shouldShowClearButton && !value?.length) {\n // hide the clear button when the input field is empty\n setShouldShowClearButton(false);\n }\n\n handleTaggedInputChange({ name, value });\n onChange?.({ name, value });\n }}\n onClick={onClick}\n onFocus={(e) => {\n setIsInputFocussed(true);\n onFocus?.(e);\n }}\n onBlur={(e) => {\n setIsInputFocussed(false);\n onBlur?.(e);\n }}\n onKeyDown={(e) => {\n handleTaggedInputKeydown(e);\n }}\n onSubmit={onSubmit}\n isDisabled={isDisabled}\n necessityIndicator={necessityIndicator}\n isRequired={isRequired}\n leadingIcon={leadingIcon ?? icon}\n prefix={prefix}\n trailingInteractionElement={renderInteractionElement()}\n trailingIcon={trailingIcon}\n suffix={suffix}\n validationState={validationState}\n errorText={errorText}\n helpText={helpText}\n successText={successText}\n trailingFooterSlot={(value) => {\n return maxCharacters ? (\n <BaseBox marginTop={hintMarginTop[size]} marginRight=\"spacing.1\">\n <CharacterCounter\n currentCount={value?.length ?? 0}\n maxCount={maxCharacters}\n size={size}\n />\n </BaseBox>\n ) : null;\n }}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n testID={testID}\n {...getKeyboardAndAutocompleteProps({\n type,\n keyboardReturnKeyType,\n autoCompleteSuggestionType,\n autoCapitalize,\n })}\n size={size}\n {...rest}\n />\n );\n};\n\nconst TextInput = assignWithoutSideEffects(React.forwardRef(_TextInput), {\n displayName: 'TextInput',\n});\n\nexport type { TextInputProps };\nexport { TextInput };\n"],"names":["isReactNative","_textInputRef","getPlatformType","_TextInput","_ref","ref","label","accessibilityLabel","_ref$labelPosition","labelPosition","placeholder","_ref$type","type","defaultValue","name","value","maxCharacters","onChange","onClick","onFocus","onBlur","onSubmit","isDisabled","necessityIndicator","validationState","errorText","helpText","successText","isRequired","icon","prefix","showClearButton","onClearButtonClick","isLoading","suffix","autoFocus","keyboardReturnKeyType","autoCompleteSuggestionType","autoCapitalize","testID","_ref$size","size","leadingIcon","trailingIcon","isTaggedInput","tags","onTagChange","rest","_objectWithoutProperties","_excluded","textInputRef","React","useRef","mergedRef","useMergeRefs","_useState","useState","_useState2","_slicedToArray","shouldShowClearButton","setShouldShowClearButton","_useState3","_useState4","isInputFocussed","setIsInputFocussed","_useTaggedInput","useTaggedInput","inputRef","activeTagIndex","setActiveTagIndex","getTags","handleTaggedInputKeydown","handleTaggedInputChange","handleTagsClear","useEffect","Boolean","renderInteractionElement","_jsx","Spinner","color","IconButton","CloseIcon","_textInputRef$current","isEmpty","current","clear","focus","HTMLInputElement","BaseInput","Object","assign","id","componentName","MetaConstants","TextInput","hideLabelText","isDropdownTrigger","undefined","showAllTags","maxTagRows","_ref2","length","e","onKeyDown","trailingInteractionElement","trailingFooterSlot","_value$length","BaseBox","marginTop","hintMarginTop","marginRight","children","CharacterCounter","currentCount","maxCount","getKeyboardAndAutocompleteProps","assignWithoutSideEffects","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,oBAAA,CAAA,eAAA,CAAA,aAAA,CAAA,MAAA,CAAA,cAAA,CAAA,MAAA,CAAA,OAAA,CAAA,eAAA,CAAA,UAAA,CAAA,SAAA,CAAA,SAAA,CAAA,QAAA,CAAA,UAAA,CAAA,YAAA,CAAA,oBAAA,CAAA,iBAAA,CAAA,WAAA,CAAA,UAAA,CAAA,aAAA,CAAA,YAAA,CAAA,MAAA,CAAA,QAAA,CAAA,iBAAA,CAAA,oBAAA,CAAA,WAAA,CAAA,QAAA,CAAA,WAAA,CAAA,uBAAA,CAAA,4BAAA,CAAA,gBAAA,CAAA,QAAA,CAAA,MAAA,CAAA,aAAA,CAAA,cAAA,CAAA,eAAA,CAAA,MAAA,CAAA,aAAA,CAAA,CAwIA,IAAMA,aAAa,CAAG,SAAhBA,aAAaA,CAAIC,aAAkB,CAA4C,CACnF,OAAOC,eAAe,EAAE,GAAK,cAAc,CAC7C,CAAC,CAED,IAAMC,UAA2E,CAAG,SAA9EA,UAA2EA,CAAAC,IAAA,CA0C/EC,GAAG,CACc,CAzCf,IAAAC,KAAK,CAAAF,IAAA,CAALE,KAAK,CACLC,kBAAkB,CAAAH,IAAA,CAAlBG,kBAAkB,CAAAC,kBAAA,CAAAJ,IAAA,CAClBK,aAAa,CAAbA,aAAa,CAAAD,kBAAA,GAAA,KAAA,CAAA,CAAG,KAAK,CAAAA,kBAAA,CACrBE,WAAW,CAAAN,IAAA,CAAXM,WAAW,CAAAC,SAAA,CAAAP,I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EA,eAAgB,CACjCC,SAAS,CAAEA,SAAU,CACrBC,QAAQ,CAAEA,QAAS,CACnBC,WAAW,CAAEA,WAAY,CACzB8E,kBAAkB,CAAE,SAAAA,kBAAAA,CAAC1F,KAAK,CAAK,CAAA2F,IAAAA,aAAA,CAC7B,OAAO1F,aAAa,CAClB6D,GAAA,CAAC8B,OAAO,CAAA,CAACC,SAAS,CAAEC,aAAa,CAACpE,IAAI,CAAE,CAACqE,WAAW,CAAC,WAAW,CAAAC,QAAA,CAC9DlC,GAAA,CAACmC,gBAAgB,CAAA,CACfC,YAAY,CAAAP,CAAAA,aAAA,CAAE3F,KAAK,EAALA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,KAAK,CAAEsF,MAAM,QAAAK,aAAA,CAAI,CAAE,CACjCQ,QAAQ,CAAElG,aAAc,CACxByB,IAAI,CAAEA,IAAK,CACZ,CAAC,CACK,CAAC,CACR,IAAI,CACV,CAAE,CAEFN,SAAS,CAAEA,SAAU,CACrBI,MAAM,CAAEA,MAAO,CAAA,CACX4E,+BAA+B,CAAC,CAClCvG,IAAI,CAAJA,IAAI,CACJwB,qBAAqB,CAArBA,qBAAqB,CACrBC,0BAA0B,CAA1BA,0BAA0B,CAC1BC,cAAc,CAAdA,cACF,CAAC,CAAC,CACFG,CAAAA,IAAI,CAAEA,IAAK,EACPM,IAAI,CACT,CAAC,CAEN,CAAC,CAEK,IAAA+C,SAAS,CAAGsB,wBAAwB,CAACjE,cAAK,CAACkE,UAAU,CAAClH,UAAU,CAAC,CAAE,CACvEmH,WAAW,CAAE,WACf,CAAC;;;;"}
|
|
@@ -23,8 +23,9 @@ import '../../../tokens/global/typography.js';
|
|
|
23
23
|
import '../../../tokens/global/motion.js';
|
|
24
24
|
import { makeAccessible } from '../../../utils/makeAccessible/makeAccessible.native.js';
|
|
25
25
|
import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
26
|
+
import { makeAnalyticsAttribute } from '../../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
26
27
|
|
|
27
|
-
var _excluded=["children","icon","iconPosition","isDisabled","onClick","onKeyDown","variant","href","target","rel","color","opacity","accessibilityProps","className","style","size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp"],_excluded2=["currentInteraction","setCurrentInteraction"];var getColorToken=function getColorToken(_ref){var variant=_ref.variant,color=_ref.color,currentInteraction=_ref.currentInteraction,isDisabled=_ref.isDisabled,element=_ref.element;var state=currentInteraction;var map={default:'normal',hover:'subtle',focus:'normal',disabled:'disabled'};if(isDisabled&&variant=='button'){state='disabled';}if(color&&color!=='primary'){if(color!=='white'){return `interactive.${element}.${color}.${map[state]}`;}return `interactive.${element}.staticWhite.${map[state]}`;}return `interactive.${element}.primary.${map[state]}`;};var getProps=function getProps(_ref2){var theme=_ref2.theme,variant=_ref2.variant,currentInteraction=_ref2.currentInteraction,children=_ref2.children,isDisabled=_ref2.isDisabled,color=_ref2.color,target=_ref2.target,size=_ref2.size;var isButton=variant==='button';var textSizes={fontSize:{xsmall:25,small:75,medium:100,large:200},lineHeight:{xsmall:25,small:75,medium:100,large:200}};var props={as:isButton?'button':'a',textDecorationLine:!isButton&¤tInteraction!=='default'?'underline':'none',iconColor:getColorToken({variant:variant,color:color,element:'icon',currentInteraction:currentInteraction,isDisabled:isDisabled}),fontSize:textSizes.fontSize[size],lineHeight:textSizes.lineHeight[size],iconSize:size,iconPadding:children!=null&&children.trim()?'spacing.2':'spacing.0',textColor:getColorToken({variant:variant,color:color,element:'text',currentInteraction:currentInteraction,isDisabled:isDisabled}),focusRingColor:getIn(theme.colors,'interactive.background.primary.faded'),motionDuration:'duration.2xquick',motionEasing:'easing.standard.effective',cursor:isButton&&isDisabled?'not-allowed':'pointer',disabled:isButton&&isDisabled,role:isButton?'button':'link',defaultRel:target&&target==='_blank'?'noreferrer noopener':undefined,type:isButton?'button':undefined};return props;};var _BaseLink=function _BaseLink(_ref3,ref){var children=_ref3.children,Icon=_ref3.icon,_ref3$iconPosition=_ref3.iconPosition,iconPosition=_ref3$iconPosition===void 0?'left':_ref3$iconPosition,_ref3$isDisabled=_ref3.isDisabled,isDisabled=_ref3$isDisabled===void 0?false:_ref3$isDisabled,onClick=_ref3.onClick,onKeyDown=_ref3.onKeyDown,_ref3$variant=_ref3.variant,variant=_ref3$variant===void 0?'anchor':_ref3$variant,href=_ref3.href,target=_ref3.target,rel=_ref3.rel,_ref3$color=_ref3.color,color=_ref3$color===void 0?'primary':_ref3$color,opacity=_ref3.opacity,accessibilityProps=_ref3.accessibilityProps,className=_ref3.className,style=_ref3.style,_ref3$size=_ref3.size,size=_ref3$size===void 0?'medium':_ref3$size,testID=_ref3.testID,hitSlop=_ref3.hitSlop,htmlTitle=_ref3.htmlTitle,_onBlur=_ref3.onBlur,_onFocus=_ref3.onFocus,_onMouseLeave=_ref3.onMouseLeave,onMouseMove=_ref3.onMouseMove,onPointerDown=_ref3.onPointerDown,onPointerEnter=_ref3.onPointerEnter,onTouchStart=_ref3.onTouchStart,onTouchEnd=_ref3.onTouchEnd,onMouseDown=_ref3.onMouseDown,onMouseUp=_ref3.onMouseUp,
|
|
28
|
+
var _excluded=["children","icon","iconPosition","isDisabled","onClick","onKeyDown","variant","href","target","rel","color","opacity","accessibilityProps","className","style","size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp"],_excluded2=["currentInteraction","setCurrentInteraction"];var getColorToken=function getColorToken(_ref){var variant=_ref.variant,color=_ref.color,currentInteraction=_ref.currentInteraction,isDisabled=_ref.isDisabled,element=_ref.element;var state=currentInteraction;var map={default:'normal',hover:'subtle',focus:'normal',disabled:'disabled'};if(isDisabled&&variant=='button'){state='disabled';}if(color&&color!=='primary'){if(color!=='white'){return `interactive.${element}.${color}.${map[state]}`;}return `interactive.${element}.staticWhite.${map[state]}`;}return `interactive.${element}.primary.${map[state]}`;};var getProps=function getProps(_ref2){var theme=_ref2.theme,variant=_ref2.variant,currentInteraction=_ref2.currentInteraction,children=_ref2.children,isDisabled=_ref2.isDisabled,color=_ref2.color,target=_ref2.target,size=_ref2.size;var isButton=variant==='button';var textSizes={fontSize:{xsmall:25,small:75,medium:100,large:200},lineHeight:{xsmall:25,small:75,medium:100,large:200}};var props={as:isButton?'button':'a',textDecorationLine:!isButton&¤tInteraction!=='default'?'underline':'none',iconColor:getColorToken({variant:variant,color:color,element:'icon',currentInteraction:currentInteraction,isDisabled:isDisabled}),fontSize:textSizes.fontSize[size],lineHeight:textSizes.lineHeight[size],iconSize:size,iconPadding:children!=null&&children.trim()?'spacing.2':'spacing.0',textColor:getColorToken({variant:variant,color:color,element:'text',currentInteraction:currentInteraction,isDisabled:isDisabled}),focusRingColor:getIn(theme.colors,'interactive.background.primary.faded'),motionDuration:'duration.2xquick',motionEasing:'easing.standard.effective',cursor:isButton&&isDisabled?'not-allowed':'pointer',disabled:isButton&&isDisabled,role:isButton?'button':'link',defaultRel:target&&target==='_blank'?'noreferrer noopener':undefined,type:isButton?'button':undefined};return props;};var _BaseLink=function _BaseLink(_ref3,ref){var children=_ref3.children,Icon=_ref3.icon,_ref3$iconPosition=_ref3.iconPosition,iconPosition=_ref3$iconPosition===void 0?'left':_ref3$iconPosition,_ref3$isDisabled=_ref3.isDisabled,isDisabled=_ref3$isDisabled===void 0?false:_ref3$isDisabled,onClick=_ref3.onClick,onKeyDown=_ref3.onKeyDown,_ref3$variant=_ref3.variant,variant=_ref3$variant===void 0?'anchor':_ref3$variant,href=_ref3.href,target=_ref3.target,rel=_ref3.rel,_ref3$color=_ref3.color,color=_ref3$color===void 0?'primary':_ref3$color,opacity=_ref3.opacity,accessibilityProps=_ref3.accessibilityProps,className=_ref3.className,style=_ref3.style,_ref3$size=_ref3.size,size=_ref3$size===void 0?'medium':_ref3$size,testID=_ref3.testID,hitSlop=_ref3.hitSlop,htmlTitle=_ref3.htmlTitle,_onBlur=_ref3.onBlur,_onFocus=_ref3.onFocus,_onMouseLeave=_ref3.onMouseLeave,onMouseMove=_ref3.onMouseMove,onPointerDown=_ref3.onPointerDown,onPointerEnter=_ref3.onPointerEnter,onTouchStart=_ref3.onTouchStart,onTouchEnd=_ref3.onTouchEnd,onMouseDown=_ref3.onMouseDown,onMouseUp=_ref3.onMouseUp,rest=_objectWithoutProperties(_ref3,_excluded);var childrenString=getStringFromReactText(children);var _useInteraction=useInteraction(),currentInteraction=_useInteraction.currentInteraction,setCurrentInteraction=_useInteraction.setCurrentInteraction,syntheticEvents=_objectWithoutProperties(_useInteraction,_excluded2);var _useTheme=useTheme(),theme=_useTheme.theme;if(__DEV__){if(!Icon&&!(childrenString!=null&&childrenString.trim())){throwBladeError({message:`At least one of icon or text is required to render a link.`,moduleName:'BaseLink'});}}var _getProps=getProps({theme:theme,variant:variant,currentInteraction:currentInteraction,children:childrenString,isDisabled:isDisabled,color:color,target:target,size:size}),as=_getProps.as,textDecorationLine=_getProps.textDecorationLine,iconColor=_getProps.iconColor,iconPadding=_getProps.iconPadding,iconSize=_getProps.iconSize,fontSize=_getProps.fontSize,textColor=_getProps.textColor,focusRingColor=_getProps.focusRingColor,motionDuration=_getProps.motionDuration,motionEasing=_getProps.motionEasing,cursor=_getProps.cursor,disabled=_getProps.disabled,role=_getProps.role,defaultRel=_getProps.defaultRel,type=_getProps.type,lineHeight=_getProps.lineHeight;var handleOnClick=function handleOnClick(event){if(onClick){onClick(event);}};var asProp=isReactNative()?undefined:'span';return jsx(StyledLink,Object.assign({ref:ref},metaAttribute({name:MetaConstants.Link,testID:testID}),{accessibilityProps:Object.assign({},makeAccessible(Object.assign({role:role,disabled:disabled},accessibilityProps))),variant:variant,as:as,href:href,target:target,rel:rel!=null?rel:defaultRel,onClick:handleOnClick},syntheticEvents,{onBlur:function onBlur(event){_onBlur==null?void 0:_onBlur(event);syntheticEvents.onBlur();},onFocus:function onFocus(event){_onFocus==null?void 0:_onFocus(event);syntheticEvents.onFocus();},onMouseLeave:function onMouseLeave(event){if(_onMouseLeave){_onMouseLeave(event);}syntheticEvents.onMouseLeave();},onMouseMove:onMouseMove,onPointerDown:onPointerDown,onPointerEnter:onPointerEnter,onTouchStart:onTouchStart,onTouchEnd:onTouchEnd,onKeyDown:onKeyDown,onMouseDown:onMouseDown,onMouseUp:onMouseUp,disabled:disabled,type:type,cursor:cursor,focusRingColor:focusRingColor,motionDuration:motionDuration,motionEasing:motionEasing,setCurrentInteraction:setCurrentInteraction},getStyledProps(rest),makeAnalyticsAttribute(rest),{className:className,style:style,hitSlop:hitSlop,title:htmlTitle,children:jsxs(BaseBox,{as:asProp,display:"flex",flexDirection:"row",className:"content-container",alignItems:"center",opacity:opacity,children:[Icon&&iconPosition=='left'?jsx(BaseBox,{as:asProp,paddingRight:iconPadding,display:"flex",alignItems:"center",children:jsx(Icon,{color:iconColor,size:iconSize})}):null,jsx(BaseText,{as:asProp,textDecorationLine:textDecorationLine,color:textColor,fontSize:fontSize,lineHeight:lineHeight,textAlign:"center",fontWeight:"medium",children:children}),Icon&&iconPosition=='right'?jsx(BaseBox,{as:asProp,paddingLeft:iconPadding,display:"flex",alignItems:"center",children:jsx(Icon,{color:iconColor,size:iconSize})}):null]})}));};var BaseLink=assignWithoutSideEffects(React__default.forwardRef(_BaseLink),{displayName:'BaseLink',componentId:'BaseLink'});
|
|
28
29
|
|
|
29
30
|
export { BaseLink as default };
|
|
30
31
|
//# sourceMappingURL=BaseLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLink.js","sources":["../../../../../../src/components/Link/BaseLink/BaseLink.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/prefer-ts-expect-error */\n/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type { SyntheticEvent } from 'react';\nimport React from 'react';\nimport type { CSSObject } from 'styled-components';\nimport type { GestureResponderEvent } from 'react-native';\nimport StyledBaseLink from './StyledBaseLink';\nimport getIn from '~utils/lodashButBetter/get';\nimport useInteraction from '~utils/useInteraction';\nimport type { IconColors, IconComponent, IconProps } from '~components/Icons';\nimport type { Theme } from '~components/BladeProvider';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { BaseText } from '~components/Typography/BaseText';\nimport type {\n DotNotationSpacingStringToken,\n StringChildrenType,\n TestID,\n BladeElementRef,\n} from '~utils/types';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport type { Platform } from '~utils';\nimport { isReactNative } from '~utils';\nimport type { DurationString, EasingString, FontSize, Typography } from '~tokens/global';\nimport type {\n BaseTextProps,\n BaseTextSizes,\n TextColors,\n} from '~components/Typography/BaseText/types';\nimport { getStringFromReactText } from '~src/utils/getStringChildren';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { AccessibilityProps } from '~utils/makeAccessible';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport type { BladeCommonEvents } from '~components/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport type { ActionStates } from '~utils/useInteraction';\n\ntype BaseLinkCommonProps = {\n color?: 'primary' | 'white' | 'positive' | 'negative' | 'notice' | 'information' | 'neutral';\n icon?: IconComponent;\n iconPosition?: 'left' | 'right';\n onClick?: (event: SyntheticEvent) => void;\n onBlur?: Platform.Select<{\n native: (event: GestureResponderEvent) => void;\n web: (event: React.FocusEvent<HTMLButtonElement>) => void;\n }>;\n onMouseLeave?: Platform.Select<{\n native: (event: GestureResponderEvent) => void;\n web: (event: React.MouseEvent<HTMLButtonElement>) => void;\n }>;\n onKeyDown?: Platform.Select<{\n native: (event: GestureResponderEvent) => void;\n web: (event: React.KeyboardEvent<HTMLButtonElement>) => void;\n }>;\n accessibilityProps?: Partial<AccessibilityProps>;\n\n /**\n * Sets the size of the link\n *\n * @default medium\n */\n size?: Extract<BaseTextSizes, 'xsmall' | 'small' | 'medium' | 'large'>;\n /**\n * Defines how far your touch can start away from the link. This is a react-native only prop and has no effect on web.\n */\n hitSlop?:\n | {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n }\n | number;\n /**\n * The title of the link which is displayed as a tooltip. This is a web only prop and has no effect on react-native.\n */\n htmlTitle?: string;\n opacity?: number;\n} & TestID &\n StyledPropsBlade &\n Omit<BladeCommonEvents, 'onBlur' | 'onMouseLeave'>;\n\n/*\n Mandatory children prop when icon is not provided\n*/\ntype BaseLinkWithoutIconProps = BaseLinkCommonProps & {\n icon?: undefined;\n children: StringChildrenType;\n};\n\n/*\n Optional children prop when icon is provided\n*/\ntype BaseLinkWithIconProps = BaseLinkCommonProps & {\n icon: IconComponent;\n children?: StringChildrenType;\n};\n\n/*\n BaseLink Props with or without an icon\n*/\ntype BaseLinkPropsWithOrWithoutIcon = BaseLinkWithIconProps | BaseLinkWithoutIconProps;\n\n/*\n BaseLink Props when variant is anchor\n*/\ntype BaseLinkAnchorVariantProps = BaseLinkPropsWithOrWithoutIcon & {\n variant?: 'anchor';\n href?: string;\n target?: string;\n rel?: string;\n isDisabled?: undefined;\n};\n\n/*\n BaseLink Props when variant is button\n*/\ntype BaseLinkButtonVariantProps = BaseLinkPropsWithOrWithoutIcon & {\n variant?: 'button';\n isDisabled?: boolean;\n href?: undefined;\n target?: undefined;\n rel?: undefined;\n};\n\n/*\n BaseLink Props when variant is anchor or button\n*/\nexport type BaseLinkProps = BaseLinkAnchorVariantProps | BaseLinkButtonVariantProps;\n\ntype BaseLinkStyleProps = {\n as: 'a' | 'button';\n textDecorationLine: 'underline' | 'none';\n iconColor: IconProps['color'];\n iconSize: IconProps['size'];\n iconPadding: DotNotationSpacingStringToken;\n textColor: BaseTextProps['color'];\n focusRingColor: string;\n motionDuration: DurationString;\n motionEasing: EasingString;\n cursor: CSSObject['cursor'];\n disabled: boolean;\n role: 'button' | 'link';\n defaultRel: BaseLinkProps['rel'];\n type?: 'button';\n fontSize: BaseTextProps['fontSize'];\n lineHeight: BaseTextProps['lineHeight'];\n};\n\ntype LinkActionStates = ActionStates;\nconst getColorToken = ({\n variant,\n color,\n currentInteraction,\n isDisabled,\n element,\n}: {\n variant: BaseLinkProps['variant'];\n color: BaseLinkProps['color'];\n element: 'icon' | 'text';\n currentInteraction: LinkActionStates;\n isDisabled: boolean;\n}): IconColors | TextColors => {\n let state = currentInteraction;\n const map = {\n default: 'normal',\n hover: 'subtle',\n focus: 'normal',\n disabled: 'disabled',\n } as const;\n\n if (isDisabled && variant == 'button') {\n state = 'disabled';\n }\n\n if (color && color !== 'primary') {\n if (color !== 'white') {\n return `interactive.${element}.${color}.${map[state]}`;\n }\n return `interactive.${element}.staticWhite.${map[state]}`;\n }\n return `interactive.${element}.primary.${map[state]}`;\n};\n\nconst getProps = ({\n theme,\n variant,\n currentInteraction,\n children,\n isDisabled,\n color,\n target,\n size,\n}: {\n theme: Theme;\n variant: NonNullable<BaseLinkProps['variant']>;\n currentInteraction: LinkActionStates;\n children?: string;\n isDisabled: boolean;\n color: BaseLinkProps['color'];\n target: BaseLinkProps['target'];\n size: NonNullable<BaseLinkProps['size']>;\n}): BaseLinkStyleProps => {\n const isButton = variant === 'button';\n const textSizes: {\n fontSize: Record<NonNullable<BaseLinkProps['size']>, keyof FontSize>;\n lineHeight: Record<NonNullable<BaseLinkProps['size']>, keyof Typography['lineHeights']>;\n } = {\n fontSize: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n lineHeight: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n };\n\n const props: BaseLinkStyleProps = {\n as: isButton ? 'button' : 'a',\n textDecorationLine: !isButton && currentInteraction !== 'default' ? 'underline' : 'none',\n iconColor: getColorToken({\n variant,\n color,\n element: 'icon',\n currentInteraction,\n isDisabled,\n }) as IconProps['color'],\n fontSize: textSizes.fontSize[size],\n lineHeight: textSizes.lineHeight[size],\n iconSize: size,\n iconPadding: children?.trim() ? 'spacing.2' : 'spacing.0',\n textColor: getColorToken({\n variant,\n color,\n element: 'text',\n currentInteraction,\n isDisabled,\n }) as BaseTextProps['color'],\n focusRingColor: getIn(theme.colors, 'interactive.background.primary.faded'),\n motionDuration: 'duration.2xquick',\n motionEasing: 'easing.standard.effective',\n cursor: isButton && isDisabled ? 'not-allowed' : 'pointer',\n disabled: isButton && isDisabled,\n role: isButton ? 'button' : 'link',\n defaultRel: target && target === '_blank' ? 'noreferrer noopener' : undefined,\n type: isButton ? 'button' : undefined,\n };\n\n return props;\n};\n\nconst _BaseLink: React.ForwardRefRenderFunction<BladeElementRef, BaseLinkProps> = (\n {\n children,\n icon: Icon,\n iconPosition = 'left',\n isDisabled = false,\n onClick,\n onKeyDown,\n variant = 'anchor',\n href,\n target,\n rel,\n color = 'primary',\n opacity,\n accessibilityProps,\n // @ts-expect-error avoiding exposing to public\n className,\n // @ts-expect-error avoiding exposing to public\n style,\n size = 'medium',\n testID,\n hitSlop,\n htmlTitle,\n onBlur,\n onFocus,\n onMouseLeave,\n onMouseMove,\n onPointerDown,\n onPointerEnter,\n onTouchStart,\n onTouchEnd,\n onMouseDown,\n onMouseUp,\n ...styledProps\n },\n ref,\n) => {\n const childrenString = getStringFromReactText(children);\n const { currentInteraction, setCurrentInteraction, ...syntheticEvents } = useInteraction();\n const { theme } = useTheme();\n if (__DEV__) {\n if (!Icon && !childrenString?.trim()) {\n throwBladeError({\n message: `At least one of icon or text is required to render a link.`,\n moduleName: 'BaseLink',\n });\n }\n }\n const {\n as,\n textDecorationLine,\n iconColor,\n iconPadding,\n iconSize,\n fontSize,\n textColor,\n focusRingColor,\n motionDuration,\n motionEasing,\n cursor,\n disabled,\n role,\n defaultRel,\n type,\n lineHeight,\n } = getProps({\n theme,\n variant,\n currentInteraction,\n children: childrenString,\n isDisabled,\n color,\n target,\n size,\n });\n\n const handleOnClick = (event: SyntheticEvent): void => {\n if (onClick) {\n onClick(event);\n }\n };\n\n const asProp = isReactNative() ? undefined : 'span';\n return (\n <StyledBaseLink\n ref={ref as never}\n {...metaAttribute({ name: MetaConstants.Link, testID })}\n accessibilityProps={{\n ...makeAccessible({\n role,\n disabled,\n ...accessibilityProps,\n }),\n }}\n variant={variant}\n as={as}\n href={href}\n target={target}\n rel={rel ?? defaultRel}\n onClick={handleOnClick}\n {...syntheticEvents}\n onBlur={(event: any) => {\n onBlur?.(event);\n syntheticEvents.onBlur();\n }}\n onFocus={(event: any) => {\n onFocus?.(event);\n syntheticEvents.onFocus();\n }}\n onMouseLeave={(event: any) => {\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n syntheticEvents.onMouseLeave();\n }}\n onMouseMove={onMouseMove}\n onPointerDown={onPointerDown}\n onPointerEnter={onPointerEnter}\n onTouchStart={onTouchStart}\n onTouchEnd={onTouchEnd}\n onKeyDown={onKeyDown}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n disabled={disabled}\n type={type}\n cursor={cursor}\n focusRingColor={focusRingColor}\n motionDuration={motionDuration}\n motionEasing={motionEasing}\n setCurrentInteraction={setCurrentInteraction}\n {...getStyledProps(styledProps)}\n // @ts-ignore Because we avoided exposing className to public\n className={className}\n style={style}\n hitSlop={hitSlop}\n title={htmlTitle}\n >\n <BaseBox\n as={asProp}\n display=\"flex\"\n flexDirection=\"row\"\n className=\"content-container\"\n alignItems=\"center\"\n opacity={opacity}\n >\n {Icon && iconPosition == 'left' ? (\n <BaseBox as={asProp} paddingRight={iconPadding} display=\"flex\" alignItems=\"center\">\n <Icon color={iconColor} size={iconSize} />\n </BaseBox>\n ) : null}\n <BaseText\n as={asProp}\n textDecorationLine={textDecorationLine}\n color={textColor}\n fontSize={fontSize}\n lineHeight={lineHeight}\n textAlign=\"center\"\n fontWeight=\"medium\"\n >\n {children}\n </BaseText>\n {Icon && iconPosition == 'right' ? (\n <BaseBox as={asProp} paddingLeft={iconPadding} display=\"flex\" alignItems=\"center\">\n <Icon color={iconColor} size={iconSize} />\n </BaseBox>\n ) : null}\n </BaseBox>\n </StyledBaseLink>\n );\n};\n\nconst BaseLink = assignWithoutSideEffects(React.forwardRef(_BaseLink), {\n displayName: 'BaseLink',\n componentId: 'BaseLink',\n});\n\nexport default BaseLink;\n"],"names":["getColorToken","_ref","variant","color","currentInteraction","isDisabled","element","state","map","default","hover","focus","disabled","getProps","_ref2","theme","children","target","size","isButton","textSizes","fontSize","xsmall","small","medium","large","lineHeight","props","as","textDecorationLine","iconColor","iconSize","iconPadding","trim","textColor","focusRingColor","getIn","colors","motionDuration","motionEasing","cursor","role","defaultRel","undefined","type","_BaseLink","_ref3","ref","Icon","icon","_ref3$iconPosition","iconPosition","_ref3$isDisabled","onClick","onKeyDown","_ref3$variant","href","rel","_ref3$color","opacity","accessibilityProps","className","style","_ref3$size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp","styledProps","_objectWithoutProperties","_excluded","childrenString","getStringFromReactText","_useInteraction","useInteraction","setCurrentInteraction","syntheticEvents","_excluded2","_useTheme","useTheme","__DEV__","throwBladeError","message","moduleName","_getProps","handleOnClick","event","asProp","isReactNative","_jsx","StyledBaseLink","Object","assign","metaAttribute","name","MetaConstants","Link","makeAccessible","getStyledProps","title","_jsxs","BaseBox","display","flexDirection","alignItems","paddingRight","BaseText","textAlign","fontWeight","paddingLeft","BaseLink","assignWithoutSideEffects","React","forwardRef","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAA,SAAA,CAAA,CAAA,UAAA,CAAA,MAAA,CAAA,cAAA,CAAA,YAAA,CAAA,SAAA,CAAA,WAAA,CAAA,SAAA,CAAA,MAAA,CAAA,QAAA,CAAA,KAAA,CAAA,OAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,WAAA,CAAA,OAAA,CAAA,MAAA,CAAA,QAAA,CAAA,SAAA,CAAA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I,CACRmE,GAAA,CAACiB,QAAQ,CAAA,CACPvF,EAAE,CAAEoE,MAAO,CACXnE,kBAAkB,CAAEA,kBAAmB,CACvC1B,KAAK,CAAE+B,SAAU,CACjBb,QAAQ,CAAEA,QAAS,CACnBK,UAAU,CAAEA,UAAW,CACvB0F,SAAS,CAAC,QAAQ,CAClBC,UAAU,CAAC,QAAQ,CAAArG,QAAA,CAElBA,QAAQ,CACD,CAAC,CACVgC,IAAI,EAAIG,YAAY,EAAI,OAAO,CAC9B+C,GAAA,CAACY,OAAO,CAAA,CAAClF,EAAE,CAAEoE,MAAO,CAACsB,WAAW,CAAEtF,WAAY,CAAC+E,OAAO,CAAC,MAAM,CAACE,UAAU,CAAC,QAAQ,CAAAjG,QAAA,CAC/EkF,GAAA,CAAClD,IAAI,CAAA,CAAC7C,KAAK,CAAE2B,SAAU,CAACZ,IAAI,CAAEa,QAAS,CAAE,CAAC,CACnC,CAAC,CACR,IAAI,CAAA,CACD,CAAC,CAAA,CACI,CAAC,CAErB,CAAC,CAEK,IAAAwF,QAAQ,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAAC7E,SAAS,CAAC,CAAE,CACrE8E,WAAW,CAAE,UAAU,CACvBC,WAAW,CAAE,UACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseLink.js","sources":["../../../../../../src/components/Link/BaseLink/BaseLink.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable @typescript-eslint/prefer-ts-expect-error */\n/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport type { SyntheticEvent } from 'react';\nimport React from 'react';\nimport type { CSSObject } from 'styled-components';\nimport type { GestureResponderEvent } from 'react-native';\nimport StyledBaseLink from './StyledBaseLink';\nimport getIn from '~utils/lodashButBetter/get';\nimport useInteraction from '~utils/useInteraction';\nimport type { IconColors, IconComponent, IconProps } from '~components/Icons';\nimport type { Theme } from '~components/BladeProvider';\nimport { useTheme } from '~components/BladeProvider';\nimport BaseBox from '~components/Box/BaseBox';\nimport { BaseText } from '~components/Typography/BaseText';\nimport type {\n DotNotationSpacingStringToken,\n StringChildrenType,\n TestID,\n BladeElementRef,\n} from '~utils/types';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport type { Platform } from '~utils';\nimport { isReactNative } from '~utils';\nimport type { DurationString, EasingString, FontSize, Typography } from '~tokens/global';\nimport type {\n BaseTextProps,\n BaseTextSizes,\n TextColors,\n} from '~components/Typography/BaseText/types';\nimport { getStringFromReactText } from '~src/utils/getStringChildren';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { AccessibilityProps } from '~utils/makeAccessible';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport type { BladeCommonEvents } from '~components/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport type { ActionStates } from '~utils/useInteraction';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype BaseLinkCommonProps = {\n color?: 'primary' | 'white' | 'positive' | 'negative' | 'notice' | 'information' | 'neutral';\n icon?: IconComponent;\n iconPosition?: 'left' | 'right';\n onClick?: (event: SyntheticEvent) => void;\n onBlur?: Platform.Select<{\n native: (event: GestureResponderEvent) => void;\n web: (event: React.FocusEvent<HTMLButtonElement>) => void;\n }>;\n onMouseLeave?: Platform.Select<{\n native: (event: GestureResponderEvent) => void;\n web: (event: React.MouseEvent<HTMLButtonElement>) => void;\n }>;\n onKeyDown?: Platform.Select<{\n native: (event: GestureResponderEvent) => void;\n web: (event: React.KeyboardEvent<HTMLButtonElement>) => void;\n }>;\n accessibilityProps?: Partial<AccessibilityProps>;\n\n /**\n * Sets the size of the link\n *\n * @default medium\n */\n size?: Extract<BaseTextSizes, 'xsmall' | 'small' | 'medium' | 'large'>;\n /**\n * Defines how far your touch can start away from the link. This is a react-native only prop and has no effect on web.\n */\n hitSlop?:\n | {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n }\n | number;\n /**\n * The title of the link which is displayed as a tooltip. This is a web only prop and has no effect on react-native.\n */\n htmlTitle?: string;\n opacity?: number;\n} & TestID &\n StyledPropsBlade &\n Omit<BladeCommonEvents, 'onBlur' | 'onMouseLeave'>;\n\n/*\n Mandatory children prop when icon is not provided\n*/\ntype BaseLinkWithoutIconProps = BaseLinkCommonProps & {\n icon?: undefined;\n children: StringChildrenType;\n};\n\n/*\n Optional children prop when icon is provided\n*/\ntype BaseLinkWithIconProps = BaseLinkCommonProps & {\n icon: IconComponent;\n children?: StringChildrenType;\n};\n\n/*\n BaseLink Props with or without an icon\n*/\ntype BaseLinkPropsWithOrWithoutIcon = BaseLinkWithIconProps | BaseLinkWithoutIconProps;\n\n/*\n BaseLink Props when variant is anchor\n*/\ntype BaseLinkAnchorVariantProps = BaseLinkPropsWithOrWithoutIcon & {\n variant?: 'anchor';\n href?: string;\n target?: string;\n rel?: string;\n isDisabled?: undefined;\n};\n\n/*\n BaseLink Props when variant is button\n*/\ntype BaseLinkButtonVariantProps = BaseLinkPropsWithOrWithoutIcon & {\n variant?: 'button';\n isDisabled?: boolean;\n href?: undefined;\n target?: undefined;\n rel?: undefined;\n};\n\n/*\n BaseLink Props when variant is anchor or button\n*/\nexport type BaseLinkProps = BaseLinkAnchorVariantProps | BaseLinkButtonVariantProps;\n\ntype BaseLinkStyleProps = {\n as: 'a' | 'button';\n textDecorationLine: 'underline' | 'none';\n iconColor: IconProps['color'];\n iconSize: IconProps['size'];\n iconPadding: DotNotationSpacingStringToken;\n textColor: BaseTextProps['color'];\n focusRingColor: string;\n motionDuration: DurationString;\n motionEasing: EasingString;\n cursor: CSSObject['cursor'];\n disabled: boolean;\n role: 'button' | 'link';\n defaultRel: BaseLinkProps['rel'];\n type?: 'button';\n fontSize: BaseTextProps['fontSize'];\n lineHeight: BaseTextProps['lineHeight'];\n};\n\ntype LinkActionStates = ActionStates;\nconst getColorToken = ({\n variant,\n color,\n currentInteraction,\n isDisabled,\n element,\n}: {\n variant: BaseLinkProps['variant'];\n color: BaseLinkProps['color'];\n element: 'icon' | 'text';\n currentInteraction: LinkActionStates;\n isDisabled: boolean;\n}): IconColors | TextColors => {\n let state = currentInteraction;\n const map = {\n default: 'normal',\n hover: 'subtle',\n focus: 'normal',\n disabled: 'disabled',\n } as const;\n\n if (isDisabled && variant == 'button') {\n state = 'disabled';\n }\n\n if (color && color !== 'primary') {\n if (color !== 'white') {\n return `interactive.${element}.${color}.${map[state]}`;\n }\n return `interactive.${element}.staticWhite.${map[state]}`;\n }\n return `interactive.${element}.primary.${map[state]}`;\n};\n\nconst getProps = ({\n theme,\n variant,\n currentInteraction,\n children,\n isDisabled,\n color,\n target,\n size,\n}: {\n theme: Theme;\n variant: NonNullable<BaseLinkProps['variant']>;\n currentInteraction: LinkActionStates;\n children?: string;\n isDisabled: boolean;\n color: BaseLinkProps['color'];\n target: BaseLinkProps['target'];\n size: NonNullable<BaseLinkProps['size']>;\n}): BaseLinkStyleProps => {\n const isButton = variant === 'button';\n const textSizes: {\n fontSize: Record<NonNullable<BaseLinkProps['size']>, keyof FontSize>;\n lineHeight: Record<NonNullable<BaseLinkProps['size']>, keyof Typography['lineHeights']>;\n } = {\n fontSize: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n lineHeight: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n };\n\n const props: BaseLinkStyleProps = {\n as: isButton ? 'button' : 'a',\n textDecorationLine: !isButton && currentInteraction !== 'default' ? 'underline' : 'none',\n iconColor: getColorToken({\n variant,\n color,\n element: 'icon',\n currentInteraction,\n isDisabled,\n }) as IconProps['color'],\n fontSize: textSizes.fontSize[size],\n lineHeight: textSizes.lineHeight[size],\n iconSize: size,\n iconPadding: children?.trim() ? 'spacing.2' : 'spacing.0',\n textColor: getColorToken({\n variant,\n color,\n element: 'text',\n currentInteraction,\n isDisabled,\n }) as BaseTextProps['color'],\n focusRingColor: getIn(theme.colors, 'interactive.background.primary.faded'),\n motionDuration: 'duration.2xquick',\n motionEasing: 'easing.standard.effective',\n cursor: isButton && isDisabled ? 'not-allowed' : 'pointer',\n disabled: isButton && isDisabled,\n role: isButton ? 'button' : 'link',\n defaultRel: target && target === '_blank' ? 'noreferrer noopener' : undefined,\n type: isButton ? 'button' : undefined,\n };\n\n return props;\n};\n\nconst _BaseLink: React.ForwardRefRenderFunction<BladeElementRef, BaseLinkProps> = (\n {\n children,\n icon: Icon,\n iconPosition = 'left',\n isDisabled = false,\n onClick,\n onKeyDown,\n variant = 'anchor',\n href,\n target,\n rel,\n color = 'primary',\n opacity,\n accessibilityProps,\n // @ts-expect-error avoiding exposing to public\n className,\n // @ts-expect-error avoiding exposing to public\n style,\n size = 'medium',\n testID,\n hitSlop,\n htmlTitle,\n onBlur,\n onFocus,\n onMouseLeave,\n onMouseMove,\n onPointerDown,\n onPointerEnter,\n onTouchStart,\n onTouchEnd,\n onMouseDown,\n onMouseUp,\n ...rest\n },\n ref,\n) => {\n const childrenString = getStringFromReactText(children);\n const { currentInteraction, setCurrentInteraction, ...syntheticEvents } = useInteraction();\n const { theme } = useTheme();\n if (__DEV__) {\n if (!Icon && !childrenString?.trim()) {\n throwBladeError({\n message: `At least one of icon or text is required to render a link.`,\n moduleName: 'BaseLink',\n });\n }\n }\n const {\n as,\n textDecorationLine,\n iconColor,\n iconPadding,\n iconSize,\n fontSize,\n textColor,\n focusRingColor,\n motionDuration,\n motionEasing,\n cursor,\n disabled,\n role,\n defaultRel,\n type,\n lineHeight,\n } = getProps({\n theme,\n variant,\n currentInteraction,\n children: childrenString,\n isDisabled,\n color,\n target,\n size,\n });\n\n const handleOnClick = (event: SyntheticEvent): void => {\n if (onClick) {\n onClick(event);\n }\n };\n\n const asProp = isReactNative() ? undefined : 'span';\n return (\n <StyledBaseLink\n ref={ref as never}\n {...metaAttribute({ name: MetaConstants.Link, testID })}\n accessibilityProps={{\n ...makeAccessible({\n role,\n disabled,\n ...accessibilityProps,\n }),\n }}\n variant={variant}\n as={as}\n href={href}\n target={target}\n rel={rel ?? defaultRel}\n onClick={handleOnClick}\n {...syntheticEvents}\n onBlur={(event: any) => {\n onBlur?.(event);\n syntheticEvents.onBlur();\n }}\n onFocus={(event: any) => {\n onFocus?.(event);\n syntheticEvents.onFocus();\n }}\n onMouseLeave={(event: any) => {\n if (onMouseLeave) {\n onMouseLeave(event);\n }\n syntheticEvents.onMouseLeave();\n }}\n onMouseMove={onMouseMove}\n onPointerDown={onPointerDown}\n onPointerEnter={onPointerEnter}\n onTouchStart={onTouchStart}\n onTouchEnd={onTouchEnd}\n onKeyDown={onKeyDown}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n disabled={disabled}\n type={type}\n cursor={cursor}\n focusRingColor={focusRingColor}\n motionDuration={motionDuration}\n motionEasing={motionEasing}\n setCurrentInteraction={setCurrentInteraction}\n {...getStyledProps(rest)}\n {...makeAnalyticsAttribute(rest)}\n // @ts-ignore Because we avoided exposing className to public\n className={className}\n style={style}\n hitSlop={hitSlop}\n title={htmlTitle}\n >\n <BaseBox\n as={asProp}\n display=\"flex\"\n flexDirection=\"row\"\n className=\"content-container\"\n alignItems=\"center\"\n opacity={opacity}\n >\n {Icon && iconPosition == 'left' ? (\n <BaseBox as={asProp} paddingRight={iconPadding} display=\"flex\" alignItems=\"center\">\n <Icon color={iconColor} size={iconSize} />\n </BaseBox>\n ) : null}\n <BaseText\n as={asProp}\n textDecorationLine={textDecorationLine}\n color={textColor}\n fontSize={fontSize}\n lineHeight={lineHeight}\n textAlign=\"center\"\n fontWeight=\"medium\"\n >\n {children}\n </BaseText>\n {Icon && iconPosition == 'right' ? (\n <BaseBox as={asProp} paddingLeft={iconPadding} display=\"flex\" alignItems=\"center\">\n <Icon color={iconColor} size={iconSize} />\n </BaseBox>\n ) : null}\n </BaseBox>\n </StyledBaseLink>\n );\n};\n\nconst BaseLink = assignWithoutSideEffects(React.forwardRef(_BaseLink), {\n displayName: 'BaseLink',\n componentId: 'BaseLink',\n});\n\nexport default BaseLink;\n"],"names":["getColorToken","_ref","variant","color","currentInteraction","isDisabled","element","state","map","default","hover","focus","disabled","getProps","_ref2","theme","children","target","size","isButton","textSizes","fontSize","xsmall","small","medium","large","lineHeight","props","as","textDecorationLine","iconColor","iconSize","iconPadding","trim","textColor","focusRingColor","getIn","colors","motionDuration","motionEasing","cursor","role","defaultRel","undefined","type","_BaseLink","_ref3","ref","Icon","icon","_ref3$iconPosition","iconPosition","_ref3$isDisabled","onClick","onKeyDown","_ref3$variant","href","rel","_ref3$color","opacity","accessibilityProps","className","style","_ref3$size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp","rest","_objectWithoutProperties","_excluded","childrenString","getStringFromReactText","_useInteraction","useInteraction","setCurrentInteraction","syntheticEvents","_excluded2","_useTheme","useTheme","__DEV__","throwBladeError","message","moduleName","_getProps","handleOnClick","event","asProp","isReactNative","_jsx","StyledBaseLink","Object","assign","metaAttribute","name","MetaConstants","Link","makeAccessible","getStyledProps","makeAnalyticsAttribute","title","_jsxs","BaseBox","display","flexDirection","alignItems","paddingRight","BaseText","textAlign","fontWeight","paddingLeft","BaseLink","assignWithoutSideEffects","React","forwardRef","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAA,SAAA,CAAA,CAAA,UAAA,CAAA,MAAA,CAAA,cAAA,CAAA,YAAA,CAAA,SAAA,CAAA,WAAA,CAAA,SAAA,CAAA,MAAA,CAAA,QAAA,CAAA,KAAA,CAAA,OAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,WAAA,CAAA,OAAA,CAAA,MAAA,CAAA,QAAA,CAAA,SAAA,CAAA,WAAA,CAAA,QAAA,CAAA,SAAA,CAAA,cAAA,CAAA,aAAA,CAAA,eAAA,CAAA,gBAAA,CAAA,cAAA,CAAA,YAAA,CAAA,aAAA,C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,CACnBK,UAAU,CAAEA,UAAW,CACvB2F,SAAS,CAAC,QAAQ,CAClBC,UAAU,CAAC,QAAQ,CAAAtG,QAAA,CAElBA,QAAQ,CACD,CAAC,CACVgC,IAAI,EAAIG,YAAY,EAAI,OAAO,CAC9B+C,GAAA,CAACa,OAAO,CAAA,CAACnF,EAAE,CAAEoE,MAAO,CAACuB,WAAW,CAAEvF,WAAY,CAACgF,OAAO,CAAC,MAAM,CAACE,UAAU,CAAC,QAAQ,CAAAlG,QAAA,CAC/EkF,GAAA,CAAClD,IAAI,CAAA,CAAC7C,KAAK,CAAE2B,SAAU,CAACZ,IAAI,CAAEa,QAAS,CAAE,CAAC,CACnC,CAAC,CACR,IAAI,CAAA,CACD,CAAC,CAAA,CACI,CAAC,CAErB,CAAC,CAEK,IAAAyF,QAAQ,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAAC9E,SAAS,CAAC,CAAE,CACrE+E,WAAW,CAAE,UAAU,CACvBC,WAAW,CAAE,UACf,CAAC;;;;"}
|
|
@@ -8,9 +8,10 @@ import '../../../tokens/global/typography.js';
|
|
|
8
8
|
import '../../../tokens/global/motion.js';
|
|
9
9
|
import '../../BladeProvider/useTheme.js';
|
|
10
10
|
import { assignWithoutSideEffects } from '../../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
11
|
+
import { makeAnalyticsAttribute } from '../../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
11
12
|
import { jsx } from 'react/jsx-runtime';
|
|
12
13
|
|
|
13
|
-
var _excluded=["children","icon","iconPosition","isDisabled","onClick","variant","color","href","target","rel","accessibilityLabel","size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp"];var _Link=function _Link(_ref,ref){var children=_ref.children,icon=_ref.icon,_ref$iconPosition=_ref.iconPosition,iconPosition=_ref$iconPosition===void 0?'left':_ref$iconPosition,_ref$isDisabled=_ref.isDisabled,isDisabled=_ref$isDisabled===void 0?false:_ref$isDisabled,onClick=_ref.onClick,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'anchor':_ref$variant,_ref$color=_ref.color,color=_ref$color===void 0?'primary':_ref$color,href=_ref.href,target=_ref.target,rel=_ref.rel,accessibilityLabel=_ref.accessibilityLabel,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,hitSlop=_ref.hitSlop,htmlTitle=_ref.htmlTitle,onBlur=_ref.onBlur,onFocus=_ref.onFocus,onMouseLeave=_ref.onMouseLeave,onMouseMove=_ref.onMouseMove,onPointerDown=_ref.onPointerDown,onPointerEnter=_ref.onPointerEnter,onTouchStart=_ref.onTouchStart,onTouchEnd=_ref.onTouchEnd,onMouseDown=_ref.onMouseDown,onMouseUp=_ref.onMouseUp,rest=_objectWithoutProperties(_ref,_excluded);return jsx(BaseLink,Object.assign({},icon?{icon:icon,children:children}:{children:children},variant==='anchor'?{variant:variant,href:href,target:target,rel:rel}:{variant:variant,isDisabled:isDisabled},{ref:ref,iconPosition:iconPosition,onClick:onClick,accessibilityProps:{label:accessibilityLabel,describedBy:rest['aria-describedby']},size:size,color:color,testID:testID,hitSlop:hitSlop,htmlTitle:htmlTitle,onBlur:onBlur,onFocus:onFocus,onMouseLeave:onMouseLeave,onMouseMove:onMouseMove,onPointerDown:onPointerDown,onPointerEnter:onPointerEnter,onTouchStart:onTouchStart,onTouchEnd:onTouchEnd,onMouseDown:onMouseDown,onMouseUp:onMouseUp},getStyledProps(rest)));};var Link=assignWithoutSideEffects(React__default.forwardRef(_Link),{displayName:'Link',componentId:'Link'});
|
|
14
|
+
var _excluded=["children","icon","iconPosition","isDisabled","onClick","variant","color","href","target","rel","accessibilityLabel","size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp"];var _Link=function _Link(_ref,ref){var children=_ref.children,icon=_ref.icon,_ref$iconPosition=_ref.iconPosition,iconPosition=_ref$iconPosition===void 0?'left':_ref$iconPosition,_ref$isDisabled=_ref.isDisabled,isDisabled=_ref$isDisabled===void 0?false:_ref$isDisabled,onClick=_ref.onClick,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'anchor':_ref$variant,_ref$color=_ref.color,color=_ref$color===void 0?'primary':_ref$color,href=_ref.href,target=_ref.target,rel=_ref.rel,accessibilityLabel=_ref.accessibilityLabel,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,hitSlop=_ref.hitSlop,htmlTitle=_ref.htmlTitle,onBlur=_ref.onBlur,onFocus=_ref.onFocus,onMouseLeave=_ref.onMouseLeave,onMouseMove=_ref.onMouseMove,onPointerDown=_ref.onPointerDown,onPointerEnter=_ref.onPointerEnter,onTouchStart=_ref.onTouchStart,onTouchEnd=_ref.onTouchEnd,onMouseDown=_ref.onMouseDown,onMouseUp=_ref.onMouseUp,rest=_objectWithoutProperties(_ref,_excluded);return jsx(BaseLink,Object.assign({},icon?{icon:icon,children:children}:{children:children},variant==='anchor'?{variant:variant,href:href,target:target,rel:rel}:{variant:variant,isDisabled:isDisabled},{ref:ref,iconPosition:iconPosition,onClick:onClick,accessibilityProps:{label:accessibilityLabel,describedBy:rest['aria-describedby']},size:size,color:color,testID:testID,hitSlop:hitSlop,htmlTitle:htmlTitle,onBlur:onBlur,onFocus:onFocus,onMouseLeave:onMouseLeave,onMouseMove:onMouseMove,onPointerDown:onPointerDown,onPointerEnter:onPointerEnter,onTouchStart:onTouchStart,onTouchEnd:onTouchEnd,onMouseDown:onMouseDown,onMouseUp:onMouseUp},getStyledProps(rest),makeAnalyticsAttribute(rest)));};var Link=assignWithoutSideEffects(React__default.forwardRef(_Link),{displayName:'Link',componentId:'Link'});
|
|
14
15
|
|
|
15
16
|
export { Link as default };
|
|
16
17
|
//# sourceMappingURL=Link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sources":["../../../../../../src/components/Link/Link/Link.tsx"],"sourcesContent":["import type { ReactElement, SyntheticEvent } from 'react';\nimport React from 'react';\nimport type { BaseLinkProps } from '../BaseLink';\nimport { BaseLink } from '../BaseLink';\nimport type { IconComponent } from '~components/Icons';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type {
|
|
1
|
+
{"version":3,"file":"Link.js","sources":["../../../../../../src/components/Link/Link/Link.tsx"],"sourcesContent":["import type { ReactElement, SyntheticEvent } from 'react';\nimport React from 'react';\nimport type { BaseLinkProps } from '../BaseLink';\nimport { BaseLink } from '../BaseLink';\nimport type { IconComponent } from '~components/Icons';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type {\n StringChildrenType,\n TestID,\n BladeElementRef,\n DataAnalyticsAttribute,\n} from '~utils/types';\nimport type { Platform } from '~utils';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport type { BladeCommonEvents } from '~components/types';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype LinkCommonProps = {\n variant?: 'anchor' | 'button';\n icon?: IconComponent;\n color?: 'primary' | 'white' | 'neutral' | 'negative' | 'positive';\n iconPosition?: 'left' | 'right';\n isDisabled?: boolean;\n onClick?: (event: SyntheticEvent) => void;\n href?: string;\n target?: string;\n accessibilityLabel?: string;\n\n /**\n * It is exposed for internal usage with tooltip.\n *\n * @private\n */\n 'aria-describedby'?: string;\n\n /**\n * Sets the size of the link\n *\n * @default medium\n */\n size?: BaseLinkProps['size'];\n} & TestID &\n StyledPropsBlade &\n BladeCommonEvents &\n Platform.Select<{\n native: {\n /**\n * Defines how far your touch can start away from the link\n */\n hitSlop?:\n | {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n }\n | number;\n /**\n * This is a web only prop and has no effect on react-native.\n */\n htmlTitle?: undefined;\n };\n web: {\n /**\n * This is a react-native only prop and has no effect on web.\n */\n hitSlop?: undefined;\n /**\n * The title of the link which is displayed as a tooltip.\n */\n htmlTitle?: string;\n };\n }>;\n\n/*\n Mandatory children prop when icon is not provided\n*/\ntype LinkWithoutIconProps = LinkCommonProps & {\n icon?: undefined;\n children: StringChildrenType;\n};\n\n/*\n Optional children prop when icon is provided\n*/\ntype LinkWithIconProps = LinkCommonProps & {\n icon: IconComponent;\n children?: StringChildrenType;\n};\n\n/*\n Link Props with or without an icon\n*/\ntype LinkPropsWithOrWithoutIcon = LinkWithIconProps | LinkWithoutIconProps;\n\n/*\n Link Props when variant is anchor\n*/\ntype LinkAnchorVariantProps = LinkPropsWithOrWithoutIcon & {\n variant?: 'anchor';\n href?: string;\n target?: string;\n rel?: string;\n isDisabled?: undefined;\n} & DataAnalyticsAttribute;\n\n/*\n Link Props when variant is button\n*/\nexport type LinkButtonVariantProps = LinkPropsWithOrWithoutIcon & {\n variant?: 'button';\n isDisabled?: boolean;\n href?: undefined;\n target?: undefined;\n rel?: undefined;\n} & DataAnalyticsAttribute;\n\n/*\n Link Props when variant is anchor or button\n*/\nexport type LinkProps = LinkAnchorVariantProps | LinkButtonVariantProps;\n\nconst _Link: React.ForwardRefRenderFunction<BladeElementRef, LinkProps> = (\n {\n children,\n icon,\n iconPosition = 'left',\n isDisabled = false,\n onClick,\n variant = 'anchor',\n color = 'primary',\n href,\n target,\n rel,\n accessibilityLabel,\n size = 'medium',\n testID,\n hitSlop,\n htmlTitle,\n onBlur,\n onFocus,\n onMouseLeave,\n onMouseMove,\n onPointerDown,\n onPointerEnter,\n onTouchStart,\n onTouchEnd,\n onMouseDown,\n onMouseUp,\n ...rest\n },\n ref,\n): ReactElement => {\n return (\n <BaseLink\n {...(icon ? { icon, children } : { children })}\n {...(variant === 'anchor' ? { variant, href, target, rel } : { variant, isDisabled })}\n ref={ref as never}\n iconPosition={iconPosition}\n onClick={onClick}\n accessibilityProps={{ label: accessibilityLabel, describedBy: rest['aria-describedby'] }}\n size={size}\n color={color}\n testID={testID}\n hitSlop={hitSlop}\n htmlTitle={htmlTitle}\n onBlur={onBlur}\n onFocus={onFocus}\n onMouseLeave={onMouseLeave}\n onMouseMove={onMouseMove}\n onPointerDown={onPointerDown}\n onPointerEnter={onPointerEnter}\n onTouchStart={onTouchStart}\n onTouchEnd={onTouchEnd}\n onMouseDown={onMouseDown}\n onMouseUp={onMouseUp}\n {...getStyledProps(rest)}\n {...makeAnalyticsAttribute(rest)}\n />\n );\n};\n\nconst Link = assignWithoutSideEffects(React.forwardRef(_Link), {\n displayName: 'Link',\n componentId: 'Link',\n});\n\nexport default Link;\n"],"names":["_Link","_ref","ref","children","icon","_ref$iconPosition","iconPosition","_ref$isDisabled","isDisabled","onClick","_ref$variant","variant","_ref$color","color","href","target","rel","accessibilityLabel","_ref$size","size","testID","hitSlop","htmlTitle","onBlur","onFocus","onMouseLeave","onMouseMove","onPointerDown","onPointerEnter","onTouchStart","onTouchEnd","onMouseDown","onMouseUp","rest","_objectWithoutProperties","_excluded","_jsx","BaseLink","Object","assign","accessibilityProps","label","describedBy","getStyledProps","makeAnalyticsAttribute","Link","assignWithoutSideEffects","React","forwardRef","displayName","componentId"],"mappings":";;;;;;;;;;;;;kTA2HA,IAAMA,KAAiE,CAAG,SAApEA,KAAiEA,CAAAC,IAAA,CA6BrEC,GAAG,CACc,CAAA,IA5BfC,QAAQ,CAAAF,IAAA,CAARE,QAAQ,CACRC,IAAI,CAAAH,IAAA,CAAJG,IAAI,CAAAC,iBAAA,CAAAJ,IAAA,CACJK,YAAY,CAAZA,YAAY,CAAAD,iBAAA,UAAG,MAAM,CAAAA,iBAAA,CAAAE,eAAA,CAAAN,IAAA,CACrBO,UAAU,CAAVA,UAAU,CAAAD,eAAA,GAAG,KAAA,CAAA,CAAA,KAAK,CAAAA,eAAA,CAClBE,OAAO,CAAAR,IAAA,CAAPQ,OAAO,CAAAC,YAAA,CAAAT,IAAA,CACPU,OAAO,CAAPA,OAAO,CAAAD,YAAA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O,CAAPA,OAAO,CAAEG,IAAI,CAAJA,IAAI,CAAEC,MAAM,CAANA,MAAM,CAAEC,GAAG,CAAHA,GAAI,CAAC,CAAG,CAAEL,OAAO,CAAPA,OAAO,CAAEH,UAAU,CAAVA,UAAW,CAAC,CACpFN,CAAAA,GAAG,CAAEA,GAAa,CAClBI,YAAY,CAAEA,YAAa,CAC3BG,OAAO,CAAEA,OAAQ,CACjB+B,kBAAkB,CAAE,CAAEC,KAAK,CAAExB,kBAAkB,CAAEyB,WAAW,CAAET,IAAI,CAAC,kBAAkB,CAAE,CAAE,CACzFd,IAAI,CAAEA,IAAK,CACXN,KAAK,CAAEA,KAAM,CACbO,MAAM,CAAEA,MAAO,CACfC,OAAO,CAAEA,OAAQ,CACjBC,SAAS,CAAEA,SAAU,CACrBC,MAAM,CAAEA,MAAO,CACfC,OAAO,CAAEA,OAAQ,CACjBC,YAAY,CAAEA,YAAa,CAC3BC,WAAW,CAAEA,WAAY,CACzBC,aAAa,CAAEA,aAAc,CAC7BC,cAAc,CAAEA,cAAe,CAC/BC,YAAY,CAAEA,YAAa,CAC3BC,UAAU,CAAEA,UAAW,CACvBC,WAAW,CAAEA,WAAY,CACzBC,SAAS,CAAEA,SAAU,CACjBW,CAAAA,cAAc,CAACV,IAAI,CAAC,CACpBW,sBAAsB,CAACX,IAAI,CAAC,CACjC,CAAC,CAEN,CAAC,CAEK,IAAAY,IAAI,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAAChD,KAAK,CAAC,CAAE,CAC7DiD,WAAW,CAAE,MAAM,CACnBC,WAAW,CAAE,MACf,CAAC;;;;"}
|
|
@@ -23,8 +23,9 @@ import '../BottomSheet/BottomSheetStack.js';
|
|
|
23
23
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
24
24
|
import { BaseBox } from '../Box/BaseBox/BaseBox.native.js';
|
|
25
25
|
import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.native.js';
|
|
26
|
+
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
26
27
|
|
|
27
|
-
var _excluded=["accessibilityLabel","color","type","isIndeterminate","label","showPercentage","size","value","variant","min","max","testID"];var progressBarHeight={small:size[2],medium:size[4],large:size[0]};var ProgressBar=function ProgressBar(_ref){var _label$trim;var accessibilityLabel=_ref.accessibilityLabel,color=_ref.color,type=_ref.type,_ref$isIndeterminate=_ref.isIndeterminate,isIndeterminate=_ref$isIndeterminate===void 0?false:_ref$isIndeterminate,label=_ref.label,_ref$showPercentage=_ref.showPercentage,showPercentage=_ref$showPercentage===void 0?true:_ref$showPercentage,_ref$size=_ref.size,size=_ref$size===void 0?'small':_ref$size,_ref$value=_ref.value,value=_ref$value===void 0?0:_ref$value,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'progress':_ref$variant,_ref$min=_ref.min,min=_ref$min===void 0?0:_ref$min,_ref$max=_ref.max,max=_ref$max===void 0?100:_ref$max,testID=_ref.testID,
|
|
28
|
+
var _excluded=["accessibilityLabel","color","type","isIndeterminate","label","showPercentage","size","value","variant","min","max","testID"];var progressBarHeight={small:size[2],medium:size[4],large:size[0]};var ProgressBar=function ProgressBar(_ref){var _label$trim;var accessibilityLabel=_ref.accessibilityLabel,color=_ref.color,type=_ref.type,_ref$isIndeterminate=_ref.isIndeterminate,isIndeterminate=_ref$isIndeterminate===void 0?false:_ref$isIndeterminate,label=_ref.label,_ref$showPercentage=_ref.showPercentage,showPercentage=_ref$showPercentage===void 0?true:_ref$showPercentage,_ref$size=_ref.size,size=_ref$size===void 0?'small':_ref$size,_ref$value=_ref.value,value=_ref$value===void 0?0:_ref$value,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'progress':_ref$variant,_ref$min=_ref.min,min=_ref$min===void 0?0:_ref$min,_ref$max=_ref.max,max=_ref$max===void 0?100:_ref$max,testID=_ref.testID,rest=_objectWithoutProperties(_ref,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var progressType=!type&&(variant==='meter'||variant==='progress')?variant:type;var progressVariant=variant==='meter'||variant==='progress'?'linear':variant;var id=useId(`${progressType}-${progressVariant}`);if(__DEV__){if(progressType==='meter'&&isIndeterminate){throwBladeError({moduleName:'ProgressBar',message:`Cannot set 'isIndeterminate' when 'type' or 'variant' is 'meter'.`});}if(progressVariant==='circular'&&isIndeterminate){throwBladeError({moduleName:'ProgressBar',message:`Cannot set 'isIndeterminate' when 'variant' is 'circular'.`});}if(progressVariant==='linear'&&size==='large'){throwBladeError({moduleName:'ProgressBar',message:`Large size isn't available when 'variant' is 'linear'.`});}if(type&&(variant==='progress'||variant==='meter')){throwBladeError({moduleName:'ProgressBar',message:`variant can only be 'linear' or 'circular' when 'type=${type}'.`});}}var unfilledBackgroundColor=theme.colors.feedback.background.neutral.subtle;var filledBackgroundColor=color?theme.colors.feedback.background[color].intense:theme.colors.surface.background.primary.intense;var hasLabel=label&&((_label$trim=label.trim())==null?void 0:_label$trim.length)>0;var isMeter=progressType==='meter';var isCircular=progressVariant==='circular';var progressValue=clamp(value,min,max);var percentageValue=(progressValue-min)*100/(max-min);var percentageProgressValue=isMeter?parseFloat(percentageValue.toFixed(1)):Math.floor(percentageValue);var shouldShowPercentage=showPercentage&&!isMeter&&!isIndeterminate;var accessibilityProps={role:'progressbar',label:accessibilityLabel!=null?accessibilityLabel:label,valueNow:percentageProgressValue,valueText:`${percentageProgressValue}%`,valueMin:min,valueMax:max};if(isMeter){accessibilityProps.role='meter';accessibilityProps.valueNow=progressValue;accessibilityProps.valueText=`${progressValue}`;}if(isIndeterminate){accessibilityProps.valueNow=undefined;accessibilityProps.valueMin=undefined;accessibilityProps.valueMax=undefined;accessibilityProps.valueText=undefined;}return jsx(BaseBox,Object.assign({},getStyledProps(rest),metaAttribute({name:MetaConstants.ProgressBar,testID:testID}),makeAnalyticsAttribute(rest),{children:jsxs(BaseBox,{display:"flex",flexDirection:"column",width:"100%",children:[!isCircular?jsxs(BaseBox,{display:"flex",flexDirection:"row",justifyContent:hasLabel?'space-between':'flex-end',children:[hasLabel?jsx(Text,{as:"label",variant:"body",size:"small",color:"surface.text.gray.subtle",children:label}):null,shouldShowPercentage?jsx(BaseBox,{marginBottom:"spacing.2",children:jsx(Text,{variant:"body",size:"small",color:"surface.text.gray.subtle",children:`${percentageProgressValue}%`})}):null]}):null,jsx(BaseBox,Object.assign({id:id},makeAccessible({role:accessibilityProps.role,label:accessibilityProps.label,valueNow:accessibilityProps.valueNow,valueText:accessibilityProps.valueText,valueMin:accessibilityProps.valueMin,valueMax:accessibilityProps.valueMax}),{children:isCircular?jsx(CircularProgressBarFilled,{size:size,label:label,progressPercent:percentageProgressValue,isMeter:isMeter,showPercentage:showPercentage,backgroundColor:unfilledBackgroundColor,fillColor:filledBackgroundColor,pulseMotionDuration:"duration.2xgentle",fillMotionDuration:"duration.2xgentle",pulseMotionDelay:"delay.long",motionEasing:"easing.standard.revealing"}):jsx(BaseBox,{backgroundColor:unfilledBackgroundColor,height:makeSize(progressBarHeight[size]),overflow:"hidden",position:"relative",children:jsx(ProgressBarFilled,{backgroundColor:filledBackgroundColor,progress:percentageProgressValue,fillMotionDuration:"duration.2xgentle",pulseMotionDuration:"duration.2xgentle",indeterminateMotionDuration:"duration.2xgentle",pulseMotionDelay:"delay.long",motionEasing:"easing.standard.revealing",type:progressType,isIndeterminate:isIndeterminate})})}))]})}));};
|
|
28
29
|
|
|
29
30
|
export { ProgressBar };
|
|
30
31
|
//# sourceMappingURL=ProgressBar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgressBar.js","sources":["../../../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { ProgressBarFilled } from './ProgressBarFilled';\nimport { CircularProgressBarFilled } from './CircularProgressBar';\nimport clamp from '~utils/lodashButBetter/clamp';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { Text } from '~components/Typography/Text';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { useId } from '~utils/useId';\nimport { useTheme } from '~components/BladeProvider';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { FeedbackColors } from '~tokens/theme/theme';\nimport { size } from '~tokens/global';\nimport type { TestID } from '~utils/types';\nimport { makeSize } from '~utils/makeSize';\nimport type { AccessibilityProps } from '~utils/makeAccessible';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { throwBladeError } from '~utils/logger';\n\ntype ProgressBarCommonProps = {\n /**\n * Sets aria-label to help users know what the progress bar is for. Default value is the same as the `label` passed.\n */\n accessibilityLabel?: string;\n /**\n * Sets the color of the progress bar which changes the feedback color.\n */\n color?: FeedbackColors;\n /**\n * Sets the type of the progress bar.\n * @default 'progress'\n */\n type?: 'meter' | 'progress';\n /**\n * Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.\n */\n label?: string;\n /**\n * Sets the size of the progress bar.\n * Note: 'large' size isn't available when the variant is 'linear'.\n * @default 'small'\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the progress value of the progress bar.\n * @default 'small'\n */\n value?: number;\n /**\n * Sets the minimum value for the progress bar.\n * @default 0\n */\n min?: number;\n /**\n * Sets the maximum value for the progress bar.\n * @default 100\n */\n max?: number;\n} & TestID &\n StyledPropsBlade;\n\ntype ProgressBarVariant = 'progress' | 'meter' | 'linear' | 'circular';\n\ntype ProgressBarProgressProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for the progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'progress' | 'linear' | 'circular'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default true\n */\n showPercentage?: boolean;\n};\n\ntype ProgressBarMeterProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for thr progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'meter' | 'linear' | 'circular'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: undefined;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default false\n */\n showPercentage?: undefined;\n};\n\ntype ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;\n\nconst progressBarHeight: Record<NonNullable<ProgressBarProps['size']>, 2 | 4 | 0> = {\n small: size[2],\n medium: size[4],\n // Large size isn't available when variant is 'linear'\n large: size[0],\n};\n\nconst ProgressBar = ({\n accessibilityLabel,\n color,\n type,\n isIndeterminate = false,\n label,\n showPercentage = true,\n size = 'small',\n value = 0,\n variant = 'progress',\n min = 0,\n max = 100,\n testID,\n ...styledProps\n}: ProgressBarProps): ReactElement => {\n const { theme } = useTheme();\n const progressType = !type && (variant === 'meter' || variant === 'progress') ? variant : type;\n const progressVariant = variant === 'meter' || variant === 'progress' ? 'linear' : variant;\n const id = useId(`${progressType}-${progressVariant}`);\n\n if (__DEV__) {\n if (progressType === 'meter' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'type' or 'variant' is 'meter'.`,\n });\n }\n\n if (progressVariant === 'circular' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'variant' is 'circular'.`,\n });\n }\n\n if (progressVariant === 'linear' && size === 'large') {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Large size isn't available when 'variant' is 'linear'.`,\n });\n }\n\n if (type && (variant === 'progress' || variant === 'meter')) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `variant can only be 'linear' or 'circular' when 'type=${type}'.`,\n });\n }\n }\n\n const unfilledBackgroundColor = theme.colors.feedback.background.neutral\n .subtle as BaseBoxProps['backgroundColor'];\n const filledBackgroundColor = color\n ? theme.colors.feedback.background[color].intense\n : theme.colors.surface.background.primary.intense;\n const hasLabel = label && label.trim()?.length > 0;\n const isMeter = progressType === 'meter';\n const isCircular = progressVariant === 'circular';\n const progressValue = clamp(value, min, max);\n const percentageValue = ((progressValue - min) * 100) / (max - min);\n const percentageProgressValue = isMeter\n ? parseFloat(percentageValue.toFixed(1))\n : Math.floor(percentageValue);\n const shouldShowPercentage = showPercentage && !isMeter && !isIndeterminate;\n const accessibilityProps: Pick<\n AccessibilityProps,\n 'role' | 'label' | 'valueMax' | 'valueNow' | 'valueMin' | 'valueText'\n > = {\n role: 'progressbar',\n label: accessibilityLabel ?? label,\n valueNow: percentageProgressValue,\n valueText: `${percentageProgressValue}%`,\n valueMin: min,\n valueMax: max,\n };\n\n if (isMeter) {\n accessibilityProps.role = 'meter';\n accessibilityProps.valueNow = progressValue;\n accessibilityProps.valueText = `${progressValue}`;\n }\n\n if (isIndeterminate) {\n accessibilityProps.valueNow = undefined;\n accessibilityProps.valueMin = undefined;\n accessibilityProps.valueMax = undefined;\n accessibilityProps.valueText = undefined;\n }\n\n return (\n <BaseBox\n {...getStyledProps(styledProps)}\n {...metaAttribute({ name: MetaConstants.ProgressBar, testID })}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\" width=\"100%\">\n {!isCircular ? (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent={hasLabel ? 'space-between' : 'flex-end'}\n >\n {hasLabel ? (\n <Text as=\"label\" variant=\"body\" size=\"small\" color=\"surface.text.gray.subtle\">\n {label}\n </Text>\n ) : null}\n {shouldShowPercentage ? (\n <BaseBox marginBottom=\"spacing.2\">\n <Text\n variant=\"body\"\n size=\"small\"\n color=\"surface.text.gray.subtle\"\n >{`${percentageProgressValue}%`}</Text>\n </BaseBox>\n ) : null}\n </BaseBox>\n ) : null}\n\n <BaseBox\n id={id}\n {...makeAccessible({\n role: accessibilityProps.role,\n label: accessibilityProps.label,\n valueNow: accessibilityProps.valueNow,\n valueText: accessibilityProps.valueText,\n valueMin: accessibilityProps.valueMin,\n valueMax: accessibilityProps.valueMax,\n })}\n >\n {isCircular ? (\n <CircularProgressBarFilled\n size={size}\n label={label}\n progressPercent={percentageProgressValue}\n isMeter={isMeter}\n showPercentage={showPercentage}\n backgroundColor={unfilledBackgroundColor as string}\n fillColor={filledBackgroundColor}\n pulseMotionDuration=\"duration.2xgentle\"\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n />\n ) : (\n <BaseBox\n backgroundColor={unfilledBackgroundColor}\n height={makeSize(progressBarHeight[size])}\n overflow=\"hidden\"\n position=\"relative\"\n >\n <ProgressBarFilled\n backgroundColor={filledBackgroundColor}\n progress={percentageProgressValue}\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDuration=\"duration.2xgentle\"\n indeterminateMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n type={progressType}\n isIndeterminate={isIndeterminate}\n />\n </BaseBox>\n )}\n </BaseBox>\n </BaseBox>\n </BaseBox>\n );\n};\n\nexport type { ProgressBarProps, ProgressBarVariant };\nexport { ProgressBar };\n"],"names":["progressBarHeight","small","size","medium","large","ProgressBar","_ref","_label$trim","accessibilityLabel","color","type","_ref$isIndeterminate","isIndeterminate","label","_ref$showPercentage","showPercentage","_ref$size","_ref$value","value","_ref$variant","variant","_ref$min","min","_ref$max","max","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","progressType","progressVariant","id","useId","__DEV__","throwBladeError","moduleName","message","unfilledBackgroundColor","colors","feedback","background","neutral","subtle","filledBackgroundColor","intense","surface","primary","hasLabel","trim","length","isMeter","isCircular","progressValue","clamp","percentageValue","percentageProgressValue","parseFloat","toFixed","Math","floor","shouldShowPercentage","accessibilityProps","role","valueNow","valueText","valueMin","valueMax","undefined","_jsx","BaseBox","Object","assign","getStyledProps","metaAttribute","name","MetaConstants","children","_jsxs","display","flexDirection","width","justifyContent","Text","as","marginBottom","makeAccessible","CircularProgressBarFilled","progressPercent","backgroundColor","fillColor","pulseMotionDuration","fillMotionDuration","pulseMotionDelay","motionEasing","height","makeSize","overflow","position","ProgressBarFilled","progress","indeterminateMotionDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;6IAsGA,IAAMA,iBAA2E,CAAG,CAClFC,KAAK,CAAEC,IAAI,CAAC,CAAC,CAAC,CACdC,MAAM,CAAED,IAAI,CAAC,CAAC,CAAC,CAEfE,KAAK,CAAEF,IAAI,CAAC,CAAC,CACf,CAAC,CAEK,IAAAG,WAAW,CAAG,SAAdA,WAAWA,CAAAC,IAAA,CAcqB,KAAAC,WAAA,CAAA,IAbpCC,kBAAkB,CAAAF,IAAA,CAAlBE,kBAAkB,CAClBC,KAAK,CAAAH,IAAA,CAALG,KAAK,CACLC,IAAI,CAAAJ,IAAA,CAAJI,IAAI,CAAAC,oBAAA,CAAAL,IAAA,CACJM,eAAe,CAAfA,eAAe,CAAAD,oBAAA,UAAG,KAAK,CAAAA,oBAAA,CACvBE,KAAK,CAAAP,IAAA,CAALO,KAAK,CAAAC,mBAAA,CAAAR,IAAA,CACLS,cAAc,CAAdA,cAAc,CAAAD,mBAAA,GAAG,KAAA,CAAA,CAAA,IAAI,CAAAA,mBAAA,CAAAE,SAAA,CAAAV,IAAA,CACrBJ,IAAI,CAAJA,IAAI,CAAAc,SAAA,GAAA,KAAA,CAAA,CAAG,OAAO,CAAAA,SAAA,CAAAC,UAAA,CAAAX,IAAA,CACdY,KAAK,CAALA,KAAK,CAAAD,UAAA,GAAG,KAAA,CAAA,CAAA,CAAC,CAAAA,UAAA,CAAAE,YAAA,CAAAb,IAAA,CACTc,OAAO,CAAPA,OAAO,CAAAD,YAAA,GAAA,KAAA,CAAA,CAAG,UAAU,CAAAA,YAAA,CAAAE,QAAA,CAAAf,IAAA,CACpBgB,GAAG,CAAHA,GAAG,CAAAD,QAAA,GAAG,KAAA,CAAA,CAAA,CAAC,CA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C,UAAU,CAAArB,QAAA,CAEnBR,GAAA,CAAC8B,iBAAiB,CAChBV,CAAAA,eAAe,CAAE7C,qBAAsB,CACvCwD,QAAQ,CAAE5C,uBAAwB,CAClCoC,kBAAkB,CAAC,mBAAmB,CACtCD,mBAAmB,CAAC,mBAAmB,CACvCU,2BAA2B,CAAC,mBAAmB,CAC/CR,gBAAgB,CAAC,YAAY,CAC7BC,YAAY,CAAC,2BAA2B,CACxCtF,IAAI,CAAEsB,YAAa,CACnBpB,eAAe,CAAEA,eAAgB,CAClC,CAAC,CACK,CACV,CACM,CAAA,CAAC,CACH,CAAA,CAAC,CACH,CAAA,CAAC,CAEd;;;;"}
|
|
1
|
+
{"version":3,"file":"ProgressBar.js","sources":["../../../../../src/components/ProgressBar/ProgressBar.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport { ProgressBarFilled } from './ProgressBarFilled';\nimport { CircularProgressBarFilled } from './CircularProgressBar';\nimport clamp from '~utils/lodashButBetter/clamp';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { Text } from '~components/Typography/Text';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { useId } from '~utils/useId';\nimport { useTheme } from '~components/BladeProvider';\nimport type { BaseBoxProps } from '~components/Box/BaseBox';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { FeedbackColors } from '~tokens/theme/theme';\nimport { size } from '~tokens/global';\nimport type { DataAnalyticsAttribute, TestID } from '~utils/types';\nimport { makeSize } from '~utils/makeSize';\nimport type { AccessibilityProps } from '~utils/makeAccessible';\nimport { makeAccessible } from '~utils/makeAccessible';\nimport { throwBladeError } from '~utils/logger';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype ProgressBarCommonProps = {\n /**\n * Sets aria-label to help users know what the progress bar is for. Default value is the same as the `label` passed.\n */\n accessibilityLabel?: string;\n /**\n * Sets the color of the progress bar which changes the feedback color.\n */\n color?: FeedbackColors;\n /**\n * Sets the type of the progress bar.\n * @default 'progress'\n */\n type?: 'meter' | 'progress';\n /**\n * Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.\n */\n label?: string;\n /**\n * Sets the size of the progress bar.\n * Note: 'large' size isn't available when the variant is 'linear'.\n * @default 'small'\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Sets the progress value of the progress bar.\n * @default 'small'\n */\n value?: number;\n /**\n * Sets the minimum value for the progress bar.\n * @default 0\n */\n min?: number;\n /**\n * Sets the maximum value for the progress bar.\n * @default 100\n */\n max?: number;\n} & TestID &\n DataAnalyticsAttribute &\n StyledPropsBlade;\n\ntype ProgressBarVariant = 'progress' | 'meter' | 'linear' | 'circular';\n\ntype ProgressBarProgressProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for the progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'progress' | 'linear' | 'circular'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: boolean;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default true\n */\n showPercentage?: boolean;\n};\n\ntype ProgressBarMeterProps = ProgressBarCommonProps & {\n /**\n * Sets the variant to be rendered for thr progress bar.\n * @default 'progress'\n */\n variant?: Extract<ProgressBarVariant, 'meter' | 'linear' | 'circular'>;\n /**\n * Sets whether the progress bar is in an indeterminate state.\n * @default false\n */\n isIndeterminate?: undefined;\n /**\n * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.\n * @default false\n */\n showPercentage?: undefined;\n};\n\ntype ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;\n\nconst progressBarHeight: Record<NonNullable<ProgressBarProps['size']>, 2 | 4 | 0> = {\n small: size[2],\n medium: size[4],\n // Large size isn't available when variant is 'linear'\n large: size[0],\n};\n\nconst ProgressBar = ({\n accessibilityLabel,\n color,\n type,\n isIndeterminate = false,\n label,\n showPercentage = true,\n size = 'small',\n value = 0,\n variant = 'progress',\n min = 0,\n max = 100,\n testID,\n ...rest\n}: ProgressBarProps): ReactElement => {\n const { theme } = useTheme();\n const progressType = !type && (variant === 'meter' || variant === 'progress') ? variant : type;\n const progressVariant = variant === 'meter' || variant === 'progress' ? 'linear' : variant;\n const id = useId(`${progressType}-${progressVariant}`);\n\n if (__DEV__) {\n if (progressType === 'meter' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'type' or 'variant' is 'meter'.`,\n });\n }\n\n if (progressVariant === 'circular' && isIndeterminate) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Cannot set 'isIndeterminate' when 'variant' is 'circular'.`,\n });\n }\n\n if (progressVariant === 'linear' && size === 'large') {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `Large size isn't available when 'variant' is 'linear'.`,\n });\n }\n\n if (type && (variant === 'progress' || variant === 'meter')) {\n throwBladeError({\n moduleName: 'ProgressBar',\n message: `variant can only be 'linear' or 'circular' when 'type=${type}'.`,\n });\n }\n }\n\n const unfilledBackgroundColor = theme.colors.feedback.background.neutral\n .subtle as BaseBoxProps['backgroundColor'];\n const filledBackgroundColor = color\n ? theme.colors.feedback.background[color].intense\n : theme.colors.surface.background.primary.intense;\n const hasLabel = label && label.trim()?.length > 0;\n const isMeter = progressType === 'meter';\n const isCircular = progressVariant === 'circular';\n const progressValue = clamp(value, min, max);\n const percentageValue = ((progressValue - min) * 100) / (max - min);\n const percentageProgressValue = isMeter\n ? parseFloat(percentageValue.toFixed(1))\n : Math.floor(percentageValue);\n const shouldShowPercentage = showPercentage && !isMeter && !isIndeterminate;\n const accessibilityProps: Pick<\n AccessibilityProps,\n 'role' | 'label' | 'valueMax' | 'valueNow' | 'valueMin' | 'valueText'\n > = {\n role: 'progressbar',\n label: accessibilityLabel ?? label,\n valueNow: percentageProgressValue,\n valueText: `${percentageProgressValue}%`,\n valueMin: min,\n valueMax: max,\n };\n\n if (isMeter) {\n accessibilityProps.role = 'meter';\n accessibilityProps.valueNow = progressValue;\n accessibilityProps.valueText = `${progressValue}`;\n }\n\n if (isIndeterminate) {\n accessibilityProps.valueNow = undefined;\n accessibilityProps.valueMin = undefined;\n accessibilityProps.valueMax = undefined;\n accessibilityProps.valueText = undefined;\n }\n\n return (\n <BaseBox\n {...getStyledProps(rest)}\n {...metaAttribute({ name: MetaConstants.ProgressBar, testID })}\n {...makeAnalyticsAttribute(rest)}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\" width=\"100%\">\n {!isCircular ? (\n <BaseBox\n display=\"flex\"\n flexDirection=\"row\"\n justifyContent={hasLabel ? 'space-between' : 'flex-end'}\n >\n {hasLabel ? (\n <Text as=\"label\" variant=\"body\" size=\"small\" color=\"surface.text.gray.subtle\">\n {label}\n </Text>\n ) : null}\n {shouldShowPercentage ? (\n <BaseBox marginBottom=\"spacing.2\">\n <Text\n variant=\"body\"\n size=\"small\"\n color=\"surface.text.gray.subtle\"\n >{`${percentageProgressValue}%`}</Text>\n </BaseBox>\n ) : null}\n </BaseBox>\n ) : null}\n\n <BaseBox\n id={id}\n {...makeAccessible({\n role: accessibilityProps.role,\n label: accessibilityProps.label,\n valueNow: accessibilityProps.valueNow,\n valueText: accessibilityProps.valueText,\n valueMin: accessibilityProps.valueMin,\n valueMax: accessibilityProps.valueMax,\n })}\n >\n {isCircular ? (\n <CircularProgressBarFilled\n size={size}\n label={label}\n progressPercent={percentageProgressValue}\n isMeter={isMeter}\n showPercentage={showPercentage}\n backgroundColor={unfilledBackgroundColor as string}\n fillColor={filledBackgroundColor}\n pulseMotionDuration=\"duration.2xgentle\"\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n />\n ) : (\n <BaseBox\n backgroundColor={unfilledBackgroundColor}\n height={makeSize(progressBarHeight[size])}\n overflow=\"hidden\"\n position=\"relative\"\n >\n <ProgressBarFilled\n backgroundColor={filledBackgroundColor}\n progress={percentageProgressValue}\n fillMotionDuration=\"duration.2xgentle\"\n pulseMotionDuration=\"duration.2xgentle\"\n indeterminateMotionDuration=\"duration.2xgentle\"\n pulseMotionDelay=\"delay.long\"\n motionEasing=\"easing.standard.revealing\"\n type={progressType}\n isIndeterminate={isIndeterminate}\n />\n </BaseBox>\n )}\n </BaseBox>\n </BaseBox>\n </BaseBox>\n );\n};\n\nexport type { ProgressBarProps, ProgressBarVariant };\nexport { ProgressBar };\n"],"names":["progressBarHeight","small","size","medium","large","ProgressBar","_ref","_label$trim","accessibilityLabel","color","type","_ref$isIndeterminate","isIndeterminate","label","_ref$showPercentage","showPercentage","_ref$size","_ref$value","value","_ref$variant","variant","_ref$min","min","_ref$max","max","testID","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","progressType","progressVariant","id","useId","__DEV__","throwBladeError","moduleName","message","unfilledBackgroundColor","colors","feedback","background","neutral","subtle","filledBackgroundColor","intense","surface","primary","hasLabel","trim","length","isMeter","isCircular","progressValue","clamp","percentageValue","percentageProgressValue","parseFloat","toFixed","Math","floor","shouldShowPercentage","accessibilityProps","role","valueNow","valueText","valueMin","valueMax","undefined","_jsx","BaseBox","Object","assign","getStyledProps","metaAttribute","name","MetaConstants","makeAnalyticsAttribute","children","_jsxs","display","flexDirection","width","justifyContent","Text","as","marginBottom","makeAccessible","CircularProgressBarFilled","progressPercent","backgroundColor","fillColor","pulseMotionDuration","fillMotionDuration","pulseMotionDelay","motionEasing","height","makeSize","overflow","position","ProgressBarFilled","progress","indeterminateMotionDuration"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;6IAwGA,IAAMA,iBAA2E,CAAG,CAClFC,KAAK,CAAEC,IAAI,CAAC,CAAC,CAAC,CACdC,MAAM,CAAED,IAAI,CAAC,CAAC,CAAC,CAEfE,KAAK,CAAEF,IAAI,CAAC,CAAC,CACf,CAAC,CAEK,IAAAG,WAAW,CAAG,SAAdA,WAAWA,CAAAC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ClC,CAAC,CACK,CACV,CACM,CAAA,CAAC,CACH,CAAA,CAAC,CACH,CAAA,CAAC,CAEd;;;;"}
|
|
@@ -22,9 +22,10 @@ import useTheme from '../BladeProvider/useTheme.js';
|
|
|
22
22
|
import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
|
|
23
23
|
import '@babel/runtime/helpers/defineProperty';
|
|
24
24
|
import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
|
|
25
|
+
import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
25
26
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
26
27
|
|
|
27
|
-
var _excluded=["value","children","helpText","isDisabled","size","testID"];var _Radio=function _Radio(_ref,ref){var _groupProps$state,_groupProps$size;var value=_ref.value,children=_ref.children,helpText=_ref.helpText,isDisabled=_ref.isDisabled,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,
|
|
28
|
+
var _excluded=["value","children","helpText","isDisabled","size","testID"];var _Radio=function _Radio(_ref,ref){var _groupProps$state,_groupProps$size;var value=_ref.value,children=_ref.children,helpText=_ref.helpText,isDisabled=_ref.isDisabled,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,rest=_objectWithoutProperties(_ref,_excluded);var _useTheme=useTheme(),theme=_useTheme.theme;var groupProps=useRadioGroupContext();var isInsideGroup=!isEmpty(groupProps);if(__DEV__){if(!isInsideGroup){throwBladeError({moduleName:'Radio',message:'Cannot use <Radio /> outside of <RadioGroup />'});}}var isChecked=groupProps==null?void 0:(_groupProps$state=groupProps.state)==null?void 0:_groupProps$state.isChecked(value);var defaultChecked=(groupProps==null?void 0:groupProps.defaultValue)===undefined?undefined:(groupProps==null?void 0:groupProps.defaultValue)===value;var validationState=groupProps==null?void 0:groupProps.validationState;var hasError=validationState==='error';var _isDisabled=isDisabled!=null?isDisabled:groupProps==null?void 0:groupProps.isDisabled;var _isRequired=(groupProps==null?void 0:groupProps.isRequired)||(groupProps==null?void 0:groupProps.necessityIndicator)==='required';var name=groupProps==null?void 0:groupProps.name;var showHelpText=helpText;var isReactNative=getPlatformType()==='react-native';var _size=(_groupProps$size=groupProps.size)!=null?_groupProps$size:size;var handleChange=function handleChange(_ref2){var isChecked=_ref2.isChecked,value=_ref2.value;if(isChecked){var _groupProps$state2;groupProps==null?void 0:(_groupProps$state2=groupProps.state)==null?void 0:_groupProps$state2.setValue(value);}else {var _groupProps$state3;groupProps==null?void 0:(_groupProps$state3=groupProps.state)==null?void 0:_groupProps$state3.removeValue();}};var _useRadio=useRadio({defaultChecked:defaultChecked,isChecked:isChecked,hasError:hasError,isDisabled:_isDisabled,isRequired:_isRequired,name:name,value:value,onChange:handleChange}),state=_useRadio.state,ids=_useRadio.ids,inputProps=_useRadio.inputProps;var helpTextLeftSpacing=makeSize(radioSizes.icon[size].width+theme.spacing[3]);return jsx(BaseBox,Object.assign({},getStyledProps(rest),{children:jsx(SelectorLabel,{componentName:MetaConstants.RadioLabel,inputProps:isReactNative?inputProps:{},testID:testID,children:jsxs(BaseBox,{display:"flex",flexDirection:"column",children:[jsxs(BaseBox,{display:"flex",alignItems:"center",flexDirection:"row",children:[jsx(SelectorInput,Object.assign({hoverTokens:radioHoverTokens,isChecked:state.isChecked,isDisabled:_isDisabled,hasError:hasError,inputProps:inputProps,ref:ref},makeAnalyticsAttribute(rest))),jsx(RadioIcon,{size:_size,isChecked:state.isChecked,isDisabled:_isDisabled,isNegative:hasError}),children?jsx(SelectorTitle,{size:_size,isDisabled:_isDisabled,children:children}):null]}),showHelpText&&jsx(BaseBox,{marginLeft:helpTextLeftSpacing,children:jsx(SelectorSupportText,{size:_size,id:ids==null?void 0:ids.helpTextId,children:helpText})})]})})}));};var Radio=assignWithoutSideEffects(React__default.forwardRef(_Radio),{displayName:'Radio'});
|
|
28
29
|
|
|
29
30
|
export { Radio };
|
|
30
31
|
//# sourceMappingURL=Radio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type { BladeElementRef, StringChildrenType, TestID } from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...styledProps },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(styledProps)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","styledProps","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","__DEV__","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","Object","assign","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,UAAA,CAAA,UAAA,CAAA,YAAA,CAAA,MAAA,CAAA,QAAA,CAAA,CAiDA,IAAMA,MAAmE,CAAG,SAAtEA,MAAmEA,CAAAC,IAAA,CAEvEC,GAAG,CACA,KAAAC,iBAAA,CAAAC,gBAAA,CAFD,IAAAC,KAAK,CAAAJ,IAAA,CAALI,KAAK,CAAEC,QAAQ,CAAAL,IAAA,CAARK,QAAQ,CAAEC,QAAQ,CAAAN,IAAA,CAARM,QAAQ,CAAEC,UAAU,CAAAP,IAAA,CAAVO,UAAU,CAAAC,SAAA,CAAAR,IAAA,CAAES,IAAI,CAAJA,IAAI,CAAAD,SAAA,GAAA,KAAA,CAAA,CAA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,CACTgC,YAAY,EACXqB,GAAA,CAACC,OAAO,CAAA,CAACkB,UAAU,CAAEzB,mBAAoB,CAAA/C,QAAA,CACvCqD,GAAA,CAACoB,mBAAmB,CAACrE,CAAAA,IAAI,CAAE+B,KAAM,CAACuC,EAAE,CAAE7B,GAAG,EAAHA,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,GAAG,CAAE8B,UAAW,CAAA3E,QAAA,CACnDC,QAAQ,CACU,CAAC,CACf,CACV,CAAA,CACM,CAAC,CACG,CAAC,EACT,CAAC,CAEd,CAAC,CAEK,IAAA2E,KAAK,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAACrF,MAAM,CAAC,CAAE,CAAEsF,WAAW,CAAE,OAAQ,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../../../../src/components/Radio/Radio.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-plus-operands */\n/* eslint-disable @typescript-eslint/no-shadow */\nimport React from 'react';\nimport type { OnChange } from './useRadio';\nimport { useRadio } from './useRadio';\nimport { RadioIcon } from './RadioIcon/RadioIcon';\nimport { useRadioGroupContext } from './RadioGroup/RadioContext';\nimport { radioHoverTokens, radioSizes } from './radioTokens';\nimport isEmpty from '~utils/lodashButBetter/isEmpty';\nimport { SelectorLabel } from '~components/Form/Selector/SelectorLabel';\nimport BaseBox from '~components/Box/BaseBox';\nimport { SelectorTitle } from '~components/Form/Selector/SelectorTitle';\nimport { SelectorSupportText } from '~components/Form/Selector/SelectorSupportText';\nimport { SelectorInput } from '~components/Form/Selector/SelectorInput';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport type {\n BladeElementRef,\n DataAnalyticsAttribute,\n StringChildrenType,\n TestID,\n} from '~utils/types';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { getPlatformType, makeSize, useTheme } from '~utils';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { throwBladeError } from '~utils/logger';\nimport { makeAnalyticsAttribute } from '~utils/makeAnalyticsAttribute';\n\ntype RadioProps = {\n /**\n * Sets the label text of the Radio\n */\n children?: StringChildrenType;\n /**\n * Help text for the Radio\n */\n helpText?: string;\n /**\n * The value to be used in the Radio input.\n * This is the value that will be returned on form submission.\n */\n value: string;\n /**\n * If `true`, the Radio will be disabled\n *\n * @default false\n */\n isDisabled?: boolean;\n /**\n * Size of the radios\n *\n * @default \"medium\"\n */\n size?: 'small' | 'medium' | 'large';\n} & TestID &\n DataAnalyticsAttribute &\n StyledPropsBlade;\n\nconst _Radio: React.ForwardRefRenderFunction<BladeElementRef, RadioProps> = (\n { value, children, helpText, isDisabled, size = 'medium', testID, ...rest },\n ref,\n) => {\n const { theme } = useTheme();\n const groupProps = useRadioGroupContext();\n const isInsideGroup = !isEmpty(groupProps);\n\n if (__DEV__) {\n if (!isInsideGroup) {\n throwBladeError({\n moduleName: 'Radio',\n message: 'Cannot use <Radio /> outside of <RadioGroup />',\n });\n }\n }\n\n const isChecked = groupProps?.state?.isChecked(value);\n const defaultChecked =\n groupProps?.defaultValue === undefined ? undefined : groupProps?.defaultValue === value;\n const validationState = groupProps?.validationState;\n const hasError = validationState === 'error';\n const _isDisabled = isDisabled ?? groupProps?.isDisabled;\n const _isRequired = groupProps?.isRequired || groupProps?.necessityIndicator === 'required';\n const name = groupProps?.name;\n const showHelpText = helpText;\n const isReactNative = getPlatformType() === 'react-native';\n const _size = groupProps.size ?? size;\n\n const handleChange: OnChange = ({ isChecked, value }) => {\n if (isChecked) {\n groupProps?.state?.setValue(value!);\n } else {\n groupProps?.state?.removeValue();\n }\n };\n\n const { state, ids, inputProps } = useRadio({\n defaultChecked,\n isChecked,\n hasError,\n isDisabled: _isDisabled,\n isRequired: _isRequired,\n name,\n value,\n onChange: handleChange,\n });\n\n // radio icon's size & margin + margin-left of SelectorTitle which is 2\n const helpTextLeftSpacing = makeSize(radioSizes.icon[size].width + theme.spacing[3]);\n\n return (\n <BaseBox {...getStyledProps(rest)}>\n <SelectorLabel\n componentName={MetaConstants.RadioLabel}\n inputProps={isReactNative ? inputProps : {}}\n testID={testID}\n >\n <BaseBox display=\"flex\" flexDirection=\"column\">\n <BaseBox display=\"flex\" alignItems=\"center\" flexDirection=\"row\">\n <SelectorInput\n hoverTokens={radioHoverTokens}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n hasError={hasError}\n inputProps={inputProps}\n ref={ref}\n {...makeAnalyticsAttribute(rest)}\n />\n <RadioIcon\n size={_size}\n isChecked={state.isChecked}\n isDisabled={_isDisabled}\n isNegative={hasError}\n />\n {children ? (\n <SelectorTitle size={_size} isDisabled={_isDisabled}>\n {children}\n </SelectorTitle>\n ) : null}\n </BaseBox>\n {showHelpText && (\n <BaseBox marginLeft={helpTextLeftSpacing}>\n <SelectorSupportText size={_size} id={ids?.helpTextId}>\n {helpText}\n </SelectorSupportText>\n </BaseBox>\n )}\n </BaseBox>\n </SelectorLabel>\n </BaseBox>\n );\n};\n\nconst Radio = assignWithoutSideEffects(React.forwardRef(_Radio), { displayName: 'Radio' });\n\nexport type { RadioProps };\nexport { Radio };\n"],"names":["_Radio","_ref","ref","_groupProps$state","_groupProps$size","value","children","helpText","isDisabled","_ref$size","size","testID","rest","_objectWithoutProperties","_excluded","_useTheme","useTheme","theme","groupProps","useRadioGroupContext","isInsideGroup","isEmpty","__DEV__","throwBladeError","moduleName","message","isChecked","state","defaultChecked","defaultValue","undefined","validationState","hasError","_isDisabled","_isRequired","isRequired","necessityIndicator","name","showHelpText","isReactNative","getPlatformType","_size","handleChange","_ref2","_groupProps$state2","setValue","_groupProps$state3","removeValue","_useRadio","useRadio","onChange","ids","inputProps","helpTextLeftSpacing","makeSize","radioSizes","icon","width","spacing","_jsx","BaseBox","Object","assign","getStyledProps","SelectorLabel","componentName","MetaConstants","RadioLabel","_jsxs","display","flexDirection","alignItems","SelectorInput","hoverTokens","radioHoverTokens","makeAnalyticsAttribute","RadioIcon","isNegative","SelectorTitle","marginLeft","SelectorSupportText","id","helpTextId","Radio","assignWithoutSideEffects","React","forwardRef","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,UAAA,CAAA,UAAA,CAAA,YAAA,CAAA,MAAA,CAAA,QAAA,CAAA,CAwDA,IAAMA,MAAmE,CAAG,SAAtEA,MAAmEA,CAAAC,IAAA,CAEvEC,GAAG,CACA,CAAA,IAAAC,iBAAA,CAAAC,gBAAA,CAFD,IAAAC,KAAK,CAAAJ,IAAA,CAALI,KAAK,CAAEC,QAAQ,CAAAL,IAAA,CAARK,QAAQ,CAAEC,QAAQ,CAAAN,IAAA,CAARM,QAAQ,CAAEC,UAAU,CAAAP,IAAA,CAAVO,UAAU,CAAAC,SAAA,CAAAR,IAAA,CAAES,IAAI,CAAJA,IAAI,CAAAD,SAAA,UAAG,QAAQ,CAAAA,SAAA,CAAEE,MAAM,CAAAV,IAAA,CAANU,MAAM,CAAKC,IAAI,CAAAC,wBAAA,CAAAZ,IAAA,CAAAa,SAAA,CAGzE,CAAA,IAAAC,SAAA,CAAkBC,QAAQ,EAAE,CAApBC,KAAK,CAAAF,SAAA,CAALE,KAAK,CACb,IAAMC,UAAU,CAAGC,oBAAoB,EAAE,CACzC,IAAMC,aAAa,CAAG,CAACC,OAAO,CAACH,UAAU,CAAC,CAE1C,GAAII,OAAO,CAAE,CACX,GAAI,CAACF,aAAa,CAAE,CAClBG,eAAe,CAAC,CACdC,UAAU,CAAE,OAAO,CACnBC,OAAO,CAAE,gDACX,CAAC,CAAC,CACJ,CACF,CAEA,IAAMC,SAAS,CAAGR,UAAU,EAAAf,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA,iBAAA,CAAVe,UAAU,CAAES,KAAK,GAAjBxB,IAAAA,CAAAA,KAAAA,CAAAA,CAAAA,iBAAA,CAAmBuB,SAAS,CAACrB,KAAK,CAAC,CACrD,IAAMuB,cAAc,CA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A,CAC7DqD,GAAA,CAACa,aAAa,CAAAX,MAAA,CAAAC,MAAA,CAAA,CACZW,WAAW,CAAEC,gBAAiB,CAC9BhD,SAAS,CAAEC,KAAK,CAACD,SAAU,CAC3BlB,UAAU,CAAEyB,WAAY,CACxBD,QAAQ,CAAEA,QAAS,CACnBoB,UAAU,CAAEA,UAAW,CACvBlD,GAAG,CAAEA,GAAI,CACLyE,CAAAA,sBAAsB,CAAC/D,IAAI,CAAC,CACjC,CAAC,CACF+C,GAAA,CAACiB,SAAS,CACRlE,CAAAA,IAAI,CAAE+B,KAAM,CACZf,SAAS,CAAEC,KAAK,CAACD,SAAU,CAC3BlB,UAAU,CAAEyB,WAAY,CACxB4C,UAAU,CAAE7C,QAAS,CACtB,CAAC,CACD1B,QAAQ,CACPqD,GAAA,CAACmB,aAAa,CAACpE,CAAAA,IAAI,CAAE+B,KAAM,CAACjC,UAAU,CAAEyB,WAAY,CAAA3B,QAAA,CACjDA,QAAQ,CACI,CAAC,CACd,IAAI,EACD,CAAC,CACTgC,YAAY,EACXqB,GAAA,CAACC,OAAO,EAACmB,UAAU,CAAE1B,mBAAoB,CAAA/C,QAAA,CACvCqD,GAAA,CAACqB,mBAAmB,CAAA,CAACtE,IAAI,CAAE+B,KAAM,CAACwC,EAAE,CAAE9B,GAAG,EAAA,IAAA,CAAA,KAAA,CAAA,CAAHA,GAAG,CAAE+B,UAAW,CAAA5E,QAAA,CACnDC,QAAQ,CACU,CAAC,CACf,CACV,EACM,CAAC,CACG,CAAC,CACT,CAAA,CAAC,CAEd,CAAC,CAEK,IAAA4E,KAAK,CAAGC,wBAAwB,CAACC,cAAK,CAACC,UAAU,CAACtF,MAAM,CAAC,CAAE,CAAEuF,WAAW,CAAE,OAAQ,CAAC;;;;"}
|
|
@@ -20,8 +20,9 @@ import '@gorhom/portal';
|
|
|
20
20
|
import 'react-native-gesture-handler';
|
|
21
21
|
import '../../BottomSheet/BottomSheetStack.js';
|
|
22
22
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
23
|
+
import { makeAnalyticsAttribute } from '../../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
|
|
23
24
|
|
|
24
|
-
var _excluded=["children","label","helpText","isDisabled","isRequired","necessityIndicator","labelPosition","validationState","errorText","name","defaultValue","onChange","value","size","testID"];var RadioGroup=function RadioGroup(_ref){var children=_ref.children,label=_ref.label,helpText=_ref.helpText,_ref$isDisabled=_ref.isDisabled,isDisabled=_ref$isDisabled===void 0?false:_ref$isDisabled,_ref$isRequired=_ref.isRequired,isRequired=_ref$isRequired===void 0?false:_ref$isRequired,_ref$necessityIndicat=_ref.necessityIndicator,necessityIndicator=_ref$necessityIndicat===void 0?'none':_ref$necessityIndicat,_ref$labelPosition=_ref.labelPosition,labelPosition=_ref$labelPosition===void 0?'top':_ref$labelPosition,_ref$validationState=_ref.validationState,validationState=_ref$validationState===void 0?'none':_ref$validationState,errorText=_ref.errorText,name=_ref.name,defaultValue=_ref.defaultValue,onChange=_ref.onChange,value=_ref.value,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,
|
|
25
|
+
var _excluded=["children","label","helpText","isDisabled","isRequired","necessityIndicator","labelPosition","validationState","errorText","name","defaultValue","onChange","value","size","testID"];var RadioGroup=function RadioGroup(_ref){var children=_ref.children,label=_ref.label,helpText=_ref.helpText,_ref$isDisabled=_ref.isDisabled,isDisabled=_ref$isDisabled===void 0?false:_ref$isDisabled,_ref$isRequired=_ref.isRequired,isRequired=_ref$isRequired===void 0?false:_ref$isRequired,_ref$necessityIndicat=_ref.necessityIndicator,necessityIndicator=_ref$necessityIndicat===void 0?'none':_ref$necessityIndicat,_ref$labelPosition=_ref.labelPosition,labelPosition=_ref$labelPosition===void 0?'top':_ref$labelPosition,_ref$validationState=_ref.validationState,validationState=_ref$validationState===void 0?'none':_ref$validationState,errorText=_ref.errorText,name=_ref.name,defaultValue=_ref.defaultValue,onChange=_ref.onChange,value=_ref.value,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,testID=_ref.testID,rest=_objectWithoutProperties(_ref,_excluded);var _useRadioGroup=useRadioGroup({defaultValue:defaultValue,isDisabled:isDisabled,isRequired:isRequired,labelPosition:labelPosition,name:name,necessityIndicator:necessityIndicator,onChange:onChange,validationState:validationState,value:value,size:size}),contextValue=_useRadioGroup.contextValue,ids=_useRadioGroup.ids;var _useTheme=useTheme(),theme=_useTheme.theme;var _useBreakpoint=useBreakpoint({breakpoints:theme.breakpoints}),matchedDeviceType=_useBreakpoint.matchedDeviceType;var showError=validationState==='error'&&errorText;var showHelpText=!showError&&helpText;var accessibilityText=`${showError?errorText:''} ${showHelpText?helpText:''}`.trim();var gap=radioSizes.group.gap[size][matchedDeviceType];var childCount=React__default.Children.count(children);return jsx(RadioGroupProvider,{value:contextValue,children:jsx(BaseBox,Object.assign({},getStyledProps(rest),{children:jsxs(SelectorGroupField,Object.assign({position:labelPosition,labelledBy:ids.labelId,accessibilityRole:"radiogroup",componentName:"radio-group",testID:testID},makeAnalyticsAttribute(rest),{children:[label?jsx(FormLabel,{as:"span",necessityIndicator:necessityIndicator,position:labelPosition,id:ids.labelId,accessibilityText:accessibilityText&&`,${accessibilityText}`,size:size,children:label}):null,jsxs(BaseBox,{children:[jsx(BaseBox,{display:"flex",flexDirection:"column",children:React__default.Children.map(children,function(child,index){return jsx(BaseBox,{marginBottom:index===childCount-1?makeSize(0):gap,children:child},index);})}),jsx(FormHint,{size:size,type:validationState==='error'?'error':'help',errorText:errorText,helpText:helpText})]})]}))}))});};
|
|
25
26
|
|
|
26
27
|
export { RadioGroup };
|
|
27
28
|
//# sourceMappingURL=RadioGroup.js.map
|