@greatapps/common 1.1.674 → 1.1.675
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/ConfigurationsMyAccountModal.mjs +6 -8
- package/dist/components/account/ConfigurationsMyAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmDeleteAccountModal.mjs +19 -20
- package/dist/components/account/ConfirmDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs +11 -10
- package/dist/components/account/ConfirmGlobalPreferencesModal.mjs.map +1 -1
- package/dist/components/account/DeleteAccountModal.mjs +28 -34
- package/dist/components/account/DeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/DisableTwoFactorAuthModal.mjs +5 -7
- package/dist/components/account/DisableTwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs +9 -8
- package/dist/components/account/IsntPossibleDeleteAccountModal.mjs.map +1 -1
- package/dist/components/account/TwoFactorAuthModal.mjs +23 -22
- package/dist/components/account/TwoFactorAuthModal.mjs.map +1 -1
- package/dist/components/account/constants.mjs +4 -4
- package/dist/components/account/constants.mjs.map +1 -1
- package/dist/components/account/hooks/useChangeEmailForm.mjs +3 -5
- package/dist/components/account/hooks/useChangeEmailForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePasswordForm.mjs +3 -26
- package/dist/components/account/hooks/useChangePasswordForm.mjs.map +1 -1
- package/dist/components/account/hooks/useChangePhoneForm.mjs +9 -18
- package/dist/components/account/hooks/useChangePhoneForm.mjs.map +1 -1
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs +3 -26
- package/dist/components/account/hooks/useDisableTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/hooks/useOtpVerification.mjs +3 -19
- package/dist/components/account/hooks/useOtpVerification.mjs.map +1 -1
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs +4 -27
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/ChangeEmailModal.mjs +28 -25
- package/dist/components/account/sections/ChangeEmailModal.mjs.map +1 -1
- package/dist/components/account/sections/ChangePasswordSection.mjs +6 -8
- package/dist/components/account/sections/ChangePasswordSection.mjs.map +1 -1
- package/dist/components/account/sections/ChangePhoneModal.mjs +27 -24
- package/dist/components/account/sections/ChangePhoneModal.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +22 -37
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +24 -48
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/components/account/sections/SecuritySection.mjs +9 -11
- package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
- package/dist/components/account/sections/TokenSection.mjs +8 -24
- package/dist/components/account/sections/TokenSection.mjs.map +1 -1
- package/dist/components/layouts/AppMobileNavBar.mjs +148 -2
- package/dist/components/layouts/AppMobileNavBar.mjs.map +1 -1
- package/dist/components/layouts/NavBar.mjs +3 -5
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +3 -5
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +4 -6
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +7 -9
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
- package/dist/components/modals/BuyCreditsModal.mjs +18 -17
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
- package/dist/components/modals/CreditsDisabledModal.mjs +4 -6
- package/dist/components/modals/CreditsDisabledModal.mjs.map +1 -1
- package/dist/components/modals/PaidPlanRequiredModal.mjs +3 -5
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +24 -27
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs +7 -9
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CardFormFields.mjs +22 -25
- package/dist/components/modals/cards/CardFormFields.mjs.map +1 -1
- package/dist/components/modals/cards/DeleteCardModal.mjs +8 -10
- package/dist/components/modals/cards/DeleteCardModal.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +2 -4
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/OverdueInvoiceBanner.mjs +2 -4
- package/dist/components/navigation/OverdueInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/PendingCancellationBanner.mjs +6 -4
- package/dist/components/navigation/PendingCancellationBanner.mjs.map +1 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +6 -8
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs +6 -4
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/BottomLinks.mjs +3 -5
- package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +1 -3
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs +1 -3
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +3 -5
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/pages/NotFoundPage.mjs +3 -5
- package/dist/components/pages/NotFoundPage.mjs.map +1 -1
- package/dist/components/pages/notifications/Notifications.mjs +10 -13
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -1
- package/dist/components/ui/buttons/CopyButton.mjs +5 -9
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -1
- package/dist/components/ui/data-display/CardItem.mjs +5 -7
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +8 -10
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/components/ui/feedback/CircularProgress.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +1 -3
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/form/ComboboxField.mjs +6 -11
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -1
- package/dist/components/ui/form/DatePicker.mjs +2 -5
- package/dist/components/ui/form/DatePicker.mjs.map +1 -1
- package/dist/components/ui/form/DateRangePicker.mjs +2 -5
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -1
- package/dist/components/ui/form/PhoneInput.mjs +3 -5
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
- package/dist/components/ui/form/SelectField.mjs +3 -6
- package/dist/components/ui/form/SelectField.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs +18 -11
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs +15 -6
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs.map +1 -1
- package/dist/index.mjs +2 -16
- package/dist/index.mjs.map +1 -1
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs +1 -2
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs.map +1 -1
- package/dist/modules/images/utils/validate-image.mjs +8 -8
- package/dist/modules/images/utils/validate-image.mjs.map +1 -1
- package/dist/modules/plans/types/plan.type.mjs +0 -3
- package/dist/modules/plans/types/plan.type.mjs.map +1 -1
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs +34 -56
- package/dist/modules/plans/utils/map-api-plan-to-ui.mjs.map +1 -1
- package/dist/modules/subscriptions/utils/periodicity.mjs +14 -20
- package/dist/modules/subscriptions/utils/periodicity.mjs.map +1 -1
- package/dist/providers/auth.provider.mjs +1 -9
- package/dist/providers/auth.provider.mjs.map +1 -1
- package/dist/server.mjs +0 -2
- package/dist/server.mjs.map +1 -1
- package/dist/utils/format/currency.mjs +4 -32
- package/dist/utils/format/currency.mjs.map +1 -1
- package/dist/utils/intl/locales.mjs +2 -3
- package/dist/utils/intl/locales.mjs.map +1 -1
- package/package.json +1 -7
- package/src/components/account/ConfigurationsMyAccountModal.tsx +6 -10
- package/src/components/account/ConfirmDeleteAccountModal.tsx +13 -22
- package/src/components/account/ConfirmGlobalPreferencesModal.tsx +10 -12
- package/src/components/account/DeleteAccountModal.tsx +24 -34
- package/src/components/account/DisableTwoFactorAuthModal.tsx +6 -11
- package/src/components/account/IsntPossibleDeleteAccountModal.tsx +6 -8
- package/src/components/account/TwoFactorAuthModal.tsx +29 -33
- package/src/components/account/constants.ts +5 -8
- package/src/components/account/hooks/useChangeEmailForm.tsx +3 -5
- package/src/components/account/hooks/useChangePasswordForm.tsx +6 -20
- package/src/components/account/hooks/useChangePhoneForm.tsx +10 -16
- package/src/components/account/hooks/useDisableTwoFactorAuthForm.tsx +6 -20
- package/src/components/account/hooks/useOtpVerification.tsx +4 -16
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +7 -21
- package/src/components/account/sections/ChangeEmailModal.tsx +21 -35
- package/src/components/account/sections/ChangePasswordSection.tsx +6 -10
- package/src/components/account/sections/ChangePhoneModal.tsx +22 -50
- package/src/components/account/sections/MyProfileSection.tsx +23 -37
- package/src/components/account/sections/PreferencesSection.tsx +25 -52
- package/src/components/account/sections/SecuritySection.tsx +10 -19
- package/src/components/account/sections/TokenSection.tsx +10 -22
- package/src/components/layouts/AppMobileNavBar.tsx +154 -1
- package/src/components/layouts/NavBar.tsx +3 -5
- package/src/components/layouts/NotificationsPopover.tsx +3 -5
- package/src/components/layouts/ProfilePopover.tsx +4 -6
- package/src/components/layouts/UsersSelectorPopover.tsx +7 -9
- package/src/components/modals/BuyCreditsModal.tsx +16 -18
- package/src/components/modals/CreditsDisabledModal.tsx +6 -6
- package/src/components/modals/PaidPlanRequiredModal.tsx +3 -5
- package/src/components/modals/cards/AddCardModal.tsx +27 -29
- package/src/components/modals/cards/CannotDeleteCardModal.tsx +8 -9
- package/src/components/modals/cards/CardFormFields.tsx +22 -25
- package/src/components/modals/cards/DeleteCardModal.tsx +8 -10
- package/src/components/navigation/CancelledSubscriptionBanner.tsx +2 -4
- package/src/components/navigation/OverdueInvoiceBanner.tsx +2 -4
- package/src/components/navigation/PendingCancellationBanner.tsx +2 -4
- package/src/components/navigation/ProjectSelectorPopover.tsx +6 -8
- package/src/components/navigation/UpcomingInvoiceBanner.tsx +2 -4
- package/src/components/navigation/subcomponents/BottomLinks.tsx +3 -5
- package/src/components/navigation/subcomponents/CreditsCard.tsx +1 -3
- package/src/components/navigation/subcomponents/PlanCard.tsx +1 -3
- package/src/components/navigation/subcomponents/ProjectSelector.tsx +3 -5
- package/src/components/pages/NotFoundPage.tsx +3 -5
- package/src/components/pages/notifications/Notifications.tsx +10 -13
- package/src/components/ui/buttons/CopyButton.tsx +5 -10
- package/src/components/ui/data-display/CardItem.tsx +5 -7
- package/src/components/ui/data-display/PaymentInfoCard.tsx +8 -10
- package/src/components/ui/feedback/CircularProgress.tsx +0 -4
- package/src/components/ui/feedback/DefaultCircularProgress.tsx +1 -3
- package/src/components/ui/form/ComboboxField.tsx +6 -11
- package/src/components/ui/form/DatePicker.tsx +2 -5
- package/src/components/ui/form/DateRangePicker.tsx +2 -5
- package/src/components/ui/form/PhoneInput.tsx +3 -5
- package/src/components/ui/form/SelectField.tsx +3 -6
- package/src/components/widgets/ImageUpload/ImageCropModal.tsx +11 -19
- package/src/components/widgets/ImageUpload/ImageTooSmallModal.tsx +5 -6
- package/src/index.ts +2 -12
- package/src/modules/cards/hooks/handle-delete-card.hook.ts +3 -8
- package/src/modules/images/utils/validate-image.ts +8 -23
- package/src/modules/plans/types/plan.type.ts +0 -3
- package/src/modules/plans/utils/map-api-plan-to-ui.ts +46 -103
- package/src/modules/subscriptions/utils/periodicity.ts +12 -29
- package/src/providers/auth.provider.tsx +1 -13
- package/src/server.ts +0 -2
- package/src/utils/format/currency.ts +7 -62
- package/src/utils/intl/locales.ts +2 -3
- package/dist/i18n/config.mjs +0 -13
- package/dist/i18n/config.mjs.map +0 -1
- package/dist/i18n/country-language.mjs +0 -74
- package/dist/i18n/country-language.mjs.map +0 -1
- package/dist/i18n/messages/en-us.mjs +0 -492
- package/dist/i18n/messages/en-us.mjs.map +0 -1
- package/dist/i18n/messages/es-es.mjs +0 -492
- package/dist/i18n/messages/es-es.mjs.map +0 -1
- package/dist/i18n/messages/index.mjs +0 -16
- package/dist/i18n/messages/index.mjs.map +0 -1
- package/dist/i18n/messages/pt-br.mjs +0 -505
- package/dist/i18n/messages/pt-br.mjs.map +0 -1
- package/dist/i18n/normalize.mjs +0 -12
- package/dist/i18n/normalize.mjs.map +0 -1
- package/dist/i18n/resolve-locale.mjs +0 -42
- package/dist/i18n/resolve-locale.mjs.map +0 -1
- package/dist/i18n.mjs +0 -14
- package/dist/i18n.mjs.map +0 -1
- package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs +0 -20
- package/dist/modules/accounts/hooks/use-currency-formatter.hook.mjs.map +0 -1
- package/dist/utils/intl/cookie-domain.mjs +0 -17
- package/dist/utils/intl/cookie-domain.mjs.map +0 -1
- package/dist/utils/intl/locale-cookie.mjs +0 -13
- package/dist/utils/intl/locale-cookie.mjs.map +0 -1
- package/src/i18n/config.ts +0 -17
- package/src/i18n/country-language.ts +0 -60
- package/src/i18n/messages/en-us.ts +0 -512
- package/src/i18n/messages/es-es.ts +0 -513
- package/src/i18n/messages/index.ts +0 -24
- package/src/i18n/messages/pt-br.ts +0 -536
- package/src/i18n/normalize.ts +0 -15
- package/src/i18n/resolve-locale.ts +0 -77
- package/src/i18n.ts +0 -10
- package/src/modules/accounts/hooks/use-currency-formatter.hook.tsx +0 -32
- package/src/utils/intl/cookie-domain.ts +0 -29
- package/src/utils/intl/locale-cookie.ts +0 -18
|
@@ -8,7 +8,6 @@ import useIsMobile from "../../../hooks/useIsMobile";
|
|
|
8
8
|
import { useCards } from "../../../modules/cards/hooks/cards.hook";
|
|
9
9
|
import { useModalManager } from "../../../store/useModalManager";
|
|
10
10
|
import { useIsDefaultWhitelabel } from "../../../providers/whitelabel.provider";
|
|
11
|
-
import { useTranslations } from "next-intl";
|
|
12
11
|
function PaymentInfoCard({
|
|
13
12
|
email,
|
|
14
13
|
selectedCardId,
|
|
@@ -18,7 +17,6 @@ function PaymentInfoCard({
|
|
|
18
17
|
hideDelete,
|
|
19
18
|
hideSetDefault
|
|
20
19
|
}) {
|
|
21
|
-
const translate = useTranslations();
|
|
22
20
|
const isMobile = useIsMobile();
|
|
23
21
|
const { openModal } = useModalManager();
|
|
24
22
|
const isDefaultWl = useIsDefaultWhitelabel();
|
|
@@ -62,11 +60,11 @@ function PaymentInfoCard({
|
|
|
62
60
|
if (!hasCards) {
|
|
63
61
|
return /* @__PURE__ */ jsxs("div", { className: "border border-zinc-200 rounded-lg overflow-hidden", children: [
|
|
64
62
|
email && /* @__PURE__ */ jsxs("div", { className: "flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3", children: [
|
|
65
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children:
|
|
63
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children: "E-mail" }),
|
|
66
64
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-950 flex-1", children: email })
|
|
67
65
|
] }),
|
|
68
66
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center h-[60px] px-4 gap-3", children: [
|
|
69
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children:
|
|
67
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children: "Pagamento" }),
|
|
70
68
|
/* @__PURE__ */ jsxs(
|
|
71
69
|
"button",
|
|
72
70
|
{
|
|
@@ -75,7 +73,7 @@ function PaymentInfoCard({
|
|
|
75
73
|
className: "flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit",
|
|
76
74
|
children: [
|
|
77
75
|
/* @__PURE__ */ jsx(IconPlus, { className: "size-[18px]" }),
|
|
78
|
-
/* @__PURE__ */ jsx("span", { className: "px-1.5", children:
|
|
76
|
+
/* @__PURE__ */ jsx("span", { className: "px-1.5", children: "Adicionar cart\xE3o" })
|
|
79
77
|
]
|
|
80
78
|
}
|
|
81
79
|
)
|
|
@@ -85,7 +83,7 @@ function PaymentInfoCard({
|
|
|
85
83
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
|
|
86
84
|
/* @__PURE__ */ jsxs("div", { className: "border border-zinc-200 rounded-lg overflow-hidden", children: [
|
|
87
85
|
email && /* @__PURE__ */ jsxs("div", { className: "flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3", children: [
|
|
88
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children:
|
|
86
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children: "E-mail" }),
|
|
89
87
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-950 flex-1", children: email })
|
|
90
88
|
] }),
|
|
91
89
|
/* @__PURE__ */ jsx(
|
|
@@ -94,7 +92,7 @@ function PaymentInfoCard({
|
|
|
94
92
|
className: "flex items-center px-4 py-4 cursor-pointer gap-3",
|
|
95
93
|
onClick: () => setIsExpanded((prev) => !prev),
|
|
96
94
|
children: !isExpanded ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children:
|
|
95
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-small-medium text-zinc-500 w-[100px]", children: "Pagamento" }),
|
|
98
96
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0.5 flex-1 min-w-0", children: [
|
|
99
97
|
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-zinc-950 truncate", children: selectedCard?.name }),
|
|
100
98
|
/* @__PURE__ */ jsxs("span", { className: "paragraph-small-medium text-zinc-950", children: [
|
|
@@ -105,7 +103,7 @@ function PaymentInfoCard({
|
|
|
105
103
|
selectedCard && /* @__PURE__ */ jsx(CardBrandIcon, { brand: selectedCard.brand }),
|
|
106
104
|
/* @__PURE__ */ jsx("div", { className: "size-8 flex items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(IconChevronDown, { className: "size-[18px] text-zinc-500" }) })
|
|
107
105
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
108
|
-
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-zinc-950 flex-1", children:
|
|
106
|
+
/* @__PURE__ */ jsx("span", { className: "paragraph-small-semibold text-zinc-950 flex-1", children: "Selecione a forma de pagamento" }),
|
|
109
107
|
/* @__PURE__ */ jsx("div", { className: "size-8 flex items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(IconChevronDown, { className: "size-[18px] text-zinc-500 rotate-180" }) })
|
|
110
108
|
] })
|
|
111
109
|
}
|
|
@@ -133,7 +131,7 @@ function PaymentInfoCard({
|
|
|
133
131
|
type: "button",
|
|
134
132
|
onClick: onManageCards,
|
|
135
133
|
className: `flex items-center justify-center h-10 px-4 paragraph-small-semibold rounded-lg transition-colors cursor-pointer mt-2 ${isDefaultWl ? "text-cyan-600 border border-cyan-200 hover:bg-cyan-50" : "text-zinc-600 border border-zinc-200 hover:bg-zinc-50"}`,
|
|
136
|
-
children:
|
|
134
|
+
children: "Gerenciar cart\xF5es"
|
|
137
135
|
}
|
|
138
136
|
)
|
|
139
137
|
]
|
|
@@ -148,7 +146,7 @@ function PaymentInfoCard({
|
|
|
148
146
|
className: "flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit",
|
|
149
147
|
children: [
|
|
150
148
|
/* @__PURE__ */ jsx(IconPlus, { className: "size-[18px]" }),
|
|
151
|
-
/* @__PURE__ */ jsx("span", { className: "px-1.5", children: isExpanded ?
|
|
149
|
+
/* @__PURE__ */ jsx("span", { className: "px-1.5", children: isExpanded ? "Adicionar cart\xE3o" : "Nova forma de pagamento" })
|
|
152
150
|
]
|
|
153
151
|
}
|
|
154
152
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/data-display/PaymentInfoCard.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useState } from 'react';\nimport { IconChevronDown, IconPlus } from '@tabler/icons-react';\nimport { CardBrandIcon } from './CardBrandIcons';\nimport { CardItem } from './CardItem';\nimport useIsMobile from '../../../hooks/useIsMobile';\nimport { useCards } from '../../../modules/cards/hooks/cards.hook';\nimport { useModalManager } from '../../../store/useModalManager';\nimport { useIsDefaultWhitelabel } from '../../../providers/whitelabel.provider';\nimport type { Card } from '../../../modules/cards/types';\nimport { useTranslations } from 'next-intl';\n\ntype PaymentInfoCardProps = {\n email?: string;\n selectedCardId: string;\n onCardSelect: (cardId: string) => void;\n onManageCards?: () => void;\n onOpenAddCard?: () => void;\n hideDelete?: boolean;\n hideSetDefault?: boolean;\n};\n\nexport function PaymentInfoCard({\n email,\n selectedCardId,\n onCardSelect,\n onManageCards,\n onOpenAddCard,\n hideDelete,\n hideSetDefault,\n}: PaymentInfoCardProps) {\n const translate = useTranslations();\n const isMobile = useIsMobile();\n const { openModal } = useModalManager();\n const isDefaultWl = useIsDefaultWhitelabel();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const { data: cardsData } = useCards();\n const cards = cardsData?.data ?? [];\n\n const selectedCard = cards.find(\n (card) => card.id.toString() === selectedCardId.toString(),\n );\n\n const hasCards = cards.length > 0;\n\n const hasMoreThan3Cards = cards.length > 3;\n const shouldShowManageButton = isMobile && hasMoreThan3Cards;\n const displayedCards = shouldShowManageButton ? cards.slice(0, 3) : cards;\n\n const handleOpenAddCardModal = useCallback(() => {\n if (onOpenAddCard) {\n onOpenAddCard();\n return;\n }\n openModal('addCardModal', {\n onCardAdded: (cardId: string) => onCardSelect(cardId),\n });\n }, [openModal, onOpenAddCard, onCardSelect]);\n\n const handleSelectCard = useCallback(\n (cardId: string) => {\n onCardSelect(cardId);\n setIsExpanded(false);\n },\n [onCardSelect],\n );\n\n const handleAfterDelete = useCallback(\n (card: Card) => {\n if (card.id.toString() === selectedCardId.toString()) {\n const remaining = cards.filter((c) => c.id !== card.id);\n if (remaining.length > 0) {\n onCardSelect(remaining[0].id.toString());\n }\n }\n },\n [cards, selectedCardId, onCardSelect],\n );\n\n if (!hasCards) {\n return (\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">{translate('common.cards.paymentInfo.email')}</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n <div className=\"flex items-center h-[60px] px-4 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">{translate('common.cards.paymentInfo.payment')}</span>\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">{translate('common.cards.paymentInfo.addCard')}</span>\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">{translate('common.cards.paymentInfo.email')}</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n\n <div\n className=\"flex items-center px-4 py-4 cursor-pointer gap-3\"\n onClick={() => setIsExpanded((prev) => !prev)}\n >\n {!isExpanded ? (\n <>\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">{translate('common.cards.paymentInfo.payment')}</span>\n <div className=\"flex flex-col gap-0.5 flex-1 min-w-0\">\n <span className=\"paragraph-small-semibold text-zinc-950 truncate\">\n {selectedCard?.name}\n </span>\n <span className=\"paragraph-small-medium text-zinc-950\">\n •••• {selectedCard?.number?.replaceAll(/\\D/g, '')?.slice(-4)}\n </span>\n </div>\n {selectedCard && <CardBrandIcon brand={selectedCard.brand} />}\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500\" />\n </div>\n </>\n ) : (\n <>\n <span className=\"paragraph-small-semibold text-zinc-950 flex-1\">\n {translate('common.cards.paymentInfo.selectPaymentMethod')}\n </span>\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500 rotate-180\" />\n </div>\n </>\n )}\n </div>\n\n <div\n className={`flex flex-col gap-2 px-4 overflow-hidden transition-all duration-300 ease-in-out ${\n isExpanded ? 'max-h-[500px] pb-4 opacity-100' : 'max-h-0 pb-0 opacity-0'\n }`}\n >\n {displayedCards.map((card) => (\n <CardItem\n key={card.id}\n card={card}\n isSelected={card.id.toString() === selectedCardId.toString()}\n onSelect={() => handleSelectCard(card.id.toString())}\n hideDelete={hideDelete}\n hideSetDefault={hideSetDefault}\n onAfterDelete={handleAfterDelete}\n />\n ))}\n {shouldShowManageButton && onManageCards && (\n <button\n type=\"button\"\n onClick={onManageCards}\n className={`flex items-center justify-center h-10 px-4 paragraph-small-semibold rounded-lg transition-colors cursor-pointer mt-2 ${\n isDefaultWl\n ? 'text-cyan-600 border border-cyan-200 hover:bg-cyan-50'\n : 'text-zinc-600 border border-zinc-200 hover:bg-zinc-50'\n }`}\n >\n {translate('common.cards.paymentInfo.manageCards')}\n </button>\n )}\n </div>\n </div>\n\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">\n {isExpanded ? translate('common.cards.paymentInfo.addCard') : translate('common.cards.paymentInfo.newPaymentMethod')}\n </span>\n </button>\n </div>\n );\n}\n"],"mappings":";AAsFU,SAmCE,UAlCA,KADF;AApFV,SAAS,aAAa,gBAAgB;AACtC,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AAEvC,SAAS,uBAAuB;AAYzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,YAAY,gBAAgB;AAClC,QAAM,WAAW,YAAY;AAC7B,QAAM,EAAE,UAAU,IAAI,gBAAgB;AACtC,QAAM,cAAc,uBAAuB;AAE3C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAElD,QAAM,EAAE,MAAM,UAAU,IAAI,SAAS;AACrC,QAAM,QAAQ,WAAW,QAAQ,CAAC;AAElC,QAAM,eAAe,MAAM;AAAA,IACzB,CAAC,SAAS,KAAK,GAAG,SAAS,MAAM,eAAe,SAAS;AAAA,EAC3D;AAEA,QAAM,WAAW,MAAM,SAAS;AAEhC,QAAM,oBAAoB,MAAM,SAAS;AACzC,QAAM,yBAAyB,YAAY;AAC3C,QAAM,iBAAiB,yBAAyB,MAA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A,eAAe;AAAA;AAAA,cANV,KAAK;AAAA,YAOZ,CACD;AAAA,YACA,0BAA0B,iBACzB;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,SAAS;AAAA,gBACT,WAAW,wHACT,cACI,0DACA,uDACN;AAAA,gBAEC,oBAAU,sCAAsC;AAAA;AAAA,YACnD;AAAA;AAAA;AAAA,MAEJ;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,WAAU;AAAA,QAEV;AAAA,8BAAC,YAAS,WAAU,eAAc;AAAA,UAClC,oBAAC,UAAK,WAAU,UACb,uBAAa,UAAU,kCAAkC,IAAI,UAAU,2CAA2C,GACrH;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/data-display/PaymentInfoCard.tsx"],"sourcesContent":["'use client';\n\nimport { useCallback, useState } from 'react';\nimport { IconChevronDown, IconPlus } from '@tabler/icons-react';\nimport { CardBrandIcon } from './CardBrandIcons';\nimport { CardItem } from './CardItem';\nimport useIsMobile from '../../../hooks/useIsMobile';\nimport { useCards } from '../../../modules/cards/hooks/cards.hook';\nimport { useModalManager } from '../../../store/useModalManager';\nimport { useIsDefaultWhitelabel } from '../../../providers/whitelabel.provider';\nimport type { Card } from '../../../modules/cards/types';\n\ntype PaymentInfoCardProps = {\n email?: string;\n selectedCardId: string;\n onCardSelect: (cardId: string) => void;\n onManageCards?: () => void;\n onOpenAddCard?: () => void;\n hideDelete?: boolean;\n hideSetDefault?: boolean;\n};\n\nexport function PaymentInfoCard({\n email,\n selectedCardId,\n onCardSelect,\n onManageCards,\n onOpenAddCard,\n hideDelete,\n hideSetDefault,\n}: PaymentInfoCardProps) {\n const isMobile = useIsMobile();\n const { openModal } = useModalManager();\n const isDefaultWl = useIsDefaultWhitelabel();\n\n const [isExpanded, setIsExpanded] = useState(false);\n\n const { data: cardsData } = useCards();\n const cards = cardsData?.data ?? [];\n\n const selectedCard = cards.find(\n (card) => card.id.toString() === selectedCardId.toString(),\n );\n\n const hasCards = cards.length > 0;\n\n const hasMoreThan3Cards = cards.length > 3;\n const shouldShowManageButton = isMobile && hasMoreThan3Cards;\n const displayedCards = shouldShowManageButton ? cards.slice(0, 3) : cards;\n\n const handleOpenAddCardModal = useCallback(() => {\n if (onOpenAddCard) {\n onOpenAddCard();\n return;\n }\n openModal('addCardModal', {\n onCardAdded: (cardId: string) => onCardSelect(cardId),\n });\n }, [openModal, onOpenAddCard, onCardSelect]);\n\n const handleSelectCard = useCallback(\n (cardId: string) => {\n onCardSelect(cardId);\n setIsExpanded(false);\n },\n [onCardSelect],\n );\n\n const handleAfterDelete = useCallback(\n (card: Card) => {\n if (card.id.toString() === selectedCardId.toString()) {\n const remaining = cards.filter((c) => c.id !== card.id);\n if (remaining.length > 0) {\n onCardSelect(remaining[0].id.toString());\n }\n }\n },\n [cards, selectedCardId, onCardSelect],\n );\n\n if (!hasCards) {\n return (\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">E-mail</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n <div className=\"flex items-center h-[60px] px-4 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">Pagamento</span>\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">Adicionar cartão</span>\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"border border-zinc-200 rounded-lg overflow-hidden\">\n {email && (\n <div className=\"flex items-center h-[60px] px-4 border-b border-zinc-200 gap-3\">\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">E-mail</span>\n <span className=\"paragraph-small-medium text-zinc-950 flex-1\">{email}</span>\n </div>\n )}\n\n <div\n className=\"flex items-center px-4 py-4 cursor-pointer gap-3\"\n onClick={() => setIsExpanded((prev) => !prev)}\n >\n {!isExpanded ? (\n <>\n <span className=\"paragraph-small-medium text-zinc-500 w-[100px]\">Pagamento</span>\n <div className=\"flex flex-col gap-0.5 flex-1 min-w-0\">\n <span className=\"paragraph-small-semibold text-zinc-950 truncate\">\n {selectedCard?.name}\n </span>\n <span className=\"paragraph-small-medium text-zinc-950\">\n •••• {selectedCard?.number?.replaceAll(/\\D/g, '')?.slice(-4)}\n </span>\n </div>\n {selectedCard && <CardBrandIcon brand={selectedCard.brand} />}\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500\" />\n </div>\n </>\n ) : (\n <>\n <span className=\"paragraph-small-semibold text-zinc-950 flex-1\">\n Selecione a forma de pagamento\n </span>\n <div className=\"size-8 flex items-center justify-center rounded-lg\">\n <IconChevronDown className=\"size-[18px] text-zinc-500 rotate-180\" />\n </div>\n </>\n )}\n </div>\n\n <div\n className={`flex flex-col gap-2 px-4 overflow-hidden transition-all duration-300 ease-in-out ${\n isExpanded ? 'max-h-[500px] pb-4 opacity-100' : 'max-h-0 pb-0 opacity-0'\n }`}\n >\n {displayedCards.map((card) => (\n <CardItem\n key={card.id}\n card={card}\n isSelected={card.id.toString() === selectedCardId.toString()}\n onSelect={() => handleSelectCard(card.id.toString())}\n hideDelete={hideDelete}\n hideSetDefault={hideSetDefault}\n onAfterDelete={handleAfterDelete}\n />\n ))}\n {shouldShowManageButton && onManageCards && (\n <button\n type=\"button\"\n onClick={onManageCards}\n className={`flex items-center justify-center h-10 px-4 paragraph-small-semibold rounded-lg transition-colors cursor-pointer mt-2 ${\n isDefaultWl\n ? 'text-cyan-600 border border-cyan-200 hover:bg-cyan-50'\n : 'text-zinc-600 border border-zinc-200 hover:bg-zinc-50'\n }`}\n >\n Gerenciar cartões\n </button>\n )}\n </div>\n </div>\n\n <button\n type=\"button\"\n onClick={handleOpenAddCardModal}\n className=\"flex items-center h-8 px-2 paragraph-small-semibold text-zinc-950 border border-zinc-200 rounded-md hover:border-zinc-400 transition-colors cursor-pointer w-fit\"\n >\n <IconPlus className=\"size-[18px]\" />\n <span className=\"px-1.5\">\n {isExpanded ? 'Adicionar cartão' : 'Nova forma de pagamento'}\n </span>\n </button>\n </div>\n );\n}\n"],"mappings":";AAoFU,SAmCE,UAlCA,KADF;AAlFV,SAAS,aAAa,gBAAgB;AACtC,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,OAAO,iBAAiB;AACxB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AAahC,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,WAAW,YAAY;AAC7B,QAAM,EAAE,UAAU,IAAI,gBAAgB;AACtC,QAAM,cAAc,uBAAuB;AAE3C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAElD,QAAM,EAAE,MAAM,UAAU,IAAI,SAAS;AACrC,QAAM,QAAQ,WAAW,QAAQ,CAAC;AAElC,QAAM,eAAe,MAAM;AAAA,IACzB,CAAC,SAAS,KAAK,GAAG,SAAS,MAAM,eAAe,SAAS;AAAA,EAC3D;AAEA,QAAM,WAAW,MAAM,SAAS;AAEhC,QAAM,oBAAoB,MAAM,SAAS;AACzC,QAAM,yBAAyB,YAAY;AAC3C,QAAM,iBAAiB,yBAAyB,MAAM,MAAM,GAAG,CAAC,IAAI;AAEpE,QAAM,yBAAyB,YAAY,MAAM;AAC/C,QAAI,eAAe;AACjB,oBAAc;AACd;AAAA,I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;AAAA,YAED;AAAA;AAAA;AAAA,MAEJ;AAAA,OACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,SAAS;AAAA,QACT,WAAU;AAAA,QAEV;AAAA,8BAAC,YAAS,WAAU,eAAc;AAAA,UAClC,oBAAC,UAAK,WAAU,UACb,uBAAa,wBAAqB,2BACrC;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/feedback/CircularProgress.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport {\n calculateRadius,\n calculateCircumference,\n calculatePercentage,\n calculateCircularProgressOffset,\n} from \"../../../infra/utils/percentage\";\n\ninterface CircularProgressProps {\n current: number;\n total: number;\n size?: number;\n strokeWidth?: number;\n children?: ReactNode;\n}\n\nexport default function CircularProgress({\n current,\n total,\n size = 62,\n strokeWidth = 3,\n children,\n}: CircularProgressProps) {\n const radius = calculateRadius(size, strokeWidth);\n const circumference = calculateCircumference(radius);\n const percentage = calculatePercentage(current, total);\n const offset = calculateCircularProgressOffset(percentage, circumference);\n\n return (\n <div\n className=\"relative flex items-center justify-center\"\n style={{ width: size, height: size }}\n role=\"progressbar\"\n aria-valuenow={current}\n aria-valuemin={0}\n aria-valuemax={total}\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/feedback/CircularProgress.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport {\n calculateRadius,\n calculateCircumference,\n calculatePercentage,\n calculateCircularProgressOffset,\n} from \"../../../infra/utils/percentage\";\n\ninterface CircularProgressProps {\n current: number;\n total: number;\n size?: number;\n strokeWidth?: number;\n children?: ReactNode;\n}\n\nexport default function CircularProgress({\n current,\n total,\n size = 62,\n strokeWidth = 3,\n children,\n}: CircularProgressProps) {\n const radius = calculateRadius(size, strokeWidth);\n const circumference = calculateCircumference(radius);\n const percentage = calculatePercentage(current, total);\n const offset = calculateCircularProgressOffset(percentage, circumference);\n\n return (\n <div\n className=\"relative flex items-center justify-center\"\n style={{ width: size, height: size }}\n role=\"progressbar\"\n aria-valuenow={current}\n aria-valuemin={0}\n aria-valuemax={total}\n aria-label=\"Progresso\"\n >\n <svg width={size} height={size} className=\"absolute\">\n <circle\n cx={size / 2}\n cy={size / 2}\n r={radius}\n stroke=\"var(--color-gray-50)\"\n strokeWidth={strokeWidth}\n fill=\"white\"\n />\n\n <circle\n cx={size / 2}\n cy={size / 2}\n r={radius}\n stroke=\"var(--color-gray-950)\"\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={offset}\n strokeLinecap=\"round\"\n transform={`rotate(-90 ${size / 2} ${size / 2})`}\n className=\"transition-all duration-300 ease-in-out\"\n />\n </svg>\n\n <div className=\"relative z-10 flex items-center justify-center w-[50px] h-[50px] rounded-full bg-gray-50 paragraph-small-semibold\">\n {children ?? (\n <>\n <span className=\"text-gray-600\">{current}</span>\n <span className=\"text-gray-500\">/</span>\n <span className=\"text-gray-600\">{total}</span>\n </>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":"AAsCM,SA2BI,UA1BF,KADF;AArCN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUQ,SAAR,iBAAkC;AAAA,EACvC;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAAA,EACd;AACF,GAA0B;AACxB,QAAM,SAAS,gBAAgB,MAAM,WAAW;AAChD,QAAM,gBAAgB,uBAAuB,MAAM;AACnD,QAAM,aAAa,oBAAoB,SAAS,KAAK;AACrD,QAAM,SAAS,gCAAgC,YAAY,aAAa;AAExE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,MACnC,MAAK;AAAA,MACL,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,cAAW;AAAA,MAEX;AAAA,6BAAC,SAAI,OAAO,MAAM,QAAQ,MAAM,WAAU,YACxC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,OAAO;AAAA,cACX,IAAI,OAAO;AAAA,cACX,GAAG;AAAA,cACH,QAAO;AAAA,cACP;AAAA,cACA,MAAK;AAAA;AAAA,UACP;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC,IAAI,OAAO;AAAA,cACX,IAAI,OAAO;AAAA,cACX,GAAG;AAAA,cACH,QAAO;AAAA,cACP;AAAA,cACA,MAAK;AAAA,cACL,iBAAiB;AAAA,cACjB,kBAAkB;AAAA,cAClB,eAAc;AAAA,cACd,WAAW,cAAc,OAAO,CAAC,IAAI,OAAO,CAAC;AAAA,cAC7C,WAAU;AAAA;AAAA,UACZ;AAAA,WACF;AAAA,QAEA,oBAAC,SAAI,WAAU,qHACZ,sBACC,iCACE;AAAA,8BAAC,UAAK,WAAU,iBAAiB,mBAAQ;AAAA,UACzC,oBAAC,UAAK,WAAU,iBAAgB,eAAC;AAAA,UACjC,oBAAC,UAAK,WAAU,iBAAiB,iBAAM;AAAA,WACzC,GAEJ;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
3
|
import {
|
|
5
4
|
calculateRadius,
|
|
6
5
|
calculateCircumference,
|
|
@@ -14,7 +13,6 @@ function DefaultCircularProgress({
|
|
|
14
13
|
size = 62,
|
|
15
14
|
strokeWidth = 3
|
|
16
15
|
}) {
|
|
17
|
-
const translate = useTranslations();
|
|
18
16
|
const isDefaultWl = useIsDefaultWhitelabel();
|
|
19
17
|
const radius = calculateRadius(size, strokeWidth);
|
|
20
18
|
const circumference = calculateCircumference(radius);
|
|
@@ -29,7 +27,7 @@ function DefaultCircularProgress({
|
|
|
29
27
|
"aria-valuenow": current,
|
|
30
28
|
"aria-valuemin": 0,
|
|
31
29
|
"aria-valuemax": total,
|
|
32
|
-
"aria-label":
|
|
30
|
+
"aria-label": "Progresso de exporta\xE7\xE3o",
|
|
33
31
|
children: /* @__PURE__ */ jsxs("svg", { width: size, height: size, className: "absolute", children: [
|
|
34
32
|
/* @__PURE__ */ jsx(
|
|
35
33
|
"circle",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/feedback/DefaultCircularProgress.tsx"],"sourcesContent":["'use client';\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/feedback/DefaultCircularProgress.tsx"],"sourcesContent":["'use client';\n\nimport {\n calculateRadius,\n calculateCircumference,\n calculatePercentage,\n calculateCircularProgressOffset,\n} from \"../../../infra/utils/percentage\";\nimport { useIsDefaultWhitelabel } from \"../../../providers/whitelabel.provider\";\n\ninterface CircularProgressProps {\n current: number;\n total: number;\n size?: number;\n strokeWidth?: number;\n}\n\nexport default function DefaultCircularProgress({\n current,\n total,\n size = 62,\n strokeWidth = 3,\n}: CircularProgressProps) {\n const isDefaultWl = useIsDefaultWhitelabel();\n const radius = calculateRadius(size, strokeWidth);\n const circumference = calculateCircumference(radius);\n const percentage = calculatePercentage(current, total);\n const offset = calculateCircularProgressOffset(percentage, circumference);\n\n return (\n <div\n className=\"relative flex items-center justify-center\"\n style={{ width: size, height: size }}\n role=\"progressbar\"\n aria-valuenow={current}\n aria-valuemin={0}\n aria-valuemax={total}\n aria-label=\"Progresso de exportação\"\n >\n <svg width={size} height={size} className=\"absolute\">\n <circle\n cx={size / 2}\n cy={size / 2}\n r={radius}\n stroke=\"var(--color-zinc-200)\"\n strokeWidth={strokeWidth}\n fill=\"none\"\n />\n <circle\n cx={size / 2}\n cy={size / 2}\n r={radius}\n stroke={isDefaultWl ? \"var(--color-cyan-300)\" : \"var(--color-zinc-300)\"}\n strokeWidth={strokeWidth}\n fill=\"none\"\n strokeDasharray={circumference}\n strokeDashoffset={offset}\n strokeLinecap=\"round\"\n transform={`rotate(-90 ${size / 2} ${size / 2})`}\n className=\"transition-all duration-300 ease-in-out\"\n />\n </svg>\n </div>\n );\n}\n"],"mappings":";AAuCM,SACE,KADF;AArCN;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AASxB,SAAR,wBAAyC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,cAAc;AAChB,GAA0B;AACxB,QAAM,cAAc,uBAAuB;AAC3C,QAAM,SAAS,gBAAgB,MAAM,WAAW;AAChD,QAAM,gBAAgB,uBAAuB,MAAM;AACnD,QAAM,aAAa,oBAAoB,SAAS,KAAK;AACrD,QAAM,SAAS,gCAAgC,YAAY,aAAa;AAExE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO,EAAE,OAAO,MAAM,QAAQ,KAAK;AAAA,MACnC,MAAK;AAAA,MACL,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,cAAW;AAAA,MAEX,+BAAC,SAAI,OAAO,MAAM,QAAQ,MAAM,WAAU,YACxC;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI,OAAO;AAAA,YACX,IAAI,OAAO;AAAA,YACX,GAAG;AAAA,YACH,QAAO;AAAA,YACP;AAAA,YACA,MAAK;AAAA;AAAA,QACP;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI,OAAO;AAAA,YACX,IAAI,OAAO;AAAA,YACX,GAAG;AAAA,YACH,QAAQ,cAAc,0BAA0B;AAAA,YAChD;AAAA,YACA,MAAK;AAAA,YACL,iBAAiB;AAAA,YACjB,kBAAkB;AAAA,YAClB,eAAc;AAAA,YACd,WAAW,cAAc,OAAO,CAAC,IAAI,OAAO,CAAC;AAAA,YAC7C,WAAU;AAAA;AAAA,QACZ;AAAA,SACF;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useMemo } from "react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
4
|
import { IconCheck, IconChevronDown, IconSearch } from "@tabler/icons-react";
|
|
6
5
|
import { Popover, PopoverContent, PopoverTrigger } from "../overlay/Popover";
|
|
7
6
|
import { cn } from "../../../infra/utils/clsx";
|
|
8
7
|
function ComboboxField({
|
|
9
8
|
options,
|
|
10
9
|
label,
|
|
11
|
-
placeholder,
|
|
12
|
-
searchPlaceholder,
|
|
13
|
-
emptyMessage,
|
|
10
|
+
placeholder = "Selecione uma op\xE7\xE3o",
|
|
11
|
+
searchPlaceholder = "Buscar...",
|
|
12
|
+
emptyMessage = "Nenhuma op\xE7\xE3o encontrada.",
|
|
14
13
|
value,
|
|
15
14
|
onChange,
|
|
16
15
|
disabled = false,
|
|
@@ -18,10 +17,6 @@ function ComboboxField({
|
|
|
18
17
|
className,
|
|
19
18
|
containerClassName
|
|
20
19
|
}) {
|
|
21
|
-
const translate = useTranslations();
|
|
22
|
-
const resolvedPlaceholder = placeholder ?? translate("common.forms.combobox.placeholder");
|
|
23
|
-
const resolvedSearchPlaceholder = searchPlaceholder ?? translate("common.forms.combobox.searchPlaceholder");
|
|
24
|
-
const resolvedEmptyMessage = emptyMessage ?? translate("common.forms.combobox.emptyMessage");
|
|
25
20
|
const [open, setOpen] = useState(false);
|
|
26
21
|
const [search, setSearch] = useState("");
|
|
27
22
|
const selectedOption = useMemo(
|
|
@@ -64,7 +59,7 @@ function ComboboxField({
|
|
|
64
59
|
className
|
|
65
60
|
),
|
|
66
61
|
children: [
|
|
67
|
-
/* @__PURE__ */ jsx("span", { className: cn("truncate text-left", !selectedOption && "text-gray-400"), children: selectedOption ? selectedOption.displayValue ?? selectedOption.label :
|
|
62
|
+
/* @__PURE__ */ jsx("span", { className: cn("truncate text-left", !selectedOption && "text-gray-400"), children: selectedOption ? selectedOption.displayValue ?? selectedOption.label : placeholder }),
|
|
68
63
|
icon ?? /* @__PURE__ */ jsx(
|
|
69
64
|
IconChevronDown,
|
|
70
65
|
{
|
|
@@ -92,14 +87,14 @@ function ComboboxField({
|
|
|
92
87
|
"input",
|
|
93
88
|
{
|
|
94
89
|
autoFocus: true,
|
|
95
|
-
placeholder:
|
|
90
|
+
placeholder: searchPlaceholder,
|
|
96
91
|
value: search,
|
|
97
92
|
onChange: (e) => setSearch(e.target.value),
|
|
98
93
|
className: "flex h-full w-full bg-transparent text-sm outline-none placeholder:text-gray-400 paragraph-small-medium text-gray-950"
|
|
99
94
|
}
|
|
100
95
|
)
|
|
101
96
|
] }),
|
|
102
|
-
/* @__PURE__ */ jsx("div", { className: "overflow-y-auto max-h-[280px] p-1", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-6 text-center paragraph-small-medium text-gray-500", children:
|
|
97
|
+
/* @__PURE__ */ jsx("div", { className: "overflow-y-auto max-h-[280px] p-1", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-6 text-center paragraph-small-medium text-gray-500", children: emptyMessage }) : filteredOptions.map((option) => {
|
|
103
98
|
const isSelected = value === option.value;
|
|
104
99
|
return /* @__PURE__ */ jsxs(
|
|
105
100
|
"div",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/form/ComboboxField.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useMemo } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/form/ComboboxField.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useMemo } from 'react';\nimport { IconCheck, IconChevronDown, IconSearch } from '@tabler/icons-react';\nimport { Popover, PopoverContent, PopoverTrigger } from '../overlay/Popover';\nimport { cn } from '../../../infra/utils/clsx';\n\nexport type ComboboxOption = {\n value: string;\n label: string;\n displayValue?: string;\n};\n\ninterface ComboboxFieldProps {\n options: ComboboxOption[];\n label?: string;\n placeholder?: string;\n searchPlaceholder?: string;\n emptyMessage?: string;\n value?: string;\n onChange?: (value: string) => void;\n disabled?: boolean;\n icon?: React.ReactNode;\n className?: string;\n containerClassName?: string;\n}\n\nexport function ComboboxField({\n options,\n label,\n placeholder = 'Selecione uma opção',\n searchPlaceholder = 'Buscar...',\n emptyMessage = 'Nenhuma opção encontrada.',\n value,\n onChange,\n disabled = false,\n icon,\n className,\n containerClassName,\n}: ComboboxFieldProps) {\n const [open, setOpen] = useState(false);\n const [search, setSearch] = useState('');\n\n const selectedOption = useMemo(\n () => options.find((o) => o.value === value),\n [options, value]\n );\n\n const filteredOptions = useMemo(() => {\n const q = search.trim().toLowerCase();\n if (!q) return options;\n return options.filter((o) => o.label.toLowerCase().includes(q));\n }, [options, search]);\n\n const handleSelect = (optionValue: string) => {\n onChange?.(optionValue);\n setOpen(false);\n setSearch('');\n };\n\n return (\n <div className={cn('flex flex-col gap-1.5', containerClassName)}>\n {label && (\n <div className=\"flex items-center gap-1 paragraph-xsmall-semibold\">\n <span className=\"text-gray-600\">{label}</span>\n </div>\n )}\n\n <Popover\n open={open}\n onOpenChange={(v) => {\n if (!disabled) {\n setOpen(v);\n if (!v) setSearch('');\n }\n }}\n >\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n disabled={disabled}\n className={cn(\n 'paragraph-small-medium w-full h-10 text-gray-950 px-4 transition-colors',\n 'flex items-center justify-between gap-2 rounded-md border bg-transparent',\n 'border-gray-200 hover:border-gray-400 focus:border-gray-950 focus:outline-none',\n disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer',\n className\n )}\n >\n <span className={cn('truncate text-left', !selectedOption && 'text-gray-400')}>\n {selectedOption\n ? (selectedOption.displayValue ?? selectedOption.label)\n : placeholder}\n </span>\n {icon ?? (\n <IconChevronDown\n className={cn(\n 'size-4 opacity-50 shrink-0 transition-all duration-200',\n open && 'rotate-180 opacity-100 text-gray-950'\n )}\n />\n )}\n </button>\n </PopoverTrigger>\n\n <PopoverContent\n className=\"p-0 overflow-hidden rounded-md border shadow-md\"\n align=\"start\"\n sideOffset={4}\n style={{ width: 'var(--radix-popover-trigger-width)' }}\n onWheel={(e) => e.stopPropagation()}\n >\n <div className=\"flex items-center gap-2 border-b border-gray-100 px-3 h-9\">\n <IconSearch className=\"size-4 shrink-0 opacity-50 text-gray-500\" />\n <input\n autoFocus\n placeholder={searchPlaceholder}\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n className=\"flex h-full w-full bg-transparent text-sm outline-none placeholder:text-gray-400 paragraph-small-medium text-gray-950\"\n />\n </div>\n\n <div className=\"overflow-y-auto max-h-[280px] p-1\">\n {filteredOptions.length === 0 ? (\n <p className=\"py-6 text-center paragraph-small-medium text-gray-500\">{emptyMessage}</p>\n ) : (\n filteredOptions.map((option) => {\n const isSelected = value === option.value;\n return (\n <div\n key={option.value}\n className={cn(\n 'flex items-center gap-2 rounded-sm px-2 h-9 cursor-pointer select-none',\n 'paragraph-small-medium text-gray-950',\n 'hover:bg-gray-100',\n isSelected && 'bg-gray-50'\n )}\n onClick={() => handleSelect(option.value)}\n >\n <span className=\"flex-1 truncate\">{option.label}</span>\n {isSelected && <IconCheck className=\"size-4 shrink-0 text-pages-600\" />}\n </div>\n );\n })\n )}\n </div>\n </PopoverContent>\n </Popover>\n </div>\n );\n}\n\nexport default ComboboxField;\n"],"mappings":";AAgEU,cAcA,YAdA;AA9DV,SAAS,UAAU,eAAe;AAClC,SAAS,WAAW,iBAAiB,kBAAkB;AACvD,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,UAAU;AAsBZ,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AACF,GAAuB;AACrB,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,CAAC,QA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AA,UAEJ,GACF;AAAA,UAEA;AAAA,YAAC;AAAA;AAAA,cACC,WAAU;AAAA,cACV,OAAM;AAAA,cACN,YAAY;AAAA,cACZ,OAAO,EAAE,OAAO,qCAAqC;AAAA,cACrD,SAAS,CAAC,MAAM,EAAE,gBAAgB;AAAA,cAElC;AAAA,qCAAC,SAAI,WAAU,6DACb;AAAA,sCAAC,cAAW,WAAU,4CAA2C;AAAA,kBACjE;AAAA,oBAAC;AAAA;AAAA,sBACC,WAAS;AAAA,sBACT,aAAa;AAAA,sBACb,OAAO;AAAA,sBACP,UAAU,CAAC,MAAM,UAAU,EAAE,OAAO,KAAK;AAAA,sBACzC,WAAU;AAAA;AAAA,kBACZ;AAAA,mBACF;AAAA,gBAEA,oBAAC,SAAI,WAAU,qCACZ,0BAAgB,WAAW,IAC1B,oBAAC,OAAE,WAAU,yDAAyD,wBAAa,IAEnF,gBAAgB,IAAI,CAAC,WAAW;AAC9B,wBAAM,aAAa,UAAU,OAAO;AACpC,yBACE;AAAA,oBAAC;AAAA;AAAA,sBAEC,WAAW;AAAA,wBACT;AAAA,wBACA;AAAA,wBACA;AAAA,wBACA,cAAc;AAAA,sBAChB;AAAA,sBACA,SAAS,MAAM,aAAa,OAAO,KAAK;AAAA,sBAExC;AAAA,4CAAC,UAAK,WAAU,mBAAmB,iBAAO,OAAM;AAAA,wBAC/C,cAAc,oBAAC,aAAU,WAAU,kCAAiC;AAAA;AAAA;AAAA,oBAVhE,OAAO;AAAA,kBAWd;AAAA,gBAEJ,CAAC,GAEL;AAAA;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAEA,IAAO,wBAAQ;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, forwardRef, useEffect } from "react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
4
|
import { format } from "date-fns";
|
|
6
5
|
import { Calendar } from "./Calendar";
|
|
7
6
|
import { Popover, PopoverContent, PopoverTrigger } from "../overlay/Popover";
|
|
@@ -11,9 +10,7 @@ const isoParaDataLocal = (iso) => {
|
|
|
11
10
|
return new Date(ano, mes - 1, dia);
|
|
12
11
|
};
|
|
13
12
|
const DatePicker = forwardRef(
|
|
14
|
-
({ value, onChange, placeholder, className, disabled }, ref) => {
|
|
15
|
-
const translate = useTranslations();
|
|
16
|
-
const resolvedPlaceholder = placeholder ?? translate("common.forms.datePicker.placeholder");
|
|
13
|
+
({ value, onChange, placeholder = "Selecione a data", className, disabled }, ref) => {
|
|
17
14
|
const [open, setOpen] = useState(false);
|
|
18
15
|
const [date, setDate] = useState(() => {
|
|
19
16
|
return value ? isoParaDataLocal(value) : void 0;
|
|
@@ -34,7 +31,7 @@ const DatePicker = forwardRef(
|
|
|
34
31
|
onChange?.(void 0);
|
|
35
32
|
}
|
|
36
33
|
};
|
|
37
|
-
const displayText = date ? format(date, "dd/MM/yyyy") :
|
|
34
|
+
const displayText = date ? format(date, "dd/MM/yyyy") : placeholder;
|
|
38
35
|
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
39
36
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
40
37
|
"button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/form/DatePicker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, forwardRef, useEffect } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/form/DatePicker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, forwardRef, useEffect } from \"react\";\nimport { format } from \"date-fns\";\nimport { Calendar } from \"./Calendar\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../overlay/Popover\";\nimport { cn } from \"../../../infra/utils/clsx\";\n\n// Converte string ISO (yyyy-MM-dd) para Date no fuso horário local\n// Evita bug de timezone onde new Date(\"2025-08-02\") interpreta como UTC\nconst isoParaDataLocal = (iso: string): Date => {\n const [ano, mes, dia] = iso.split(\"-\").map(Number);\n return new Date(ano, mes - 1, dia);\n};\n\ninterface DatePickerProps {\n value?: string;\n onChange?: (date: string | undefined) => void;\n placeholder?: string;\n className?: string;\n disabled?: boolean;\n}\n\nexport const DatePicker = forwardRef<HTMLButtonElement, DatePickerProps>(\n (\n { value, onChange, placeholder = \"Selecione a data\", className, disabled },\n ref,\n ) => {\n const [open, setOpen] = useState(false);\n const [date, setDate] = useState<Date | undefined>(() => {\n return value ? isoParaDataLocal(value) : undefined;\n });\n\n // Sincroniza estado interno quando value mudar externamente\n useEffect(() => {\n if (value) {\n setDate(isoParaDataLocal(value));\n } else {\n setDate(undefined);\n }\n }, [value]);\n\n const handleDateSelect = (selectedDate: Date | undefined) => {\n setDate(selectedDate);\n\n if (selectedDate) {\n onChange?.(format(selectedDate, \"yyyy-MM-dd\"));\n setOpen(false); // Fecha o popover após seleção\n } else {\n onChange?.(undefined);\n }\n };\n\n const displayText = date ? format(date, \"dd/MM/yyyy\") : placeholder;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n ref={ref}\n disabled={disabled}\n className={cn(\n \"flex items-center gap-2 px-4 h-10 border rounded-lg transition-colors w-full justify-start\",\n \"border-gray-200 hover:border-gray-400 focus-within:border-gray-950\",\n \"disabled:opacity-50 disabled:cursor-not-allowed\",\n className,\n )}\n >\n <span\n className={cn(\n \"paragraph-small-medium\",\n date ? \"text-gray-950\" : \"text-gray-500\",\n )}\n >\n {displayText}\n </span>\n </button>\n </PopoverTrigger>\n <PopoverContent\n className=\"w-auto p-0 bg-white rounded-2xl shadow-md border border-gray-200\"\n align=\"start\"\n sideOffset={8}\n >\n <div className=\"p-3\">\n <Calendar\n mode=\"single\"\n selected={date}\n onSelect={handleDateSelect}\n />\n </div>\n </PopoverContent>\n </Popover>\n );\n },\n);\n\nDatePicker.displayName = \"DateP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AAkB;AAAA,cAC3B;AAAA,cAEC;AAAA;AAAA,UACH;AAAA;AAAA,MACF,GACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAM;AAAA,UACN,YAAY;AAAA,UAEZ,8BAAC,SAAI,WAAU,OACb;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU;AAAA,cACV,UAAU;AAAA;AAAA,UACZ,GACF;AAAA;AAAA,MACF;AAAA,OACF;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, forwardRef, useEffect } from "react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
4
|
import { format } from "date-fns";
|
|
6
5
|
import { IconCalendar } from "@tabler/icons-react";
|
|
7
6
|
import { Calendar } from "./Calendar";
|
|
@@ -12,9 +11,7 @@ const isoParaDataLocal = (iso) => {
|
|
|
12
11
|
return new Date(ano, mes - 1, dia);
|
|
13
12
|
};
|
|
14
13
|
const DateRangePicker = forwardRef(
|
|
15
|
-
({ value, onChange, placeholder, className, disabled }, ref) => {
|
|
16
|
-
const translate = useTranslations();
|
|
17
|
-
const resolvedPlaceholder = placeholder ?? translate("common.forms.dateRangePicker.placeholder");
|
|
14
|
+
({ value, onChange, placeholder = "Selecione o per\xEDodo", className, disabled }, ref) => {
|
|
18
15
|
const [open, setOpen] = useState(false);
|
|
19
16
|
const [range, setRange] = useState(() => {
|
|
20
17
|
if (value?.from && value?.to) {
|
|
@@ -46,7 +43,7 @@ const DateRangePicker = forwardRef(
|
|
|
46
43
|
onChange?.(void 0);
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
|
-
const displayText = range?.from && range?.to ? `${format(range.from, "dd/MM/yyyy")} - ${format(range.to, "dd/MM/yyyy")}` :
|
|
46
|
+
const displayText = range?.from && range?.to ? `${format(range.from, "dd/MM/yyyy")} - ${format(range.to, "dd/MM/yyyy")}` : placeholder;
|
|
50
47
|
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
51
48
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
52
49
|
"button",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/form/DateRangePicker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, forwardRef, useEffect } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/form/DateRangePicker.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, forwardRef, useEffect } from \"react\";\nimport { format } from \"date-fns\";\nimport { IconCalendar } from '@tabler/icons-react';\nimport { DateRange } from \"react-day-picker\";\nimport { Calendar } from \"./Calendar\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"../overlay/Popover\";\nimport { cn } from \"../../../infra/utils/clsx\";\n\n// Converte string ISO (yyyy-MM-dd) para Date no fuso horário local\n// Evita bug de timezone onde new Date(\"2025-08-02\") interpreta como UTC\nconst isoParaDataLocal = (iso: string): Date => {\n const [ano, mes, dia] = iso.split(\"-\").map(Number);\n return new Date(ano, mes - 1, dia);\n};\n\ninterface DateRangePickerProps {\n value?: { from: string; to: string };\n onChange?: (range: { from: string; to: string } | undefined) => void;\n placeholder?: string;\n className?: string;\n disabled?: boolean;\n}\n\nexport const DateRangePicker = forwardRef<HTMLButtonElement, DateRangePickerProps>(\n ({ value, onChange, placeholder = \"Selecione o período\", className, disabled }, ref) => {\n const [open, setOpen] = useState(false);\n const [range, setRange] = useState<DateRange | undefined>(() => {\n if (value?.from && value?.to) {\n return {\n from: isoParaDataLocal(value.from),\n to: isoParaDataLocal(value.to)\n };\n }\n return undefined;\n });\n\n useEffect(() => {\n if (value?.from && value?.to) {\n setRange({\n from: isoParaDataLocal(value.from),\n to: isoParaDataLocal(value.to)\n });\n } else {\n setRange(undefined);\n }\n }, [value]);\n\n const handleRangeSelect = (newRange: DateRange | undefined) => {\n setRange(newRange);\n\n if (newRange?.from && newRange?.to) {\n onChange?.({\n from: format(newRange.from, \"yyyy-MM-dd\"),\n to: format(newRange.to, \"yyyy-MM-dd\")\n });\n } else {\n onChange?.(undefined);\n }\n };\n\n const displayText = range?.from && range?.to\n ? `${format(range.from, \"dd/MM/yyyy\")} - ${format(range.to, \"dd/MM/yyyy\")}`\n : placeholder;\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n ref={ref}\n disabled={disabled}\n className={cn(\n \"flex items-center gap-2 px-4 h-10 border rounded-lg transition-colors w-full justify-start\",\n \"border-gray-200 hover:border-gray-400 focus-within:border-gray-950\",\n \"disabled:opacity-50 disabled:cursor-not-allowed\",\n className\n )}\n >\n <IconCalendar size={20} className=\"text-gray-400\" />\n <span className={cn(\n \"paragraph-small-medium\",\n range?.from && range?.to ? \"text-gray-950\" : \"text-gray-500\"\n )}>\n {displayText}\n </span>\n </button>\n </PopoverTrigger>\n <PopoverContent\n className=\"w-auto p-0 bg-white rounded-2xl shadow-md border border-gray-200\"\n align=\"start\"\n sideOffset={8}\n >\n <div className=\"p-3\">\n <Calendar\n mode=\"range\"\n selected={range}\n onSelect={handleRangeSelect}\n numberOfMonths={1}\n />\n </div>\n </PopoverContent>\n </Popover>\n );\n }\n);\n\nDateRangePicker.displayName = \"DateRangePicker\";\n"],"mappings":";AAqEU,SAUE,KAVF;AAnEV,SAAS,UAAU,YAAY,iBAAiB;AAChD,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB;AACzB,SAAS,SAAS,gBAAgB,sBAAsB;AACxD,SAAS,UAAU;AAInB,MAAM,mBAAmB,CAAC,QAAsB;AAC9C,QAAM,CAAC,KAAK,KAAK,GAAG,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM;AACjD,SAAO,IAAI,KAAK,KAAK,MAAM,GAA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,gBAAa,MAAM,IAAI,WAAU,iBAAgB;AAAA,YAClD,oBAAC,UAAK,WAAW;AAAA,cACf;AAAA,cACA,OAAO,QAAQ,OAAO,KAAK,kBAAkB;AAAA,YAC/C,GACG,uBACH;AAAA;AAAA;AAAA,MACF,GACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAM;AAAA,UACN,YAAY;AAAA,UAEZ,8BAAC,SAAI,WAAU,OACb;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU;AAAA,cACV,UAAU;AAAA,cACV,gBAAgB;AAAA;AAAA,UAClB,GACF;AAAA;AAAA,MACF;AAAA,OACF;AAAA,EAEJ;AACF;AAEA,gBAAgB,cAAc;","names":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect, useRef } from "react";
|
|
4
|
-
import { useTranslations } from "next-intl";
|
|
5
4
|
import { AsYouType } from "libphonenumber-js";
|
|
6
5
|
import { Input, Separator, Popover, PopoverTrigger, PopoverContent, cn } from "@greatapps/common";
|
|
7
6
|
import { IconChevronDown, IconSearch } from "@tabler/icons-react";
|
|
@@ -25,7 +24,6 @@ function PhoneInput({
|
|
|
25
24
|
classnameContainer,
|
|
26
25
|
className
|
|
27
26
|
}) {
|
|
28
|
-
const translate = useTranslations();
|
|
29
27
|
const parsed = parsePhoneValue(value ?? "");
|
|
30
28
|
const [selectedCountry, setSelectedCountry] = useState(parsed.country);
|
|
31
29
|
const [phoneNumber, setPhoneNumber] = useState(parsed.number);
|
|
@@ -85,7 +83,7 @@ function PhoneInput({
|
|
|
85
83
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
86
84
|
label && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 paragraph-xsmall-semibold", children: [
|
|
87
85
|
/* @__PURE__ */ jsx("span", { className: "text-zinc-600", children: label }),
|
|
88
|
-
optional && /* @__PURE__ */ jsx("span", { className: "text-zinc-500", children:
|
|
86
|
+
optional && /* @__PURE__ */ jsx("span", { className: "text-zinc-500", children: "(Opcional)" }),
|
|
89
87
|
required && /* @__PURE__ */ jsx("span", { className: "text-red-600", children: "*" })
|
|
90
88
|
] }),
|
|
91
89
|
/* @__PURE__ */ jsxs(
|
|
@@ -120,7 +118,7 @@ function PhoneInput({
|
|
|
120
118
|
{
|
|
121
119
|
type: "text",
|
|
122
120
|
className: "flex-1 text-sm outline-none placeholder:text-zinc-400",
|
|
123
|
-
placeholder:
|
|
121
|
+
placeholder: "Buscar pa\xEDs...",
|
|
124
122
|
value: search,
|
|
125
123
|
onChange: (e) => setSearch(e.target.value),
|
|
126
124
|
autoFocus: true
|
|
@@ -145,7 +143,7 @@ function PhoneInput({
|
|
|
145
143
|
},
|
|
146
144
|
country.iso
|
|
147
145
|
)),
|
|
148
|
-
filtered.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-zinc-500 p-3 text-center", children:
|
|
146
|
+
filtered.length === 0 && /* @__PURE__ */ jsx("p", { className: "text-sm text-zinc-500 p-3 text-center", children: "Nenhum pa\xEDs encontrado" })
|
|
149
147
|
] })
|
|
150
148
|
] })
|
|
151
149
|
] }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/form/PhoneInput.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useEffect, useRef } from 'react';\nimport { useTranslations } from 'next-intl';\nimport { AsYouType, CountryCode } from 'libphonenumber-js';\nimport { Input, Separator, Popover, PopoverTrigger, PopoverContent, cn } from '@greatapps/common';\nimport { IconChevronDown, IconSearch } from '@tabler/icons-react';\nimport { COUNTRIES, Country, flagUrl, parsePhoneValue } from '../../../utils/countries';\n\nfunction formatNational(digits: string, iso: string): string {\n const raw = digits.replace(/\\D/g, '');\n if (!raw) return '';\n return new AsYouType(iso as CountryCode).input(raw);\n}\n\ninterface PhoneInputProps {\n value?: string;\n onChange?: (value: string) => void;\n label?: string;\n optional?: boolean;\n required?: boolean;\n hintMessage?: string;\n error?: boolean;\n errorMessage?: string;\n placeholder?: string;\n disabled?: boolean;\n classnameContainer?: string;\n className?: string;\n}\n\nexport default function PhoneInput({\n value,\n onChange,\n label,\n optional = false,\n required = false,\n hintMessage,\n error = false,\n errorMessage,\n placeholder,\n disabled = false,\n classnameContainer,\n className,\n}: PhoneInputProps) {\n const translate = useTranslations();\n const parsed = parsePhoneValue(value ?? '');\n const [selectedCountry, setSelectedCountry] = useState<Country>(parsed.country);\n const [phoneNumber, setPhoneNumber] = useState(parsed.number);\n const [search, setSearch] = useState('');\n const [open, setOpen] = useState(false);\n const prevValueRef = useRef(value);\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (value !== prevValueRef.current) {\n prevValueRef.current = value;\n const p = parsePhoneValue(value ?? '');\n setSelectedCountry(p.country);\n setPhoneNumber(formatNational(p.number, p.country.iso));\n }\n }, [value]);\n\n const emit = (country: Country, number: string) => {\n onChange?.(`${country.dial} ${number}`);\n };\n\n const handleCountrySelect = (country: Country) => {\n const reformatted = formatNational(phoneNumber, country.iso);\n setSelectedCountry(country);\n setPhoneNumber(reformatted);\n setOpen(false);\n setSearch('');\n emit(country, reformatted);\n };\n\n const handleNumberChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const rawInput = e.target.value;\n const digits = rawInput.replace(/\\D/g, '');\n if (digits.length > 15) return;\n\n const cursorPos = e.target.selectionStart ?? rawInput.length;\n const digitsBeforeCursor = rawInput.slice(0, cursorPos).replace(/\\D/g, '').length;\n\n const formatted = formatNational(rawInput, selectedCountry.iso);\n setPhoneNumber(formatted);\n emit(selectedCountry, formatted);\n\n requestAnimationFrame(() => {\n if (!inputRef.current) return;\n let digitCount = 0;\n let newPos = formatted.length;\n for (let i = 0; i < formatted.length; i++) {\n if (/\\d/.test(formatted[i])) {\n digitCount++;\n if (digitCount === digitsBeforeCursor) {\n newPos = i + 1;\n break;\n }\n }\n }\n inputRef.current.setSelectionRange(newPos, newPos);\n });\n };\n\n const filtered = COUNTRIES.filter(\n (c) =>\n c.name.toLowerCase().includes(search.toLowerCase()) ||\n c.dial.includes(search) ||\n c.iso.toLowerCase().includes(search.toLowerCase())\n );\n\n const finalMessage = error && errorMessage ? errorMessage : hintMessage;\n const showMessage = finalMessage && finalMessage.trim() !== '';\n\n return (\n <div className=\"flex flex-col gap-1.5\">\n {label && (\n <div className=\"flex items-center gap-1 paragraph-xsmall-semibold\">\n <span className=\"text-zinc-600\">{label}</span>\n {optional && <span className=\"text-zinc-500\">{translate('common.forms.phoneInput.optional')}</span>}\n {required && <span className=\"text-red-600\">*</span>}\n </div>\n )}\n\n <div\n className={cn(\n 'flex gap-2 items-center border rounded-lg h-10 transition-colors',\n error\n ? 'border-red-600 hover:border-red-700'\n : 'border-zinc-200 hover:border-zinc-400 focus-within:border-zinc-950',\n disabled && 'cursor-not-allowed',\n classnameContainer\n )}\n >\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n className=\"flex items-center gap-1.5 px-3 h-full shrink-0 focus:outline-none\"\n disabled={disabled}\n >\n <img src={flagUrl(selectedCountry.iso)} alt={selectedCountry.iso} className=\"w-5 h-5 rounded-full\" />\n <span className=\"paragraph-small-regular text-zinc-950\">{selectedCountry.dial}</span>\n <IconChevronDown size={14} className={cn(\"text-zinc-500 transition-transform duration-200\", open && \"rotate-180\")} />\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-72 p-0 z-[1010]\" align=\"start\" side=\"top\">\n <div className=\"flex items-center gap-2 p-2 border-b border-zinc-100\">\n <IconSearch size={14} className=\"text-zinc-400 shrink-0\" />\n <input\n type=\"text\"\n className=\"flex-1 text-sm outline-none placeholder:text-zinc-400\"\n placeholder={translate('common.forms.phoneInput.searchPlaceholder')}\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n autoFocus\n />\n </div>\n <div className=\"max-h-60 overflow-y-auto overscroll-contain\" onTouchMove={(e) => e.stopPropagation()} onWheel={(e) => e.stopPropagation()}>\n {filtered.map((country) => (\n <button\n key={country.iso}\n type=\"button\"\n className={cn(\n 'flex items-center gap-2.5 w-full px-3 py-2 text-left hover:bg-zinc-50 transition-colors',\n selectedCountry.iso === country.iso && 'bg-zinc-100'\n )}\n onClick={() => handleCountrySelect(country)}\n >\n <img src={flagUrl(country.iso)} alt={country.iso} className=\"w-5 h-5 rounded-full shrink-0\" />\n <span className=\"paragraph-small-regular text-zinc-950 flex-1 truncate\">\n {country.name}\n </span>\n <span className=\"paragraph-small-regular text-zinc-500 shrink-0\">\n {country.dial}\n </span>\n </button>\n ))}\n {filtered.length === 0 && (\n <p className=\"text-sm text-zinc-500 p-3 text-center\">{translate('common.forms.phoneInput.emptyMessage')}</p>\n )}\n </div>\n </PopoverContent>\n </Popover>\n\n <Separator orientation=\"vertical\" />\n\n <Input\n ref={inputRef}\n type=\"tel\"\n value={phoneNumber}\n onChange={handleNumberChange}\n placeholder={placeholder}\n disabled={disabled}\n className={cn(\n 'paragraph-small-medium w-full h-full text-zinc-950 border-0 focus-visible:ring-0 focus-visible:ring-offset-0',\n disabled && 'cursor-not-allowed',\n className\n )}\n />\n </div>\n\n {showMessage && (\n <span className={cn('paragraph-xsmall-medium', error ? 'text-red-600' : 'text-zinc-600')}>\n {finalMessage}\n </span>\n )}\n </div>\n );\n}\n"],"mappings":";AAqHQ,SACE,KADF;AAnHR,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,uBAAuB;AAChC,SAAS,iBAA8B;AACvC,SAAS,OAAO,WAAW,SAAS,gBAAgB,gBAAgB,UAAU;AAC9E,SAAS,iBAAiB,kBAAkB;AAC5C,SAAS,WAAoB,SAAS,uBAAuB;AAE7D,SAAS,eAAe,QAAgB,KAAqB;AAC3D,QAAM,MAAM,OAAO,QAAQ,OAAO,EAAE;AACpC,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,IAAI,UAAU,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C,UAAK,WAAU,kDACb,kBAAQ,MACX;AAAA;AAAA;AAAA,kBAdK,QAAQ;AAAA,gBAef,CACD;AAAA,gBACA,SAAS,WAAW,KACnB,oBAAC,OAAE,WAAU,yCAAyC,oBAAU,sCAAsC,GAAE;AAAA,iBAE5G;AAAA,eACF;AAAA,aACF;AAAA,UAEA,oBAAC,aAAU,aAAY,YAAW;AAAA,UAElC;AAAA,YAAC;AAAA;AAAA,cACC,KAAK;AAAA,cACL,MAAK;AAAA,cACL,OAAO;AAAA,cACP,UAAU;AAAA,cACV;AAAA,cACA;AAAA,cACA,WAAW;AAAA,gBACT;AAAA,gBACA,YAAY;AAAA,gBACZ;AAAA,cACF;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,IAEC,eACC,oBAAC,UAAK,WAAW,GAAG,2BAA2B,QAAQ,iBAAiB,eAAe,GACpF,wBACH;AAAA,KAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/form/PhoneInput.tsx"],"sourcesContent":["'use client';\n\nimport { useState, useEffect, useRef } from 'react';\nimport { AsYouType, CountryCode } from 'libphonenumber-js';\nimport { Input, Separator, Popover, PopoverTrigger, PopoverContent, cn } from '@greatapps/common';\nimport { IconChevronDown, IconSearch } from '@tabler/icons-react';\nimport { COUNTRIES, Country, flagUrl, parsePhoneValue } from '../../../utils/countries';\n\nfunction formatNational(digits: string, iso: string): string {\n const raw = digits.replace(/\\D/g, '');\n if (!raw) return '';\n return new AsYouType(iso as CountryCode).input(raw);\n}\n\ninterface PhoneInputProps {\n value?: string;\n onChange?: (value: string) => void;\n label?: string;\n optional?: boolean;\n required?: boolean;\n hintMessage?: string;\n error?: boolean;\n errorMessage?: string;\n placeholder?: string;\n disabled?: boolean;\n classnameContainer?: string;\n className?: string;\n}\n\nexport default function PhoneInput({\n value,\n onChange,\n label,\n optional = false,\n required = false,\n hintMessage,\n error = false,\n errorMessage,\n placeholder,\n disabled = false,\n classnameContainer,\n className,\n}: PhoneInputProps) {\n const parsed = parsePhoneValue(value ?? '');\n const [selectedCountry, setSelectedCountry] = useState<Country>(parsed.country);\n const [phoneNumber, setPhoneNumber] = useState(parsed.number);\n const [search, setSearch] = useState('');\n const [open, setOpen] = useState(false);\n const prevValueRef = useRef(value);\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n if (value !== prevValueRef.current) {\n prevValueRef.current = value;\n const p = parsePhoneValue(value ?? '');\n setSelectedCountry(p.country);\n setPhoneNumber(formatNational(p.number, p.country.iso));\n }\n }, [value]);\n\n const emit = (country: Country, number: string) => {\n onChange?.(`${country.dial} ${number}`);\n };\n\n const handleCountrySelect = (country: Country) => {\n const reformatted = formatNational(phoneNumber, country.iso);\n setSelectedCountry(country);\n setPhoneNumber(reformatted);\n setOpen(false);\n setSearch('');\n emit(country, reformatted);\n };\n\n const handleNumberChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const rawInput = e.target.value;\n const digits = rawInput.replace(/\\D/g, '');\n if (digits.length > 15) return;\n\n const cursorPos = e.target.selectionStart ?? rawInput.length;\n const digitsBeforeCursor = rawInput.slice(0, cursorPos).replace(/\\D/g, '').length;\n\n const formatted = formatNational(rawInput, selectedCountry.iso);\n setPhoneNumber(formatted);\n emit(selectedCountry, formatted);\n\n requestAnimationFrame(() => {\n if (!inputRef.current) return;\n let digitCount = 0;\n let newPos = formatted.length;\n for (let i = 0; i < formatted.length; i++) {\n if (/\\d/.test(formatted[i])) {\n digitCount++;\n if (digitCount === digitsBeforeCursor) {\n newPos = i + 1;\n break;\n }\n }\n }\n inputRef.current.setSelectionRange(newPos, newPos);\n });\n };\n\n const filtered = COUNTRIES.filter(\n (c) =>\n c.name.toLowerCase().includes(search.toLowerCase()) ||\n c.dial.includes(search) ||\n c.iso.toLowerCase().includes(search.toLowerCase())\n );\n\n const finalMessage = error && errorMessage ? errorMessage : hintMessage;\n const showMessage = finalMessage && finalMessage.trim() !== '';\n\n return (\n <div className=\"flex flex-col gap-1.5\">\n {label && (\n <div className=\"flex items-center gap-1 paragraph-xsmall-semibold\">\n <span className=\"text-zinc-600\">{label}</span>\n {optional && <span className=\"text-zinc-500\">(Opcional)</span>}\n {required && <span className=\"text-red-600\">*</span>}\n </div>\n )}\n\n <div\n className={cn(\n 'flex gap-2 items-center border rounded-lg h-10 transition-colors',\n error\n ? 'border-red-600 hover:border-red-700'\n : 'border-zinc-200 hover:border-zinc-400 focus-within:border-zinc-950',\n disabled && 'cursor-not-allowed',\n classnameContainer\n )}\n >\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n className=\"flex items-center gap-1.5 px-3 h-full shrink-0 focus:outline-none\"\n disabled={disabled}\n >\n <img src={flagUrl(selectedCountry.iso)} alt={selectedCountry.iso} className=\"w-5 h-5 rounded-full\" />\n <span className=\"paragraph-small-regular text-zinc-950\">{selectedCountry.dial}</span>\n <IconChevronDown size={14} className={cn(\"text-zinc-500 transition-transform duration-200\", open && \"rotate-180\")} />\n </button>\n </PopoverTrigger>\n <PopoverContent className=\"w-72 p-0 z-[1010]\" align=\"start\" side=\"top\">\n <div className=\"flex items-center gap-2 p-2 border-b border-zinc-100\">\n <IconSearch size={14} className=\"text-zinc-400 shrink-0\" />\n <input\n type=\"text\"\n className=\"flex-1 text-sm outline-none placeholder:text-zinc-400\"\n placeholder=\"Buscar país...\"\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n autoFocus\n />\n </div>\n <div className=\"max-h-60 overflow-y-auto overscroll-contain\" onTouchMove={(e) => e.stopPropagation()} onWheel={(e) => e.stopPropagation()}>\n {filtered.map((country) => (\n <button\n key={country.iso}\n type=\"button\"\n className={cn(\n 'flex items-center gap-2.5 w-full px-3 py-2 text-left hover:bg-zinc-50 transition-colors',\n selectedCountry.iso === country.iso && 'bg-zinc-100'\n )}\n onClick={() => handleCountrySelect(country)}\n >\n <img src={flagUrl(country.iso)} alt={country.iso} className=\"w-5 h-5 rounded-full shrink-0\" />\n <span className=\"paragraph-small-regular text-zinc-950 flex-1 truncate\">\n {country.name}\n </span>\n <span className=\"paragraph-small-regular text-zinc-500 shrink-0\">\n {country.dial}\n </span>\n </button>\n ))}\n {filtered.length === 0 && (\n <p className=\"text-sm text-zinc-500 p-3 text-center\">Nenhum país encontrado</p>\n )}\n </div>\n </PopoverContent>\n </Popover>\n\n <Separator orientation=\"vertical\" />\n\n <Input\n ref={inputRef}\n type=\"tel\"\n value={phoneNumber}\n onChange={handleNumberChange}\n placeholder={placeholder}\n disabled={disabled}\n className={cn(\n 'paragraph-small-medium w-full h-full text-zinc-950 border-0 focus-visible:ring-0 focus-visible:ring-offset-0',\n disabled && 'cursor-not-allowed',\n className\n )}\n />\n </div>\n\n {showMessage && (\n <span className={cn('paragraph-xsmall-medium', error ? 'text-red-600' : 'text-zinc-600')}>\n {finalMessage}\n </span>\n )}\n </div>\n );\n}\n"],"mappings":";AAmHQ,SACE,KADF;AAjHR,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,iBAA8B;AACvC,SAAS,OAAO,WAAW,SAAS,gBAAgB,gBAAgB,UAAU;AAC9E,SAAS,iBAAiB,kBAAkB;AAC5C,SAAS,WAAoB,SAAS,uBAAuB;AAE7D,SAAS,eAAe,QAAgB,KAAqB;AAC3D,QAAM,MAAM,OAAO,QAAQ,OAAO,EAAE;AACpC,MAAI,CAAC,IAAK,QAAO;AACjB,SAAO,IAAI,UAAU,GAAkB,EAAE,MAAM,GAAG;AACpD;AAiBe,SAAR,WAA4B;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,WAAW;AAAA,EACX;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA;AACF,GAAoB;AAClB,QAAM,SAAS,gBAAgB,SAAS,EAAE;AAC1C,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAkB,OAAO,OAAO;AAC9E,QAAM,CAAC,aAAa,cAA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A,cACF;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IACF;AAAA,IAEC,eACC,oBAAC,UAAK,WAAW,GAAG,2BAA2B,QAAQ,iBAAiB,eAAe,GACpF,wBACH;AAAA,KAEJ;AAEJ;","names":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useTranslations } from "next-intl";
|
|
4
3
|
import {
|
|
5
4
|
Select,
|
|
6
5
|
SelectContent,
|
|
@@ -16,7 +15,7 @@ function SelectField({
|
|
|
16
15
|
hintMessage,
|
|
17
16
|
error = false,
|
|
18
17
|
errorMessage,
|
|
19
|
-
placeholder,
|
|
18
|
+
placeholder = "Selecione uma op\xE7\xE3o",
|
|
20
19
|
options,
|
|
21
20
|
value,
|
|
22
21
|
defaultValue,
|
|
@@ -26,8 +25,6 @@ function SelectField({
|
|
|
26
25
|
className,
|
|
27
26
|
containerClassName
|
|
28
27
|
}) {
|
|
29
|
-
const translate = useTranslations();
|
|
30
|
-
const resolvedPlaceholder = placeholder ?? translate("common.forms.select.placeholder");
|
|
31
28
|
const handleValueChange = (selectedValue) => {
|
|
32
29
|
if (!onChange) return;
|
|
33
30
|
const selectedOption = options.find((option) => String(option.value) === selectedValue);
|
|
@@ -40,7 +37,7 @@ function SelectField({
|
|
|
40
37
|
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", containerClassName), children: [
|
|
41
38
|
label && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 paragraph-xsmall-semibold", children: [
|
|
42
39
|
/* @__PURE__ */ jsx("span", { className: "text-gray-600", children: label }),
|
|
43
|
-
optional && /* @__PURE__ */ jsx("span", { className: "text-gray-500", children:
|
|
40
|
+
optional && /* @__PURE__ */ jsx("span", { className: "text-gray-500", children: "(Opcional)" }),
|
|
44
41
|
required && /* @__PURE__ */ jsx("span", { className: "text-red-600", children: "*" })
|
|
45
42
|
] }),
|
|
46
43
|
/* @__PURE__ */ jsxs(
|
|
@@ -61,7 +58,7 @@ function SelectField({
|
|
|
61
58
|
className
|
|
62
59
|
),
|
|
63
60
|
icon,
|
|
64
|
-
children: /* @__PURE__ */ jsx(SelectValue, { placeholder
|
|
61
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder, children: value !== void 0 && (() => {
|
|
65
62
|
const selectedOption = options.find((opt) => String(opt.value) === String(value));
|
|
66
63
|
return selectedOption?.displayValue || selectedOption?.label;
|
|
67
64
|
})() })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/form/SelectField.tsx"],"sourcesContent":["'use client';\r\n\r\nimport React from 'react';\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/form/SelectField.tsx"],"sourcesContent":["'use client';\r\n\r\nimport React from 'react';\r\nimport {\r\n Select,\r\n SelectContent,\r\n SelectItem,\r\n SelectTrigger,\r\n SelectValue,\r\n} from './Select';\r\nimport { cn } from '../../../infra/utils/clsx';\r\n\r\ntype SelectOption = {\r\n value: string | number | boolean;\r\n label: React.ReactNode;\r\n displayValue?: string;\r\n};\r\n\r\ninterface SelectFieldProps {\r\n options: SelectOption[];\r\n label?: string;\r\n optional?: boolean;\r\n required?: boolean;\r\n hintMessage?: string;\r\n error?: boolean;\r\n errorMessage?: string;\r\n placeholder?: string;\r\n value?: string | number | boolean;\r\n defaultValue?: string | number | boolean;\r\n onChange?: (value: string | number | boolean) => void;\r\n disabled?: boolean;\r\n icon?: React.ReactNode;\r\n className?: string;\r\n containerClassName?: string;\r\n}\r\n\r\nexport function SelectField({\r\n label,\r\n optional = false,\r\n required = false,\r\n hintMessage,\r\n error = false,\r\n errorMessage,\r\n placeholder = 'Selecione uma opção',\r\n options,\r\n value,\r\n defaultValue,\r\n onChange,\r\n disabled = false,\r\n icon,\r\n className,\r\n containerClassName,\r\n}: SelectFieldProps) {\r\n const handleValueChange = (selectedValue: string) => {\r\n if (!onChange) return;\r\n const selectedOption = options.find((option) => String(option.value) === selectedValue);\r\n if (selectedOption) {\r\n onChange(selectedOption.value);\r\n }\r\n };\r\n\r\n const finalMessage = error && errorMessage ? errorMessage : hintMessage;\r\n const messageColor = error ? 'text-red-600' : 'text-gray-600';\r\n\r\n return (\r\n <div className={cn('flex flex-col gap-1.5', containerClassName)}>\r\n {label && (\r\n <div className=\"flex items-center gap-1 paragraph-xsmall-semibold\">\r\n <span className=\"text-gray-600\">{label}</span>\r\n {optional && <span className=\"text-gray-500\">(Opcional)</span>}\r\n {required && <span className=\"text-red-600\">*</span>}\r\n </div>\r\n )}\r\n\r\n <Select\r\n value={value !== undefined ? String(value) : undefined}\r\n defaultValue={defaultValue !== undefined ? String(defaultValue) : undefined}\r\n onValueChange={handleValueChange}\r\n disabled={disabled}\r\n >\r\n <SelectTrigger\r\n className={cn(\r\n 'paragraph-small-medium w-full h-10 text-gray-950 px-4 transition-colors',\r\n error\r\n ? 'border-red-600 hover:border-red-700 focus:border-red-600'\r\n : 'border-gray-200 hover:border-gray-400 focus-within:border-gray-950 focus:border-gray-950',\r\n disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer',\r\n className\r\n )}\r\n icon={icon}\r\n >\r\n <SelectValue placeholder={placeholder}>\r\n {value !== undefined &&\r\n (() => {\r\n const selectedOption = options.find((opt) => String(opt.value) === String(value));\r\n return selectedOption?.displayValue || selectedOption?.label;\r\n })()}\r\n </SelectValue>\r\n </SelectTrigger>\r\n <SelectContent sideOffset={4}>\r\n {options.map((option) => (\r\n <SelectItem key={String(option.value)} value={String(option.value)}>\r\n {option.label}\r\n </SelectItem>\r\n ))}\r\n </SelectContent>\r\n </Select>\r\n\r\n {finalMessage && (\r\n <span className={cn('paragraph-xsmall-medium', messageColor)}>{finalMessage}</span>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nSelectField.displayName = 'SelectField';\r\n\r\nexport default SelectField;\r\n"],"mappings":";AAmEQ,SACE,KADF;AAhER;AAAA,EACE;AAA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