@greatapps/common 1.1.173 → 1.1.175
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/components/account/AccountModals.mjs +18 -0
- package/dist/components/account/AccountModals.mjs.map +1 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs +132 -0
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +45 -0
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +45 -0
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -0
- package/dist/components/account/DeleteAccountModal.mjs +123 -0
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +67 -0
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +42 -0
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -0
- package/dist/components/account/TwoFactorAuthModal.mjs +190 -0
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -0
- package/dist/components/account/constants.mjs +29 -0
- package/dist/components/account/constants.mjs.map +1 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs +53 -0
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs +47 -0
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs +74 -0
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs +33 -0
- package/dist/components/account/hooks/useConfigurationsModal.mjs.map +1 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +54 -0
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/hooks/useOtpVerification.mjs +94 -0
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +80 -0
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs +181 -0
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs +64 -0
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs +184 -0
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -0
- package/dist/components/account/sections/MyProfileSection.mjs +303 -0
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -0
- package/dist/components/account/sections/PreferencesSection.mjs +250 -0
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -0
- package/dist/components/account/sections/SecuritySection.mjs +147 -0
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -0
- package/dist/components/handlers/SearchParamsHandler.mjs +24 -0
- package/dist/components/handlers/SearchParamsHandler.mjs.map +1 -0
- package/dist/components/layouts/AppMobileNavBar.mjs +115 -0
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -0
- package/dist/components/layouts/AppNavBar.mjs +49 -0
- package/dist/components/layouts/AppNavBar.mjs.map +1 -0
- package/dist/components/layouts/MainLayout.mjs +60 -0
- package/dist/components/layouts/MainLayout.mjs.map +1 -0
- package/dist/components/layouts/MdSideBarNavigation.mjs +54 -0
- package/dist/components/layouts/MdSideBarNavigation.mjs.map +1 -0
- package/dist/components/layouts/NavBar.mjs +132 -0
- package/dist/components/layouts/NavBar.mjs.map +1 -0
- package/dist/components/layouts/NavBarItem.mjs +23 -0
- package/dist/components/layouts/NavBarItem.mjs.map +1 -0
- package/dist/components/layouts/NotificationsPopover.mjs +97 -0
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -0
- package/dist/components/layouts/ProfilePopover.mjs +149 -0
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -0
- package/dist/components/layouts/SideBarNavigation.mjs +22 -0
- package/dist/components/layouts/SideBarNavigation.mjs.map +1 -0
- package/dist/components/layouts/UsersSelectorPopover.mjs +230 -0
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -0
- package/dist/components/modals/ModalManager.mjs +19 -0
- package/dist/components/modals/ModalManager.mjs.map +1 -0
- package/dist/components/modals/Modals.mjs +20 -0
- package/dist/components/modals/Modals.mjs.map +1 -0
- package/dist/components/navigation/AppNavigation.mjs +30 -0
- package/dist/components/navigation/AppNavigation.mjs.map +1 -0
- package/dist/components/navigation/AppNavigationContext.mjs +13 -0
- package/dist/components/navigation/AppNavigationContext.mjs.map +1 -0
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +59 -0
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -0
- package/dist/components/navigation/NavItem.mjs +35 -0
- package/dist/components/navigation/NavItem.mjs.map +1 -0
- package/dist/components/navigation/NavItemsContext.mjs +16 -0
- package/dist/components/navigation/NavItemsContext.mjs.map +1 -0
- package/dist/components/navigation/ProjectSelectorPopover.mjs +128 -0
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -0
- package/dist/components/navigation/shells/DesktopShell.mjs +11 -0
- package/dist/components/navigation/shells/DesktopShell.mjs.map +1 -0
- package/dist/components/navigation/shells/MdShell.mjs +11 -0
- package/dist/components/navigation/shells/MdShell.mjs.map +1 -0
- package/dist/components/navigation/shells/MobileShell.mjs +27 -0
- package/dist/components/navigation/shells/MobileShell.mjs.map +1 -0
- package/dist/components/navigation/shells/TabsMobileShell.mjs +59 -0
- package/dist/components/navigation/shells/TabsMobileShell.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +30 -0
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/NavItems.mjs +25 -0
- package/dist/components/navigation/subcomponents/NavItems.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/PlanCard.mjs +25 -0
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -0
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +130 -0
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -0
- package/dist/components/navigation/types.mjs +1 -0
- package/dist/components/navigation/types.mjs.map +1 -0
- package/dist/components/pages/notifications/Notifications.mjs +156 -0
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -0
- package/dist/components/ui/buttons/Button.mjs +52 -0
- package/dist/components/ui/buttons/Button.mjs.map +1 -0
- package/dist/components/ui/buttons/CancelButton.mjs +17 -0
- package/dist/components/ui/buttons/CancelButton.mjs.map +1 -0
- package/dist/components/ui/buttons/CopyButton.mjs +42 -0
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -0
- package/dist/components/ui/data-display/Accordion.mjs +76 -0
- package/dist/components/ui/data-display/Accordion.mjs.map +1 -0
- package/dist/components/ui/data-display/Badge.mjs +42 -0
- package/dist/components/ui/data-display/Badge.mjs.map +1 -0
- package/dist/components/ui/data-display/Card.mjs +92 -0
- package/dist/components/ui/data-display/Card.mjs.map +1 -0
- package/dist/components/ui/data-display/Pagination.mjs +118 -0
- package/dist/components/ui/data-display/Pagination.mjs.map +1 -0
- package/dist/components/ui/data-display/ScrollArea.mjs +62 -0
- package/dist/components/ui/data-display/ScrollArea.mjs.map +1 -0
- package/dist/components/ui/data-display/Separator.mjs +28 -0
- package/dist/components/ui/data-display/Separator.mjs.map +1 -0
- package/dist/components/ui/data-display/Table.mjs +116 -0
- package/dist/components/ui/data-display/Table.mjs.map +1 -0
- package/dist/components/ui/data-display/Tabs.mjs +69 -0
- package/dist/components/ui/data-display/Tabs.mjs.map +1 -0
- package/dist/components/ui/data-display/UserAvatar.mjs +49 -0
- package/dist/components/ui/data-display/UserAvatar.mjs.map +1 -0
- package/dist/components/ui/feedback/CircularProgress.mjs +71 -0
- package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -0
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +50 -0
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -0
- package/dist/components/ui/feedback/LoadingOverlay.mjs +19 -0
- package/dist/components/ui/feedback/LoadingOverlay.mjs.map +1 -0
- package/dist/components/ui/feedback/Progress.mjs +37 -0
- package/dist/components/ui/feedback/Progress.mjs.map +1 -0
- package/dist/components/ui/feedback/Toast.mjs +77 -0
- package/dist/components/ui/feedback/Toast.mjs.map +1 -0
- package/dist/components/ui/form/Calendar.mjs +204 -0
- package/dist/components/ui/form/Calendar.mjs.map +1 -0
- package/dist/components/ui/form/Checkbox.mjs +33 -0
- package/dist/components/ui/form/Checkbox.mjs.map +1 -0
- package/dist/components/ui/form/ComboboxField.mjs +130 -0
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -0
- package/dist/components/ui/form/DatePicker.mjs +82 -0
- package/dist/components/ui/form/DatePicker.mjs.map +1 -0
- package/dist/components/ui/form/DateRangePicker.mjs +92 -0
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -0
- package/dist/components/ui/form/FormField.mjs +103 -0
- package/dist/components/ui/form/FormField.mjs.map +1 -0
- package/dist/components/ui/form/Input.mjs +21 -0
- package/dist/components/ui/form/Input.mjs.map +1 -0
- package/dist/components/ui/form/InputOtp.mjs +70 -0
- package/dist/components/ui/form/InputOtp.mjs.map +1 -0
- package/dist/components/ui/form/PhoneInput.mjs +174 -0
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -0
- package/dist/components/ui/form/RadioGroup.mjs +37 -0
- package/dist/components/ui/form/RadioGroup.mjs.map +1 -0
- package/dist/components/ui/form/Select.mjs +179 -0
- package/dist/components/ui/form/Select.mjs.map +1 -0
- package/dist/components/ui/form/SelectField.mjs +80 -0
- package/dist/components/ui/form/SelectField.mjs.map +1 -0
- package/dist/components/ui/form/Switch.mjs +33 -0
- package/dist/components/ui/form/Switch.mjs.map +1 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs +40 -0
- package/dist/components/ui/form/SwitchOptionFieldWithIcon.mjs.map +1 -0
- package/dist/components/ui/form/TextAreaField.mjs +56 -0
- package/dist/components/ui/form/TextAreaField.mjs.map +1 -0
- package/dist/components/ui/form/Textarea.mjs +20 -0
- package/dist/components/ui/form/Textarea.mjs.map +1 -0
- package/dist/components/ui/overlay/Command.mjs +178 -0
- package/dist/components/ui/overlay/Command.mjs.map +1 -0
- package/dist/components/ui/overlay/Dialog.mjs +142 -0
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -0
- package/dist/components/ui/overlay/Popover.mjs +46 -0
- package/dist/components/ui/overlay/Popover.mjs.map +1 -0
- package/dist/components/ui/overlay/Sheet.mjs +142 -0
- package/dist/components/ui/overlay/Sheet.mjs.map +1 -0
- package/dist/components/ui/overlay/Tooltip.mjs +57 -0
- package/dist/components/ui/overlay/Tooltip.mjs.map +1 -0
- package/dist/components/widgets/notifications/NotificationCard.mjs +54 -0
- package/dist/components/widgets/notifications/NotificationCard.mjs.map +1 -0
- package/dist/enums/AccountSectionType.mjs +11 -0
- package/dist/enums/AccountSectionType.mjs.map +1 -0
- package/dist/hooks/copy-to-clipboard.hook.mjs +52 -0
- package/dist/hooks/copy-to-clipboard.hook.mjs.map +1 -0
- package/dist/hooks/useCountdownTimer.mjs +29 -0
- package/dist/hooks/useCountdownTimer.mjs.map +1 -0
- package/dist/hooks/useDebounce.mjs +19 -0
- package/dist/hooks/useDebounce.mjs.map +1 -0
- package/dist/hooks/useDebounceState.mjs +12 -0
- package/dist/hooks/useDebounceState.mjs.map +1 -0
- package/dist/hooks/useDebouncedEffect.mjs +44 -0
- package/dist/hooks/useDebouncedEffect.mjs.map +1 -0
- package/dist/hooks/useIsMobile.mjs +18 -0
- package/dist/hooks/useIsMobile.mjs.map +1 -0
- package/dist/hooks/usePasswordVisibility.mjs +13 -0
- package/dist/hooks/usePasswordVisibility.mjs.map +1 -0
- package/dist/index.mjs +457 -0
- package/dist/index.mjs.map +1 -0
- package/dist/infra/api/client.mjs +136 -0
- package/dist/infra/api/client.mjs.map +1 -0
- package/dist/infra/api/types.mjs +31 -0
- package/dist/infra/api/types.mjs.map +1 -0
- package/dist/infra/utils/client-info.mjs +27 -0
- package/dist/infra/utils/client-info.mjs.map +1 -0
- package/dist/infra/utils/clsx.mjs +9 -0
- package/dist/infra/utils/clsx.mjs.map +1 -0
- package/dist/infra/utils/params.mjs +21 -0
- package/dist/infra/utils/params.mjs.map +1 -0
- package/dist/infra/utils/parser.mjs +24 -0
- package/dist/infra/utils/parser.mjs.map +1 -0
- package/dist/infra/utils/percentage.mjs +20 -0
- package/dist/infra/utils/percentage.mjs.map +1 -0
- package/dist/middleware.mjs +10 -0
- package/dist/middleware.mjs.map +1 -0
- package/dist/middlewares/chain.mjs +37 -0
- package/dist/middlewares/chain.mjs.map +1 -0
- package/dist/middlewares/create-auth-middleware.mjs +28 -0
- package/dist/middlewares/create-auth-middleware.mjs.map +1 -0
- package/dist/middlewares/types.mjs +11 -0
- package/dist/middlewares/types.mjs.map +1 -0
- package/dist/modules/accounts/actions/account-management.action.mjs +82 -0
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/find-current-account.action.mjs +10 -0
- package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs +10 -0
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs +10 -0
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs +24 -0
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +71 -0
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs +17 -0
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs +17 -0
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -0
- package/dist/modules/accounts/services/account.service.mjs +180 -0
- package/dist/modules/accounts/services/account.service.mjs.map +1 -0
- package/dist/modules/accounts/services/currency.service.mjs +24 -0
- package/dist/modules/accounts/services/currency.service.mjs.map +1 -0
- package/dist/modules/accounts/services/timezone.service.mjs +65 -0
- package/dist/modules/accounts/services/timezone.service.mjs.map +1 -0
- package/dist/modules/accounts/services/two-factor.service.mjs +77 -0
- package/dist/modules/accounts/services/two-factor.service.mjs.map +1 -0
- package/dist/modules/accounts/types.mjs +1 -0
- package/dist/modules/accounts/types.mjs.map +1 -0
- package/dist/modules/auth/actions/login.action.mjs +14 -0
- package/dist/modules/auth/actions/login.action.mjs.map +1 -0
- package/dist/modules/auth/actions/logout.action.mjs +14 -0
- package/dist/modules/auth/actions/logout.action.mjs.map +1 -0
- package/dist/modules/auth/actions/register.action.mjs +14 -0
- package/dist/modules/auth/actions/register.action.mjs.map +1 -0
- package/dist/modules/auth/actions/validate-session.action.mjs +60 -0
- package/dist/modules/auth/actions/validate-session.action.mjs.map +1 -0
- package/dist/modules/auth/actions/verify-two-factor.action.mjs +17 -0
- package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -0
- package/dist/modules/auth/hooks/login.hook.mjs +13 -0
- package/dist/modules/auth/hooks/login.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/logout.hook.mjs +13 -0
- package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/register.hook.mjs +13 -0
- package/dist/modules/auth/hooks/register.hook.mjs.map +1 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs +63 -0
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -0
- package/dist/modules/auth/schema.mjs +1 -0
- package/dist/modules/auth/schema.mjs.map +1 -0
- package/dist/modules/auth/services/auth.service.mjs +294 -0
- package/dist/modules/auth/services/auth.service.mjs.map +1 -0
- package/dist/modules/auth/utils/get-user-context.mjs +24 -0
- package/dist/modules/auth/utils/get-user-context.mjs.map +1 -0
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +10 -0
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +76 -0
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs +31 -0
- package/dist/modules/ia-credits/services/ia-credits.service.mjs.map +1 -0
- package/dist/modules/ia-credits/types.mjs +25 -0
- package/dist/modules/ia-credits/types.mjs.map +1 -0
- package/dist/modules/projects/actions/add-project-user.action.mjs +10 -0
- package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-available-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/list-project-users.action.mjs +10 -0
- package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -0
- package/dist/modules/projects/actions/remove-project-user.action.mjs +10 -0
- package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +34 -0
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +34 -0
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -0
- package/dist/modules/projects/services/project-users.service.mjs +78 -0
- package/dist/modules/projects/services/project-users.service.mjs.map +1 -0
- package/dist/modules/projects/types.mjs +22 -0
- package/dist/modules/projects/types.mjs.map +1 -0
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +10 -0
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs +12 -0
- package/dist/modules/subscriptions/constants/addons.constants.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +20 -0
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +18 -0
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs +32 -0
- package/dist/modules/subscriptions/services/subscriptions.service.mjs.map +1 -0
- package/dist/modules/subscriptions/types.mjs +57 -0
- package/dist/modules/subscriptions/types.mjs.map +1 -0
- package/dist/modules/users/action/find-user-by-id.action.mjs +10 -0
- package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -0
- package/dist/modules/users/action/list-messages.action.mjs +13 -0
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +10 -0
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs +10 -0
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -0
- package/dist/modules/users/hooks/messages.hook.mjs +57 -0
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -0
- package/dist/modules/users/schema/messages.schema.mjs +21 -0
- package/dist/modules/users/schema/messages.schema.mjs.map +1 -0
- package/dist/modules/users/schema.mjs +11 -0
- package/dist/modules/users/schema.mjs.map +1 -0
- package/dist/modules/users/services/messages.service.mjs +35 -0
- package/dist/modules/users/services/messages.service.mjs.map +1 -0
- package/dist/modules/users/services/user.service.mjs +50 -0
- package/dist/modules/users/services/user.service.mjs.map +1 -0
- package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs +15 -0
- package/dist/modules/whitelabel/actions/find-whitelabel-styles.action.mjs.map +1 -0
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs +21 -0
- package/dist/modules/whitelabel/actions/find-whitelabel.action.mjs.map +1 -0
- package/dist/modules/whitelabel/schema.mjs +1 -0
- package/dist/modules/whitelabel/schema.mjs.map +1 -0
- package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs +81 -0
- package/dist/modules/whitelabel/services/whitelabel-styles.service.mjs.map +1 -0
- package/dist/modules/whitelabel/services/whitelabel.service.mjs +61 -0
- package/dist/modules/whitelabel/services/whitelabel.service.mjs.map +1 -0
- package/dist/modules/whitelabel/styles-schema.mjs +1 -0
- package/dist/modules/whitelabel/styles-schema.mjs.map +1 -0
- package/dist/providers/auth.provider.mjs +100 -0
- package/dist/providers/auth.provider.mjs.map +1 -0
- package/dist/providers/query.provider.mjs +99 -0
- package/dist/providers/query.provider.mjs.map +1 -0
- package/dist/providers/whitelabel.provider.mjs +31 -0
- package/dist/providers/whitelabel.provider.mjs.map +1 -0
- package/dist/server.mjs +84 -0
- package/dist/server.mjs.map +1 -0
- package/dist/store/useAccountModals.mjs +18 -0
- package/dist/store/useAccountModals.mjs.map +1 -0
- package/dist/store/useMdSidebarStore.mjs +11 -0
- package/dist/store/useMdSidebarStore.mjs.map +1 -0
- package/dist/store/useMobileNavbarSheet.mjs +14 -0
- package/dist/store/useMobileNavbarSheet.mjs.map +1 -0
- package/dist/store/useModalManager.mjs +75 -0
- package/dist/store/useModalManager.mjs.map +1 -0
- package/dist/utils/browser/clipboard.mjs +36 -0
- package/dist/utils/browser/clipboard.mjs.map +1 -0
- package/dist/utils/countries.mjs +219 -0
- package/dist/utils/countries.mjs.map +1 -0
- package/dist/utils/file/index.mjs +9 -0
- package/dist/utils/file/index.mjs.map +1 -0
- package/dist/utils/format/masks.mjs +56 -0
- package/dist/utils/format/masks.mjs.map +1 -0
- package/dist/utils/intl/locales.mjs +12 -0
- package/dist/utils/intl/locales.mjs.map +1 -0
- package/dist/utils/safeServerAction.mjs +16 -0
- package/dist/utils/safeServerAction.mjs.map +1 -0
- package/dist/utils/validators/account.mjs +26 -0
- package/dist/utils/validators/account.mjs.map +1 -0
- package/dist/utils/validators/common.mjs +47 -0
- package/dist/utils/validators/common.mjs.map +1 -0
- package/dist/utils/withAction.mjs +13 -0
- package/dist/utils/withAction.mjs.map +1 -0
- package/package.json +3 -2
- package/src/components/account/hooks/useChangePhoneForm.tsx +81 -69
- package/src/components/account/sections/ChangeEmailModal.tsx +2 -1
- package/src/components/account/sections/ChangePhoneModal.tsx +231 -229
- package/src/components/ui/form/PhoneInput.tsx +205 -98
- package/src/modules/accounts/actions/account-management.action.ts +4 -4
- package/src/modules/accounts/services/account.service.ts +4 -4
- package/src/utils/countries.ts +224 -0
|
@@ -1,98 +1,205 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { Input } from '
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef } from 'react';
|
|
4
|
+
import { AsYouType, CountryCode } from 'libphonenumber-js';
|
|
5
|
+
import { Input, Separator, Popover, PopoverTrigger, PopoverContent, cn } from '@greatapps/common';
|
|
6
|
+
import { IconChevronDown, IconSearch } from '@tabler/icons-react';
|
|
7
|
+
import { COUNTRIES, Country, flagUrl, parsePhoneValue } from '../../../utils/countries';
|
|
8
|
+
|
|
9
|
+
function formatNational(digits: string, iso: string): string {
|
|
10
|
+
const raw = digits.replace(/\D/g, '');
|
|
11
|
+
if (!raw) return '';
|
|
12
|
+
return new AsYouType(iso as CountryCode).input(raw);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface PhoneInputProps {
|
|
16
|
+
value?: string;
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
label?: string;
|
|
19
|
+
optional?: boolean;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
hintMessage?: string;
|
|
22
|
+
error?: boolean;
|
|
23
|
+
errorMessage?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
classnameContainer?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default function PhoneInput({
|
|
31
|
+
value,
|
|
32
|
+
onChange,
|
|
33
|
+
label,
|
|
34
|
+
optional = false,
|
|
35
|
+
required = false,
|
|
36
|
+
hintMessage,
|
|
37
|
+
error = false,
|
|
38
|
+
errorMessage,
|
|
39
|
+
placeholder,
|
|
40
|
+
disabled = false,
|
|
41
|
+
classnameContainer,
|
|
42
|
+
className,
|
|
43
|
+
}: PhoneInputProps) {
|
|
44
|
+
const parsed = parsePhoneValue(value ?? '');
|
|
45
|
+
const [selectedCountry, setSelectedCountry] = useState<Country>(parsed.country);
|
|
46
|
+
const [phoneNumber, setPhoneNumber] = useState(parsed.number);
|
|
47
|
+
const [search, setSearch] = useState('');
|
|
48
|
+
const [open, setOpen] = useState(false);
|
|
49
|
+
const prevValueRef = useRef(value);
|
|
50
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (value !== prevValueRef.current) {
|
|
54
|
+
prevValueRef.current = value;
|
|
55
|
+
const p = parsePhoneValue(value ?? '');
|
|
56
|
+
setSelectedCountry(p.country);
|
|
57
|
+
setPhoneNumber(formatNational(p.number, p.country.iso));
|
|
58
|
+
}
|
|
59
|
+
}, [value]);
|
|
60
|
+
|
|
61
|
+
const emit = (country: Country, number: string) => {
|
|
62
|
+
onChange?.(`${country.dial} ${number}`);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const handleCountrySelect = (country: Country) => {
|
|
66
|
+
const reformatted = formatNational(phoneNumber, country.iso);
|
|
67
|
+
setSelectedCountry(country);
|
|
68
|
+
setPhoneNumber(reformatted);
|
|
69
|
+
setOpen(false);
|
|
70
|
+
setSearch('');
|
|
71
|
+
emit(country, reformatted);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleNumberChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
75
|
+
const rawInput = e.target.value;
|
|
76
|
+
const cursorPos = e.target.selectionStart ?? rawInput.length;
|
|
77
|
+
const digitsBeforeCursor = rawInput.slice(0, cursorPos).replace(/\D/g, '').length;
|
|
78
|
+
|
|
79
|
+
const formatted = formatNational(rawInput, selectedCountry.iso);
|
|
80
|
+
setPhoneNumber(formatted);
|
|
81
|
+
emit(selectedCountry, formatted);
|
|
82
|
+
|
|
83
|
+
requestAnimationFrame(() => {
|
|
84
|
+
if (!inputRef.current) return;
|
|
85
|
+
let digitCount = 0;
|
|
86
|
+
let newPos = formatted.length;
|
|
87
|
+
for (let i = 0; i < formatted.length; i++) {
|
|
88
|
+
if (/\d/.test(formatted[i])) {
|
|
89
|
+
digitCount++;
|
|
90
|
+
if (digitCount === digitsBeforeCursor) {
|
|
91
|
+
newPos = i + 1;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
inputRef.current.setSelectionRange(newPos, newPos);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const filtered = COUNTRIES.filter(
|
|
101
|
+
(c) =>
|
|
102
|
+
c.name.toLowerCase().includes(search.toLowerCase()) ||
|
|
103
|
+
c.dial.includes(search) ||
|
|
104
|
+
c.iso.toLowerCase().includes(search.toLowerCase())
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const finalMessage = error && errorMessage ? errorMessage : hintMessage;
|
|
108
|
+
const showMessage = finalMessage && finalMessage.trim() !== '';
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div className="flex flex-col gap-1.5">
|
|
112
|
+
{label && (
|
|
113
|
+
<div className="flex items-center gap-1 paragraph-xsmall-semibold">
|
|
114
|
+
<span className="text-zinc-600">{label}</span>
|
|
115
|
+
{optional && <span className="text-zinc-500">(Opcional)</span>}
|
|
116
|
+
{required && <span className="text-red-600">*</span>}
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
<div
|
|
121
|
+
className={cn(
|
|
122
|
+
'flex gap-2 items-center border rounded-lg h-10 transition-colors',
|
|
123
|
+
error
|
|
124
|
+
? 'border-red-600 hover:border-red-700'
|
|
125
|
+
: 'border-zinc-200 hover:border-zinc-400 focus-within:border-zinc-950',
|
|
126
|
+
disabled && 'opacity-50 cursor-not-allowed',
|
|
127
|
+
classnameContainer
|
|
128
|
+
)}
|
|
129
|
+
>
|
|
130
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
131
|
+
<PopoverTrigger asChild>
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
className="flex items-center gap-1.5 px-3 h-full shrink-0 focus:outline-none"
|
|
135
|
+
disabled={disabled}
|
|
136
|
+
>
|
|
137
|
+
<img src={flagUrl(selectedCountry.iso)} alt={selectedCountry.iso} className="w-5 h-5 rounded-full" />
|
|
138
|
+
<span className="paragraph-small-regular text-zinc-950">{selectedCountry.dial}</span>
|
|
139
|
+
<IconChevronDown size={14} className={cn("text-zinc-500 transition-transform duration-200", open && "rotate-180")} />
|
|
140
|
+
</button>
|
|
141
|
+
</PopoverTrigger>
|
|
142
|
+
<PopoverContent className="w-72 p-0" align="start">
|
|
143
|
+
<div className="flex items-center gap-2 p-2 border-b border-zinc-100">
|
|
144
|
+
<IconSearch size={14} className="text-zinc-400 shrink-0" />
|
|
145
|
+
<input
|
|
146
|
+
type="text"
|
|
147
|
+
className="flex-1 text-sm outline-none placeholder:text-zinc-400"
|
|
148
|
+
placeholder="Buscar país..."
|
|
149
|
+
value={search}
|
|
150
|
+
onChange={(e) => setSearch(e.target.value)}
|
|
151
|
+
autoFocus
|
|
152
|
+
/>
|
|
153
|
+
</div>
|
|
154
|
+
<div className="max-h-60 overflow-y-auto overscroll-contain" onTouchMove={(e) => e.stopPropagation()}>
|
|
155
|
+
{filtered.map((country) => (
|
|
156
|
+
<button
|
|
157
|
+
key={country.iso}
|
|
158
|
+
type="button"
|
|
159
|
+
className={cn(
|
|
160
|
+
'flex items-center gap-2.5 w-full px-3 py-2 text-left hover:bg-zinc-50 transition-colors',
|
|
161
|
+
selectedCountry.iso === country.iso && 'bg-zinc-100'
|
|
162
|
+
)}
|
|
163
|
+
onClick={() => handleCountrySelect(country)}
|
|
164
|
+
>
|
|
165
|
+
<img src={flagUrl(country.iso)} alt={country.iso} className="w-5 h-5 rounded-full shrink-0" />
|
|
166
|
+
<span className="paragraph-small-regular text-zinc-950 flex-1 truncate">
|
|
167
|
+
{country.name}
|
|
168
|
+
</span>
|
|
169
|
+
<span className="paragraph-small-regular text-zinc-500 shrink-0">
|
|
170
|
+
{country.dial}
|
|
171
|
+
</span>
|
|
172
|
+
</button>
|
|
173
|
+
))}
|
|
174
|
+
{filtered.length === 0 && (
|
|
175
|
+
<p className="text-sm text-zinc-500 p-3 text-center">Nenhum país encontrado</p>
|
|
176
|
+
)}
|
|
177
|
+
</div>
|
|
178
|
+
</PopoverContent>
|
|
179
|
+
</Popover>
|
|
180
|
+
|
|
181
|
+
<Separator orientation="vertical" />
|
|
182
|
+
|
|
183
|
+
<Input
|
|
184
|
+
ref={inputRef}
|
|
185
|
+
type="tel"
|
|
186
|
+
value={phoneNumber}
|
|
187
|
+
onChange={handleNumberChange}
|
|
188
|
+
placeholder={placeholder}
|
|
189
|
+
disabled={disabled}
|
|
190
|
+
className={cn(
|
|
191
|
+
'paragraph-small-medium w-full h-full text-zinc-950 border-0 focus-visible:ring-0 focus-visible:ring-offset-0',
|
|
192
|
+
disabled && 'cursor-not-allowed',
|
|
193
|
+
className
|
|
194
|
+
)}
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
{showMessage && (
|
|
199
|
+
<span className={cn('paragraph-xsmall-medium', error ? 'text-red-600' : 'text-zinc-600')}>
|
|
200
|
+
{finalMessage}
|
|
201
|
+
</span>
|
|
202
|
+
)}
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
@@ -57,12 +57,12 @@ export async function confirmEmailChangeAction(token: string, newEmail: string)
|
|
|
57
57
|
return safeServerAction(() => accountService.confirmContactReset('email', token, newEmail));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
export async function requestPhoneChangeAction(newPhone: string) {
|
|
61
|
-
return safeServerAction(() => accountService.requestContactReset('phone', newPhone));
|
|
60
|
+
export async function requestPhoneChangeAction(newPhone: string, ddi?: string) {
|
|
61
|
+
return safeServerAction(() => accountService.requestContactReset('phone', newPhone, ddi));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export async function confirmPhoneChangeAction(token: string, newPhone: string) {
|
|
65
|
-
return safeServerAction(() => accountService.confirmContactReset('phone', token, newPhone));
|
|
64
|
+
export async function confirmPhoneChangeAction(token: string, newPhone: string, ddi?: string) {
|
|
65
|
+
return safeServerAction(() => accountService.confirmContactReset('phone', token, newPhone, ddi));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export async function generateTwoFactorAction() {
|
|
@@ -182,11 +182,11 @@ class AccountService {
|
|
|
182
182
|
return response;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
async requestContactReset(type: 'email' | 'phone', newContact: string): Promise<void> {
|
|
185
|
+
async requestContactReset(type: 'email' | 'phone', newContact: string, ddi?: string): Promise<void> {
|
|
186
186
|
const { id_account, id_user } = await getUserContext();
|
|
187
187
|
const response = await api.apps.post<{ status: number; message: string }>(
|
|
188
188
|
`/accounts/${id_account}/users/${id_user}/resetContact/request`,
|
|
189
|
-
{ type, newContact }
|
|
189
|
+
{ type, newContact, ...(ddi ? { ddi } : {}) }
|
|
190
190
|
);
|
|
191
191
|
|
|
192
192
|
if (response.status === 0) {
|
|
@@ -198,11 +198,11 @@ class AccountService {
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
async confirmContactReset(type: 'email' | 'phone', token: string, newContact: string): Promise<void> {
|
|
201
|
+
async confirmContactReset(type: 'email' | 'phone', token: string, newContact: string, ddi?: string): Promise<void> {
|
|
202
202
|
const { id_account, id_user } = await getUserContext();
|
|
203
203
|
const response = await api.apps.post<{ status: number; message: string }>(
|
|
204
204
|
`/accounts/${id_account}/users/${id_user}/resetContact/confirm`,
|
|
205
|
-
{ type, token, newContact }
|
|
205
|
+
{ type, token, newContact, ...(ddi ? { ddi } : {}) }
|
|
206
206
|
);
|
|
207
207
|
|
|
208
208
|
if (response.status === 0) {
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
export interface Country {
|
|
2
|
+
iso: string;
|
|
3
|
+
name: string;
|
|
4
|
+
dial: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function flagUrl(iso: string): string {
|
|
8
|
+
return `https://hatscripts.github.io/circle-flags/flags/${iso.toLowerCase()}.svg`;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const COUNTRIES: Country[] = [
|
|
12
|
+
{ iso: 'BR', name: 'Brasil', dial: '+55' },
|
|
13
|
+
{ iso: 'US', name: 'United States', dial: '+1' },
|
|
14
|
+
{ iso: 'PT', name: 'Portugal', dial: '+351' },
|
|
15
|
+
{ iso: 'AF', name: 'Afghanistan', dial: '+93' },
|
|
16
|
+
{ iso: 'AL', name: 'Albania', dial: '+355' },
|
|
17
|
+
{ iso: 'DZ', name: 'Algeria', dial: '+213' },
|
|
18
|
+
{ iso: 'AD', name: 'Andorra', dial: '+376' },
|
|
19
|
+
{ iso: 'AO', name: 'Angola', dial: '+244' },
|
|
20
|
+
{ iso: 'AG', name: 'Antigua and Barbuda', dial: '+1268' },
|
|
21
|
+
{ iso: 'AR', name: 'Argentina', dial: '+54' },
|
|
22
|
+
{ iso: 'AM', name: 'Armenia', dial: '+374' },
|
|
23
|
+
{ iso: 'AU', name: 'Australia', dial: '+61' },
|
|
24
|
+
{ iso: 'AT', name: 'Austria', dial: '+43' },
|
|
25
|
+
{ iso: 'AZ', name: 'Azerbaijan', dial: '+994' },
|
|
26
|
+
{ iso: 'BS', name: 'Bahamas', dial: '+1242' },
|
|
27
|
+
{ iso: 'BH', name: 'Bahrain', dial: '+973' },
|
|
28
|
+
{ iso: 'BD', name: 'Bangladesh', dial: '+880' },
|
|
29
|
+
{ iso: 'BB', name: 'Barbados', dial: '+1246' },
|
|
30
|
+
{ iso: 'BY', name: 'Belarus', dial: '+375' },
|
|
31
|
+
{ iso: 'BE', name: 'Belgium', dial: '+32' },
|
|
32
|
+
{ iso: 'BZ', name: 'Belize', dial: '+501' },
|
|
33
|
+
{ iso: 'BJ', name: 'Benin', dial: '+229' },
|
|
34
|
+
{ iso: 'BT', name: 'Bhutan', dial: '+975' },
|
|
35
|
+
{ iso: 'BO', name: 'Bolivia', dial: '+591' },
|
|
36
|
+
{ iso: 'BA', name: 'Bosnia and Herzegovina', dial: '+387' },
|
|
37
|
+
{ iso: 'BW', name: 'Botswana', dial: '+267' },
|
|
38
|
+
{ iso: 'BN', name: 'Brunei', dial: '+673' },
|
|
39
|
+
{ iso: 'BG', name: 'Bulgaria', dial: '+359' },
|
|
40
|
+
{ iso: 'BF', name: 'Burkina Faso', dial: '+226' },
|
|
41
|
+
{ iso: 'BI', name: 'Burundi', dial: '+257' },
|
|
42
|
+
{ iso: 'KH', name: 'Cambodia', dial: '+855' },
|
|
43
|
+
{ iso: 'CM', name: 'Cameroon', dial: '+237' },
|
|
44
|
+
{ iso: 'CA', name: 'Canada', dial: '+1' },
|
|
45
|
+
{ iso: 'CV', name: 'Cape Verde', dial: '+238' },
|
|
46
|
+
{ iso: 'CF', name: 'Central African Republic', dial: '+236' },
|
|
47
|
+
{ iso: 'TD', name: 'Chad', dial: '+235' },
|
|
48
|
+
{ iso: 'CL', name: 'Chile', dial: '+56' },
|
|
49
|
+
{ iso: 'CN', name: 'China', dial: '+86' },
|
|
50
|
+
{ iso: 'CO', name: 'Colombia', dial: '+57' },
|
|
51
|
+
{ iso: 'KM', name: 'Comoros', dial: '+269' },
|
|
52
|
+
{ iso: 'CG', name: 'Congo', dial: '+242' },
|
|
53
|
+
{ iso: 'CD', name: 'Congo (DR)', dial: '+243' },
|
|
54
|
+
{ iso: 'CR', name: 'Costa Rica', dial: '+506' },
|
|
55
|
+
{ iso: 'HR', name: 'Croatia', dial: '+385' },
|
|
56
|
+
{ iso: 'CU', name: 'Cuba', dial: '+53' },
|
|
57
|
+
{ iso: 'CY', name: 'Cyprus', dial: '+357' },
|
|
58
|
+
{ iso: 'CZ', name: 'Czech Republic', dial: '+420' },
|
|
59
|
+
{ iso: 'DK', name: 'Denmark', dial: '+45' },
|
|
60
|
+
{ iso: 'DJ', name: 'Djibouti', dial: '+253' },
|
|
61
|
+
{ iso: 'DM', name: 'Dominica', dial: '+1767' },
|
|
62
|
+
{ iso: 'DO', name: 'Dominican Republic', dial: '+1809' },
|
|
63
|
+
{ iso: 'EC', name: 'Ecuador', dial: '+593' },
|
|
64
|
+
{ iso: 'EG', name: 'Egypt', dial: '+20' },
|
|
65
|
+
{ iso: 'SV', name: 'El Salvador', dial: '+503' },
|
|
66
|
+
{ iso: 'GQ', name: 'Equatorial Guinea', dial: '+240' },
|
|
67
|
+
{ iso: 'ER', name: 'Eritrea', dial: '+291' },
|
|
68
|
+
{ iso: 'EE', name: 'Estonia', dial: '+372' },
|
|
69
|
+
{ iso: 'SZ', name: 'Eswatini', dial: '+268' },
|
|
70
|
+
{ iso: 'ET', name: 'Ethiopia', dial: '+251' },
|
|
71
|
+
{ iso: 'FJ', name: 'Fiji', dial: '+679' },
|
|
72
|
+
{ iso: 'FI', name: 'Finland', dial: '+358' },
|
|
73
|
+
{ iso: 'FR', name: 'France', dial: '+33' },
|
|
74
|
+
{ iso: 'GA', name: 'Gabon', dial: '+241' },
|
|
75
|
+
{ iso: 'GM', name: 'Gambia', dial: '+220' },
|
|
76
|
+
{ iso: 'GE', name: 'Georgia', dial: '+995' },
|
|
77
|
+
{ iso: 'DE', name: 'Germany', dial: '+49' },
|
|
78
|
+
{ iso: 'GH', name: 'Ghana', dial: '+233' },
|
|
79
|
+
{ iso: 'GR', name: 'Greece', dial: '+30' },
|
|
80
|
+
{ iso: 'GD', name: 'Grenada', dial: '+1473' },
|
|
81
|
+
{ iso: 'GT', name: 'Guatemala', dial: '+502' },
|
|
82
|
+
{ iso: 'GN', name: 'Guinea', dial: '+224' },
|
|
83
|
+
{ iso: 'GW', name: 'Guinea-Bissau', dial: '+245' },
|
|
84
|
+
{ iso: 'GY', name: 'Guyana', dial: '+592' },
|
|
85
|
+
{ iso: 'HT', name: 'Haiti', dial: '+509' },
|
|
86
|
+
{ iso: 'HN', name: 'Honduras', dial: '+504' },
|
|
87
|
+
{ iso: 'HU', name: 'Hungary', dial: '+36' },
|
|
88
|
+
{ iso: 'IS', name: 'Iceland', dial: '+354' },
|
|
89
|
+
{ iso: 'IN', name: 'India', dial: '+91' },
|
|
90
|
+
{ iso: 'ID', name: 'Indonesia', dial: '+62' },
|
|
91
|
+
{ iso: 'IR', name: 'Iran', dial: '+98' },
|
|
92
|
+
{ iso: 'IQ', name: 'Iraq', dial: '+964' },
|
|
93
|
+
{ iso: 'IE', name: 'Ireland', dial: '+353' },
|
|
94
|
+
{ iso: 'IL', name: 'Israel', dial: '+972' },
|
|
95
|
+
{ iso: 'IT', name: 'Italy', dial: '+39' },
|
|
96
|
+
{ iso: 'JM', name: 'Jamaica', dial: '+1876' },
|
|
97
|
+
{ iso: 'JP', name: 'Japan', dial: '+81' },
|
|
98
|
+
{ iso: 'JO', name: 'Jordan', dial: '+962' },
|
|
99
|
+
{ iso: 'KZ', name: 'Kazakhstan', dial: '+7' },
|
|
100
|
+
{ iso: 'KE', name: 'Kenya', dial: '+254' },
|
|
101
|
+
{ iso: 'KI', name: 'Kiribati', dial: '+686' },
|
|
102
|
+
{ iso: 'KW', name: 'Kuwait', dial: '+965' },
|
|
103
|
+
{ iso: 'KG', name: 'Kyrgyzstan', dial: '+996' },
|
|
104
|
+
{ iso: 'LA', name: 'Laos', dial: '+856' },
|
|
105
|
+
{ iso: 'LV', name: 'Latvia', dial: '+371' },
|
|
106
|
+
{ iso: 'LB', name: 'Lebanon', dial: '+961' },
|
|
107
|
+
{ iso: 'LS', name: 'Lesotho', dial: '+266' },
|
|
108
|
+
{ iso: 'LR', name: 'Liberia', dial: '+231' },
|
|
109
|
+
{ iso: 'LY', name: 'Libya', dial: '+218' },
|
|
110
|
+
{ iso: 'LI', name: 'Liechtenstein', dial: '+423' },
|
|
111
|
+
{ iso: 'LT', name: 'Lithuania', dial: '+370' },
|
|
112
|
+
{ iso: 'LU', name: 'Luxembourg', dial: '+352' },
|
|
113
|
+
{ iso: 'MG', name: 'Madagascar', dial: '+261' },
|
|
114
|
+
{ iso: 'MW', name: 'Malawi', dial: '+265' },
|
|
115
|
+
{ iso: 'MY', name: 'Malaysia', dial: '+60' },
|
|
116
|
+
{ iso: 'MV', name: 'Maldives', dial: '+960' },
|
|
117
|
+
{ iso: 'ML', name: 'Mali', dial: '+223' },
|
|
118
|
+
{ iso: 'MT', name: 'Malta', dial: '+356' },
|
|
119
|
+
{ iso: 'MH', name: 'Marshall Islands', dial: '+692' },
|
|
120
|
+
{ iso: 'MR', name: 'Mauritania', dial: '+222' },
|
|
121
|
+
{ iso: 'MU', name: 'Mauritius', dial: '+230' },
|
|
122
|
+
{ iso: 'MX', name: 'Mexico', dial: '+52' },
|
|
123
|
+
{ iso: 'FM', name: 'Micronesia', dial: '+691' },
|
|
124
|
+
{ iso: 'MD', name: 'Moldova', dial: '+373' },
|
|
125
|
+
{ iso: 'MC', name: 'Monaco', dial: '+377' },
|
|
126
|
+
{ iso: 'MN', name: 'Mongolia', dial: '+976' },
|
|
127
|
+
{ iso: 'ME', name: 'Montenegro', dial: '+382' },
|
|
128
|
+
{ iso: 'MA', name: 'Morocco', dial: '+212' },
|
|
129
|
+
{ iso: 'MZ', name: 'Mozambique', dial: '+258' },
|
|
130
|
+
{ iso: 'MM', name: 'Myanmar', dial: '+95' },
|
|
131
|
+
{ iso: 'NA', name: 'Namibia', dial: '+264' },
|
|
132
|
+
{ iso: 'NR', name: 'Nauru', dial: '+674' },
|
|
133
|
+
{ iso: 'NP', name: 'Nepal', dial: '+977' },
|
|
134
|
+
{ iso: 'NL', name: 'Netherlands', dial: '+31' },
|
|
135
|
+
{ iso: 'NZ', name: 'New Zealand', dial: '+64' },
|
|
136
|
+
{ iso: 'NI', name: 'Nicaragua', dial: '+505' },
|
|
137
|
+
{ iso: 'NE', name: 'Niger', dial: '+227' },
|
|
138
|
+
{ iso: 'NG', name: 'Nigeria', dial: '+234' },
|
|
139
|
+
{ iso: 'KP', name: 'North Korea', dial: '+850' },
|
|
140
|
+
{ iso: 'MK', name: 'North Macedonia', dial: '+389' },
|
|
141
|
+
{ iso: 'NO', name: 'Norway', dial: '+47' },
|
|
142
|
+
{ iso: 'OM', name: 'Oman', dial: '+968' },
|
|
143
|
+
{ iso: 'PK', name: 'Pakistan', dial: '+92' },
|
|
144
|
+
{ iso: 'PW', name: 'Palau', dial: '+680' },
|
|
145
|
+
{ iso: 'PS', name: 'Palestine', dial: '+970' },
|
|
146
|
+
{ iso: 'PA', name: 'Panama', dial: '+507' },
|
|
147
|
+
{ iso: 'PG', name: 'Papua New Guinea', dial: '+675' },
|
|
148
|
+
{ iso: 'PY', name: 'Paraguay', dial: '+595' },
|
|
149
|
+
{ iso: 'PE', name: 'Peru', dial: '+51' },
|
|
150
|
+
{ iso: 'PH', name: 'Philippines', dial: '+63' },
|
|
151
|
+
{ iso: 'PL', name: 'Poland', dial: '+48' },
|
|
152
|
+
{ iso: 'QA', name: 'Qatar', dial: '+974' },
|
|
153
|
+
{ iso: 'RO', name: 'Romania', dial: '+40' },
|
|
154
|
+
{ iso: 'RU', name: 'Russia', dial: '+7' },
|
|
155
|
+
{ iso: 'RW', name: 'Rwanda', dial: '+250' },
|
|
156
|
+
{ iso: 'KN', name: 'Saint Kitts and Nevis', dial: '+1869' },
|
|
157
|
+
{ iso: 'LC', name: 'Saint Lucia', dial: '+1758' },
|
|
158
|
+
{ iso: 'VC', name: 'Saint Vincent and the Grenadines', dial: '+1784' },
|
|
159
|
+
{ iso: 'WS', name: 'Samoa', dial: '+685' },
|
|
160
|
+
{ iso: 'SM', name: 'San Marino', dial: '+378' },
|
|
161
|
+
{ iso: 'ST', name: 'São Tomé and Príncipe', dial: '+239' },
|
|
162
|
+
{ iso: 'SA', name: 'Saudi Arabia', dial: '+966' },
|
|
163
|
+
{ iso: 'SN', name: 'Senegal', dial: '+221' },
|
|
164
|
+
{ iso: 'RS', name: 'Serbia', dial: '+381' },
|
|
165
|
+
{ iso: 'SC', name: 'Seychelles', dial: '+248' },
|
|
166
|
+
{ iso: 'SL', name: 'Sierra Leone', dial: '+232' },
|
|
167
|
+
{ iso: 'SG', name: 'Singapore', dial: '+65' },
|
|
168
|
+
{ iso: 'SK', name: 'Slovakia', dial: '+421' },
|
|
169
|
+
{ iso: 'SI', name: 'Slovenia', dial: '+386' },
|
|
170
|
+
{ iso: 'SB', name: 'Solomon Islands', dial: '+677' },
|
|
171
|
+
{ iso: 'SO', name: 'Somalia', dial: '+252' },
|
|
172
|
+
{ iso: 'ZA', name: 'South Africa', dial: '+27' },
|
|
173
|
+
{ iso: 'KR', name: 'South Korea', dial: '+82' },
|
|
174
|
+
{ iso: 'SS', name: 'South Sudan', dial: '+211' },
|
|
175
|
+
{ iso: 'ES', name: 'Spain', dial: '+34' },
|
|
176
|
+
{ iso: 'LK', name: 'Sri Lanka', dial: '+94' },
|
|
177
|
+
{ iso: 'SD', name: 'Sudan', dial: '+249' },
|
|
178
|
+
{ iso: 'SR', name: 'Suriname', dial: '+597' },
|
|
179
|
+
{ iso: 'SE', name: 'Sweden', dial: '+46' },
|
|
180
|
+
{ iso: 'CH', name: 'Switzerland', dial: '+41' },
|
|
181
|
+
{ iso: 'SY', name: 'Syria', dial: '+963' },
|
|
182
|
+
{ iso: 'TW', name: 'Taiwan', dial: '+886' },
|
|
183
|
+
{ iso: 'TJ', name: 'Tajikistan', dial: '+992' },
|
|
184
|
+
{ iso: 'TZ', name: 'Tanzania', dial: '+255' },
|
|
185
|
+
{ iso: 'TH', name: 'Thailand', dial: '+66' },
|
|
186
|
+
{ iso: 'TL', name: 'Timor-Leste', dial: '+670' },
|
|
187
|
+
{ iso: 'TG', name: 'Togo', dial: '+228' },
|
|
188
|
+
{ iso: 'TO', name: 'Tonga', dial: '+676' },
|
|
189
|
+
{ iso: 'TT', name: 'Trinidad and Tobago', dial: '+1868' },
|
|
190
|
+
{ iso: 'TN', name: 'Tunisia', dial: '+216' },
|
|
191
|
+
{ iso: 'TR', name: 'Turkey', dial: '+90' },
|
|
192
|
+
{ iso: 'TM', name: 'Turkmenistan', dial: '+993' },
|
|
193
|
+
{ iso: 'TV', name: 'Tuvalu', dial: '+688' },
|
|
194
|
+
{ iso: 'UG', name: 'Uganda', dial: '+256' },
|
|
195
|
+
{ iso: 'UA', name: 'Ukraine', dial: '+380' },
|
|
196
|
+
{ iso: 'AE', name: 'United Arab Emirates', dial: '+971' },
|
|
197
|
+
{ iso: 'GB', name: 'United Kingdom', dial: '+44' },
|
|
198
|
+
{ iso: 'UY', name: 'Uruguay', dial: '+598' },
|
|
199
|
+
{ iso: 'UZ', name: 'Uzbekistan', dial: '+998' },
|
|
200
|
+
{ iso: 'VU', name: 'Vanuatu', dial: '+678' },
|
|
201
|
+
{ iso: 'VE', name: 'Venezuela', dial: '+58' },
|
|
202
|
+
{ iso: 'VN', name: 'Vietnam', dial: '+84' },
|
|
203
|
+
{ iso: 'YE', name: 'Yemen', dial: '+967' },
|
|
204
|
+
{ iso: 'ZM', name: 'Zambia', dial: '+260' },
|
|
205
|
+
{ iso: 'ZW', name: 'Zimbabwe', dial: '+263' },
|
|
206
|
+
];
|
|
207
|
+
|
|
208
|
+
// Sorted by dial code length desc for correct prefix matching
|
|
209
|
+
const SORTED_BY_DIAL_LENGTH = [...COUNTRIES].sort(
|
|
210
|
+
(a, b) => b.dial.length - a.dial.length
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const DEFAULT_COUNTRY = COUNTRIES[0]; // Brasil
|
|
214
|
+
|
|
215
|
+
export function parsePhoneValue(value: string): { country: Country; number: string } {
|
|
216
|
+
if (!value) return { country: DEFAULT_COUNTRY, number: '' };
|
|
217
|
+
for (const country of SORTED_BY_DIAL_LENGTH) {
|
|
218
|
+
const prefix = country.dial + ' ';
|
|
219
|
+
if (value.startsWith(prefix)) {
|
|
220
|
+
return { country, number: value.slice(prefix.length) };
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return { country: DEFAULT_COUNTRY, number: value };
|
|
224
|
+
}
|