@aws-amplify/ui-react 5.3.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Field-6c0e096a.js +1174 -0
- package/dist/esm/PrimitiveCatalog.mjs +16255 -1
- package/dist/esm/components/AccountSettings/AccountSettings.mjs +6 -1
- package/dist/esm/components/AccountSettings/ChangePassword/ChangePassword.mjs +209 -1
- package/dist/esm/components/AccountSettings/ChangePassword/defaults.mjs +77 -1
- package/dist/esm/components/AccountSettings/DeleteUser/DeleteUser.mjs +156 -1
- package/dist/esm/components/AccountSettings/DeleteUser/defaults.mjs +85 -1
- package/dist/esm/components/AccountSettings/constants.mjs +7 -1
- package/dist/esm/components/AccountSettings/shared/Defaults.mjs +66 -1
- package/dist/esm/components/AccountSettings/utils/displayText.mjs +14 -0
- package/dist/esm/components/Authenticator/Authenticator.mjs +74 -1
- package/dist/esm/components/Authenticator/ConfirmSignIn/ConfirmSignIn.mjs +42 -1
- package/dist/esm/components/Authenticator/ConfirmSignUp/ConfirmSignUp.mjs +51 -1
- package/dist/esm/components/Authenticator/FederatedSignIn/FederatedSignIn.mjs +34 -1
- package/dist/esm/components/Authenticator/FederatedSignIn/FederatedSignInButtons/FederatedSignInButton.mjs +54 -1
- package/dist/esm/components/Authenticator/ForceNewPassword/ForceNewPassword.mjs +43 -1
- package/dist/esm/components/Authenticator/ForgotPassword/ConfirmResetPassword.mjs +39 -0
- package/dist/esm/components/Authenticator/ForgotPassword/ForgotPassword.mjs +40 -0
- package/dist/esm/components/Authenticator/RouteContainer/RouteContainer.mjs +26 -1
- package/dist/esm/components/Authenticator/Router/Router.mjs +63 -1
- package/dist/esm/components/Authenticator/SetupTotp/SetupTotp.mjs +76 -0
- package/dist/esm/components/Authenticator/SignIn/SignIn.mjs +47 -1
- package/dist/esm/components/Authenticator/SignUp/SignUp.mjs +46 -1
- package/dist/esm/components/Authenticator/VerifyUser/ConfirmVerifyUser.mjs +37 -1
- package/dist/esm/components/Authenticator/VerifyUser/VerifyUser.mjs +59 -1
- package/dist/esm/components/Authenticator/hooks/useCustomComponents/defaultComponents.mjs +62 -1
- package/dist/esm/components/Authenticator/hooks/useCustomComponents/useCustomComponents.mjs +14 -1
- package/dist/esm/components/Authenticator/hooks/useFormHandlers/useFormHandlers.mjs +30 -1
- package/dist/esm/components/Authenticator/shared/ConfirmSignInFooter.mjs +18 -1
- package/dist/esm/components/Authenticator/shared/FormField.mjs +35 -1
- package/dist/esm/components/Authenticator/shared/FormFields.mjs +15 -1
- package/dist/esm/components/Authenticator/shared/RemoteErrorMessage.mjs +11 -1
- package/dist/esm/components/Authenticator/shared/SignInSignUpTabs.mjs +27 -1
- package/dist/esm/components/Authenticator/shared/TwoButtonSubmitFooter.mjs +35 -1
- package/dist/esm/components/Authenticator/utils.mjs +3 -1
- package/dist/esm/components/Authenticator/withAuthenticator.mjs +14 -1
- package/dist/esm/components/ThemeProvider/ThemeContext.mjs +8 -0
- package/dist/esm/components/ThemeProvider/ThemeProvider.mjs +23 -1
- package/dist/esm/components/index.mjs +5 -1
- package/dist/esm/components/shared/ValidationErrors.mjs +15 -1
- package/dist/esm/helpers/utils.mjs +6 -1
- package/dist/esm/hooks/useAuth.mjs +73 -1
- package/dist/esm/hooks/useBreakpointValue.mjs +29 -1
- package/dist/esm/hooks/useComposeRefsCallback.mjs +20 -1
- package/dist/esm/hooks/useDeprecationWarning.mjs +15 -1
- package/dist/esm/hooks/useStorageURL.mjs +40 -1
- package/dist/esm/hooks/useTheme.mjs +23 -1
- package/dist/esm/hooks/useThemeBreakpoint.mjs +19 -1
- package/dist/esm/index.mjs +71 -1
- package/dist/esm/internal.mjs +32 -1
- package/dist/esm/primitives/Accordion/Accordion.mjs +28 -0
- package/dist/esm/primitives/Accordion/AccordionContainer.mjs +49 -0
- package/dist/esm/primitives/Accordion/AccordionContent.mjs +15 -0
- package/dist/esm/primitives/Accordion/AccordionContext.mjs +6 -0
- package/dist/esm/primitives/Accordion/AccordionIcon.mjs +20 -0
- package/dist/esm/primitives/Accordion/AccordionItem.mjs +19 -0
- package/dist/esm/primitives/Accordion/AccordionTrigger.mjs +27 -0
- package/dist/esm/primitives/Alert/Alert.mjs +36 -1
- package/dist/esm/primitives/Alert/AlertIcon.mjs +36 -1
- package/dist/esm/primitives/Autocomplete/Autocomplete.mjs +67 -1
- package/dist/esm/primitives/Autocomplete/AutocompleteMenu.mjs +36 -1
- package/dist/esm/primitives/Autocomplete/AutocompleteOption.mjs +12 -1
- package/dist/esm/primitives/Autocomplete/useAutocomplete.mjs +188 -1
- package/dist/esm/primitives/Badge/Badge.mjs +16 -1
- package/dist/esm/primitives/Breadcrumbs/BreadcrumbContainer.mjs +18 -1
- package/dist/esm/primitives/Breadcrumbs/BreadcrumbItem.mjs +16 -1
- package/dist/esm/primitives/Breadcrumbs/BreadcrumbLink.mjs +24 -1
- package/dist/esm/primitives/Breadcrumbs/BreadcrumbSeparator.mjs +16 -1
- package/dist/esm/primitives/Breadcrumbs/Breadcrumbs.mjs +28 -1
- package/dist/esm/primitives/Button/Button.mjs +33 -1
- package/dist/esm/primitives/ButtonGroup/ButtonGroup.mjs +19 -1
- package/dist/esm/primitives/Card/Card.mjs +15 -1
- package/dist/esm/primitives/Checkbox/Checkbox.mjs +84 -1
- package/dist/esm/primitives/CheckboxField/CheckboxField.mjs +24 -1
- package/dist/esm/primitives/Collection/Collection.mjs +58 -1
- package/dist/esm/primitives/Collection/utils.mjs +30 -1
- package/dist/esm/primitives/Divider/Divider.mjs +16 -1
- package/dist/esm/primitives/DropZone/DropZone.mjs +27 -1
- package/dist/esm/primitives/DropZone/DropZoneChildren.mjs +39 -1
- package/dist/esm/primitives/DropZone/DropZoneContainer.mjs +18 -1
- package/dist/esm/primitives/DropZone/DropZoneProvider.mjs +8 -1
- package/dist/esm/primitives/DropZone/filterAllowedFiles.mjs +34 -0
- package/dist/esm/primitives/DropZone/useDropZone.mjs +65 -1
- package/dist/esm/primitives/Field/Field.mjs +20 -1
- package/dist/esm/primitives/Field/FieldClearButton.mjs +21 -1
- package/dist/esm/primitives/Field/FieldDescription.mjs +11 -1
- package/dist/esm/primitives/Field/FieldErrorMessage.mjs +10 -1
- package/dist/esm/primitives/FieldGroup/FieldGroup.mjs +29 -1
- package/dist/esm/primitives/FieldGroupIcon/FieldGroupIcon.mjs +12 -1
- package/dist/esm/primitives/FieldGroupIcon/FieldGroupIconButton.mjs +11 -1
- package/dist/esm/primitives/Fieldset/Fieldset.mjs +33 -1
- package/dist/esm/primitives/Fieldset/useFieldset.mjs +13 -1
- package/dist/esm/primitives/Flex/Flex.mjs +13 -1
- package/dist/esm/primitives/Grid/Grid.mjs +13 -1
- package/dist/esm/primitives/Heading/Heading.mjs +21 -1
- package/dist/esm/primitives/HighlightMatch/HighlightMatch.mjs +28 -1
- package/dist/esm/primitives/Icon/Icon.mjs +36 -1
- package/dist/esm/primitives/Icon/context/IconsContext.mjs +5 -1
- package/dist/esm/primitives/Icon/context/IconsProvider.mjs +8 -1
- package/dist/esm/primitives/Icon/context/useIcons.mjs +12 -1
- package/dist/esm/primitives/Icon/icons/IconAdd.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconCheck.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconCheckCircle.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconCheckCircleOutline.mjs +13 -1
- package/dist/esm/primitives/Icon/icons/IconChevronLeft.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconChevronRight.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconClose.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconEdit.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconError.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconExpandMore.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconFile.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconIndeterminate.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconInfo.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconMenu.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconRemove.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconSearch.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconStar.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconUpload.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconVisibility.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconVisibilityOff.mjs +15 -1
- package/dist/esm/primitives/Icon/icons/IconWarning.mjs +15 -1
- package/dist/esm/primitives/Image/Image.mjs +13 -1
- package/dist/esm/primitives/Input/Input.mjs +15 -1
- package/dist/esm/primitives/Label/Label.mjs +14 -1
- package/dist/esm/primitives/Link/Link.mjs +15 -1
- package/dist/esm/primitives/Loader/Loader.mjs +56 -1
- package/dist/esm/primitives/Menu/Menu.mjs +31 -1
- package/dist/esm/primitives/Menu/MenuButton.mjs +18 -1
- package/dist/esm/primitives/Menu/MenuItem.mjs +22 -1
- package/dist/esm/primitives/Message/Message.mjs +23 -1
- package/dist/esm/primitives/Message/MessageContainer.mjs +19 -1
- package/dist/esm/primitives/Message/MessageContent.mjs +12 -1
- package/dist/esm/primitives/Message/MessageDismiss.mjs +28 -1
- package/dist/esm/primitives/Message/MessageHeading.mjs +12 -1
- package/dist/esm/primitives/Message/MessageIcon.mjs +35 -1
- package/dist/esm/primitives/Message/useMessage.mjs +9 -1
- package/dist/esm/primitives/Pagination/Pagination.mjs +31 -1
- package/dist/esm/primitives/Pagination/PaginationItem.mjs +48 -1
- package/dist/esm/primitives/Pagination/usePagination.mjs +41 -1
- package/dist/esm/primitives/Pagination/usePaginationItems.mjs +39 -1
- package/dist/esm/primitives/Pagination/useRange.mjs +72 -1
- package/dist/esm/primitives/PasswordField/PasswordField.mjs +25 -1
- package/dist/esm/primitives/PasswordField/ShowPasswordButton.mjs +30 -1
- package/dist/esm/primitives/PhoneNumberField/DialCodeSelect.mjs +21 -0
- package/dist/esm/primitives/PhoneNumberField/PhoneNumberField.mjs +17 -1
- package/dist/esm/primitives/Placeholder/Placeholder.mjs +18 -1
- package/dist/esm/primitives/Radio/Radio.mjs +31 -1
- package/dist/esm/primitives/RadioGroupField/RadioGroupField.mjs +55 -1
- package/dist/esm/primitives/RadioGroupField/context.mjs +9 -1
- package/dist/esm/primitives/Rating/Rating.mjs +44 -1
- package/dist/esm/primitives/Rating/RatingIcon.mjs +11 -1
- package/dist/esm/primitives/Rating/RatingMixedIcon.mjs +13 -1
- package/dist/esm/primitives/Rating/utils.mjs +18 -1
- package/dist/esm/primitives/ScrollView/ScrollView.mjs +13 -1
- package/dist/esm/primitives/SearchField/SearchField.mjs +38 -1
- package/dist/esm/primitives/SearchField/SearchFieldButton.mjs +21 -1
- package/dist/esm/primitives/SearchField/useSearchField.mjs +64 -1
- package/dist/esm/primitives/Select/Select.mjs +31 -1
- package/dist/esm/primitives/SelectField/SelectField.mjs +42 -1
- package/dist/esm/primitives/SliderField/SliderField.mjs +77 -1
- package/dist/esm/primitives/StepperField/StepperField.mjs +60 -1
- package/dist/esm/primitives/StepperField/useStepper.mjs +113 -1
- package/dist/esm/primitives/SwitchField/SwitchField.mjs +48 -1
- package/dist/esm/primitives/SwitchField/useSwitch.mjs +30 -1
- package/dist/esm/primitives/Table/Table.mjs +18 -1
- package/dist/esm/primitives/Table/TableBody.mjs +10 -1
- package/dist/esm/primitives/Table/TableCell.mjs +12 -1
- package/dist/esm/primitives/Table/TableFoot.mjs +10 -1
- package/dist/esm/primitives/Table/TableHead.mjs +10 -1
- package/dist/esm/primitives/Table/TableRow.mjs +10 -1
- package/dist/esm/primitives/Tabs/Tabs.mjs +24 -1
- package/dist/esm/primitives/Tabs/TabsContainer.mjs +35 -0
- package/dist/esm/primitives/Tabs/TabsContext.mjs +8 -0
- package/dist/esm/primitives/Tabs/TabsItem.mjs +24 -0
- package/dist/esm/primitives/Tabs/TabsList.mjs +85 -0
- package/dist/esm/primitives/Tabs/TabsPanel.mjs +19 -0
- package/dist/esm/primitives/Text/Text.mjs +16 -1
- package/dist/esm/primitives/TextArea/TextArea.mjs +15 -1
- package/dist/esm/primitives/TextAreaField/TextAreaField.mjs +36 -1
- package/dist/esm/primitives/TextField/TextField.mjs +34 -1
- package/dist/esm/primitives/ToggleButton/ToggleButton.mjs +24 -1
- package/dist/esm/primitives/ToggleButton/useToggleButton.mjs +23 -1
- package/dist/esm/primitives/ToggleButtonGroup/ToggleButtonGroup.mjs +35 -1
- package/dist/esm/primitives/ToggleButtonGroup/useToggleButtonGroup.mjs +36 -1
- package/dist/esm/primitives/View/View.mjs +23 -1
- package/dist/esm/primitives/VisuallyHidden/VisuallyHidden.mjs +13 -1
- package/dist/esm/primitives/index.mjs +63 -1
- package/dist/esm/primitives/shared/constants.mjs +98 -1
- package/dist/esm/primitives/shared/getStyleValue.mjs +25 -1
- package/dist/esm/primitives/shared/responsive/getMediaQueries.mjs +29 -1
- package/dist/esm/primitives/shared/responsive/useBreakpoint.mjs +39 -1
- package/dist/esm/primitives/shared/responsive/utils.mjs +51 -1
- package/dist/esm/primitives/shared/styleUtils.mjs +122 -1
- package/dist/esm/primitives/shared/utils.mjs +60 -1
- package/dist/esm/primitives/types/style.mjs +104 -1
- package/dist/esm/primitives/types/theme.mjs +7 -1
- package/dist/esm/primitives/utils/getTestId.mjs +3 -1
- package/dist/esm/primitives/utils/primitiveWithForwardRef.mjs +14 -0
- package/dist/esm/primitives/utils/splitPrimitiveProps.mjs +36 -1
- package/dist/esm/primitives/utils/useLayoutEffect.mjs +13 -1
- package/dist/esm/primitives/utils/useStableId.mjs +34 -1
- package/dist/esm/version.mjs +3 -1
- package/dist/index.js +3485 -1
- package/dist/internal.js +16403 -1
- package/dist/styles/StorageManager.css +138 -0
- package/dist/styles/StorageManager.layer.css +140 -0
- package/dist/styles/_fieldControl.css +0 -0
- package/dist/styles/_fieldControl.layer.css +3 -0
- package/dist/styles/accordion.css +64 -0
- package/dist/styles/accordion.layer.css +66 -0
- package/dist/styles/alert.css +44 -0
- package/dist/styles/alert.layer.css +46 -0
- package/dist/styles/authenticator.css +72 -0
- package/dist/styles/authenticator.layer.css +74 -0
- package/dist/styles/autocomplete.css +48 -0
- package/dist/styles/autocomplete.layer.css +50 -0
- package/dist/styles/badge.css +35 -0
- package/dist/styles/badge.layer.css +37 -0
- package/dist/styles/base.css +1491 -0
- package/dist/styles/base.layer.css +1493 -0
- package/dist/styles/breadcrumbs.css +40 -0
- package/dist/styles/breadcrumbs.layer.css +42 -0
- package/dist/styles/button.css +1122 -0
- package/dist/styles/button.layer.css +1124 -0
- package/dist/styles/card.css +26 -0
- package/dist/styles/card.layer.css +28 -0
- package/dist/styles/checkbox.css +95 -0
- package/dist/styles/checkbox.layer.css +97 -0
- package/dist/styles/checkboxField.css +6 -0
- package/dist/styles/checkboxField.layer.css +8 -0
- package/dist/styles/collection.css +70 -0
- package/dist/styles/collection.layer.css +72 -0
- package/dist/styles/copy.css +27 -0
- package/dist/styles/copy.layer.css +29 -0
- package/dist/styles/dialCodeSelect.css +3 -0
- package/dist/styles/dialCodeSelect.layer.css +5 -0
- package/dist/styles/divider.css +47 -0
- package/dist/styles/divider.layer.css +49 -0
- package/dist/styles/dropZone.css +45 -0
- package/dist/styles/dropZone.layer.css +47 -0
- package/dist/styles/field.css +17 -0
- package/dist/styles/field.layer.css +19 -0
- package/dist/styles/fieldGroup.css +130 -0
- package/dist/styles/fieldGroup.layer.css +132 -0
- package/dist/styles/fieldMessages.css +10 -0
- package/dist/styles/fieldMessages.layer.css +12 -0
- package/dist/styles/fieldModifiers.css +15 -0
- package/dist/styles/fieldModifiers.layer.css +17 -0
- package/dist/styles/fieldset.css +37 -0
- package/dist/styles/fieldset.layer.css +39 -0
- package/dist/styles/flex.css +8 -0
- package/dist/styles/flex.layer.css +10 -0
- package/dist/styles/grid.css +3 -0
- package/dist/styles/grid.layer.css +5 -0
- package/dist/styles/heading.css +40 -0
- package/dist/styles/heading.layer.css +42 -0
- package/dist/styles/highlightMatch.css +3 -0
- package/dist/styles/highlightMatch.layer.css +5 -0
- package/dist/styles/icon.css +14 -0
- package/dist/styles/icon.layer.css +16 -0
- package/dist/styles/image.css +9 -0
- package/dist/styles/image.layer.css +11 -0
- package/dist/styles/inAppMessaging.css +179 -0
- package/dist/styles/inAppMessaging.layer.css +181 -0
- package/dist/styles/input.css +83 -0
- package/dist/styles/input.layer.css +85 -0
- package/dist/styles/link.css +26 -0
- package/dist/styles/link.layer.css +28 -0
- package/dist/styles/liveness.css +374 -0
- package/dist/styles/liveness.layer.css +376 -0
- package/dist/styles/loader.css +108 -0
- package/dist/styles/loader.layer.css +110 -0
- package/dist/styles/menu.css +54 -0
- package/dist/styles/menu.layer.css +56 -0
- package/dist/styles/message.css +111 -0
- package/dist/styles/message.layer.css +113 -0
- package/dist/styles/pagination.css +41 -0
- package/dist/styles/pagination.layer.css +43 -0
- package/dist/styles/passwordField.css +49 -0
- package/dist/styles/passwordField.layer.css +51 -0
- package/dist/styles/phoneNumberField.css +30 -0
- package/dist/styles/phoneNumberField.layer.css +32 -0
- package/dist/styles/placeholder.css +31 -0
- package/dist/styles/placeholder.layer.css +33 -0
- package/dist/styles/radio.css +82 -0
- package/dist/styles/radio.layer.css +84 -0
- package/dist/styles/radioGroupField.css +25 -0
- package/dist/styles/radioGroupField.layer.css +27 -0
- package/dist/styles/radiogroup.css +5 -0
- package/dist/styles/radiogroup.layer.css +7 -0
- package/dist/styles/rating.css +33 -0
- package/dist/styles/rating.layer.css +35 -0
- package/dist/styles/reset.css +76 -0
- package/dist/styles/reset.layer.css +78 -0
- package/dist/styles/scrollView.css +4 -0
- package/dist/styles/scrollView.layer.css +6 -0
- package/dist/styles/searchField.css +29 -0
- package/dist/styles/searchField.layer.css +31 -0
- package/dist/styles/select.css +128 -0
- package/dist/styles/select.layer.css +130 -0
- package/dist/styles/selectField.css +18 -0
- package/dist/styles/selectField.layer.css +20 -0
- package/dist/styles/sliderField.css +143 -0
- package/dist/styles/sliderField.layer.css +145 -0
- package/dist/styles/stepperField.css +77 -0
- package/dist/styles/stepperField.layer.css +79 -0
- package/dist/styles/switchField.css +76 -0
- package/dist/styles/switchField.layer.css +78 -0
- package/dist/styles/table.css +146 -0
- package/dist/styles/table.layer.css +148 -0
- package/dist/styles/tabs.css +87 -0
- package/dist/styles/tabs.layer.css +89 -0
- package/dist/styles/text.css +40 -0
- package/dist/styles/text.layer.css +42 -0
- package/dist/styles/textArea.css +71 -0
- package/dist/styles/textArea.layer.css +73 -0
- package/dist/styles/textAreaField.css +12 -0
- package/dist/styles/textAreaField.layer.css +14 -0
- package/dist/styles/textField.css +14 -0
- package/dist/styles/textField.layer.css +16 -0
- package/dist/styles/toggleButton.css +280 -0
- package/dist/styles/toggleButton.layer.css +282 -0
- package/dist/styles/toggleButtonGroup.css +31 -0
- package/dist/styles/toggleButtonGroup.layer.css +33 -0
- package/dist/styles/visuallyHidden.css +12 -0
- package/dist/styles/visuallyHidden.layer.css +14 -0
- package/dist/styles.css +299 -685
- package/dist/styles.layer.css +6115 -0
- package/dist/types/components/AccountSettings/ChangePassword/ChangePassword.d.ts +6 -6
- package/dist/types/components/AccountSettings/ChangePassword/types.d.ts +3 -0
- package/dist/types/components/AccountSettings/DeleteUser/DeleteUser.d.ts +3 -3
- package/dist/types/components/AccountSettings/DeleteUser/types.d.ts +7 -2
- package/dist/types/components/AccountSettings/utils/displayText.d.ts +18 -0
- package/dist/types/components/AccountSettings/utils/index.d.ts +1 -0
- package/dist/types/components/Authenticator/Authenticator.d.ts +4 -3
- package/dist/types/components/Authenticator/ConfirmSignIn/ConfirmSignIn.d.ts +2 -2
- package/dist/types/components/Authenticator/ConfirmSignUp/ConfirmSignUp.d.ts +2 -2
- package/dist/types/components/Authenticator/{ResetPassword → ForgotPassword}/index.d.ts +1 -1
- package/dist/types/components/Authenticator/{SetupTOTP/SetupTOTP.d.ts → SetupTotp/SetupTotp.d.ts} +1 -1
- package/dist/types/components/Authenticator/SetupTotp/index.d.ts +1 -0
- package/dist/types/components/Authenticator/SignIn/SignIn.d.ts +2 -2
- package/dist/types/components/Authenticator/SignUp/SignUp.d.ts +2 -2
- package/dist/types/components/Authenticator/VerifyUser/ConfirmVerifyUser.d.ts +2 -2
- package/dist/types/components/Authenticator/hooks/useCustomComponents/defaultComponents.d.ts +1 -1
- package/dist/types/components/Authenticator/withAuthenticator.d.ts +2 -2
- package/dist/types/components/ThemeProvider/ThemeContext.d.ts +6 -0
- package/dist/types/components/ThemeProvider/ThemeProvider.d.ts +1 -2
- package/dist/types/components/ThemeProvider/index.d.ts +1 -1
- package/dist/types/components/index.d.ts +0 -1
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/useAuth.d.ts +2 -2
- package/dist/types/hooks/useStorageURL.d.ts +2 -6
- package/dist/types/hooks/useTheme.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal.d.ts +0 -12
- package/dist/types/primitives/Accordion/Accordion.d.ts +19 -0
- package/dist/types/primitives/Accordion/AccordionContainer.d.ts +8 -0
- package/dist/types/primitives/Accordion/AccordionContent.d.ts +9 -0
- package/dist/types/primitives/Accordion/AccordionContext.d.ts +9 -0
- package/dist/types/primitives/Accordion/AccordionIcon.d.ts +9 -0
- package/dist/types/primitives/Accordion/AccordionItem.d.ts +6 -0
- package/dist/types/primitives/Accordion/AccordionTrigger.d.ts +9 -0
- package/dist/types/primitives/Accordion/index.d.ts +2 -0
- package/dist/types/primitives/Accordion/types.d.ts +49 -0
- package/dist/types/primitives/Alert/AlertIcon.d.ts +5 -2
- package/dist/types/primitives/Breadcrumbs/BreadcrumbItem.d.ts +1 -1
- package/dist/types/primitives/DropZone/DropZoneChildren.d.ts +10 -3
- package/dist/types/primitives/DropZone/filterAllowedFiles.d.ts +10 -0
- package/dist/types/primitives/Icon/context/IconsContext.d.ts +1 -1
- package/dist/types/primitives/PhoneNumberField/DialCodeSelect.d.ts +2 -0
- package/dist/types/primitives/StepperField/useStepper.d.ts +1 -1
- package/dist/types/primitives/Tabs/Tabs.d.ts +14 -3
- package/dist/types/primitives/Tabs/TabsContainer.d.ts +6 -0
- package/dist/types/primitives/Tabs/TabsContext.d.ts +7 -0
- package/dist/types/primitives/Tabs/TabsItem.d.ts +6 -0
- package/dist/types/primitives/Tabs/TabsList.d.ts +6 -0
- package/dist/types/primitives/Tabs/TabsPanel.d.ts +6 -0
- package/dist/types/primitives/Tabs/index.d.ts +2 -1
- package/dist/types/primitives/Tabs/types.d.ts +93 -0
- package/dist/types/primitives/components.d.ts +2 -2
- package/dist/types/primitives/index.d.ts +0 -1
- package/dist/types/primitives/shared/constants.d.ts +0 -6
- package/dist/types/primitives/shared/responsive/utils.d.ts +1 -1
- package/dist/types/primitives/shared/styleUtils.d.ts +2 -2
- package/dist/types/primitives/types/collection.d.ts +2 -2
- package/dist/types/primitives/types/fieldset.d.ts +1 -1
- package/dist/types/primitives/types/index.d.ts +0 -3
- package/dist/types/primitives/types/radioGroupField.d.ts +2 -1
- package/dist/types/primitives/types/view.d.ts +32 -2
- package/dist/types/primitives/utils/primitiveWithForwardRef.d.ts +11 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +13 -45
- package/dist/Field-4bd811d7.js +0 -1
- package/dist/esm/components/Authenticator/ResetPassword/ConfirmResetPassword.mjs +0 -1
- package/dist/esm/components/Authenticator/ResetPassword/ResetPassword.mjs +0 -1
- package/dist/esm/components/Authenticator/SetupTOTP/SetupTOTP.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/FileUploader.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/UploadDropZone/UploadDropZone.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/UploadPreviewer/UploadPreviewer.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/UploadTracker/UploadMessage.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/UploadTracker/UploadTracker.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/hooks/useFileUploader/useFileUploader.mjs +0 -1
- package/dist/esm/components/Storage/FileUploader/types.mjs +0 -1
- package/dist/esm/components/ThemeProvider/AmplifyContext.mjs +0 -1
- package/dist/esm/helpers/constants.mjs +0 -1
- package/dist/esm/hooks/actions/constants.mjs +0 -1
- package/dist/esm/hooks/actions/shared/types.mjs +0 -1
- package/dist/esm/hooks/actions/shared/useTypeCastFields.mjs +0 -1
- package/dist/esm/hooks/actions/useAuthSignOutAction.mjs +0 -1
- package/dist/esm/hooks/actions/useDataStoreCreateAction.mjs +0 -1
- package/dist/esm/hooks/actions/useDataStoreDeleteAction.mjs +0 -1
- package/dist/esm/hooks/actions/useDataStoreUpdateAction.mjs +0 -1
- package/dist/esm/hooks/actions/useNavigateAction.mjs +0 -1
- package/dist/esm/hooks/actions/useStateMutationAction.mjs +0 -1
- package/dist/esm/hooks/useAmplify.mjs +0 -1
- package/dist/esm/hooks/useDataStore.mjs +0 -1
- package/dist/esm/primitives/Expander/Expander.mjs +0 -1
- package/dist/esm/primitives/Expander/ExpanderItem.mjs +0 -1
- package/dist/esm/primitives/PhoneNumberField/CountryCodeSelect.mjs +0 -1
- package/dist/esm/primitives/shared/datastore.mjs +0 -1
- package/dist/esm/studio/findChildOverrides.mjs +0 -1
- package/dist/esm/studio/getOverrideProps.mjs +0 -1
- package/dist/esm/studio/getOverridesFromVariants.mjs +0 -1
- package/dist/esm/studio/mergeVariantsAndOverrides.mjs +0 -1
- package/dist/styles.js +0 -2
- package/dist/types/components/Authenticator/SetupTOTP/index.d.ts +0 -1
- package/dist/types/components/Storage/FileUploader/FileUploader.d.ts +0 -3
- package/dist/types/components/Storage/FileUploader/UploadDropZone/UploadDropZone.d.ts +0 -3
- package/dist/types/components/Storage/FileUploader/UploadDropZone/index.d.ts +0 -1
- package/dist/types/components/Storage/FileUploader/UploadPreviewer/UploadPreviewer.d.ts +0 -3
- package/dist/types/components/Storage/FileUploader/UploadPreviewer/index.d.ts +0 -1
- package/dist/types/components/Storage/FileUploader/UploadTracker/UploadMessage.d.ts +0 -3
- package/dist/types/components/Storage/FileUploader/UploadTracker/UploadTracker.d.ts +0 -3
- package/dist/types/components/Storage/FileUploader/UploadTracker/index.d.ts +0 -1
- package/dist/types/components/Storage/FileUploader/hooks/index.d.ts +0 -1
- package/dist/types/components/Storage/FileUploader/hooks/useFileUploader/index.d.ts +0 -2
- package/dist/types/components/Storage/FileUploader/hooks/useFileUploader/types.d.ts +0 -18
- package/dist/types/components/Storage/FileUploader/hooks/useFileUploader/useFileUploader.d.ts +0 -9
- package/dist/types/components/Storage/FileUploader/index.d.ts +0 -1
- package/dist/types/components/Storage/FileUploader/types.d.ts +0 -91
- package/dist/types/components/Storage/index.d.ts +0 -1
- package/dist/types/components/ThemeProvider/AmplifyContext.d.ts +0 -6
- package/dist/types/hooks/actions/constants.d.ts +0 -39
- package/dist/types/hooks/actions/shared/types.d.ts +0 -27
- package/dist/types/hooks/actions/shared/useTypeCastFields.d.ts +0 -15
- package/dist/types/hooks/actions/testModels/model.d.ts +0 -25
- package/dist/types/hooks/actions/testModels/schema.d.ts +0 -2
- package/dist/types/hooks/actions/testModels/todo.d.ts +0 -13
- package/dist/types/hooks/actions/useAuthSignOutAction.d.ts +0 -9
- package/dist/types/hooks/actions/useDataStoreCreateAction.d.ts +0 -9
- package/dist/types/hooks/actions/useDataStoreDeleteAction.d.ts +0 -10
- package/dist/types/hooks/actions/useDataStoreUpdateAction.d.ts +0 -10
- package/dist/types/hooks/actions/useNavigateAction.d.ts +0 -15
- package/dist/types/hooks/actions/useStateMutationAction.d.ts +0 -10
- package/dist/types/hooks/useAmplify.d.ts +0 -6
- package/dist/types/hooks/useDataStore.d.ts +0 -18
- package/dist/types/primitives/Expander/Expander.d.ts +0 -6
- package/dist/types/primitives/Expander/ExpanderItem.d.ts +0 -7
- package/dist/types/primitives/Expander/index.d.ts +0 -2
- package/dist/types/primitives/Menu/__tests_/menu.test.d.ts +0 -1
- package/dist/types/primitives/PhoneNumberField/CountryCodeSelect.d.ts +0 -2
- package/dist/types/primitives/Rating/__test__/Rating.test.d.ts +0 -1
- package/dist/types/primitives/Rating/__test__/utils.test.d.ts +0 -1
- package/dist/types/primitives/Text/__test__/Text.test.d.ts +0 -1
- package/dist/types/primitives/shared/datastore.d.ts +0 -7
- package/dist/types/primitives/shared/index.d.ts +0 -1
- package/dist/types/primitives/shared/types.d.ts +0 -15
- package/dist/types/primitives/types/datastore.d.ts +0 -31
- package/dist/types/primitives/types/expander.d.ts +0 -51
- package/dist/types/primitives/types/tabs.d.ts +0 -63
- package/dist/types/studio/findChildOverrides.d.ts +0 -18
- package/dist/types/studio/getOverrideProps.d.ts +0 -18
- package/dist/types/studio/getOverridesFromVariants.d.ts +0 -20
- package/dist/types/studio/index.d.ts +0 -5
- package/dist/types/studio/mergeVariantsAndOverrides.d.ts +0 -18
- package/dist/types/studio/types.d.ts +0 -18
- package/dist/types/styles.d.ts +0 -1
- /package/dist/types/components/Authenticator/{ResetPassword → ForgotPassword}/ConfirmResetPassword.d.ts +0 -0
- /package/dist/types/components/Authenticator/{ResetPassword/ResetPassword.d.ts → ForgotPassword/ForgotPassword.d.ts} +0 -0
|
@@ -1 +1,72 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getConsecutiveIntArray } from '../shared/utils.mjs';
|
|
3
|
+
|
|
4
|
+
const ELLIPSIS = '...';
|
|
5
|
+
/**
|
|
6
|
+
* This hook will be used to determine the range of page numbers to be rendered,
|
|
7
|
+
* including ellipsis dots(e.g., an array like [1, '...', 4, 5, 6, '...', 10]).
|
|
8
|
+
* @param currentPage current page number
|
|
9
|
+
* @param totalPages total number of pages
|
|
10
|
+
* @param siblingCount the number of siblings on each side of
|
|
11
|
+
* @returns an array that contains the range of numbers to be rendered
|
|
12
|
+
*/
|
|
13
|
+
const useRange = (currentPageParam, totalPagesParam, siblingCountParam = 1) => {
|
|
14
|
+
const range = React.useMemo(() => {
|
|
15
|
+
// The current page should not be less than 1
|
|
16
|
+
const currentPage = Math.max(currentPageParam, 1);
|
|
17
|
+
// The sibling count should not be less than 1
|
|
18
|
+
const siblingCount = Math.max(siblingCountParam, 1);
|
|
19
|
+
// The total pages should be always greater than current page
|
|
20
|
+
const totalPages = Math.max(currentPage, totalPagesParam);
|
|
21
|
+
// Note: 1-based index will be used for page value.
|
|
22
|
+
const firstPage = 1;
|
|
23
|
+
const lastPage = totalPages;
|
|
24
|
+
/**
|
|
25
|
+
* To avoid resizing our pagination component while a user is interacting with the component,
|
|
26
|
+
* the total number of items returned by the hook should remain constant.
|
|
27
|
+
* The consant is supposed to be the max number of items that would returned by the hook in all cases,
|
|
28
|
+
* so it should be calculated by 1(first page) + 1(last page) + 1(current page) + 2 * siblingCount + 2(ellipses)
|
|
29
|
+
*/
|
|
30
|
+
const maxNumOfItems = 5 + 2 * siblingCount;
|
|
31
|
+
/**
|
|
32
|
+
* Case 1: If the total number of pages is not greater than the max number of items that would potentially be returned,
|
|
33
|
+
* then no need to run through the ellipsis cases, just simply return the range from 1 to totalPages (e.g. [1, 2, 3, 4]).
|
|
34
|
+
*/
|
|
35
|
+
if (totalPages < maxNumOfItems) {
|
|
36
|
+
return getConsecutiveIntArray(1, totalPages);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Determine if ellipsis dots should be rendered on either left or right side, or both
|
|
40
|
+
*/
|
|
41
|
+
const leftSiblingPage = Math.max(currentPage - siblingCount, firstPage);
|
|
42
|
+
const rightSiblingPage = Math.min(currentPage + siblingCount, lastPage);
|
|
43
|
+
const shouldRenderStartEllipsis = leftSiblingPage > 2;
|
|
44
|
+
const shouldRenderEndEllipsis = rightSiblingPage < lastPage - 1;
|
|
45
|
+
/**
|
|
46
|
+
* Case 2: Only render ellipsis dots on the left side (e.g. [1, '...', 6, 7, 8, 9, 10]).
|
|
47
|
+
*/
|
|
48
|
+
if (shouldRenderStartEllipsis && !shouldRenderEndEllipsis) {
|
|
49
|
+
// 1(current page) + 1(last page) + 1(fill up a page for the position of end ellipsis) + 2 * siblingCount
|
|
50
|
+
const rightItemCount = 3 + 2 * siblingCount;
|
|
51
|
+
const rightRange = getConsecutiveIntArray(lastPage - rightItemCount + 1, lastPage);
|
|
52
|
+
return [firstPage, ELLIPSIS, ...rightRange];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Case 3: Only render ellipsis dots on the right side (e.g. [1, 2, 3, 4, 5, '...', 10]).
|
|
56
|
+
*/
|
|
57
|
+
if (!shouldRenderStartEllipsis && shouldRenderEndEllipsis) {
|
|
58
|
+
// 1(current page) + 1(last page) + 1(fill up a page for the position of start ellipsis) + 2 * siblingCount
|
|
59
|
+
const leftItemCount = 3 + 2 * siblingCount;
|
|
60
|
+
const leftRange = getConsecutiveIntArray(firstPage, leftItemCount);
|
|
61
|
+
return [...leftRange, ELLIPSIS, lastPage];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Case 4: Render ellipsis on both side (e.g. [1, '...', 4, 5, 6, '...', 10]).
|
|
65
|
+
*/
|
|
66
|
+
const middleRange = getConsecutiveIntArray(leftSiblingPage, rightSiblingPage);
|
|
67
|
+
return [firstPage, ELLIPSIS, ...middleRange, ELLIPSIS, lastPage];
|
|
68
|
+
}, [currentPageParam, totalPagesParam, siblingCountParam]);
|
|
69
|
+
return range;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export { ELLIPSIS, useRange };
|
|
@@ -1 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { classNames, ComponentClassName } from '@aws-amplify/ui';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ShowPasswordButton } from './ShowPasswordButton.mjs';
|
|
4
|
+
import { TextField } from '../TextField/TextField.mjs';
|
|
5
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
6
|
+
|
|
7
|
+
const PasswordFieldPrimitive = ({ autoComplete = 'current-password', label, className, hideShowPassword = false, passwordIsHiddenLabel, passwordIsShownLabel, showPasswordButtonLabel, showPasswordButtonRef, size, hasError, ...rest }, ref) => {
|
|
8
|
+
const [type, setType] = React.useState('password');
|
|
9
|
+
const showPasswordOnClick = React.useCallback(() => {
|
|
10
|
+
if (type === 'password') {
|
|
11
|
+
setType('text');
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
setType('password');
|
|
15
|
+
}
|
|
16
|
+
}, [setType, type]);
|
|
17
|
+
return (React.createElement(TextField, { autoComplete: autoComplete, outerEndComponent: hideShowPassword ? null : (React.createElement(ShowPasswordButton, { fieldType: type, onClick: showPasswordOnClick, passwordIsHiddenLabel: passwordIsHiddenLabel, passwordIsShownLabel: passwordIsShownLabel, ref: showPasswordButtonRef, size: size, showPasswordButtonLabel: showPasswordButtonLabel, hasError: hasError })), size: size, type: type, label: label, className: classNames(ComponentClassName.PasswordField, className), ref: ref, hasError: hasError, ...rest }));
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/passwordfield)
|
|
21
|
+
*/
|
|
22
|
+
const PasswordField = primitiveWithForwardRef(PasswordFieldPrimitive);
|
|
23
|
+
PasswordField.displayName = 'PasswordField';
|
|
24
|
+
|
|
25
|
+
export { PasswordField };
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName, classNameModifierByFlag } from '@aws-amplify/ui';
|
|
3
|
+
import { Button } from '../Button/Button.mjs';
|
|
4
|
+
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden.mjs';
|
|
5
|
+
import { ComponentText } from '../shared/constants.mjs';
|
|
6
|
+
import '../Icon/Icon.mjs';
|
|
7
|
+
import '../Icon/context/IconsContext.mjs';
|
|
8
|
+
import { useIcons } from '../Icon/context/useIcons.mjs';
|
|
9
|
+
import '../View/View.mjs';
|
|
10
|
+
import { IconVisibilityOff } from '../Icon/icons/IconVisibilityOff.mjs';
|
|
11
|
+
import { IconVisibility } from '../Icon/icons/IconVisibility.mjs';
|
|
12
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
13
|
+
|
|
14
|
+
const { passwordIsHidden, passwordIsShown, showPassword } = ComponentText.PasswordField;
|
|
15
|
+
const ShowPasswordButtonPrimitive = ({ fieldType, passwordIsHiddenLabel = passwordIsHidden, passwordIsShownLabel = passwordIsShown, showPasswordButtonLabel = showPassword, size, hasError, ...rest }, ref) => {
|
|
16
|
+
const icons = useIcons('passwordField');
|
|
17
|
+
const showPasswordButtonClass = classNames(ComponentClassName.FieldShowPassword, classNameModifierByFlag(ComponentClassName.FieldShowPassword, 'error', hasError));
|
|
18
|
+
const icon = fieldType === 'password'
|
|
19
|
+
? icons?.visibility ?? React.createElement(IconVisibility, { "aria-hidden": "true" })
|
|
20
|
+
: icons?.visibilityOff ?? React.createElement(IconVisibilityOff, { "aria-hidden": "true" });
|
|
21
|
+
return (React.createElement(Button, { "aria-checked": fieldType !== 'password', ariaLabel: showPasswordButtonLabel, className: showPasswordButtonClass, ref: ref, role: "switch", size: size, ...rest },
|
|
22
|
+
React.createElement(VisuallyHidden, { "aria-live": "polite" }, fieldType === 'password'
|
|
23
|
+
? passwordIsHiddenLabel
|
|
24
|
+
: passwordIsShownLabel),
|
|
25
|
+
icon));
|
|
26
|
+
};
|
|
27
|
+
const ShowPasswordButton = primitiveWithForwardRef(ShowPasswordButtonPrimitive);
|
|
28
|
+
ShowPasswordButton.displayName = 'ShowPasswordButton';
|
|
29
|
+
|
|
30
|
+
export { ShowPasswordButton };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName, countryDialCodes } from '@aws-amplify/ui';
|
|
3
|
+
import { SelectField } from '../SelectField/SelectField.mjs';
|
|
4
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
5
|
+
|
|
6
|
+
const DialCodeSelectPrimitive = ({ className, dialCodeList, isReadOnly, ...props }, ref) => {
|
|
7
|
+
const dialList = dialCodeList ?? countryDialCodes;
|
|
8
|
+
const dialCodeOptions = React.useMemo(() => dialList.map((dialCode) => (
|
|
9
|
+
// Regarding the `disabled` attribute, see comment in SelectField below
|
|
10
|
+
React.createElement("option", { key: dialCode, value: dialCode, disabled: isReadOnly }, dialCode))), [dialList, isReadOnly]);
|
|
11
|
+
return (React.createElement(SelectField
|
|
12
|
+
/*
|
|
13
|
+
Since <select> elements do not support the `readonly` html attribute, it is suggested to use the `disabled` html attribute
|
|
14
|
+
so that a screen reader will announce something to the user about the interactivity of the options list ( https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly)
|
|
15
|
+
*/
|
|
16
|
+
, { "aria-disabled": isReadOnly, autoComplete: "tel-country-code", className: classNames(ComponentClassName.CountryCodeSelect, ComponentClassName.DialCodeSelect, className), labelHidden: true, ref: ref, ...props }, dialCodeOptions));
|
|
17
|
+
};
|
|
18
|
+
const DialCodeSelect = primitiveWithForwardRef(DialCodeSelectPrimitive);
|
|
19
|
+
DialCodeSelect.displayName = 'DialCodeSelect';
|
|
20
|
+
|
|
21
|
+
export { DialCodeSelect };
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName } from '@aws-amplify/ui';
|
|
3
|
+
import { DialCodeSelect } from './DialCodeSelect.mjs';
|
|
4
|
+
import { ComponentText } from '../shared/constants.mjs';
|
|
5
|
+
import { TextField } from '../TextField/TextField.mjs';
|
|
6
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
7
|
+
|
|
8
|
+
const PhoneNumberFieldPrimitive = ({ autoComplete = 'tel-national', className, defaultDialCode, dialCodeLabel = ComponentText.PhoneNumberField.countryCodeLabel, dialCodeList, dialCodeName, dialCodeRef, hasError, isDisabled, isReadOnly, onDialCodeChange, onInput, size, variation, ...rest }, ref) => {
|
|
9
|
+
return (React.createElement(TextField, { outerStartComponent: React.createElement(DialCodeSelect, { defaultValue: defaultDialCode, dialCodeList: dialCodeList, className: className, hasError: hasError, isDisabled: isDisabled, isReadOnly: isReadOnly, label: dialCodeLabel, name: dialCodeName, onChange: onDialCodeChange, ref: dialCodeRef, size: size, variation: variation }), autoComplete: autoComplete, className: classNames(ComponentClassName.PhoneNumberField, className), hasError: hasError, isDisabled: isDisabled, isReadOnly: isReadOnly, onInput: onInput, ref: ref, size: size, type: "tel", variation: variation, ...rest }));
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/phonenumberfield)
|
|
13
|
+
*/
|
|
14
|
+
const PhoneNumberField = primitiveWithForwardRef(PhoneNumberFieldPrimitive);
|
|
15
|
+
PhoneNumberField.displayName = 'PhoneNumberField';
|
|
16
|
+
|
|
17
|
+
export { PhoneNumberField };
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName, classNameModifier } from '@aws-amplify/ui';
|
|
3
|
+
import { View } from '../View/View.mjs';
|
|
4
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
5
|
+
|
|
6
|
+
const PlaceholderPrimitive = ({ className, children, isLoaded, size, ...rest }, ref) => {
|
|
7
|
+
if (isLoaded) {
|
|
8
|
+
return React.createElement(React.Fragment, null, children);
|
|
9
|
+
}
|
|
10
|
+
return (React.createElement(View, { className: classNames(ComponentClassName.Placeholder, classNameModifier(ComponentClassName.Placeholder, size), className), ref: ref, ...rest }));
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/placeholder)
|
|
14
|
+
*/
|
|
15
|
+
const Placeholder = primitiveWithForwardRef(PlaceholderPrimitive);
|
|
16
|
+
Placeholder.displayName = 'Placeholder';
|
|
17
|
+
|
|
18
|
+
export { Placeholder };
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName, classNameModifierByFlag, classNameModifier } from '@aws-amplify/ui';
|
|
3
|
+
import { Flex } from '../Flex/Flex.mjs';
|
|
4
|
+
import { Input } from '../Input/Input.mjs';
|
|
5
|
+
import { Text } from '../Text/Text.mjs';
|
|
6
|
+
import { useRadioGroupContext } from '../RadioGroupField/context.mjs';
|
|
7
|
+
import { useFieldset } from '../Fieldset/useFieldset.mjs';
|
|
8
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
9
|
+
|
|
10
|
+
const RadioPrimitive = ({ children, className, id, isDisabled = false, testId, value, labelPosition: radioLabelPosition, ...rest }, ref) => {
|
|
11
|
+
const { currentValue, defaultValue, name, hasError, isGroupDisabled = false, isRequired, isReadOnly, onChange, size, labelPosition: groupLabelPosition, } = useRadioGroupContext();
|
|
12
|
+
const { isFieldsetDisabled } = useFieldset();
|
|
13
|
+
const shouldBeDisabled = isFieldsetDisabled
|
|
14
|
+
? isFieldsetDisabled
|
|
15
|
+
: isGroupDisabled || isDisabled || (isReadOnly && defaultValue !== value);
|
|
16
|
+
// for controlled component
|
|
17
|
+
const checked = currentValue !== undefined ? value === currentValue : undefined;
|
|
18
|
+
// for uncontrolled component
|
|
19
|
+
const defaultChecked = defaultValue !== undefined ? value === defaultValue : undefined;
|
|
20
|
+
const labelPosition = radioLabelPosition
|
|
21
|
+
? radioLabelPosition
|
|
22
|
+
: groupLabelPosition;
|
|
23
|
+
return (React.createElement(Flex, { as: "label", className: classNames(ComponentClassName.Radio, classNameModifierByFlag(ComponentClassName.Radio, `disabled`, shouldBeDisabled), labelPosition ? `amplify-label-${labelPosition}` : null, className) },
|
|
24
|
+
children && (React.createElement(Text, { as: "span", className: classNames(ComponentClassName.RadioLabel, classNameModifierByFlag(ComponentClassName.RadioLabel, `disabled`, shouldBeDisabled)) }, children)),
|
|
25
|
+
React.createElement(Input, { checked: checked, className: classNames(ComponentClassName.VisuallyHidden, ComponentClassName.RadioInput), defaultChecked: defaultChecked, hasError: hasError, id: id, isDisabled: shouldBeDisabled, isReadOnly: isReadOnly, isRequired: isRequired, onChange: onChange, ref: ref, type: "radio", name: name, value: value, ...rest }),
|
|
26
|
+
React.createElement(Flex, { "aria-hidden": "true", as: "span", className: classNames(ComponentClassName.RadioButton, classNameModifier(ComponentClassName.RadioButton, size)), testId: testId })));
|
|
27
|
+
};
|
|
28
|
+
const Radio = primitiveWithForwardRef(RadioPrimitive);
|
|
29
|
+
Radio.displayName = 'Radio';
|
|
30
|
+
|
|
31
|
+
export { Radio, RadioPrimitive };
|
|
@@ -1 +1,55 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentClassName, classNames, classNameModifier } from '@aws-amplify/ui';
|
|
3
|
+
import '../Field/FieldClearButton.mjs';
|
|
4
|
+
import { FieldDescription } from '../Field/FieldDescription.mjs';
|
|
5
|
+
import { FieldErrorMessage } from '../Field/FieldErrorMessage.mjs';
|
|
6
|
+
import '../Field/Field.mjs';
|
|
7
|
+
import { Fieldset } from '../Fieldset/Fieldset.mjs';
|
|
8
|
+
import '../Fieldset/useFieldset.mjs';
|
|
9
|
+
import { Flex } from '../Flex/Flex.mjs';
|
|
10
|
+
import { RadioGroupContext } from './context.mjs';
|
|
11
|
+
import { getTestId } from '../utils/getTestId.mjs';
|
|
12
|
+
import { useStableId } from '../utils/useStableId.mjs';
|
|
13
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
14
|
+
|
|
15
|
+
const RadioGroupFieldPrimitive = ({ children, className, defaultValue, descriptiveText, errorMessage, hasError = false, id, isDisabled, isRequired, isReadOnly, legend, legendHidden = false, labelPosition, onChange, name, size, testId, value, variation, ...rest }, ref) => {
|
|
16
|
+
const fieldId = useStableId(id);
|
|
17
|
+
const descriptionId = useStableId();
|
|
18
|
+
const ariaDescribedBy = descriptiveText ? descriptionId : undefined;
|
|
19
|
+
const radioGroupTestId = getTestId(testId, ComponentClassName.RadioGroup);
|
|
20
|
+
const radioGroupContextValue = React.useMemo(() => ({
|
|
21
|
+
currentValue: value,
|
|
22
|
+
defaultValue,
|
|
23
|
+
hasError,
|
|
24
|
+
isRequired,
|
|
25
|
+
isReadOnly,
|
|
26
|
+
isGroupDisabled: isDisabled,
|
|
27
|
+
onChange,
|
|
28
|
+
size,
|
|
29
|
+
name,
|
|
30
|
+
labelPosition,
|
|
31
|
+
}), [
|
|
32
|
+
defaultValue,
|
|
33
|
+
hasError,
|
|
34
|
+
isDisabled,
|
|
35
|
+
isRequired,
|
|
36
|
+
isReadOnly,
|
|
37
|
+
onChange,
|
|
38
|
+
size,
|
|
39
|
+
name,
|
|
40
|
+
value,
|
|
41
|
+
labelPosition,
|
|
42
|
+
]);
|
|
43
|
+
return (React.createElement(Fieldset, { className: classNames(ComponentClassName.Field, classNameModifier(ComponentClassName.Field, size), ComponentClassName.RadioGroupField, className), isDisabled: isDisabled, legend: legend, legendHidden: legendHidden, ref: ref, role: "radiogroup", size: size, testId: testId, variation: variation, ...rest },
|
|
44
|
+
React.createElement(FieldDescription, { id: descriptionId, labelHidden: legendHidden, descriptiveText: descriptiveText }),
|
|
45
|
+
React.createElement(Flex, { "aria-describedby": ariaDescribedBy, className: ComponentClassName.RadioGroup, id: fieldId, testId: radioGroupTestId },
|
|
46
|
+
React.createElement(RadioGroupContext.Provider, { value: radioGroupContextValue }, children)),
|
|
47
|
+
React.createElement(FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })));
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/radiogroupfield)
|
|
51
|
+
*/
|
|
52
|
+
const RadioGroupField = primitiveWithForwardRef(RadioGroupFieldPrimitive);
|
|
53
|
+
RadioGroupField.displayName = 'RadioGroupField';
|
|
54
|
+
|
|
55
|
+
export { RadioGroupField };
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React__default, { useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
const defaultValue = { name: 'default' };
|
|
4
|
+
const RadioGroupContext = React__default.createContext(defaultValue);
|
|
5
|
+
const useRadioGroupContext = () => {
|
|
6
|
+
return useContext(RadioGroupContext);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { RadioGroupContext, useRadioGroupContext };
|
|
@@ -1 +1,44 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNameModifier, ComponentClassName, classNames } from '@aws-amplify/ui';
|
|
3
|
+
import { Flex } from '../Flex/Flex.mjs';
|
|
4
|
+
import '../Icon/Icon.mjs';
|
|
5
|
+
import '../Icon/context/IconsContext.mjs';
|
|
6
|
+
import { useIcons } from '../Icon/context/useIcons.mjs';
|
|
7
|
+
import '../View/View.mjs';
|
|
8
|
+
import { IconStar } from '../Icon/icons/IconStar.mjs';
|
|
9
|
+
import { isIconFilled, isIconEmpty, isIconMixed } from './utils.mjs';
|
|
10
|
+
import { RatingIcon } from './RatingIcon.mjs';
|
|
11
|
+
import { RatingMixedIcon } from './RatingMixedIcon.mjs';
|
|
12
|
+
import { VisuallyHidden } from '../VisuallyHidden/VisuallyHidden.mjs';
|
|
13
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
14
|
+
|
|
15
|
+
const RATING_DEFAULT_MAX_VALUE = 5;
|
|
16
|
+
const RATING_DEFAULT_VALUE = 0;
|
|
17
|
+
const RatingPrimitive = ({ className, emptyColor, emptyIcon, fillColor, icon, maxValue = RATING_DEFAULT_MAX_VALUE, size, value = RATING_DEFAULT_VALUE, ...rest }, ref) => {
|
|
18
|
+
const icons = useIcons('rating');
|
|
19
|
+
const filledIcon = icon ?? icons?.filled ?? React.createElement(IconStar, null);
|
|
20
|
+
const _emptyIcon = emptyIcon ?? icon ?? icons?.empty ?? React.createElement(IconStar, null);
|
|
21
|
+
const items = new Array(Math.ceil(maxValue)).fill(1).map((_, index) => {
|
|
22
|
+
const currentIconIndex = index + 1;
|
|
23
|
+
if (isIconFilled(currentIconIndex, value))
|
|
24
|
+
return (React.createElement(RatingIcon, { key: index.toString(), icon: filledIcon, fill: fillColor, className: classNameModifier(ComponentClassName.RatingIcon, 'filled') }));
|
|
25
|
+
if (isIconEmpty(currentIconIndex, value))
|
|
26
|
+
return (React.createElement(RatingIcon, { key: index.toString(), icon: _emptyIcon, fill: emptyColor, className: classNameModifier(ComponentClassName.RatingIcon, 'empty') }));
|
|
27
|
+
if (isIconMixed(currentIconIndex, value))
|
|
28
|
+
return (React.createElement(RatingMixedIcon, { key: index.toString(), fillIcon: filledIcon, emptyIcon: _emptyIcon, value: value, fillColor: fillColor, emptyColor: emptyColor }));
|
|
29
|
+
});
|
|
30
|
+
return (React.createElement(Flex, { className: classNames(ComponentClassName.Rating, classNameModifier(ComponentClassName.Rating, size), className), ref: ref, ...rest },
|
|
31
|
+
items,
|
|
32
|
+
React.createElement(VisuallyHidden, null,
|
|
33
|
+
value,
|
|
34
|
+
" out of ",
|
|
35
|
+
maxValue,
|
|
36
|
+
" rating")));
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/rating)
|
|
40
|
+
*/
|
|
41
|
+
const Rating = primitiveWithForwardRef(RatingPrimitive);
|
|
42
|
+
Rating.displayName = 'Rating';
|
|
43
|
+
|
|
44
|
+
export { Rating };
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentClassName, classNames } from '@aws-amplify/ui';
|
|
3
|
+
import { View } from '../View/View.mjs';
|
|
4
|
+
|
|
5
|
+
const RatingIcon = ({ icon, fill, className, }) => {
|
|
6
|
+
return (React.createElement(View, { as: "span", className: ComponentClassName.RatingItem, "aria-hidden": "true" },
|
|
7
|
+
React.createElement(View, { as: "span", className: classNames(className), color: fill }, icon)));
|
|
8
|
+
};
|
|
9
|
+
RatingIcon.displayName = 'RatingIcon';
|
|
10
|
+
|
|
11
|
+
export { RatingIcon };
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentClassName, classNames, classNameModifier } from '@aws-amplify/ui';
|
|
3
|
+
import { View } from '../View/View.mjs';
|
|
4
|
+
|
|
5
|
+
const RatingMixedIcon = ({ emptyColor, emptyIcon, fillColor, fillIcon, value, }) => {
|
|
6
|
+
const widthPercentage = `${(value % 1) * 100}%`;
|
|
7
|
+
return (React.createElement(View, { as: "span", className: ComponentClassName.RatingItem, "aria-hidden": "true" },
|
|
8
|
+
React.createElement(View, { as: "span", className: classNames(ComponentClassName.RatingIcon, classNameModifier(ComponentClassName.RatingIcon, 'empty')), color: emptyColor }, emptyIcon),
|
|
9
|
+
React.createElement(View, { as: "span", className: classNames(ComponentClassName.RatingIcon, classNameModifier(ComponentClassName.RatingIcon, 'filled')), width: widthPercentage, color: fillColor }, fillIcon)));
|
|
10
|
+
};
|
|
11
|
+
RatingMixedIcon.displayName = 'RatingMixedIcon';
|
|
12
|
+
|
|
13
|
+
export { RatingMixedIcon };
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
const isIconFilled = (currentIconIndex, ratingValue) => {
|
|
2
|
+
if (currentIconIndex <= ratingValue)
|
|
3
|
+
return true;
|
|
4
|
+
return false;
|
|
5
|
+
};
|
|
6
|
+
const isIconEmpty = (currentIconIndex, ratingValue) => {
|
|
7
|
+
if (currentIconIndex - 1 >= ratingValue)
|
|
8
|
+
return true;
|
|
9
|
+
return false;
|
|
10
|
+
};
|
|
11
|
+
const isIconMixed = (currentIconIndex, ratingValue) => {
|
|
12
|
+
if (currentIconIndex > ratingValue && currentIconIndex - 1 < ratingValue) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { isIconEmpty, isIconFilled, isIconMixed };
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName, classNameModifier } from '@aws-amplify/ui';
|
|
3
|
+
import { View } from '../View/View.mjs';
|
|
4
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
5
|
+
|
|
6
|
+
const ScrollViewPrimitive = ({ children, className, orientation, ...rest }, ref) => (React.createElement(View, { className: classNames(ComponentClassName.ScrollView, classNameModifier(ComponentClassName.ScrollView, orientation), className), ref: ref, ...rest }, children));
|
|
7
|
+
/**
|
|
8
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/scrollview)
|
|
9
|
+
*/
|
|
10
|
+
const ScrollView = primitiveWithForwardRef(ScrollViewPrimitive);
|
|
11
|
+
ScrollView.displayName = 'ScrollView';
|
|
12
|
+
|
|
13
|
+
export { ScrollView };
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { classNames, ComponentClassName } from '@aws-amplify/ui';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { FieldClearButton } from '../Field/FieldClearButton.mjs';
|
|
4
|
+
import '../Field/FieldDescription.mjs';
|
|
5
|
+
import '../Field/FieldErrorMessage.mjs';
|
|
6
|
+
import '../Field/Field.mjs';
|
|
7
|
+
import { FieldGroupIcon } from '../FieldGroupIcon/FieldGroupIcon.mjs';
|
|
8
|
+
import '../FieldGroupIcon/FieldGroupIconButton.mjs';
|
|
9
|
+
import '../View/View.mjs';
|
|
10
|
+
import { IconSearch } from '../Icon/icons/IconSearch.mjs';
|
|
11
|
+
import '../Icon/context/IconsContext.mjs';
|
|
12
|
+
import { SearchFieldButton } from './SearchFieldButton.mjs';
|
|
13
|
+
import { TextField } from '../TextField/TextField.mjs';
|
|
14
|
+
import { useSearchField } from './useSearchField.mjs';
|
|
15
|
+
import { strHasLength } from '../shared/utils.mjs';
|
|
16
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
17
|
+
|
|
18
|
+
const SearchFieldPrimitive = ({ autoComplete = 'off', className, isDisabled, clearButtonLabel, labelHidden = true, name = 'q', hasSearchButton = true, hasSearchIcon = false, onChange, onClear, onSubmit, searchButtonRef, size, defaultValue, value, ...rest }, ref) => {
|
|
19
|
+
const { composedValue, onClearHandler, onKeyDown, onClick, handleOnChange, composedRefs, } = useSearchField({
|
|
20
|
+
defaultValue,
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
onClear,
|
|
24
|
+
onSubmit,
|
|
25
|
+
externalRef: ref,
|
|
26
|
+
});
|
|
27
|
+
const SearchButton = hasSearchButton ? (React.createElement(SearchFieldButton, { isDisabled: isDisabled, onClick: onClick, ref: searchButtonRef, size: size })) : undefined;
|
|
28
|
+
const SearchIcon = hasSearchIcon ? (React.createElement(FieldGroupIcon, null,
|
|
29
|
+
React.createElement(IconSearch, null))) : undefined;
|
|
30
|
+
return (React.createElement(TextField, { autoComplete: autoComplete, className: classNames(ComponentClassName.SearchField, className), labelHidden: labelHidden, innerStartComponent: SearchIcon, innerEndComponent: React.createElement(FieldClearButton, { ariaLabel: clearButtonLabel, excludeFromTabOrder: true, isVisible: !isDisabled && strHasLength(composedValue), onClick: onClearHandler, size: size, variation: "link" }), isDisabled: isDisabled, name: name, onChange: handleOnChange, onKeyDown: onKeyDown, outerEndComponent: SearchButton, ref: composedRefs, size: size, value: composedValue, ...rest }));
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/searchfield)
|
|
34
|
+
*/
|
|
35
|
+
const SearchField = primitiveWithForwardRef(SearchFieldPrimitive);
|
|
36
|
+
SearchField.displayName = 'SearchField';
|
|
37
|
+
|
|
38
|
+
export { SearchField };
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentClassName } from '@aws-amplify/ui';
|
|
3
|
+
import { ComponentText } from '../shared/constants.mjs';
|
|
4
|
+
import '../FieldGroupIcon/FieldGroupIcon.mjs';
|
|
5
|
+
import { FieldGroupIconButton } from '../FieldGroupIcon/FieldGroupIconButton.mjs';
|
|
6
|
+
import '../Icon/Icon.mjs';
|
|
7
|
+
import '../Icon/context/IconsContext.mjs';
|
|
8
|
+
import { useIcons } from '../Icon/context/useIcons.mjs';
|
|
9
|
+
import '../View/View.mjs';
|
|
10
|
+
import { IconSearch } from '../Icon/icons/IconSearch.mjs';
|
|
11
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
12
|
+
|
|
13
|
+
const ariaLabelText = ComponentText.SearchField.searchButtonLabel;
|
|
14
|
+
const SearchFieldButtonPrimitive = ({ size, ...props }, ref) => {
|
|
15
|
+
const icons = useIcons('searchField');
|
|
16
|
+
return (React.createElement(FieldGroupIconButton, { ariaLabel: ariaLabelText, className: ComponentClassName.SearchFieldSearch, size: size, ref: ref, type: "submit", ...props }, icons?.search ?? React.createElement(IconSearch, null)));
|
|
17
|
+
};
|
|
18
|
+
const SearchFieldButton = primitiveWithForwardRef(SearchFieldButtonPrimitive);
|
|
19
|
+
SearchFieldButton.displayName = 'SearchFieldButton';
|
|
20
|
+
|
|
21
|
+
export { SearchFieldButton };
|
|
@@ -1 +1,64 @@
|
|
|
1
|
-
import*
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { isFunction } from '@aws-amplify/ui';
|
|
3
|
+
import { ESCAPE_KEY, ENTER_KEY } from '../shared/constants.mjs';
|
|
4
|
+
import { useComposeRefsCallback } from '../../hooks/useComposeRefsCallback.mjs';
|
|
5
|
+
|
|
6
|
+
const DEFAULT_KEYS = new Set([ESCAPE_KEY, ENTER_KEY]);
|
|
7
|
+
const useSearchField = ({ defaultValue = '', value, onChange, onClear, onSubmit, externalRef, }) => {
|
|
8
|
+
const isControlled = value !== undefined;
|
|
9
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
10
|
+
const composedValue = isControlled ? value : internalValue;
|
|
11
|
+
const internalRef = React.useRef(null);
|
|
12
|
+
const composedRefs = useComposeRefsCallback({
|
|
13
|
+
externalRef,
|
|
14
|
+
internalRef,
|
|
15
|
+
});
|
|
16
|
+
const onClearHandler = React.useCallback(() => {
|
|
17
|
+
if (!isControlled) {
|
|
18
|
+
setInternalValue('');
|
|
19
|
+
}
|
|
20
|
+
internalRef?.current?.focus();
|
|
21
|
+
if (isFunction(onClear)) {
|
|
22
|
+
onClear();
|
|
23
|
+
}
|
|
24
|
+
}, [isControlled, setInternalValue, onClear]);
|
|
25
|
+
const onSubmitHandler = React.useCallback((value) => {
|
|
26
|
+
if (isFunction(onSubmit)) {
|
|
27
|
+
onSubmit(value);
|
|
28
|
+
}
|
|
29
|
+
}, [onSubmit]);
|
|
30
|
+
const onKeyDown = React.useCallback((event) => {
|
|
31
|
+
const { key } = event;
|
|
32
|
+
if (!DEFAULT_KEYS.has(key)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
if (key === ESCAPE_KEY) {
|
|
37
|
+
onClearHandler();
|
|
38
|
+
}
|
|
39
|
+
else if (key === ENTER_KEY) {
|
|
40
|
+
onSubmitHandler(composedValue);
|
|
41
|
+
}
|
|
42
|
+
}, [composedValue, onClearHandler, onSubmitHandler]);
|
|
43
|
+
const handleOnChange = React.useCallback((event) => {
|
|
44
|
+
if (!isControlled) {
|
|
45
|
+
setInternalValue(event.target.value);
|
|
46
|
+
}
|
|
47
|
+
if (isFunction(onChange)) {
|
|
48
|
+
onChange(event);
|
|
49
|
+
}
|
|
50
|
+
}, [isControlled, onChange, setInternalValue]);
|
|
51
|
+
const onClick = React.useCallback(() => {
|
|
52
|
+
onSubmitHandler(composedValue);
|
|
53
|
+
}, [onSubmitHandler, composedValue]);
|
|
54
|
+
return {
|
|
55
|
+
composedValue,
|
|
56
|
+
onClearHandler,
|
|
57
|
+
onKeyDown,
|
|
58
|
+
onClick,
|
|
59
|
+
handleOnChange,
|
|
60
|
+
composedRefs,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { useSearchField };
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { classNames, ComponentClassName, classNameModifier, classNameModifierByFlag } from '@aws-amplify/ui';
|
|
3
|
+
import { Flex } from '../Flex/Flex.mjs';
|
|
4
|
+
import '../Icon/Icon.mjs';
|
|
5
|
+
import '../Icon/context/IconsContext.mjs';
|
|
6
|
+
import { useIcons } from '../Icon/context/useIcons.mjs';
|
|
7
|
+
import { View } from '../View/View.mjs';
|
|
8
|
+
import { IconExpandMore } from '../Icon/icons/IconExpandMore.mjs';
|
|
9
|
+
import { useFieldset } from '../Fieldset/useFieldset.mjs';
|
|
10
|
+
import { primitiveWithForwardRef } from '../utils/primitiveWithForwardRef.mjs';
|
|
11
|
+
|
|
12
|
+
const SelectPrimitive = ({ autoComplete, className, size, variation, value, defaultValue, hasError, icon, iconColor, children, placeholder, isDisabled, isRequired, isMultiple = false, selectSize = 1, ...rest }, ref) => {
|
|
13
|
+
const DEFAULT_PLACEHOLDER_VALUE = '';
|
|
14
|
+
// value === undefined is to make sure that component is used in uncontrolled way so that setting defaultValue is valid
|
|
15
|
+
const shouldSetDefaultPlaceholderValue = value === undefined && defaultValue === undefined && placeholder;
|
|
16
|
+
const isExpanded = isMultiple || selectSize > 1;
|
|
17
|
+
const componentClasses = classNames(ComponentClassName.Select, ComponentClassName.FieldGroupControl, classNameModifier(ComponentClassName.Select, size), classNameModifier(ComponentClassName.Select, variation), classNameModifierByFlag(ComponentClassName.Select, 'error', hasError), classNameModifierByFlag(ComponentClassName.Select, 'expanded', isExpanded), className);
|
|
18
|
+
const icons = useIcons('select');
|
|
19
|
+
const { isFieldsetDisabled } = useFieldset();
|
|
20
|
+
return (React.createElement(View, { className: ComponentClassName.SelectWrapper },
|
|
21
|
+
React.createElement(View, { "aria-invalid": hasError, as: "select", autoComplete: autoComplete, value: value, defaultValue: shouldSetDefaultPlaceholderValue
|
|
22
|
+
? DEFAULT_PLACEHOLDER_VALUE
|
|
23
|
+
: defaultValue, isDisabled: isFieldsetDisabled ? isFieldsetDisabled : isDisabled, multiple: isMultiple, size: selectSize, required: isRequired, className: componentClasses, ref: ref, ...rest },
|
|
24
|
+
placeholder && React.createElement("option", { value: "" }, placeholder),
|
|
25
|
+
children),
|
|
26
|
+
isExpanded ? null : (React.createElement(Flex, { className: classNames(ComponentClassName.SelectIcon, classNameModifier(ComponentClassName.SelectIcon, size)), color: iconColor }, icon ?? icons?.expand ?? React.createElement(IconExpandMore, null)))));
|
|
27
|
+
};
|
|
28
|
+
const Select = primitiveWithForwardRef(SelectPrimitive);
|
|
29
|
+
Select.displayName = 'Select';
|
|
30
|
+
|
|
31
|
+
export { Select };
|