@aws-amplify/ui-react 5.3.2 → 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 -1
- 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/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/package.json +13 -45
- package/dist/Field-94e428ed.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
|
@@ -0,0 +1,1174 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var core = require('@aws-amplify/core');
|
|
5
|
+
var auth = require('aws-amplify/auth');
|
|
6
|
+
var ui = require('@aws-amplify/ui');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n["default"] = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Amplify Auth React hook
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
const useAuth = () => {
|
|
33
|
+
const [result, setResult] = React__namespace.useState({
|
|
34
|
+
error: undefined,
|
|
35
|
+
isLoading: true,
|
|
36
|
+
user: undefined,
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Hub events like `tokenRefresh` will not give back the user object.
|
|
40
|
+
* This util will be used to get current user after those events.
|
|
41
|
+
*/
|
|
42
|
+
const fetchCurrentUser = React__namespace.useCallback(async () => {
|
|
43
|
+
setResult((prevResult) => ({ ...prevResult, isLoading: true }));
|
|
44
|
+
try {
|
|
45
|
+
const user = await auth.getCurrentUser();
|
|
46
|
+
setResult({ user, isLoading: false });
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
const error = e;
|
|
50
|
+
setResult({ error, isLoading: false });
|
|
51
|
+
}
|
|
52
|
+
}, []);
|
|
53
|
+
const handleAuth = React__namespace.useCallback(({ payload }) => {
|
|
54
|
+
switch (payload.event) {
|
|
55
|
+
// success events
|
|
56
|
+
case 'signedIn':
|
|
57
|
+
case 'signUp':
|
|
58
|
+
case 'autoSignIn': {
|
|
59
|
+
setResult({ user: payload.data, isLoading: false });
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
case 'signedOut': {
|
|
63
|
+
setResult({ user: undefined, isLoading: false });
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
// failure events
|
|
67
|
+
case 'tokenRefresh_failure':
|
|
68
|
+
case 'signIn_failure': {
|
|
69
|
+
setResult({ error: payload.data, isLoading: false });
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case 'autoSignIn_failure': {
|
|
73
|
+
// autoSignIn just returns error message. Wrap it to an Error object
|
|
74
|
+
setResult({ error: new Error(payload.message), isLoading: false });
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
// events that need another fetch
|
|
78
|
+
case 'tokenRefresh': {
|
|
79
|
+
fetchCurrentUser();
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, [fetchCurrentUser]);
|
|
84
|
+
React__namespace.useEffect(() => {
|
|
85
|
+
const unsubscribe = core.Hub.listen('auth', handleAuth, 'useAuth');
|
|
86
|
+
fetchCurrentUser(); // on init, see if user is already logged in
|
|
87
|
+
return unsubscribe;
|
|
88
|
+
}, [handleAuth, fetchCurrentUser]);
|
|
89
|
+
return {
|
|
90
|
+
...result,
|
|
91
|
+
/** @deprecated Fetch is handled automatically, do not use this directly */
|
|
92
|
+
fetch: fetchCurrentUser,
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const ThemeContext = React__namespace.createContext({
|
|
97
|
+
theme: ui.createTheme(),
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get current Theme object value from Amplify context.
|
|
102
|
+
* Returns a default theme if context is not available
|
|
103
|
+
*/
|
|
104
|
+
const getThemeFromContext = (context) => {
|
|
105
|
+
if (typeof context === 'undefined' || typeof context.theme === 'undefined') {
|
|
106
|
+
return ui.createTheme();
|
|
107
|
+
}
|
|
108
|
+
return context.theme;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/theming)
|
|
112
|
+
*/
|
|
113
|
+
const useTheme = () => {
|
|
114
|
+
const context = React__namespace.useContext(ThemeContext);
|
|
115
|
+
return getThemeFromContext(context);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// For internal use, no need to export
|
|
119
|
+
const ComponentText = {
|
|
120
|
+
Alert: {
|
|
121
|
+
dismissButtonLabel: 'Dismiss alert',
|
|
122
|
+
},
|
|
123
|
+
Autocomplete: {
|
|
124
|
+
emptyText: 'No options found',
|
|
125
|
+
loadingText: 'Loading options...',
|
|
126
|
+
},
|
|
127
|
+
Collection: {
|
|
128
|
+
searchButtonLabel: 'Search',
|
|
129
|
+
searchNoResultsFound: 'No results found',
|
|
130
|
+
},
|
|
131
|
+
Fields: {
|
|
132
|
+
clearButtonLabel: 'Clear input',
|
|
133
|
+
},
|
|
134
|
+
Message: {
|
|
135
|
+
dismissLabel: 'Dismiss message',
|
|
136
|
+
},
|
|
137
|
+
PaginationItem: {
|
|
138
|
+
currentPageLabel: 'Page',
|
|
139
|
+
nextLabel: 'Go to next page',
|
|
140
|
+
pageLabel: 'Go to page',
|
|
141
|
+
previousLabel: 'Go to previous page',
|
|
142
|
+
},
|
|
143
|
+
PhoneNumberField: {
|
|
144
|
+
countryCodeLabel: 'Country code',
|
|
145
|
+
},
|
|
146
|
+
SearchField: {
|
|
147
|
+
searchButtonLabel: 'Search',
|
|
148
|
+
},
|
|
149
|
+
PasswordField: {
|
|
150
|
+
passwordIsHidden: 'Password is hidden',
|
|
151
|
+
passwordIsShown: 'Password is shown',
|
|
152
|
+
showPassword: 'Show password',
|
|
153
|
+
},
|
|
154
|
+
StepperField: {
|
|
155
|
+
increaseButtonLabel: 'Increase to',
|
|
156
|
+
decreaseButtonLabel: 'Decrease to',
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
const stylePropsToThemeKeys = {
|
|
160
|
+
backgroundColor: 'colors',
|
|
161
|
+
borderColor: 'colors',
|
|
162
|
+
borderWidth: 'borderWidths',
|
|
163
|
+
color: 'colors',
|
|
164
|
+
borderRadius: 'radii',
|
|
165
|
+
fontSize: 'fontSizes',
|
|
166
|
+
fontWeight: 'fontWeights',
|
|
167
|
+
fontFamily: 'fonts',
|
|
168
|
+
lineHeight: 'lineHeights',
|
|
169
|
+
opacity: 'opacities',
|
|
170
|
+
boxShadow: 'shadows',
|
|
171
|
+
transform: 'transforms',
|
|
172
|
+
left: 'space',
|
|
173
|
+
right: 'space',
|
|
174
|
+
top: 'space',
|
|
175
|
+
bottom: 'space',
|
|
176
|
+
height: 'space',
|
|
177
|
+
width: 'space',
|
|
178
|
+
letterSpacing: 'space',
|
|
179
|
+
margin: 'space',
|
|
180
|
+
marginBlock: 'space',
|
|
181
|
+
marginBlockEnd: 'space',
|
|
182
|
+
marginBlockStart: 'space',
|
|
183
|
+
marginInline: 'space',
|
|
184
|
+
marginInlineEnd: 'space',
|
|
185
|
+
marginInlineStart: 'space',
|
|
186
|
+
marginLeft: 'space',
|
|
187
|
+
marginRight: 'space',
|
|
188
|
+
marginTop: 'space',
|
|
189
|
+
marginBottom: 'space',
|
|
190
|
+
maxHeight: 'space',
|
|
191
|
+
maxWidth: 'space',
|
|
192
|
+
minHeight: 'space',
|
|
193
|
+
minWidth: 'space',
|
|
194
|
+
padding: 'space',
|
|
195
|
+
paddingBlock: 'space',
|
|
196
|
+
paddingBlockEnd: 'space',
|
|
197
|
+
paddingBlockStart: 'space',
|
|
198
|
+
paddingInline: 'space',
|
|
199
|
+
paddingInlineEnd: 'space',
|
|
200
|
+
paddingInlineStart: 'space',
|
|
201
|
+
paddingLeft: 'space',
|
|
202
|
+
paddingRight: 'space',
|
|
203
|
+
paddingTop: 'space',
|
|
204
|
+
paddingBottom: 'space',
|
|
205
|
+
gap: 'space',
|
|
206
|
+
columnGap: 'space',
|
|
207
|
+
rowGap: 'space',
|
|
208
|
+
};
|
|
209
|
+
// key name
|
|
210
|
+
const ESCAPE_KEY = 'Escape';
|
|
211
|
+
const ENTER_KEY = 'Enter';
|
|
212
|
+
const ARROW_UP = 'ArrowUp';
|
|
213
|
+
const ARROW_DOWN = 'ArrowDown';
|
|
214
|
+
|
|
215
|
+
const isThemeStylePropKey = (key) => {
|
|
216
|
+
return key in stylePropsToThemeKeys;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const strHasLength = (str) => typeof str === 'string' && str.length > 0;
|
|
220
|
+
const isEmptyString = (value) => typeof value === 'string' && value.length === 0;
|
|
221
|
+
const isNullOrEmptyString = (value) => value == null || isEmptyString(value);
|
|
222
|
+
/**
|
|
223
|
+
* Create a consecutive integer array from start value to end value.
|
|
224
|
+
* @param start start value
|
|
225
|
+
* @param end end value
|
|
226
|
+
* @returns an integer array with elements from start to end consecutively
|
|
227
|
+
*/
|
|
228
|
+
const getConsecutiveIntArray = (start, end) => {
|
|
229
|
+
const length = end - start + 1;
|
|
230
|
+
return Array.from({ length }, (_, idx) => idx + start);
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* TS helper function to make using Object.keys more typesafe
|
|
234
|
+
*/
|
|
235
|
+
const objectKeys = (obj) => {
|
|
236
|
+
return Object.keys(obj);
|
|
237
|
+
};
|
|
238
|
+
const getCSSVariableIfValueIsThemeKey = (propKey, value, tokens) => {
|
|
239
|
+
if (typeof value !== 'string') {
|
|
240
|
+
return value;
|
|
241
|
+
}
|
|
242
|
+
// For shorthand properties like `padding` which can accept 1, 2, 3, or 4 values
|
|
243
|
+
// run this function on each value. This would not work on CSS shorthands that
|
|
244
|
+
// mix types, like border which is a composite of borderWidth, borderStyle, and
|
|
245
|
+
// borderColor.
|
|
246
|
+
if (value.includes(' ')) {
|
|
247
|
+
return value
|
|
248
|
+
.split(' ')
|
|
249
|
+
.map((val) => getCSSVariableIfValueIsThemeKey(propKey, val, tokens))
|
|
250
|
+
.join(' ');
|
|
251
|
+
}
|
|
252
|
+
if (isThemeStylePropKey(propKey)) {
|
|
253
|
+
const path = value.split('.');
|
|
254
|
+
const tokenKey = stylePropsToThemeKeys[propKey];
|
|
255
|
+
let tokenProps = tokens[tokenKey];
|
|
256
|
+
for (let i = 0; i < path.length; i++) {
|
|
257
|
+
if (tokenProps) {
|
|
258
|
+
// overwrite tokenProps with next nested value of tokenProps
|
|
259
|
+
tokenProps = tokenProps[path[i]];
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
return ui.isDesignToken(tokenProps)
|
|
265
|
+
? `var(--${ui.cssNameTransform({
|
|
266
|
+
path: [stylePropsToThemeKeys[propKey], ...path],
|
|
267
|
+
})})`
|
|
268
|
+
: value;
|
|
269
|
+
}
|
|
270
|
+
return value;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Inspiration for getMediaQueries and useBreakpoint
|
|
274
|
+
const getMediaQueries = ({ breakpoints }) => {
|
|
275
|
+
const sortedBreakpoints = objectKeys(breakpoints).sort((a, b) => breakpoints[b] - breakpoints[a]);
|
|
276
|
+
return sortedBreakpoints.map((breakpoint, index) => {
|
|
277
|
+
let query = '';
|
|
278
|
+
const minWidth = breakpoints[breakpoint];
|
|
279
|
+
const nextBreakpoint = sortedBreakpoints[index - 1];
|
|
280
|
+
const maxWidth = nextBreakpoint ? breakpoints[nextBreakpoint] - 1 : null;
|
|
281
|
+
if (minWidth >= 0) {
|
|
282
|
+
query = `(min-width: ${minWidth}px)`;
|
|
283
|
+
}
|
|
284
|
+
if (maxWidth !== null) {
|
|
285
|
+
if (query) {
|
|
286
|
+
query += ' and ';
|
|
287
|
+
}
|
|
288
|
+
query += `(max-width: ${maxWidth}px)`;
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
breakpoint,
|
|
292
|
+
query,
|
|
293
|
+
maxWidth,
|
|
294
|
+
minWidth,
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// Inspiration for getMediaQueries and useBreakpoint
|
|
300
|
+
const useIsomorphicEffect = typeof window === 'undefined' ? React__namespace.useEffect : React__namespace.useLayoutEffect;
|
|
301
|
+
const useBreakpoint = ({ breakpoints, defaultBreakpoint, }) => {
|
|
302
|
+
const supportMatchMedia = typeof window !== 'undefined' && typeof window.matchMedia !== 'undefined';
|
|
303
|
+
const matchMedia = supportMatchMedia ? window.matchMedia : null;
|
|
304
|
+
const mediaQueries = React__namespace.useMemo(() => getMediaQueries({ breakpoints }), [breakpoints]);
|
|
305
|
+
const [breakpoint, setBreakpoint] = React__namespace.useState(defaultBreakpoint);
|
|
306
|
+
const updateBreakpoint = React__namespace.useCallback((matches, breakpoint) => {
|
|
307
|
+
if (matches) {
|
|
308
|
+
setBreakpoint(breakpoint);
|
|
309
|
+
}
|
|
310
|
+
}, [setBreakpoint]);
|
|
311
|
+
useIsomorphicEffect(() => {
|
|
312
|
+
if (!matchMedia)
|
|
313
|
+
return;
|
|
314
|
+
const unsubscribeList = mediaQueries.map(({ query, breakpoint }) => {
|
|
315
|
+
const queryList = matchMedia(query);
|
|
316
|
+
updateBreakpoint(queryList.matches, breakpoint);
|
|
317
|
+
const handleMediaChange = (event) => {
|
|
318
|
+
if (event.matches) {
|
|
319
|
+
setBreakpoint(breakpoint);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
queryList.addEventListener('change', handleMediaChange);
|
|
323
|
+
return () => queryList.removeEventListener('change', handleMediaChange);
|
|
324
|
+
});
|
|
325
|
+
return () => {
|
|
326
|
+
unsubscribeList.forEach((unsubscribe) => unsubscribe());
|
|
327
|
+
};
|
|
328
|
+
}, [breakpoints, setBreakpoint, matchMedia, mediaQueries]);
|
|
329
|
+
/** Print a nice debug value for React Devtools */
|
|
330
|
+
React__namespace.useDebugValue(breakpoint, (breakpoint) => breakpoint);
|
|
331
|
+
return breakpoint;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @internal May be removed in a future version
|
|
336
|
+
* Maps from component style props to React `style` props
|
|
337
|
+
* Note: Primarily needed to map from component style props that don't match CSS Properties directly
|
|
338
|
+
* such as wrap => flexWrap and direction => flexDirection
|
|
339
|
+
*/
|
|
340
|
+
const ComponentPropsToStylePropsMap = {
|
|
341
|
+
alignContent: 'alignContent',
|
|
342
|
+
alignItems: 'alignItems',
|
|
343
|
+
alignSelf: 'alignSelf',
|
|
344
|
+
area: 'gridArea',
|
|
345
|
+
aspectRatio: 'aspectRatio',
|
|
346
|
+
autoColumns: 'gridAutoColumns',
|
|
347
|
+
autoFlow: 'gridAutoFlow',
|
|
348
|
+
autoRows: 'gridAutoRows',
|
|
349
|
+
backgroundColor: 'backgroundColor',
|
|
350
|
+
backgroundImage: 'backgroundImage',
|
|
351
|
+
basis: 'flexBasis',
|
|
352
|
+
border: 'border',
|
|
353
|
+
borderRadius: 'borderRadius',
|
|
354
|
+
borderColor: 'borderColor',
|
|
355
|
+
borderWidth: 'borderWidth',
|
|
356
|
+
borderStyle: 'borderStyle',
|
|
357
|
+
bottom: 'bottom',
|
|
358
|
+
boxShadow: 'boxShadow',
|
|
359
|
+
color: 'color',
|
|
360
|
+
column: 'gridColumn',
|
|
361
|
+
columnEnd: 'gridColumnEnd',
|
|
362
|
+
columnGap: 'columnGap',
|
|
363
|
+
columnSpan: 'gridColumn',
|
|
364
|
+
columnStart: 'gridColumnStart',
|
|
365
|
+
direction: 'flexDirection',
|
|
366
|
+
display: 'display',
|
|
367
|
+
flex: 'flex',
|
|
368
|
+
fontFamily: 'fontFamily',
|
|
369
|
+
fontSize: 'fontSize',
|
|
370
|
+
fontStyle: 'fontStyle',
|
|
371
|
+
fontWeight: 'fontWeight',
|
|
372
|
+
gap: 'gap',
|
|
373
|
+
grow: 'flexGrow',
|
|
374
|
+
height: 'height',
|
|
375
|
+
justifyContent: 'justifyContent',
|
|
376
|
+
left: 'left',
|
|
377
|
+
letterSpacing: 'letterSpacing',
|
|
378
|
+
lineHeight: 'lineHeight',
|
|
379
|
+
margin: 'margin',
|
|
380
|
+
marginBlock: 'marginBlock',
|
|
381
|
+
marginBlockEnd: 'marginBlockEnd',
|
|
382
|
+
marginBlockStart: 'marginBlockStart',
|
|
383
|
+
marginBottom: 'marginBlockEnd',
|
|
384
|
+
marginInline: 'marginInline',
|
|
385
|
+
marginInlineEnd: 'marginInlineEnd',
|
|
386
|
+
marginInlineStart: 'marginInlineStart',
|
|
387
|
+
marginLeft: 'marginInlineStart',
|
|
388
|
+
marginRight: 'marginInlineEnd',
|
|
389
|
+
marginTop: 'marginBlockStart',
|
|
390
|
+
maxHeight: 'maxHeight',
|
|
391
|
+
maxWidth: 'maxWidth',
|
|
392
|
+
minHeight: 'minHeight',
|
|
393
|
+
minWidth: 'minWidth',
|
|
394
|
+
objectFit: 'objectFit',
|
|
395
|
+
objectPosition: 'objectPosition',
|
|
396
|
+
opacity: 'opacity',
|
|
397
|
+
order: 'order',
|
|
398
|
+
overflow: 'overflow',
|
|
399
|
+
padding: 'padding',
|
|
400
|
+
paddingBlock: 'paddingBlock',
|
|
401
|
+
paddingBlockEnd: 'paddingBlockEnd',
|
|
402
|
+
paddingBlockStart: 'paddingBlockStart',
|
|
403
|
+
paddingBottom: 'paddingBlockEnd',
|
|
404
|
+
paddingInline: 'paddingInline',
|
|
405
|
+
paddingInlineEnd: 'paddingInlineEnd',
|
|
406
|
+
paddingInlineStart: 'paddingInlineStart',
|
|
407
|
+
paddingLeft: 'paddingInlineStart',
|
|
408
|
+
paddingRight: 'paddingInlineEnd',
|
|
409
|
+
paddingTop: 'paddingBlockStart',
|
|
410
|
+
position: 'position',
|
|
411
|
+
resize: 'resize',
|
|
412
|
+
right: 'right',
|
|
413
|
+
row: 'gridRow',
|
|
414
|
+
rowEnd: 'gridRowEnd',
|
|
415
|
+
rowGap: 'rowGap',
|
|
416
|
+
rowSpan: 'gridRow',
|
|
417
|
+
rowStart: 'gridRowStart',
|
|
418
|
+
shrink: 'flexShrink',
|
|
419
|
+
templateAreas: 'gridTemplateAreas',
|
|
420
|
+
templateColumns: 'gridTemplateColumns',
|
|
421
|
+
templateRows: 'gridTemplateRows',
|
|
422
|
+
textAlign: 'textAlign',
|
|
423
|
+
textDecoration: 'textDecoration',
|
|
424
|
+
textTransform: 'textTransform',
|
|
425
|
+
top: 'top',
|
|
426
|
+
transform: 'transform',
|
|
427
|
+
transformOrigin: 'transformOrigin',
|
|
428
|
+
width: 'width',
|
|
429
|
+
whiteSpace: 'whiteSpace',
|
|
430
|
+
wrap: 'flexWrap',
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* @internal May be removed in a future version
|
|
434
|
+
*/
|
|
435
|
+
const ComponentPropsToStylePropsMapKeys = Object.keys(ComponentPropsToStylePropsMap);
|
|
436
|
+
|
|
437
|
+
const getClosestValueByBreakpoint = ({ breakpoint, breakpoints, values, }) => {
|
|
438
|
+
const value = values[breakpoint];
|
|
439
|
+
// Check if breakpoint exists in values
|
|
440
|
+
if (value !== undefined) {
|
|
441
|
+
return value;
|
|
442
|
+
}
|
|
443
|
+
// Otherwise use a lower breakpoint value
|
|
444
|
+
const breakpointsDesc = objectKeys(breakpoints).sort((a, b) => breakpoints[b] - breakpoints[a]);
|
|
445
|
+
const lowerBreakpoints = breakpointsDesc.slice(breakpointsDesc.indexOf(breakpoint));
|
|
446
|
+
for (const breakpoint of lowerBreakpoints) {
|
|
447
|
+
// Check if breakpoint exists in values
|
|
448
|
+
const value = values[breakpoint];
|
|
449
|
+
if (value !== undefined) {
|
|
450
|
+
return value;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return null;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* This takes an object and will return an object that only has the
|
|
457
|
+
* breakpoint keys
|
|
458
|
+
* @param obj
|
|
459
|
+
* @returns
|
|
460
|
+
*/
|
|
461
|
+
const valueObjToBreakpoints = (obj) => {
|
|
462
|
+
return objectKeys(obj).reduce((acc, key) => key in ui.defaultTheme.breakpoints.values
|
|
463
|
+
? { ...acc, [key]: obj[key] }
|
|
464
|
+
: acc, {});
|
|
465
|
+
};
|
|
466
|
+
const getValueAtCurrentBreakpoint = ({ breakpoint, breakpoints, values, }) => {
|
|
467
|
+
let breakpointCompatValues = {};
|
|
468
|
+
const breakpointsAscending = objectKeys(breakpoints).sort((a, b) => breakpoints[a] - breakpoints[b]);
|
|
469
|
+
if (Array.isArray(values)) {
|
|
470
|
+
values.forEach((value, index) => {
|
|
471
|
+
breakpointCompatValues[breakpointsAscending[index]] = value;
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
else if (typeof values === 'object') {
|
|
475
|
+
breakpointCompatValues = valueObjToBreakpoints(values);
|
|
476
|
+
}
|
|
477
|
+
return getClosestValueByBreakpoint({
|
|
478
|
+
breakpoint,
|
|
479
|
+
breakpoints,
|
|
480
|
+
values: breakpointCompatValues,
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* This takes an unknown value, which could be a:
|
|
486
|
+
* - design token: `color={tokens.colors.font.primary}`
|
|
487
|
+
* - string, which could be a:
|
|
488
|
+
* - theme key: `color='font.primary'`
|
|
489
|
+
* - plain style: `color='red'`
|
|
490
|
+
* - or a number: `padding={10}`
|
|
491
|
+
* and returns the appropriate and resolved value
|
|
492
|
+
*/
|
|
493
|
+
const getStyleValue = ({ value, propKey, tokens, }) => {
|
|
494
|
+
if (ui.isDesignToken(value)) {
|
|
495
|
+
return value.toString();
|
|
496
|
+
}
|
|
497
|
+
if (ui.isString(value)) {
|
|
498
|
+
return ui.isString(propKey)
|
|
499
|
+
? getCSSVariableIfValueIsThemeKey(propKey, value, tokens)
|
|
500
|
+
: value;
|
|
501
|
+
}
|
|
502
|
+
return null;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
const isSpanPrimitiveValue = (spanValue) => {
|
|
506
|
+
return (spanValue === 'auto' ||
|
|
507
|
+
(typeof spanValue === 'number' && !isNaN(spanValue)) ||
|
|
508
|
+
(typeof spanValue === 'string' && !isNaN(parseFloat(spanValue))));
|
|
509
|
+
};
|
|
510
|
+
const getGridSpan = (spanValue) => {
|
|
511
|
+
return spanValue === 'auto' ? 'auto' : `span ${spanValue}`;
|
|
512
|
+
};
|
|
513
|
+
const convertGridSpan = (spanValue) => {
|
|
514
|
+
// PropertyType
|
|
515
|
+
if (isSpanPrimitiveValue(spanValue)) {
|
|
516
|
+
return getGridSpan(spanValue);
|
|
517
|
+
}
|
|
518
|
+
// PropertyType[]
|
|
519
|
+
if (Array.isArray(spanValue)) {
|
|
520
|
+
return spanValue.map((value) => getGridSpan(value));
|
|
521
|
+
}
|
|
522
|
+
// ResponsiveObject<PropertyType>
|
|
523
|
+
if (typeof spanValue === 'object' && spanValue != null) {
|
|
524
|
+
return Object.entries(spanValue).reduce((acc, [key, value]) => ({ ...acc, [key]: getGridSpan(value) }), {});
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* Transforms style props to another target prop
|
|
530
|
+
* where the original is a simpler API than the target.
|
|
531
|
+
* This function will remove the original prop and
|
|
532
|
+
* replace target prop values with calculated
|
|
533
|
+
* E.g. rowSpan => row, columnSpan => column
|
|
534
|
+
*/
|
|
535
|
+
const useTransformStyleProps = (props) => {
|
|
536
|
+
const { rowSpan, columnSpan, row, column, ...rest } = props;
|
|
537
|
+
const { rowFromSpanValue, columnFromSpanValue } = React__namespace.useMemo(() => {
|
|
538
|
+
return {
|
|
539
|
+
rowFromSpanValue: convertGridSpan(rowSpan),
|
|
540
|
+
columnFromSpanValue: convertGridSpan(columnSpan),
|
|
541
|
+
};
|
|
542
|
+
}, [rowSpan, columnSpan]);
|
|
543
|
+
return {
|
|
544
|
+
row: !isNullOrEmptyString(row) ? row : rowFromSpanValue,
|
|
545
|
+
column: !isNullOrEmptyString(column) ? column : columnFromSpanValue,
|
|
546
|
+
...rest,
|
|
547
|
+
};
|
|
548
|
+
};
|
|
549
|
+
const isComponentStyleProp = (key) => {
|
|
550
|
+
return key in ComponentPropsToStylePropsMap;
|
|
551
|
+
};
|
|
552
|
+
/**
|
|
553
|
+
* Convert style props to CSS variables for React style prop
|
|
554
|
+
* Note: Will filter out undefined, null, and empty string prop values
|
|
555
|
+
*/
|
|
556
|
+
const convertStylePropsToStyleObj = ({ props = {}, style = {}, breakpoint, breakpoints, tokens, }) => {
|
|
557
|
+
const nonStyleProps = {};
|
|
558
|
+
Object.keys(props)
|
|
559
|
+
.filter((propKey) => props[propKey] !== null)
|
|
560
|
+
.forEach((propKey) => {
|
|
561
|
+
if (isComponentStyleProp(propKey)) {
|
|
562
|
+
const values = props[propKey];
|
|
563
|
+
if (!values || isEmptyString(values))
|
|
564
|
+
return;
|
|
565
|
+
const reactStyleProp = ComponentPropsToStylePropsMap[propKey];
|
|
566
|
+
// short circuit the style prop here if it is a string or design token
|
|
567
|
+
// so we don't have to call getValueAtCurrentBreakpoint every time
|
|
568
|
+
let value = '';
|
|
569
|
+
if (ui.isDesignToken(values)) {
|
|
570
|
+
value = values.toString();
|
|
571
|
+
}
|
|
572
|
+
else if (typeof values === 'string') {
|
|
573
|
+
value = getCSSVariableIfValueIsThemeKey(propKey, values, tokens);
|
|
574
|
+
}
|
|
575
|
+
else if (typeof values === 'number') {
|
|
576
|
+
value = values;
|
|
577
|
+
}
|
|
578
|
+
else if (typeof values === 'object') {
|
|
579
|
+
// here values should be a responsive array or object
|
|
580
|
+
value = getStyleValue({
|
|
581
|
+
propKey,
|
|
582
|
+
tokens,
|
|
583
|
+
value: getValueAtCurrentBreakpoint({
|
|
584
|
+
values,
|
|
585
|
+
breakpoint,
|
|
586
|
+
breakpoints,
|
|
587
|
+
}),
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
style = {
|
|
591
|
+
...style,
|
|
592
|
+
[reactStyleProp]: value,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
else if (typeof props[propKey] !== 'undefined') {
|
|
596
|
+
nonStyleProps[propKey] = props[propKey];
|
|
597
|
+
}
|
|
598
|
+
});
|
|
599
|
+
return { propStyles: style, nonStyleProps };
|
|
600
|
+
};
|
|
601
|
+
const useStyles = (props, style) => {
|
|
602
|
+
const { breakpoints: { values: breakpoints, defaultBreakpoint }, tokens, } = useTheme();
|
|
603
|
+
const breakpoint = useBreakpoint({
|
|
604
|
+
breakpoints,
|
|
605
|
+
defaultBreakpoint,
|
|
606
|
+
});
|
|
607
|
+
const propStyles = useTransformStyleProps(props);
|
|
608
|
+
return React__namespace.useMemo(() => convertStylePropsToStyleObj({
|
|
609
|
+
props: propStyles,
|
|
610
|
+
style,
|
|
611
|
+
breakpoint,
|
|
612
|
+
breakpoints,
|
|
613
|
+
tokens,
|
|
614
|
+
}), [propStyles, style, breakpoints, breakpoint, tokens]);
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Updates the return type for primitives wrapped in `React.forwardRef` to
|
|
619
|
+
* `React.ReactElement`. In React 18 the return type of `React.ExoticComponent`
|
|
620
|
+
* was changed from `React.ReactElement` to `React.ReactNode`, which breaks
|
|
621
|
+
* clients using React 16 and 17.
|
|
622
|
+
*
|
|
623
|
+
* @param primitive UI Primitive to be wrapped with `React.forwardRef`
|
|
624
|
+
* @returns ForwaredRef wrapped UI Primitive
|
|
625
|
+
*/
|
|
626
|
+
const primitiveWithForwardRef = (primitive) => React__namespace.forwardRef(primitive);
|
|
627
|
+
|
|
628
|
+
const ViewPrimitive = ({ as = 'div', children, testId, ariaLabel, isDisabled, style, inert, ...rest }, ref) => {
|
|
629
|
+
const { propStyles, nonStyleProps } = useStyles(rest, style);
|
|
630
|
+
return React__namespace.createElement(as, {
|
|
631
|
+
'aria-label': ariaLabel,
|
|
632
|
+
'data-testid': testId,
|
|
633
|
+
disabled: isDisabled,
|
|
634
|
+
ref,
|
|
635
|
+
inert: inert ? '' : null,
|
|
636
|
+
style: propStyles,
|
|
637
|
+
...nonStyleProps,
|
|
638
|
+
}, children);
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/view)
|
|
642
|
+
*/
|
|
643
|
+
const View = primitiveWithForwardRef(ViewPrimitive);
|
|
644
|
+
View.displayName = 'View';
|
|
645
|
+
|
|
646
|
+
const defaultViewBox = { minX: 0, minY: 0, width: 24, height: 24 };
|
|
647
|
+
const IconPrimitive = ({ className,
|
|
648
|
+
// as can be used to render other icon react components too
|
|
649
|
+
as = 'svg', fill = 'currentColor', pathData, viewBox = defaultViewBox, children, paths, ...rest }, ref) => {
|
|
650
|
+
const minX = viewBox.minX ? viewBox.minX : defaultViewBox.minX;
|
|
651
|
+
const minY = viewBox.minY ? viewBox.minY : defaultViewBox.minY;
|
|
652
|
+
const width = viewBox.width ? viewBox.width : defaultViewBox.width;
|
|
653
|
+
const height = viewBox.height ? viewBox.height : defaultViewBox.height;
|
|
654
|
+
// An icon can be drawn in 3 ways:
|
|
655
|
+
// 1. Pass it children which should be valid SVG elements
|
|
656
|
+
// 2. Pass an array of path-like objects to `paths` prop
|
|
657
|
+
// 3. Supply `pathData` for a simple icons
|
|
658
|
+
let _children;
|
|
659
|
+
if (children) {
|
|
660
|
+
_children = children;
|
|
661
|
+
}
|
|
662
|
+
if (paths) {
|
|
663
|
+
_children = paths.map((path, index) => React__namespace.createElement("path", { ...path, key: index }));
|
|
664
|
+
}
|
|
665
|
+
if (pathData) {
|
|
666
|
+
_children = React__namespace.createElement("path", { d: pathData, fill: fill });
|
|
667
|
+
}
|
|
668
|
+
return (React__namespace.createElement(View, { as: as, className: ui.classNames(ui.ComponentClassName.Icon, className), ref: ref, viewBox: `${minX} ${minY} ${width} ${height}`, ...rest }, _children));
|
|
669
|
+
};
|
|
670
|
+
/**
|
|
671
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/icon)
|
|
672
|
+
*/
|
|
673
|
+
const Icon = primitiveWithForwardRef(IconPrimitive);
|
|
674
|
+
Icon.displayName = 'Icon';
|
|
675
|
+
|
|
676
|
+
const IconsContext = React__namespace.createContext({});
|
|
677
|
+
|
|
678
|
+
function useIcons(component) {
|
|
679
|
+
const context = React__namespace.useContext(IconsContext);
|
|
680
|
+
if (component && context) {
|
|
681
|
+
return context[component];
|
|
682
|
+
}
|
|
683
|
+
return undefined;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
688
|
+
*/
|
|
689
|
+
const IconAdd = (props) => {
|
|
690
|
+
const { className, ...rest } = props;
|
|
691
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
692
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
693
|
+
React__namespace.createElement("path", { d: "M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z", fill: "currentColor" }))));
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
698
|
+
*/
|
|
699
|
+
const IconCheckCircle = (props) => {
|
|
700
|
+
const { className, ...rest } = props;
|
|
701
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
702
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
703
|
+
React__namespace.createElement("path", { d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20ZM16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z", fill: "currentColor" }))));
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
708
|
+
*/
|
|
709
|
+
const IconCheck = (props) => {
|
|
710
|
+
const { className, ...rest } = props;
|
|
711
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
712
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
713
|
+
React__namespace.createElement("path", { d: "M9.00016 16.1698L4.83016 11.9998L3.41016 13.4098L9.00016 18.9998L21.0002 6.99984L19.5902 5.58984L9.00016 16.1698Z", fill: "currentColor" }))));
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
718
|
+
*/
|
|
719
|
+
const IconChevronLeft = (props) => {
|
|
720
|
+
const { className, ...rest } = props;
|
|
721
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
722
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
723
|
+
React__namespace.createElement("path", { d: "M15.41 7.41L14 6L8 12L14 18L15.41 16.59L10.83 12L15.41 7.41Z", fill: "currentColor" }))));
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
728
|
+
*/
|
|
729
|
+
const IconChevronRight = (props) => {
|
|
730
|
+
const { className, ...rest } = props;
|
|
731
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
732
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
733
|
+
React__namespace.createElement("path", { d: "M9.99984 6L8.58984 7.41L13.1698 12L8.58984 16.59L9.99984 18L15.9998 12L9.99984 6Z", fill: "currentColor" }))));
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
738
|
+
*/
|
|
739
|
+
const IconClose = (props) => {
|
|
740
|
+
const { className, size, ...rest } = props;
|
|
741
|
+
return (React__namespace.createElement(View, { as: "span", width: size ?? '1em', height: size ?? '1em', className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
742
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", style: size ? { width: size, height: size } : undefined },
|
|
743
|
+
React__namespace.createElement("path", { d: "M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z", fill: "currentColor" }))));
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
748
|
+
*/
|
|
749
|
+
const IconError = (props) => {
|
|
750
|
+
const { className, ...rest } = props;
|
|
751
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
752
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
753
|
+
React__namespace.createElement("path", { d: "M12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM13 17H11V15H13V17ZM13 13H11V7H13V13Z", fill: "currentColor" }))));
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
758
|
+
*/
|
|
759
|
+
const IconExpandMore = (props) => {
|
|
760
|
+
const { className, ...rest } = props;
|
|
761
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
762
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
763
|
+
React__namespace.createElement("path", { d: "M16.59 8.58984L12 13.1698L7.41 8.58984L6 9.99984L12 15.9998L18 9.99984L16.59 8.58984Z", fill: "currentColor" }))));
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
768
|
+
*/
|
|
769
|
+
const IconIndeterminate = (props) => {
|
|
770
|
+
const { className, ...rest } = props;
|
|
771
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
772
|
+
React__namespace.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", height: "24", width: "24", viewBox: "0 0 24 24" },
|
|
773
|
+
React__namespace.createElement("line", { x1: "4", x2: "20", y1: "12", y2: "12", stroke: "currentColor", strokeWidth: "3" }))));
|
|
774
|
+
};
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
778
|
+
*/
|
|
779
|
+
const IconInfo = (props) => {
|
|
780
|
+
const { className, ...rest } = props;
|
|
781
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
782
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
783
|
+
React__namespace.createElement("path", { d: "M11 7H13V9H11V7ZM11 11H13V17H11V11ZM12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20Z", fill: "currentColor" }))));
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
788
|
+
*/
|
|
789
|
+
const IconMenu = (props) => {
|
|
790
|
+
const { className, ...rest } = props;
|
|
791
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
792
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
793
|
+
React__namespace.createElement("path", { d: "M3 18H21V16H3V18ZM3 13H21V11H3V13ZM3 6V8H21V6H3Z", fill: "currentColor" }))));
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
798
|
+
*/
|
|
799
|
+
const IconRemove = (props) => {
|
|
800
|
+
const { className, ...rest } = props;
|
|
801
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
802
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
803
|
+
React__namespace.createElement("path", { d: "M19 13H5V11H19V13Z", fill: "currentColor" }))));
|
|
804
|
+
};
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
808
|
+
*/
|
|
809
|
+
const IconSearch = (props) => {
|
|
810
|
+
const { className, ...rest } = props;
|
|
811
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
812
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
813
|
+
React__namespace.createElement("path", { d: "M15.5 14H14.71L14.43 13.73C15.41 12.59 16 11.11 16 9.5C16 5.91 13.09 3 9.5 3C5.91 3 3 5.91 3 9.5C3 13.09 5.91 16 9.5 16C11.11 16 12.59 15.41 13.73 14.43L14 14.71V15.5L19 20.49L20.49 19L15.5 14V14ZM9.5 14C7.01 14 5 11.99 5 9.5C5 7.01 7.01 5 9.5 5C11.99 5 14 7.01 14 9.5C14 11.99 11.99 14 9.5 14Z", fill: "currentColor" }))));
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
/**
|
|
817
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
818
|
+
*/
|
|
819
|
+
const IconStar = (props) => {
|
|
820
|
+
const { className, ...rest } = props;
|
|
821
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
822
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
823
|
+
React__namespace.createElement("path", { d: "M12 17.27L18.18 21L16.54 13.97L22 9.24L14.81 8.63L12 2L9.19 8.63L2 9.24L7.46 13.97L5.82 21L12 17.27Z", fill: "currentColor" }))));
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
828
|
+
*/
|
|
829
|
+
const IconVisibilityOff = (props) => {
|
|
830
|
+
const { className, ...rest } = props;
|
|
831
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
832
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
833
|
+
React__namespace.createElement("path", { d: "M12 6.0002C15.79 6.0002 19.17 8.1302 20.82 11.5002C20.23 12.7202 19.4 13.7702 18.41 14.6202L19.82 16.0302C21.21 14.8002 22.31 13.2602 23 11.5002C21.27 7.1102 17 4.0002 12 4.0002C10.73 4.0002 9.51 4.2002 8.36 4.5702L10.01 6.2202C10.66 6.0902 11.32 6.0002 12 6.0002ZM10.93 7.14019L13 9.2102C13.57 9.4602 14.03 9.9202 14.28 10.4902L16.35 12.5602C16.43 12.2202 16.49 11.8602 16.49 11.4902C16.5 9.0102 14.48 7.0002 12 7.0002C11.63 7.0002 11.28 7.05019 10.93 7.14019ZM2.01 3.8702L4.69 6.5502C3.06 7.8302 1.77 9.5302 1 11.5002C2.73 15.8902 7 19.0002 12 19.0002C13.52 19.0002 14.98 18.7102 16.32 18.1802L19.74 21.6002L21.15 20.1902L3.42 2.4502L2.01 3.8702ZM9.51 11.3702L12.12 13.9802C12.08 13.9902 12.04 14.0002 12 14.0002C10.62 14.0002 9.5 12.8802 9.5 11.5002C9.5 11.4502 9.51 11.4202 9.51 11.3702V11.3702ZM6.11 7.97019L7.86 9.7202C7.63 10.2702 7.5 10.8702 7.5 11.5002C7.5 13.9802 9.52 16.0002 12 16.0002C12.63 16.0002 13.23 15.8702 13.77 15.6402L14.75 16.6202C13.87 16.8602 12.95 17.0002 12 17.0002C8.21 17.0002 4.83 14.8702 3.18 11.5002C3.88 10.0702 4.9 8.89019 6.11 7.97019Z", fill: "currentColor" }))));
|
|
834
|
+
};
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
838
|
+
*/
|
|
839
|
+
const IconVisibility = (props) => {
|
|
840
|
+
const { className, ...rest } = props;
|
|
841
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
842
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
843
|
+
React__namespace.createElement("path", { d: "M12 6C15.79 6 19.17 8.13 20.82 11.5C19.17 14.87 15.79 17 12 17C8.21 17 4.83 14.87 3.18 11.5C4.83 8.13 8.21 6 12 6ZM12 4C7 4 2.73 7.11 1 11.5C2.73 15.89 7 19 12 19C17 19 21.27 15.89 23 11.5C21.27 7.11 17 4 12 4ZM12 9C13.38 9 14.5 10.12 14.5 11.5C14.5 12.88 13.38 14 12 14C10.62 14 9.5 12.88 9.5 11.5C9.5 10.12 10.62 9 12 9ZM12 7C9.52 7 7.5 9.02 7.5 11.5C7.5 13.98 9.52 16 12 16C14.48 16 16.5 13.98 16.5 11.5C16.5 9.02 14.48 7 12 7Z", fill: "currentColor" }))));
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
848
|
+
*/
|
|
849
|
+
const IconWarning = (props) => {
|
|
850
|
+
const { className, ...rest } = props;
|
|
851
|
+
return (React__namespace.createElement(View, { as: "span", width: "1em", height: "1em", className: ui.classNames(ui.ComponentClassName.Icon, className), ...rest },
|
|
852
|
+
React__namespace.createElement("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
853
|
+
React__namespace.createElement("path", { d: "M1 21H23L12 2L1 21ZM13 18H11V16H13V18ZM13 14H11V10H13V14Z", fill: "currentColor" }))));
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* @internal For internal Amplify UI use only. May be removed in a future release.
|
|
858
|
+
*/
|
|
859
|
+
const AlertIcon = ({ variation, ariaHidden, }) => {
|
|
860
|
+
const icons = useIcons('alert');
|
|
861
|
+
let icon;
|
|
862
|
+
switch (variation) {
|
|
863
|
+
case 'info':
|
|
864
|
+
icon = icons?.info ?? React__namespace.createElement(IconInfo, { "aria-hidden": ariaHidden });
|
|
865
|
+
break;
|
|
866
|
+
case 'error':
|
|
867
|
+
icon = icons?.error ?? React__namespace.createElement(IconError, { "aria-hidden": ariaHidden });
|
|
868
|
+
break;
|
|
869
|
+
case 'warning':
|
|
870
|
+
icon = icons?.warning ?? React__namespace.createElement(IconWarning, { "aria-hidden": ariaHidden });
|
|
871
|
+
break;
|
|
872
|
+
case 'success':
|
|
873
|
+
icon = icons?.success ?? React__namespace.createElement(IconCheckCircle, { "aria-hidden": ariaHidden });
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
return icon ? (React__namespace.createElement("span", { className: ui.ComponentClassName.AlertIcon }, icon)) : null;
|
|
877
|
+
};
|
|
878
|
+
AlertIcon.displayName = 'AlertIcon';
|
|
879
|
+
|
|
880
|
+
function filterAllowedFiles(files, acceptedFileTypes) {
|
|
881
|
+
// Allow any files if acceptedFileTypes is undefined, empty array, or contains '*'
|
|
882
|
+
if (!acceptedFileTypes ||
|
|
883
|
+
acceptedFileTypes.length === 0 ||
|
|
884
|
+
acceptedFileTypes.includes('*')) {
|
|
885
|
+
return { acceptedFiles: files, rejectedFiles: [] };
|
|
886
|
+
}
|
|
887
|
+
const acceptedFiles = [];
|
|
888
|
+
const rejectedFiles = [];
|
|
889
|
+
function filterFile(file) {
|
|
890
|
+
const { type = '', name = '' } = file;
|
|
891
|
+
const mimeType = type.toLowerCase();
|
|
892
|
+
const baseMimeType = mimeType.split('/')[0];
|
|
893
|
+
return acceptedFileTypes.some((type) => {
|
|
894
|
+
const validType = type.trim().toLowerCase();
|
|
895
|
+
// if the accepted file type is a file extension
|
|
896
|
+
// it will start with '.', check against the file name
|
|
897
|
+
if (validType.charAt(0) === '.') {
|
|
898
|
+
return name.toLowerCase().endsWith(validType);
|
|
899
|
+
}
|
|
900
|
+
// This is something like a image/* mime type
|
|
901
|
+
if (validType.endsWith('/*')) {
|
|
902
|
+
return baseMimeType === validType.split('/')[0];
|
|
903
|
+
}
|
|
904
|
+
return mimeType === validType;
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
files.forEach((file) => {
|
|
908
|
+
(filterFile(file) ? acceptedFiles : rejectedFiles).push(file);
|
|
909
|
+
});
|
|
910
|
+
return { acceptedFiles, rejectedFiles };
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
function useDropZone({ onDropComplete, onDragEnter: _onDragEnter, onDragLeave: _onDragLeave, onDragOver: _onDragOver, onDragStart: _onDragStart, onDrop: _onDrop, acceptedFileTypes = [], }) {
|
|
914
|
+
const [dragState, setDragState] = React.useState('inactive');
|
|
915
|
+
const onDragStart = (event) => {
|
|
916
|
+
event.dataTransfer.clearData();
|
|
917
|
+
if (ui.isFunction(_onDragStart)) {
|
|
918
|
+
_onDragStart(event);
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
const onDragEnter = (event) => {
|
|
922
|
+
event.preventDefault();
|
|
923
|
+
event.stopPropagation();
|
|
924
|
+
if (ui.isFunction(_onDragEnter)) {
|
|
925
|
+
_onDragEnter(event);
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
const onDragLeave = (event) => {
|
|
929
|
+
event.preventDefault();
|
|
930
|
+
event.stopPropagation();
|
|
931
|
+
setDragState('inactive');
|
|
932
|
+
if (ui.isFunction(_onDragLeave)) {
|
|
933
|
+
_onDragLeave(event);
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
const onDragOver = (event) => {
|
|
937
|
+
event.preventDefault();
|
|
938
|
+
event.stopPropagation();
|
|
939
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
940
|
+
if (ui.isFunction(_onDragOver)) {
|
|
941
|
+
_onDragOver(event);
|
|
942
|
+
}
|
|
943
|
+
const files = Array.from(event.dataTransfer.items).map(({ kind, type }) => ({
|
|
944
|
+
kind,
|
|
945
|
+
type,
|
|
946
|
+
}));
|
|
947
|
+
const { rejectedFiles } = filterAllowedFiles(files, acceptedFileTypes);
|
|
948
|
+
setDragState(rejectedFiles.length > 0 ? 'reject' : 'accept');
|
|
949
|
+
};
|
|
950
|
+
const onDrop = (event) => {
|
|
951
|
+
event.preventDefault();
|
|
952
|
+
event.stopPropagation();
|
|
953
|
+
setDragState('inactive');
|
|
954
|
+
const files = Array.from(event.dataTransfer.files);
|
|
955
|
+
const { acceptedFiles, rejectedFiles } = filterAllowedFiles(files, acceptedFileTypes);
|
|
956
|
+
if (ui.isFunction(_onDrop)) {
|
|
957
|
+
_onDrop(event);
|
|
958
|
+
}
|
|
959
|
+
if (ui.isFunction(onDropComplete)) {
|
|
960
|
+
onDropComplete({ acceptedFiles, rejectedFiles });
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
return {
|
|
964
|
+
onDragStart,
|
|
965
|
+
onDragEnter,
|
|
966
|
+
onDragLeave,
|
|
967
|
+
onDragOver,
|
|
968
|
+
onDrop,
|
|
969
|
+
dragState,
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
const FieldGroupIconPrimitive = ({ className, children, isVisible = true, excludeFromTabOrder = false, ...rest }, ref) => {
|
|
974
|
+
return isVisible ? (React__namespace.createElement(View, { className: ui.classNames(ui.ComponentClassName.FieldGroupIcon, className), ref: ref, tabIndex: excludeFromTabOrder ? -1 : undefined, ...rest }, children)) : null;
|
|
975
|
+
};
|
|
976
|
+
const FieldGroupIcon = primitiveWithForwardRef(FieldGroupIconPrimitive);
|
|
977
|
+
FieldGroupIcon.displayName = 'FieldGroupIcon';
|
|
978
|
+
|
|
979
|
+
const FieldsetContext = React__namespace.createContext({
|
|
980
|
+
isFieldsetDisabled: false,
|
|
981
|
+
});
|
|
982
|
+
/**
|
|
983
|
+
* @description Fieldsets in HTML can be disabled, which disables all child
|
|
984
|
+
* fieldsets and input controls. `useFieldset` passes the disabled state down
|
|
985
|
+
* via context.
|
|
986
|
+
*/
|
|
987
|
+
const useFieldset = () => React__namespace.useContext(FieldsetContext);
|
|
988
|
+
|
|
989
|
+
const FlexPrimitive = ({ className, children, ...rest }, ref) => (React__namespace.createElement(View, { className: ui.classNames(ui.ComponentClassName.Flex, className), ref: ref, ...rest }, children));
|
|
990
|
+
/**
|
|
991
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/flex)
|
|
992
|
+
*/
|
|
993
|
+
const Flex = primitiveWithForwardRef(FlexPrimitive);
|
|
994
|
+
Flex.displayName = 'Flex';
|
|
995
|
+
|
|
996
|
+
const LINEAR_EMPTY = 'linear-empty';
|
|
997
|
+
const LINEAR_FILLED = 'linear-filled';
|
|
998
|
+
const CIRCULAR_EMPTY = 'circular-empty';
|
|
999
|
+
const CIRCULAR_FILLED = 'circular-filled';
|
|
1000
|
+
// radius + strokeWidth = 50
|
|
1001
|
+
const CIRCULAR_STROKE_WIDTH = 8;
|
|
1002
|
+
const RADIUS = 42;
|
|
1003
|
+
// circumference = 2 * r * PI (r = 42)
|
|
1004
|
+
const CIRCUMFERENCE = 2 * RADIUS * Math.PI;
|
|
1005
|
+
const LoaderPrimitive = ({ className, filledColor, emptyColor, size, variation, isDeterminate = false, isPercentageTextHidden = false, percentage = 0, ...rest }, ref) => {
|
|
1006
|
+
percentage = Math.min(percentage, 100);
|
|
1007
|
+
percentage = Math.max(percentage, 0);
|
|
1008
|
+
const percent = `${percentage}%`;
|
|
1009
|
+
const componentClasses = ui.classNames(ui.ComponentClassName.Loader, ui.classNameModifier(ui.ComponentClassName.Loader, size), ui.classNameModifier(ui.ComponentClassName.Loader, variation), ui.classNameModifierByFlag(ui.ComponentClassName.Loader, 'determinate', isDeterminate), className);
|
|
1010
|
+
const linearLoader = (React__namespace.createElement("g", null,
|
|
1011
|
+
React__namespace.createElement("line", { x1: "0", x2: "100%", y1: "50%", y2: "50%", style: { stroke: String(emptyColor) }, "data-testid": LINEAR_EMPTY }),
|
|
1012
|
+
React__namespace.createElement("line", { x1: "0", x2: isDeterminate ? percent : '100%', y1: "50%", y2: "50%", style: {
|
|
1013
|
+
// To get rid of the visible stroke linecap when percentage is 0
|
|
1014
|
+
stroke: isDeterminate && percentage === 0
|
|
1015
|
+
? 'none'
|
|
1016
|
+
: filledColor
|
|
1017
|
+
? String(filledColor)
|
|
1018
|
+
: undefined,
|
|
1019
|
+
}, "data-testid": LINEAR_FILLED }),
|
|
1020
|
+
isDeterminate ? (React__namespace.createElement("text", { "aria-live": "polite", className: ui.classNames(ui.ComponentClassName.LoaderLabel, isPercentageTextHidden ? ui.ComponentClassName.VisuallyHidden : null),
|
|
1021
|
+
// -1% offset makes the text position look nicest
|
|
1022
|
+
x: `${-1 + percentage}%`, y: "200%" }, percent)) : null));
|
|
1023
|
+
// r + stroke-width should add up to 50% to avoid overflow
|
|
1024
|
+
const circularLoader = (React__namespace.createElement("g", null,
|
|
1025
|
+
React__namespace.createElement("circle", { cx: "50%", cy: "50%", r: `${RADIUS}%`, strokeWidth: `${CIRCULAR_STROKE_WIDTH}%`, style: { stroke: String(emptyColor) }, "data-testid": CIRCULAR_EMPTY }),
|
|
1026
|
+
React__namespace.createElement("circle", { cx: "50%", cy: "50%", r: `${RADIUS}%`, strokeWidth: `${CIRCULAR_STROKE_WIDTH}%`, style: {
|
|
1027
|
+
stroke: String(filledColor),
|
|
1028
|
+
strokeDasharray: isDeterminate
|
|
1029
|
+
? `${CIRCUMFERENCE}% ${CIRCUMFERENCE}%`
|
|
1030
|
+
: undefined,
|
|
1031
|
+
strokeDashoffset: isDeterminate
|
|
1032
|
+
? `${CIRCUMFERENCE - (CIRCUMFERENCE * percentage) / 100}%`
|
|
1033
|
+
: undefined,
|
|
1034
|
+
}, "data-testid": CIRCULAR_FILLED }),
|
|
1035
|
+
isDeterminate ? (React__namespace.createElement("text", { "aria-live": "polite", className: ui.classNames(ui.ComponentClassName.LoaderLabel, isPercentageTextHidden ? ui.ComponentClassName.VisuallyHidden : null),
|
|
1036
|
+
// this x and y make text position look nicest
|
|
1037
|
+
x: "130%", y: "80%" }, percent)) : null));
|
|
1038
|
+
return (React__namespace.createElement(View, { as: "svg", className: componentClasses, ref: ref, role: "img", ...rest }, variation === 'linear' ? linearLoader : circularLoader));
|
|
1039
|
+
};
|
|
1040
|
+
/**
|
|
1041
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/loader)
|
|
1042
|
+
*/
|
|
1043
|
+
const Loader = primitiveWithForwardRef(LoaderPrimitive);
|
|
1044
|
+
Loader.displayName = 'Loader';
|
|
1045
|
+
|
|
1046
|
+
// These variations support colorThemes. 'undefined' accounts for our
|
|
1047
|
+
// 'default' variation which is not named.
|
|
1048
|
+
const supportedVariations = ['link', 'primary', undefined];
|
|
1049
|
+
const ButtonPrimitive = ({ className, children, colorTheme, isFullWidth = false, isDisabled, isLoading, loadingText = '', size, type = 'button', variation, ...rest }, ref) => {
|
|
1050
|
+
// Creates our colorTheme modifier string based on if the variation
|
|
1051
|
+
// supports colorThemes and a colorTheme is used.
|
|
1052
|
+
const colorThemeModifier = supportedVariations.includes(variation) && colorTheme
|
|
1053
|
+
? `${variation ?? 'outlined'}--${colorTheme}`
|
|
1054
|
+
: undefined;
|
|
1055
|
+
const { isFieldsetDisabled } = useFieldset();
|
|
1056
|
+
const shouldBeDisabled = isFieldsetDisabled
|
|
1057
|
+
? isFieldsetDisabled
|
|
1058
|
+
: isDisabled ?? isLoading ?? rest['disabled'];
|
|
1059
|
+
const componentClasses = ui.classNames(ui.ComponentClassName.Button, ui.ComponentClassName.FieldGroupControl, ui.classNameModifier(ui.ComponentClassName.Button, variation), ui.classNameModifier(ui.ComponentClassName.Button, colorThemeModifier), ui.classNameModifier(ui.ComponentClassName.Button, size), ui.classNameModifierByFlag(ui.ComponentClassName.Button, 'disabled', shouldBeDisabled), ui.classNameModifierByFlag(ui.ComponentClassName.Button, 'loading', isLoading), ui.classNameModifierByFlag(ui.ComponentClassName.Button, 'fullwidth', isFullWidth), className);
|
|
1060
|
+
return (React__namespace.createElement(View, { ref: ref, as: "button", className: componentClasses, isDisabled: shouldBeDisabled, type: type, ...rest }, isLoading ? (React__namespace.createElement(Flex, { as: "span", className: ui.ComponentClassName.ButtonLoaderWrapper },
|
|
1061
|
+
React__namespace.createElement(Loader, { size: size }),
|
|
1062
|
+
loadingText ? loadingText : null)) : (children)));
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/button)
|
|
1066
|
+
*/
|
|
1067
|
+
const Button = primitiveWithForwardRef(ButtonPrimitive);
|
|
1068
|
+
Button.displayName = 'Button';
|
|
1069
|
+
|
|
1070
|
+
const FieldGroupIconButtonPrimitive = ({ children, className, ...rest }, ref) => (React__namespace.createElement(FieldGroupIcon, { as: Button, className: ui.classNames(ui.ComponentClassName.FieldGroupIconButton, className), ref: ref, ...rest }, children));
|
|
1071
|
+
const FieldGroupIconButton = primitiveWithForwardRef(FieldGroupIconButtonPrimitive);
|
|
1072
|
+
FieldGroupIconButton.displayName = 'FieldGroupIconButton';
|
|
1073
|
+
|
|
1074
|
+
const ariaLabelText = ComponentText.Fields.clearButtonLabel;
|
|
1075
|
+
const FieldClearButtonPrimitive = ({ ariaLabel = ariaLabelText, size, ...rest }, ref) => {
|
|
1076
|
+
const icons = useIcons('field');
|
|
1077
|
+
return (React__namespace.createElement(FieldGroupIconButton, { ariaLabel: ariaLabel, size: size, ref: ref, ...rest }, icons?.clear ?? React__namespace.createElement(IconClose, null)));
|
|
1078
|
+
};
|
|
1079
|
+
const FieldClearButton = primitiveWithForwardRef(FieldClearButtonPrimitive);
|
|
1080
|
+
FieldClearButton.displayName = 'FieldClearButton';
|
|
1081
|
+
|
|
1082
|
+
const TextPrimitive = ({ as = 'p', className, children, isTruncated, variation, ...rest }, ref) => {
|
|
1083
|
+
const componentClasses = ui.classNames(ui.ComponentClassName.Text, ui.classNameModifier(ui.ComponentClassName.Text, variation), ui.classNameModifierByFlag(ui.ComponentClassName.Text, 'truncated', isTruncated), className);
|
|
1084
|
+
return (React__namespace.createElement(View, { as: as, className: componentClasses, ref: ref, ...rest }, children));
|
|
1085
|
+
};
|
|
1086
|
+
/**
|
|
1087
|
+
* [📖 Docs](https://ui.docs.amplify.aws/react/components/text)
|
|
1088
|
+
*/
|
|
1089
|
+
const Text = primitiveWithForwardRef(TextPrimitive);
|
|
1090
|
+
Text.displayName = 'Text';
|
|
1091
|
+
|
|
1092
|
+
const QA_FIELD_DESCRIPTION = 'qa-field-description';
|
|
1093
|
+
const FieldDescription = ({ descriptiveText, labelHidden, ...rest }) => descriptiveText ? (React__namespace.createElement(Text, { "data-testid": QA_FIELD_DESCRIPTION, className: ui.classNames(ui.ComponentClassName.FieldDescription, {
|
|
1094
|
+
[ui.ComponentClassName.VisuallyHidden]: labelHidden,
|
|
1095
|
+
}), ...rest }, descriptiveText)) : null;
|
|
1096
|
+
FieldDescription.displayName = 'FieldDescription';
|
|
1097
|
+
|
|
1098
|
+
const FieldErrorMessage = ({ errorMessage, hasError, ...rest }) => {
|
|
1099
|
+
return hasError && errorMessage ? (React__namespace.createElement(Text, { className: ui.ComponentClassName.FieldErrorMessage, ...rest }, errorMessage)) : null;
|
|
1100
|
+
};
|
|
1101
|
+
FieldErrorMessage.displayName = 'FieldErrorMessage';
|
|
1102
|
+
|
|
1103
|
+
const LabelPrimitive = ({ children, className, visuallyHidden, ...rest }, ref) => {
|
|
1104
|
+
return (React__namespace.createElement(View, { as: "label", className: ui.classNames(ui.ComponentClassName.Label, className, {
|
|
1105
|
+
[ui.ComponentClassName.VisuallyHidden]: visuallyHidden,
|
|
1106
|
+
}), ref: ref, ...rest }, children));
|
|
1107
|
+
};
|
|
1108
|
+
const Label = primitiveWithForwardRef(LabelPrimitive);
|
|
1109
|
+
Label.displayName = 'Label';
|
|
1110
|
+
|
|
1111
|
+
const FieldPrimitive = (props, ref) => {
|
|
1112
|
+
const { className, size, testId, children, label, labelHidden, errorMessage, hasError, descriptiveText, ...rest } = props;
|
|
1113
|
+
return (React__namespace.createElement(Flex, { className: ui.classNames(ui.ComponentClassName.Field, ui.classNameModifier(ui.ComponentClassName.Field, size), className), testId: testId, ref: ref, ...rest },
|
|
1114
|
+
label ? React__namespace.createElement(Label, { visuallyHidden: labelHidden }, label) : null,
|
|
1115
|
+
React__namespace.createElement(FieldDescription, { labelHidden: labelHidden, descriptiveText: descriptiveText }),
|
|
1116
|
+
children,
|
|
1117
|
+
errorMessage ? (React__namespace.createElement(FieldErrorMessage, { hasError: hasError, errorMessage: errorMessage })) : null));
|
|
1118
|
+
};
|
|
1119
|
+
const Field = primitiveWithForwardRef(FieldPrimitive);
|
|
1120
|
+
Field.displayName = 'Field';
|
|
1121
|
+
|
|
1122
|
+
exports.ARROW_DOWN = ARROW_DOWN;
|
|
1123
|
+
exports.ARROW_UP = ARROW_UP;
|
|
1124
|
+
exports.AlertIcon = AlertIcon;
|
|
1125
|
+
exports.Button = Button;
|
|
1126
|
+
exports.ComponentPropsToStylePropsMap = ComponentPropsToStylePropsMap;
|
|
1127
|
+
exports.ComponentPropsToStylePropsMapKeys = ComponentPropsToStylePropsMapKeys;
|
|
1128
|
+
exports.ComponentText = ComponentText;
|
|
1129
|
+
exports.ENTER_KEY = ENTER_KEY;
|
|
1130
|
+
exports.ESCAPE_KEY = ESCAPE_KEY;
|
|
1131
|
+
exports.Field = Field;
|
|
1132
|
+
exports.FieldClearButton = FieldClearButton;
|
|
1133
|
+
exports.FieldDescription = FieldDescription;
|
|
1134
|
+
exports.FieldErrorMessage = FieldErrorMessage;
|
|
1135
|
+
exports.FieldGroupIcon = FieldGroupIcon;
|
|
1136
|
+
exports.FieldGroupIconButton = FieldGroupIconButton;
|
|
1137
|
+
exports.FieldsetContext = FieldsetContext;
|
|
1138
|
+
exports.Flex = Flex;
|
|
1139
|
+
exports.Icon = Icon;
|
|
1140
|
+
exports.IconAdd = IconAdd;
|
|
1141
|
+
exports.IconCheck = IconCheck;
|
|
1142
|
+
exports.IconCheckCircle = IconCheckCircle;
|
|
1143
|
+
exports.IconChevronLeft = IconChevronLeft;
|
|
1144
|
+
exports.IconChevronRight = IconChevronRight;
|
|
1145
|
+
exports.IconClose = IconClose;
|
|
1146
|
+
exports.IconError = IconError;
|
|
1147
|
+
exports.IconExpandMore = IconExpandMore;
|
|
1148
|
+
exports.IconIndeterminate = IconIndeterminate;
|
|
1149
|
+
exports.IconInfo = IconInfo;
|
|
1150
|
+
exports.IconMenu = IconMenu;
|
|
1151
|
+
exports.IconRemove = IconRemove;
|
|
1152
|
+
exports.IconSearch = IconSearch;
|
|
1153
|
+
exports.IconStar = IconStar;
|
|
1154
|
+
exports.IconVisibility = IconVisibility;
|
|
1155
|
+
exports.IconVisibilityOff = IconVisibilityOff;
|
|
1156
|
+
exports.IconWarning = IconWarning;
|
|
1157
|
+
exports.IconsContext = IconsContext;
|
|
1158
|
+
exports.Label = Label;
|
|
1159
|
+
exports.Loader = Loader;
|
|
1160
|
+
exports.Text = Text;
|
|
1161
|
+
exports.ThemeContext = ThemeContext;
|
|
1162
|
+
exports.View = View;
|
|
1163
|
+
exports.getConsecutiveIntArray = getConsecutiveIntArray;
|
|
1164
|
+
exports.getStyleValue = getStyleValue;
|
|
1165
|
+
exports.getValueAtCurrentBreakpoint = getValueAtCurrentBreakpoint;
|
|
1166
|
+
exports.primitiveWithForwardRef = primitiveWithForwardRef;
|
|
1167
|
+
exports.strHasLength = strHasLength;
|
|
1168
|
+
exports.useAuth = useAuth;
|
|
1169
|
+
exports.useBreakpoint = useBreakpoint;
|
|
1170
|
+
exports.useDropZone = useDropZone;
|
|
1171
|
+
exports.useFieldset = useFieldset;
|
|
1172
|
+
exports.useIcons = useIcons;
|
|
1173
|
+
exports.useStyles = useStyles;
|
|
1174
|
+
exports.useTheme = useTheme;
|