@burdenoff/microfe-auth 2026.830.1 → 2026.904.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/AuthRoot.js +43 -41
- package/dist/auth/AuthRoot.js.map +1 -1
- package/dist/auth/AuthRoutes.js +7 -0
- package/dist/auth/AuthRoutes.js.map +1 -1
- package/dist/auth/components/AuthLayout.js +65 -67
- package/dist/auth/components/AuthLayout.js.map +1 -1
- package/dist/auth/components/CaptchaV2.js +21 -24
- package/dist/auth/components/CaptchaV2.js.map +1 -1
- package/dist/auth/components/ConfirmActionDialog.js +33 -32
- package/dist/auth/components/ConfirmActionDialog.js.map +1 -1
- package/dist/auth/components/profile/UserProfileMenu.js +44 -46
- package/dist/auth/components/profile/UserProfileMenu.js.map +1 -1
- package/dist/auth/components/workspace/WorkspaceSelector.js +62 -68
- package/dist/auth/components/workspace/WorkspaceSelector.js.map +1 -1
- package/dist/auth/pages/AuditLogPage.js +65 -68
- package/dist/auth/pages/AuditLogPage.js.map +1 -1
- package/dist/auth/pages/EmailVerifyPage.js +51 -54
- package/dist/auth/pages/EmailVerifyPage.js.map +1 -1
- package/dist/auth/pages/LoginPage.js +223 -225
- package/dist/auth/pages/LoginPage.js.map +1 -1
- package/dist/auth/pages/MagicLinkPage.js +67 -69
- package/dist/auth/pages/MagicLinkPage.js.map +1 -1
- package/dist/auth/pages/MfaSetupPage.js +85 -88
- package/dist/auth/pages/MfaSetupPage.js.map +1 -1
- package/dist/auth/pages/MfaVerifyPage.js +60 -63
- package/dist/auth/pages/MfaVerifyPage.js.map +1 -1
- package/dist/auth/pages/OAuthCallbackPage.js +37 -40
- package/dist/auth/pages/OAuthCallbackPage.js.map +1 -1
- package/dist/auth/pages/PasswordResetPage.js +102 -105
- package/dist/auth/pages/PasswordResetPage.js.map +1 -1
- package/dist/auth/pages/ReactivatePage.js +54 -57
- package/dist/auth/pages/ReactivatePage.js.map +1 -1
- package/dist/auth/pages/RegisterPage.js +171 -174
- package/dist/auth/pages/RegisterPage.js.map +1 -1
- package/dist/auth/pages/SSOClearPage.js +21 -20
- package/dist/auth/pages/SSOClearPage.js.map +1 -1
- package/dist/auth/pages/SSODepositPage.js +27 -26
- package/dist/auth/pages/SSODepositPage.js.map +1 -1
- package/dist/auth/pages/SSORelayCallbackPage.js +19 -18
- package/dist/auth/pages/SSORelayCallbackPage.js.map +1 -1
- package/dist/auth/pages/SecurityPage.js +247 -250
- package/dist/auth/pages/SecurityPage.js.map +1 -1
- package/dist/auth/pages/SessionsPage.js +95 -98
- package/dist/auth/pages/SessionsPage.js.map +1 -1
- package/dist/auth/pages/SsoCallbackPage.js +53 -56
- package/dist/auth/pages/SsoCallbackPage.js.map +1 -1
- package/dist/auth/pages/SsoConfigPage.js +296 -299
- package/dist/auth/pages/SsoConfigPage.js.map +1 -1
- package/dist/auth/pages/SsoLoginPage.js +65 -68
- package/dist/auth/pages/SsoLoginPage.js.map +1 -1
- package/dist/auth/pages/UserDetailsPage.js +124 -127
- package/dist/auth/pages/UserDetailsPage.js.map +1 -1
- package/dist/auth/pages/UserProfilePage.js +171 -174
- package/dist/auth/pages/UserProfilePage.js.map +1 -1
- package/dist/auth/pages/UsersPage.js +322 -325
- package/dist/auth/pages/UsersPage.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/shared/hooks/index.d.ts +1 -6
- package/dist/shared/hooks/useTr.d.ts +16 -0
- package/dist/shared/hooks/useTr.js +14 -0
- package/dist/shared/hooks/useTr.js.map +1 -0
- package/dist/translations/en.d.ts +806 -248
- package/dist/translations/en.js +870 -0
- package/dist/translations/en.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthLayout.js","names":[],"sources":["../../../src/auth/components/AuthLayout.tsx"],"sourcesContent":["import { useState, type ReactNode } from \"react\";\nimport { LanguageSwitcher } from \"@burdenoff/fe-libs/chrome\";\nimport type { Language } from \"@burdenoff/fe-libs/chrome\";\nimport {\n useI18n,\n useAppShell,\n} from \"@burdenoff/fe-libs/shared/providers/shell\";\nimport type { Locale } from \"@burdenoff/fe-libs/shared/providers/shell\";\n\ninterface AuthLayoutProps {\n children: ReactNode;\n title: string;\n subtitle: string;\n productName?: string;\n tagline?: string;\n}\n\n/**\n * Supported languages for the auth pages.\n *\n * Must stay in sync with the locales actually seeded in\n * `i18n_translations` for the consumer products that mount microfe-auth.\n * If a locale is listed here but NOT seeded, selecting it sets\n * `setLocale(<code>)` on the I18nProvider, the next `exportTranslations`\n * call returns zero rows, every `tr()` falls back to its English default,\n * and the user gets an English UI under a non-English flag.\n *\n * Audited 2026-05-31 against alpha `i18n_translations`: only `en/ta/hi/\n * zh/es/ar` have actual translations (vibecontrols 40k+ rows each).\n * `fr` was previously listed but no product seeds it — selecting it\n * produced a half-translated UI. Removed for parity with the dashboard\n * `LanguageSwitcherSlot` (which is data-driven from `i18n_languages`).\n *\n * Adding a new locale requires updating BOTH:\n * - this list\n * - each consumer product's seed (e.g. vibecontrols-app/scripts/\n * build-i18n-bundle.ts + the new `<code>.ts` translation source).\n */\nconst AUTH_LANGUAGES: Language[] = [\n { code: \"en\", name: \"English\", nativeName: \"English\", flag: \"🇺🇸\" },\n { code: \"ta\", name: \"Tamil\", nativeName: \"தமிழ்\", flag: \"🇮🇳\" },\n { code: \"hi\", name: \"Hindi\", nativeName: \"हिन्दी\", flag: \"🇮🇳\" },\n { code: \"zh\", name: \"Chinese\", nativeName: \"中文\", flag: \"🇨🇳\" },\n { code: \"es\", name: \"Spanish\", nativeName: \"Español\", flag: \"🇪🇸\" },\n { code: \"ar\", name: \"Arabic\", nativeName: \"العربية\", flag: \"🇸🇦\" },\n];\n\n/**\n * Brand logo for the auth pages.\n *\n * Renders the host app shell's real product logo served at `/icons/icon.svg`\n * (the same asset the marketing landing page uses) so the login screen and the\n * landing page show an identical mark instead of a generic placeholder glyph.\n * Host shells that don't ship that asset (e.g. admin-app) fall back to a\n * branded initial badge rather than a broken image.\n */\nfunction BrandLogo({ brandInitial }: { brandInitial: string }) {\n const [failed, setFailed] = useState(false);\n\n if (failed) {\n return (\n <div className=\"auth-brand-badge flex size-10 items-center justify-center rounded-xl\">\n <span className=\"text-lg font-bold leading-none text-white\">\n {brandInitial}\n </span>\n </div>\n );\n }\n\n return (\n <img\n src=\"/icons/icon.svg\"\n alt=\"\"\n aria-hidden=\"true\"\n className=\"size-10 rounded-xl object-contain\"\n onError={() => setFailed(true)}\n />\n );\n}\n\n/**\n * Professional auth layout with split-screen design\n * Left side: Branding with gradient background\n * Right side: Auth form\n */\nexport function AuthLayout({\n children,\n title,\n subtitle,\n productName,\n tagline,\n}: AuthLayoutProps) {\n const shell = useAppShell();\n const displayName = productName || shell.productName || \"Burdenoff\";\n const brandInitial = shell.brandInitial || \"B\";\n const displayTagline = tagline || shell.tagline || \"Enterprise platform\";\n const { t, locale, setLocale } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n\n const handleLanguageChange = (language: Language) => {\n // AUTH_LANGUAGES intentionally lists locales (e.g. \"ar\") that are seeded\n // in consumer products but not yet present in the fe-libs Locale union.\n // The runtime I18nProvider accepts any locale code, so we cast through\n // unknown to Locale to keep the picker in parity until fe-libs widens the\n // union. Keep AUTH_LANGUAGES in sync with consumer product seeds.\n setLocale(language.code as unknown as Locale);\n };\n\n return (\n <div className=\"min-h-screen flex relative\">\n {/* Left Panel - Branding */}\n <div className=\"auth-brand-panel hidden overflow-hidden lg:flex lg:w-1/2 relative\">\n {/* Decorative Elements */}\n <div className=\"absolute inset-0 overflow-hidden\">\n <div className=\"absolute -top-40 -left-40 size-80 rounded-full bg-accent-blue/20 blur-3xl\" />\n <div className=\"absolute top-1/2 -right-20 size-96 rounded-full bg-accent-indigo/20 blur-3xl\" />\n <div className=\"absolute -bottom-40 left-1/4 size-72 rounded-full bg-accent-purple/20 blur-3xl\" />\n\n {/* Grid Pattern */}\n <div\n className=\"absolute inset-0 opacity-5\"\n style={{\n backgroundImage: `url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\")`,\n }}\n />\n </div>\n\n {/* Content */}\n <div className=\"relative z-10 flex flex-col justify-between p-12 w-full\">\n {/* Logo */}\n <div className=\"flex items-center gap-3\">\n <BrandLogo brandInitial={brandInitial} />\n <span className=\"text-xl font-bold text-[var(--color-text-primary)]\">\n {displayName}\n </span>\n </div>\n\n {/* Main Content */}\n <div className=\"max-w-md\">\n <h1 className=\"mb-4 text-4xl font-bold leading-tight text-[var(--color-text-primary)]\">\n {displayTagline}\n </h1>\n <p className=\"auth-brand-copy text-lg leading-relaxed\">\n {tr(\n \"auth.layout.taglineDescription\",\n \"Unify your teams, projects, and workflows in one intelligent workspace. Built for scale with enterprise-grade security, real-time collaboration, and seamless integrations across your entire organization.\",\n )}\n </p>\n\n {/* Features */}\n <div className=\"mt-10 space-y-4\">\n {[\n {\n icon: \"workspace\",\n text: tr(\n \"auth.layout.featureWorkspace\",\n \"Modular workspace architecture\",\n ),\n },\n {\n icon: \"realtime\",\n text: tr(\n \"auth.layout.featureRealtime\",\n \"Real-time collaboration & sync\",\n ),\n },\n {\n icon: \"security\",\n text: tr(\n \"auth.layout.featureSecurity\",\n \"Enterprise-grade security & SSO\",\n ),\n },\n {\n icon: \"scale\",\n text: tr(\n \"auth.layout.featureScale\",\n \"Unlimited scalability & performance\",\n ),\n },\n ].map((feature) => (\n <div key={feature.icon} className=\"flex items-center gap-3\">\n <div className=\"auth-highlight-chip flex size-8 items-center justify-center rounded-lg\">\n {feature.icon === \"workspace\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z\"\n />\n </svg>\n )}\n {feature.icon === \"realtime\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z\"\n />\n </svg>\n )}\n {feature.icon === \"security\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z\"\n />\n </svg>\n )}\n {feature.icon === \"scale\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z\"\n />\n </svg>\n )}\n </div>\n <span className=\"auth-brand-copy text-sm font-medium\">\n {feature.text}\n </span>\n </div>\n ))}\n </div>\n </div>\n\n {/* Footer */}\n <div className=\"auth-brand-copy-muted text-sm\">\n © {new Date().getFullYear()} Burdenoff. All rights reserved.\n </div>\n </div>\n </div>\n\n {/* Right Panel - Form */}\n <main className=\"auth-shell-gradient relative flex flex-1 items-center justify-center bg-[var(--color-bg-canvas)] p-6 sm:p-12\">\n {/* Language Switcher - Top Right */}\n <div className=\"absolute top-4 right-4 sm:top-6 sm:right-6 z-10\">\n <LanguageSwitcher\n languages={AUTH_LANGUAGES}\n currentLanguage={locale}\n onLanguageChange={handleLanguageChange}\n />\n </div>\n <div className=\"w-full max-w-md\">\n {/* Mobile Logo */}\n <div className=\"lg:hidden flex items-center justify-center gap-3 mb-8\">\n <BrandLogo brandInitial={brandInitial} />\n <span className=\"text-xl font-bold text-[var(--color-text-primary)]\">\n {displayName}\n </span>\n </div>\n\n {/* Header */}\n <div className=\"text-center lg:text-left mb-8\">\n <h2 className=\"text-2xl sm:text-3xl font-bold text-[var(--color-text-primary)] mb-2\">\n {title}\n </h2>\n <p className=\"text-[var(--color-text-secondary)]\">{subtitle}</p>\n </div>\n\n {/* Form Content */}\n {children}\n </div>\n </main>\n </div>\n );\n}\n"],"mappings":";;;;;AAsCA,IAAM,IAA6B;CACjC;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAW,MAAM;EAAQ;CACpE;EAAE,MAAM;EAAM,MAAM;EAAS,YAAY;EAAS,MAAM;EAAQ;C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ACF,CAAA;YACE,CAAA;WAEJ;aACN,kBAAC,QAAD;UAAM,WAAU;oBACb,EAAQ;UACJ,CAAA,CACH;WAlEI,EAAQ,KAkEZ,CACN;QACE,CAAA;OACF;;KAGN,kBAAC,OAAD;MAAK,WAAU;gBAAf;OAA+C;wBAC1C,IAAI,MAAM,EAAC,aAAa;OAAC;OACxB;;KACF;MACF;MAGN,kBAAC,QAAD;GAAM,WAAU;aAAhB,CAEE,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,GAAD;KACE,WAAW;KACX,iBAAiB;KACjB,mBAvKoB,MAAuB;AAMnD,QAAU,EAAS,KAA0B;;KAkKrC,CAAA;IACE,CAAA,EACN,kBAAC,OAAD;IAAK,WAAU;cAAf;KAEE,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,GAAD,EAAyB,iBAAgB,CAAA,EACzC,kBAAC,QAAD;OAAM,WAAU;iBACb;OACI,CAAA,CACH;;KAGN,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,MAAD;OAAI,WAAU;iBACX;OACE,CAAA,EACL,kBAAC,KAAD;OAAG,WAAU;iBAAsC;OAAa,CAAA,CAC5D;;KAGL;KACG;MACD;KACH"}
|
|
1
|
+
{"version":3,"file":"AuthLayout.js","names":[],"sources":["../../../src/auth/components/AuthLayout.tsx"],"sourcesContent":["import { useState, type ReactNode } from \"react\";\nimport { LanguageSwitcher } from \"@burdenoff/fe-libs/chrome\";\nimport type { Language } from \"@burdenoff/fe-libs/chrome\";\nimport {\n useI18n,\n useAppShell,\n} from \"@burdenoff/fe-libs/shared/providers/shell\";\nimport { useTr } from \"../../shared/hooks/useTr\";\nimport type { Locale } from \"@burdenoff/fe-libs/shared/providers/shell\";\n\ninterface AuthLayoutProps {\n children: ReactNode;\n title: string;\n subtitle: string;\n productName?: string;\n tagline?: string;\n}\n\n/**\n * Supported languages for the auth pages.\n *\n * Must stay in sync with the locales actually seeded in\n * `i18n_translations` for the consumer products that mount microfe-auth.\n * If a locale is listed here but NOT seeded, selecting it sets\n * `setLocale(<code>)` on the I18nProvider, the next `exportTranslations`\n * call returns zero rows, every `tr()` falls back to its English default,\n * and the user gets an English UI under a non-English flag.\n *\n * Audited 2026-05-31 against alpha `i18n_translations`: only `en/ta/hi/\n * zh/es/ar` have actual translations (vibecontrols 40k+ rows each).\n * `fr` was previously listed but no product seeds it — selecting it\n * produced a half-translated UI. Removed for parity with the dashboard\n * `LanguageSwitcherSlot` (which is data-driven from `i18n_languages`).\n *\n * Adding a new locale requires updating BOTH:\n * - this list\n * - each consumer product's seed (e.g. vibecontrols-app/scripts/\n * build-i18n-bundle.ts + the new `<code>.ts` translation source).\n */\nconst AUTH_LANGUAGES: Language[] = [\n { code: \"en\", name: \"English\", nativeName: \"English\", flag: \"🇺🇸\" },\n { code: \"ta\", name: \"Tamil\", nativeName: \"தமிழ்\", flag: \"🇮🇳\" },\n { code: \"hi\", name: \"Hindi\", nativeName: \"हिन्दी\", flag: \"🇮🇳\" },\n { code: \"zh\", name: \"Chinese\", nativeName: \"中文\", flag: \"🇨🇳\" },\n { code: \"es\", name: \"Spanish\", nativeName: \"Español\", flag: \"🇪🇸\" },\n { code: \"ar\", name: \"Arabic\", nativeName: \"العربية\", flag: \"🇸🇦\" },\n];\n\n/**\n * Brand logo for the auth pages.\n *\n * Renders the host app shell's real product logo served at `/icons/icon.svg`\n * (the same asset the marketing landing page uses) so the login screen and the\n * landing page show an identical mark instead of a generic placeholder glyph.\n * Host shells that don't ship that asset (e.g. admin-app) fall back to a\n * branded initial badge rather than a broken image.\n */\nfunction BrandLogo({ brandInitial }: { brandInitial: string }) {\n const [failed, setFailed] = useState(false);\n\n if (failed) {\n return (\n <div className=\"auth-brand-badge flex size-10 items-center justify-center rounded-xl\">\n <span className=\"text-lg font-bold leading-none text-white\">\n {brandInitial}\n </span>\n </div>\n );\n }\n\n return (\n <img\n src=\"/icons/icon.svg\"\n alt=\"\"\n aria-hidden=\"true\"\n className=\"size-10 rounded-xl object-contain\"\n onError={() => setFailed(true)}\n />\n );\n}\n\n/**\n * Professional auth layout with split-screen design\n * Left side: Branding with gradient background\n * Right side: Auth form\n */\nexport function AuthLayout({\n children,\n title,\n subtitle,\n productName,\n tagline,\n}: AuthLayoutProps) {\n const tr = useTr();\n const shell = useAppShell();\n const displayName = productName || shell.productName || \"Burdenoff\";\n const brandInitial = shell.brandInitial || \"B\";\n const displayTagline = tagline || shell.tagline || \"Enterprise platform\";\n const { locale, setLocale } = useI18n();\n\n const handleLanguageChange = (language: Language) => {\n // AUTH_LANGUAGES intentionally lists locales (e.g. \"ar\") that are seeded\n // in consumer products but not yet present in the fe-libs Locale union.\n // The runtime I18nProvider accepts any locale code, so we cast through\n // unknown to Locale to keep the picker in parity until fe-libs widens the\n // union. Keep AUTH_LANGUAGES in sync with consumer product seeds.\n setLocale(language.code as unknown as Locale);\n };\n\n return (\n <div className=\"min-h-screen flex relative\">\n {/* Left Panel - Branding */}\n <div className=\"auth-brand-panel hidden overflow-hidden lg:flex lg:w-1/2 relative\">\n {/* Decorative Elements */}\n <div className=\"absolute inset-0 overflow-hidden\">\n <div className=\"absolute -top-40 -left-40 size-80 rounded-full bg-accent-blue/20 blur-3xl\" />\n <div className=\"absolute top-1/2 -right-20 size-96 rounded-full bg-accent-indigo/20 blur-3xl\" />\n <div className=\"absolute -bottom-40 left-1/4 size-72 rounded-full bg-accent-purple/20 blur-3xl\" />\n\n {/* Grid Pattern */}\n <div\n className=\"absolute inset-0 opacity-5\"\n style={{\n backgroundImage: `url(\"data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E\")`,\n }}\n />\n </div>\n\n {/* Content */}\n <div className=\"relative z-10 flex flex-col justify-between p-12 w-full\">\n {/* Logo */}\n <div className=\"flex items-center gap-3\">\n <BrandLogo brandInitial={brandInitial} />\n <span className=\"text-xl font-bold text-[var(--color-text-primary)]\">\n {displayName}\n </span>\n </div>\n\n {/* Main Content */}\n <div className=\"max-w-md\">\n <h1 className=\"mb-4 text-4xl font-bold leading-tight text-[var(--color-text-primary)]\">\n {displayTagline}\n </h1>\n <p className=\"auth-brand-copy text-lg leading-relaxed\">\n {tr(\n \"auth.layout.taglineDescription\",\n \"Unify your teams, projects, and workflows in one intelligent workspace. Built for scale with enterprise-grade security, real-time collaboration, and seamless integrations across your entire organization.\",\n )}\n </p>\n\n {/* Features */}\n <div className=\"mt-10 space-y-4\">\n {[\n {\n icon: \"workspace\",\n text: tr(\n \"auth.layout.featureWorkspace\",\n \"Modular workspace architecture\",\n ),\n },\n {\n icon: \"realtime\",\n text: tr(\n \"auth.layout.featureRealtime\",\n \"Real-time collaboration & sync\",\n ),\n },\n {\n icon: \"security\",\n text: tr(\n \"auth.layout.featureSecurity\",\n \"Enterprise-grade security & SSO\",\n ),\n },\n {\n icon: \"scale\",\n text: tr(\n \"auth.layout.featureScale\",\n \"Unlimited scalability & performance\",\n ),\n },\n ].map((feature) => (\n <div key={feature.icon} className=\"flex items-center gap-3\">\n <div className=\"auth-highlight-chip flex size-8 items-center justify-center rounded-lg\">\n {feature.icon === \"workspace\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z\"\n />\n </svg>\n )}\n {feature.icon === \"realtime\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M17 8h2a2 2 0 012 2v6a2 2 0 01-2 2h-2v4l-4-4H9a1.994 1.994 0 01-1.414-.586m0 0L11 14h4a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2v4l.586-.586z\"\n />\n </svg>\n )}\n {feature.icon === \"security\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z\"\n />\n </svg>\n )}\n {feature.icon === \"scale\" && (\n <svg\n className=\"size-4 text-accent-blue\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z\"\n />\n </svg>\n )}\n </div>\n <span className=\"auth-brand-copy text-sm font-medium\">\n {feature.text}\n </span>\n </div>\n ))}\n </div>\n </div>\n\n {/* Footer */}\n <div className=\"auth-brand-copy-muted text-sm\">\n © {new Date().getFullYear()} Burdenoff. All rights reserved.\n </div>\n </div>\n </div>\n\n {/* Right Panel - Form */}\n <main className=\"auth-shell-gradient relative flex flex-1 items-center justify-center bg-[var(--color-bg-canvas)] p-6 sm:p-12\">\n {/* Language Switcher - Top Right */}\n <div className=\"absolute top-4 right-4 sm:top-6 sm:right-6 z-10\">\n <LanguageSwitcher\n languages={AUTH_LANGUAGES}\n currentLanguage={locale}\n onLanguageChange={handleLanguageChange}\n />\n </div>\n <div className=\"w-full max-w-md\">\n {/* Mobile Logo */}\n <div className=\"lg:hidden flex items-center justify-center gap-3 mb-8\">\n <BrandLogo brandInitial={brandInitial} />\n <span className=\"text-xl font-bold text-[var(--color-text-primary)]\">\n {displayName}\n </span>\n </div>\n\n {/* Header */}\n <div className=\"text-center lg:text-left mb-8\">\n <h2 className=\"text-2xl sm:text-3xl font-bold text-[var(--color-text-primary)] mb-2\">\n {title}\n </h2>\n <p className=\"text-[var(--color-text-secondary)]\">{subtitle}</p>\n </div>\n\n {/* Form Content */}\n {children}\n </div>\n </main>\n </div>\n );\n}\n"],"mappings":";;;;;;AAuCA,IAAM,IAA6B;CACjC;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAW,MAAM;EAAQ;CACpE;EAAE,MAAM;EAAM,MAAM;EAAS,YAAY;EAAS,MAAM;EAAQ;CAChE;EAAE,MAAM;EAAM,MAAM;EAAS,YAAY;EAAU,MAAM;EAAQ;CACjE;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAM,MAAM;EAAQ;CAC/D;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAW,MAAM;EAAQ;CACpE;EAAE,MAAM;EAAM,MAAM;EAAU,YAAY;EAAW,MAAM;EAAQ;CACpE;AAWD,SAAS,EAAU,EAAE,mBAA0C;CAC7D,IAAM,CAAC,GAAQ,KAAa,EAAS,GAAM;A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CAAA;IACE,CAAA,EACN,kBAAC,OAAD;IAAK,WAAU;cAAf;KAEE,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,GAAD,EAAyB,iBAAgB,CAAA,EACzC,kBAAC,QAAD;OAAM,WAAU;iBACb;OACI,CAAA,CACH;;KAGN,kBAAC,OAAD;MAAK,WAAU;gBAAf,CACE,kBAAC,MAAD;OAAI,WAAU;iBACX;OACE,CAAA,EACL,kBAAC,KAAD;OAAG,WAAU;iBAAsC;OAAa,CAAA,CAC5D;;KAGL;KACG;MACD;KACH"}
|
|
@@ -1,41 +1,38 @@
|
|
|
1
1
|
import { getRecaptchaSiteKey as e, isCaptchaEnabled as t } from "../utils/captchaConfig.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useTr as n } from "../../shared/hooks/useTr.js";
|
|
3
|
+
import { Suspense as r, lazy as i, useCallback as a, useState as o } from "react";
|
|
4
4
|
import { jsx as s } from "react/jsx-runtime";
|
|
5
5
|
//#region src/auth/components/CaptchaV2.tsx
|
|
6
|
-
var c =
|
|
7
|
-
let
|
|
8
|
-
|
|
9
|
-
}, [
|
|
10
|
-
|
|
11
|
-
}, [
|
|
12
|
-
return
|
|
6
|
+
var c = i(() => import("../../node_modules/react-google-recaptcha/lib/esm/index.js").then((t) => ({ default: function({ onVerify: r, onExpired: i, siteKey: c }) {
|
|
7
|
+
let l = n(), u = t.default, [, d] = o(null), f = c ?? e(), p = a((e) => {
|
|
8
|
+
r(e);
|
|
9
|
+
}, [r]), m = a(() => {
|
|
10
|
+
r(null), i?.();
|
|
11
|
+
}, [r, i]);
|
|
12
|
+
return f ? /* @__PURE__ */ s("div", {
|
|
13
13
|
className: "flex justify-center",
|
|
14
|
-
children: /* @__PURE__ */ s(
|
|
15
|
-
ref:
|
|
16
|
-
sitekey:
|
|
17
|
-
onChange:
|
|
18
|
-
onExpired:
|
|
14
|
+
children: /* @__PURE__ */ s(u, {
|
|
15
|
+
ref: d,
|
|
16
|
+
sitekey: f,
|
|
17
|
+
onChange: p,
|
|
18
|
+
onExpired: m
|
|
19
19
|
})
|
|
20
20
|
}) : /* @__PURE__ */ s("div", {
|
|
21
21
|
className: "rounded-lg bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text",
|
|
22
|
-
children: "reCAPTCHA site key is not configured."
|
|
22
|
+
children: l("auth.captcha.siteKeyMissing", "reCAPTCHA site key is not configured.")
|
|
23
23
|
});
|
|
24
24
|
} })));
|
|
25
|
-
function l({ onVerify: e, onExpired:
|
|
26
|
-
let
|
|
27
|
-
return
|
|
25
|
+
function l({ onVerify: e, onExpired: i, enabled: a, siteKey: o }) {
|
|
26
|
+
let l = n();
|
|
27
|
+
return a ?? t() ? /* @__PURE__ */ s(r, {
|
|
28
28
|
fallback: /* @__PURE__ */ s("div", {
|
|
29
29
|
className: "flex justify-center py-2",
|
|
30
|
-
children: (
|
|
31
|
-
let n = l(e);
|
|
32
|
-
return n === e ? t : n;
|
|
33
|
-
})("auth.captcha.loading", "Loading captcha...")
|
|
30
|
+
children: l("auth.captcha.loading", "Loading captcha...")
|
|
34
31
|
}),
|
|
35
32
|
children: /* @__PURE__ */ s(c, {
|
|
36
33
|
onVerify: e,
|
|
37
|
-
onExpired:
|
|
38
|
-
siteKey:
|
|
34
|
+
onExpired: i,
|
|
35
|
+
siteKey: o
|
|
39
36
|
})
|
|
40
37
|
}) : null;
|
|
41
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaV2.js","names":[],"sources":["../../../src/auth/components/CaptchaV2.tsx"],"sourcesContent":["import { lazy, Suspense, useState, useCallback } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"CaptchaV2.js","names":[],"sources":["../../../src/auth/components/CaptchaV2.tsx"],"sourcesContent":["import { lazy, Suspense, useState, useCallback } from \"react\";\nimport { useTr } from \"../../shared/hooks/useTr\";\nimport {\n getRecaptchaSiteKey,\n isCaptchaEnabled as getIsCaptchaEnabled,\n} from \"../utils/captchaConfig\";\n\ninterface CaptchaV2Props {\n onVerify: (token: string | null) => void;\n onExpired?: () => void;\n /**\n * Host-driven enable flag. When provided it takes precedence over the\n * build-time env switch (used so a per-product site key can turn the widget\n * on/off without rebuilding). When omitted, falls back to env.\n */\n enabled?: boolean;\n /**\n * reCAPTCHA v2 site key to render with. Overrides the build-time env key.\n * Resolved per-product by the caller (see `useSignupCaptcha`).\n */\n siteKey?: string;\n}\n\ninterface CaptchaWidgetProps {\n onVerify: (token: string | null) => void;\n onExpired?: () => void;\n siteKey?: string;\n}\n\n/**\n * Lazily loaded inner component that imports react-google-recaptcha.\n * Only loaded when captcha is enabled, avoiding import resolution\n * errors in dev environments where the package may not be installed.\n */\nconst LazyCaptchaWidget = lazy(() =>\n import(\"react-google-recaptcha\").then((mod) => ({\n default: function CaptchaWidget({\n onVerify,\n onExpired,\n siteKey: siteKeyProp,\n }: CaptchaWidgetProps) {\n const tr = useTr();\n const ReCAPTCHA = mod.default;\n const [, setRef] = useState<InstanceType<typeof ReCAPTCHA> | null>(null);\n const siteKey = siteKeyProp ?? getRecaptchaSiteKey();\n\n const forwardCaptchaToken = useCallback(\n (token: string | null) => {\n onVerify(token);\n },\n [onVerify],\n );\n\n const clearCaptchaToken = useCallback(() => {\n onVerify(null);\n onExpired?.();\n }, [onVerify, onExpired]);\n\n if (!siteKey) {\n return (\n <div className=\"rounded-lg bg-status-error-bg-subtle px-3 py-2 text-sm text-status-error-text\">\n {tr(\n \"auth.captcha.siteKeyMissing\",\n \"reCAPTCHA site key is not configured.\",\n )}\n </div>\n );\n }\n\n return (\n <div className=\"flex justify-center\">\n <ReCAPTCHA\n ref={setRef}\n sitekey={siteKey}\n onChange={forwardCaptchaToken}\n onExpired={clearCaptchaToken}\n />\n </div>\n );\n },\n })),\n);\n\n/**\n * reCAPTCHA v2 checkbox component.\n *\n * Enablement is host-driven via the `enabled` prop (resolved per-product from\n * the platform catalog). When `enabled` is omitted it falls back to the\n * build-time `VITE_CAPTCHA_ENABLED` env for local source-dev. Renders nothing\n * when disabled and lazily loads the Google reCAPTCHA library only when enabled.\n */\nexport function CaptchaV2({\n onVerify,\n onExpired,\n enabled,\n siteKey,\n}: CaptchaV2Props) {\n const tr = useTr();\n\n const isEnabled = enabled ?? getIsCaptchaEnabled();\n if (!isEnabled) {\n return null;\n }\n\n return (\n <Suspense\n fallback={\n <div className=\"flex justify-center py-2\">\n {tr(\"auth.captcha.loading\", \"Loading captcha...\")}\n </div>\n }\n >\n <LazyCaptchaWidget\n onVerify={onVerify}\n onExpired={onExpired}\n siteKey={siteKey}\n />\n </Suspense>\n );\n}\n"],"mappings":";;;;;AAkCA,IAAM,IAAoB,QACxB,OAAO,8DAA0B,MAAM,OAAS,EAC9C,SAAS,SAAuB,EAC9B,aACA,cACA,SAAS,KACY;CACrB,IAAM,IAAK,GAAO,EACZ,IAAY,EAAI,SAChB,GAAG,KAAU,EAAgD,KAAK,EAClE,IAAU,KAAe,GAAqB,EAE9C,IAAsB,GACzB,MAAyB;AACxB,IAAS,EAAM;IAEjB,CAAC,EAAS,CACX,EAEK,IAAoB,QAAkB;AAE1C,EADA,EAAS,KAAK,EACd,KAAa;IACZ,CAAC,GAAU,EAAU,CAAC;AAazB,QAXK,IAYH,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,GAAD;GACE,KAAK;GACL,SAAS;GACT,UAAU;GACV,WAAW;GACX,CAAA;EACE,CAAA,GAjBJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EACC,+BACA,wCACD;EACG,CAAA;GAeb,EAAE,CACJ;AAUD,SAAgB,EAAU,EACxB,aACA,cACA,YACA,cACiB;CACjB,IAAM,IAAK,GAAO;AAOlB,QALkB,KAAW,GAAqB,GAMhD,kBAAC,GAAD;EACE,UACE,kBAAC,OAAD;GAAK,WAAU;aACZ,EAAG,wBAAwB,qBAAqB;GAC7C,CAAA;YAGR,kBAAC,GAAD;GACY;GACC;GACF;GACT,CAAA;EACO,CAAA,GAhBJ"}
|
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import { AlertCircle as t, AlertTriangle as n, Info as r, Loader2 as i } from "lucide-react";
|
|
3
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
4
|
+
import { AlertDialog as s, AlertDialogAction as c, AlertDialogCancel as l, AlertDialogContent as u, AlertDialogDescription as d, AlertDialogFooter as f, AlertDialogHeader as p, AlertDialogTitle as m } from "@burdenoff/fe-libs/ui";
|
|
4
5
|
//#region src/auth/components/ConfirmActionDialog.tsx
|
|
5
|
-
var
|
|
6
|
+
var h = {
|
|
6
7
|
default: {
|
|
7
|
-
icon:
|
|
8
|
+
icon: r,
|
|
8
9
|
iconContainerClassName: "bg-[var(--color-status-info-bg-subtle)]",
|
|
9
10
|
iconClassName: "text-[var(--color-status-info-text)]",
|
|
10
11
|
actionClassName: "bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)] hover:opacity-90"
|
|
11
12
|
},
|
|
12
13
|
warning: {
|
|
13
|
-
icon:
|
|
14
|
+
icon: n,
|
|
14
15
|
iconContainerClassName: "bg-[var(--color-status-warning-bg-subtle)]",
|
|
15
16
|
iconClassName: "text-[var(--color-status-warning-text)]",
|
|
16
17
|
actionClassName: "bg-[var(--color-status-warning-bg)] text-[var(--color-text-inverse)] hover:opacity-90"
|
|
17
18
|
},
|
|
18
19
|
danger: {
|
|
19
|
-
icon:
|
|
20
|
+
icon: t,
|
|
20
21
|
iconContainerClassName: "bg-[var(--color-status-error-bg-subtle)]",
|
|
21
22
|
iconClassName: "text-[var(--color-status-error-text)]",
|
|
22
23
|
actionClassName: "bg-[var(--color-status-error-bg)] text-[var(--color-text-inverse)] hover:opacity-90"
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
open:
|
|
29
|
-
onOpenChange:
|
|
30
|
-
children: /* @__PURE__ */
|
|
26
|
+
function g({ open: t, onOpenChange: n, title: r, description: g, confirmText: _, cancelText: v, variant: y = "default", isPending: b = !1, disabled: x = !1, onConfirm: S }) {
|
|
27
|
+
let C = e(), w = _ || C("auth.confirmDialog.confirm", "Confirm"), T = v || C("auth.confirmDialog.cancel", "Cancel"), E = h[y], D = E.icon;
|
|
28
|
+
return /* @__PURE__ */ a(s, {
|
|
29
|
+
open: t,
|
|
30
|
+
onOpenChange: n,
|
|
31
|
+
children: /* @__PURE__ */ o(u, {
|
|
31
32
|
className: "max-w-md border-[var(--color-border-default)] bg-[var(--color-bg-surface)] text-[var(--color-text-primary)]",
|
|
32
|
-
children: [/* @__PURE__ */
|
|
33
|
+
children: [/* @__PURE__ */ a(p, { children: /* @__PURE__ */ o("div", {
|
|
33
34
|
className: "flex items-start gap-4",
|
|
34
|
-
children: [/* @__PURE__ */
|
|
35
|
-
className: `flex size-10 shrink-0 items-center justify-center rounded-full ${
|
|
36
|
-
children: /* @__PURE__ */
|
|
37
|
-
}), /* @__PURE__ */
|
|
35
|
+
children: [/* @__PURE__ */ a("div", {
|
|
36
|
+
className: `flex size-10 shrink-0 items-center justify-center rounded-full ${E.iconContainerClassName}`,
|
|
37
|
+
children: /* @__PURE__ */ a(D, { className: `size-5 ${E.iconClassName}` })
|
|
38
|
+
}), /* @__PURE__ */ o("div", {
|
|
38
39
|
className: "flex-1",
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
+
children: [/* @__PURE__ */ a(m, {
|
|
40
41
|
className: "text-lg text-[var(--color-text-primary)]",
|
|
41
|
-
children:
|
|
42
|
-
}), /* @__PURE__ */
|
|
42
|
+
children: r
|
|
43
|
+
}), /* @__PURE__ */ a(d, {
|
|
43
44
|
className: "mt-2 text-sm text-[var(--color-text-secondary)]",
|
|
44
|
-
children:
|
|
45
|
+
children: g
|
|
45
46
|
})]
|
|
46
47
|
})]
|
|
47
|
-
}) }), /* @__PURE__ */
|
|
48
|
+
}) }), /* @__PURE__ */ o(f, {
|
|
48
49
|
className: "mt-6",
|
|
49
|
-
children: [/* @__PURE__ */
|
|
50
|
-
disabled:
|
|
50
|
+
children: [/* @__PURE__ */ a(l, {
|
|
51
|
+
disabled: b,
|
|
51
52
|
className: "border-[var(--color-border-default)] bg-[var(--color-bg-surface)] text-[var(--color-text-primary)] hover:bg-[var(--color-bg-subtle)]",
|
|
52
|
-
children:
|
|
53
|
-
}), /* @__PURE__ */
|
|
54
|
-
disabled:
|
|
53
|
+
children: T
|
|
54
|
+
}), /* @__PURE__ */ o(c, {
|
|
55
|
+
disabled: x || b,
|
|
55
56
|
onClick: (e) => {
|
|
56
|
-
e.preventDefault(),
|
|
57
|
+
e.preventDefault(), S();
|
|
57
58
|
},
|
|
58
|
-
className:
|
|
59
|
-
children: [
|
|
59
|
+
className: E.actionClassName,
|
|
60
|
+
children: [b ? /* @__PURE__ */ a(i, { className: "size-4 animate-spin" }) : null, w]
|
|
60
61
|
})]
|
|
61
62
|
})]
|
|
62
63
|
})
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
//#endregion
|
|
66
|
-
export {
|
|
67
|
+
export { g as ConfirmActionDialog };
|
|
67
68
|
|
|
68
69
|
//# sourceMappingURL=ConfirmActionDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmActionDialog.js","names":[],"sources":["../../../src/auth/components/ConfirmActionDialog.tsx"],"sourcesContent":["import { AlertCircle, AlertTriangle, Info, Loader2 } from \"lucide-react\";\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from \"@burdenoff/fe-libs/ui\";\n\ntype ConfirmActionDialogVariant = \"default\" | \"warning\" | \"danger\";\n\ninterface ConfirmActionDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: string;\n description: string;\n confirmText?: string;\n cancelText?: string;\n variant?: ConfirmActionDialogVariant;\n isPending?: boolean;\n disabled?: boolean;\n onConfirm: () => void | Promise<void>;\n}\n\nconst VARIANT_STYLES: Record<\n ConfirmActionDialogVariant,\n {\n icon: typeof Info;\n iconContainerClassName: string;\n iconClassName: string;\n actionClassName: string;\n }\n> = {\n default: {\n icon: Info,\n iconContainerClassName: \"bg-[var(--color-status-info-bg-subtle)]\",\n iconClassName: \"text-[var(--color-status-info-text)]\",\n actionClassName:\n \"bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)] hover:opacity-90\",\n },\n warning: {\n icon: AlertTriangle,\n iconContainerClassName: \"bg-[var(--color-status-warning-bg-subtle)]\",\n iconClassName: \"text-[var(--color-status-warning-text)]\",\n actionClassName:\n \"bg-[var(--color-status-warning-bg)] text-[var(--color-text-inverse)] hover:opacity-90\",\n },\n danger: {\n icon: AlertCircle,\n iconContainerClassName: \"bg-[var(--color-status-error-bg-subtle)]\",\n iconClassName: \"text-[var(--color-status-error-text)]\",\n actionClassName:\n \"bg-[var(--color-status-error-bg)] text-[var(--color-text-inverse)] hover:opacity-90\",\n },\n};\n\nexport function ConfirmActionDialog({\n open,\n onOpenChange,\n title,\n description,\n confirmText
|
|
1
|
+
{"version":3,"file":"ConfirmActionDialog.js","names":[],"sources":["../../../src/auth/components/ConfirmActionDialog.tsx"],"sourcesContent":["import { AlertCircle, AlertTriangle, Info, Loader2 } from \"lucide-react\";\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from \"@burdenoff/fe-libs/ui\";\nimport { useTr } from \"../../shared/hooks/useTr\";\n\ntype ConfirmActionDialogVariant = \"default\" | \"warning\" | \"danger\";\n\ninterface ConfirmActionDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n title: string;\n description: string;\n confirmText?: string;\n cancelText?: string;\n variant?: ConfirmActionDialogVariant;\n isPending?: boolean;\n disabled?: boolean;\n onConfirm: () => void | Promise<void>;\n}\n\nconst VARIANT_STYLES: Record<\n ConfirmActionDialogVariant,\n {\n icon: typeof Info;\n iconContainerClassName: string;\n iconClassName: string;\n actionClassName: string;\n }\n> = {\n default: {\n icon: Info,\n iconContainerClassName: \"bg-[var(--color-status-info-bg-subtle)]\",\n iconClassName: \"text-[var(--color-status-info-text)]\",\n actionClassName:\n \"bg-[var(--color-action-primary-bg)] text-[var(--color-action-primary-text)] hover:opacity-90\",\n },\n warning: {\n icon: AlertTriangle,\n iconContainerClassName: \"bg-[var(--color-status-warning-bg-subtle)]\",\n iconClassName: \"text-[var(--color-status-warning-text)]\",\n actionClassName:\n \"bg-[var(--color-status-warning-bg)] text-[var(--color-text-inverse)] hover:opacity-90\",\n },\n danger: {\n icon: AlertCircle,\n iconContainerClassName: \"bg-[var(--color-status-error-bg-subtle)]\",\n iconClassName: \"text-[var(--color-status-error-text)]\",\n actionClassName:\n \"bg-[var(--color-status-error-bg)] text-[var(--color-text-inverse)] hover:opacity-90\",\n },\n};\n\nexport function ConfirmActionDialog({\n open,\n onOpenChange,\n title,\n description,\n confirmText,\n cancelText,\n variant = \"default\",\n isPending = false,\n disabled = false,\n onConfirm,\n}: ConfirmActionDialogProps) {\n const tr = useTr();\n const resolvedConfirmText =\n confirmText || tr(\"auth.confirmDialog.confirm\", \"Confirm\");\n const resolvedCancelText =\n cancelText || tr(\"auth.confirmDialog.cancel\", \"Cancel\");\n const styles = VARIANT_STYLES[variant];\n const Icon = styles.icon;\n\n return (\n <AlertDialog open={open} onOpenChange={onOpenChange}>\n <AlertDialogContent className=\"max-w-md border-[var(--color-border-default)] bg-[var(--color-bg-surface)] text-[var(--color-text-primary)]\">\n <AlertDialogHeader>\n <div className=\"flex items-start gap-4\">\n <div\n className={`flex size-10 shrink-0 items-center justify-center rounded-full ${styles.iconContainerClassName}`}\n >\n <Icon className={`size-5 ${styles.iconClassName}`} />\n </div>\n <div className=\"flex-1\">\n <AlertDialogTitle className=\"text-lg text-[var(--color-text-primary)]\">\n {title}\n </AlertDialogTitle>\n <AlertDialogDescription className=\"mt-2 text-sm text-[var(--color-text-secondary)]\">\n {description}\n </AlertDialogDescription>\n </div>\n </div>\n </AlertDialogHeader>\n\n <AlertDialogFooter className=\"mt-6\">\n <AlertDialogCancel\n disabled={isPending}\n className=\"border-[var(--color-border-default)] bg-[var(--color-bg-surface)] text-[var(--color-text-primary)] hover:bg-[var(--color-bg-subtle)]\"\n >\n {resolvedCancelText}\n </AlertDialogCancel>\n <AlertDialogAction\n disabled={disabled || isPending}\n onClick={(event) => {\n event.preventDefault();\n void onConfirm();\n }}\n className={styles.actionClassName}\n >\n {isPending ? <Loader2 className=\"size-4 animate-spin\" /> : null}\n {resolvedConfirmText}\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n"],"mappings":";;;;;AA4BA,IAAM,IAQF;CACF,SAAS;EACP,MAAM;EACN,wBAAwB;EACxB,eAAe;EACf,iBACE;EACH;CACD,SAAS;EACP,MAAM;EACN,wBAAwB;EACxB,eAAe;EACf,iBACE;EACH;CACD,QAAQ;EACN,MAAM;EACN,wBAAwB;EACxB,eAAe;EACf,iBACE;EACH;CACF;AAED,SAAgB,EAAoB,EAClC,SACA,iBACA,UACA,gBACA,gBACA,eACA,aAAU,WACV,eAAY,IACZ,cAAW,IACX,gBAC2B;CAC3B,IAAM,IAAK,GAAO,EACZ,IACJ,KAAe,EAAG,8BAA8B,UAAU,EACtD,IACJ,KAAc,EAAG,6BAA6B,SAAS,EACnD,IAAS,EAAe,IACxB,IAAO,EAAO;AAEpB,QACE,kBAAC,GAAD;EAAmB;EAAoB;YACrC,kBAAC,GAAD;GAAoB,WAAU;aAA9B,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,OAAD;KACE,WAAW,kEAAkE,EAAO;eAEpF,kBAAC,GAAD,EAAM,WAAW,UAAU,EAAO,iBAAmB,CAAA;KACjD,CAAA,EACN,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD;MAAkB,WAAU;gBACzB;MACgB,CAAA,EACnB,kBAAC,GAAD;MAAwB,WAAU;gBAC/B;MACsB,CAAA,CACrB;OACF;OACY,CAAA,EAEpB,kBAAC,GAAD;IAAmB,WAAU;cAA7B,CACE,kBAAC,GAAD;KACE,UAAU;KACV,WAAU;eAET;KACiB,CAAA,EACpB,kBAAC,GAAD;KACE,UAAU,KAAY;KACtB,UAAU,MAAU;AAEb,MADL,EAAM,gBAAgB,EACjB,GAAW;;KAElB,WAAW,EAAO;eANpB,CAQG,IAAY,kBAAC,GAAD,EAAS,WAAU,uBAAwB,CAAA,GAAG,MAC1D,EACiB;OACF;MACD;;EACT,CAAA"}
|
|
@@ -1,77 +1,75 @@
|
|
|
1
1
|
import { useAuthStore as e } from "../../store/authStore.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useTr as t } from "../../../shared/hooks/useTr.js";
|
|
3
|
+
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
+
import { useNavigate as a } from "react-router";
|
|
5
|
+
import { Building2 as o, ChevronDown as s, LogOut as c, UserPlus as l } from "lucide-react";
|
|
6
6
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
7
|
//#region src/auth/components/profile/UserProfileMenu.tsx
|
|
8
8
|
function f({ onSwitchWorkspace: f, onLogout: p, position: m = "right" }) {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
return n === e ? t : n;
|
|
12
|
-
}, [_, v] = r(!1), y = n(null), b = i(), x = e((e) => e.user), S = e((e) => e.currentWorkspaceId);
|
|
13
|
-
t(() => {
|
|
9
|
+
let h = t(), [g, _] = i(!1), v = r(null), y = a(), b = e((e) => e.user), x = e((e) => e.currentWorkspaceId);
|
|
10
|
+
n(() => {
|
|
14
11
|
function e(e) {
|
|
15
|
-
|
|
12
|
+
v.current && !v.current.contains(e.target) && _(!1);
|
|
16
13
|
}
|
|
17
|
-
if (
|
|
18
|
-
}, [
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
14
|
+
if (g) return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
15
|
+
}, [g]);
|
|
16
|
+
let S = () => {
|
|
17
|
+
_(!1), p();
|
|
18
|
+
}, C = () => {
|
|
19
|
+
_(!1), f?.();
|
|
23
20
|
};
|
|
24
|
-
if (!
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
27
|
-
if (
|
|
28
|
-
let e =
|
|
29
|
-
return e.length >= 2 ? `${e[0][0]}${e[1][0]}`.toUpperCase() :
|
|
21
|
+
if (!b) return null;
|
|
22
|
+
let w = () => {
|
|
23
|
+
if (b.firstName && b.lastName) return `${b.firstName[0]}${b.lastName[0]}`.toUpperCase();
|
|
24
|
+
if (b.name) {
|
|
25
|
+
let e = b.name.split(" ");
|
|
26
|
+
return e.length >= 2 ? `${e[0][0]}${e[1][0]}`.toUpperCase() : b.name.substring(0, 2).toUpperCase();
|
|
30
27
|
}
|
|
31
|
-
return
|
|
32
|
-
},
|
|
28
|
+
return b.username ? b.username.substring(0, 2).toUpperCase() : b.email.substring(0, 2).toUpperCase();
|
|
29
|
+
}, T = b.name || `${b.firstName || ""} ${b.lastName || ""}`.trim() || b.username;
|
|
33
30
|
return /* @__PURE__ */ d("div", {
|
|
34
31
|
className: "relative",
|
|
35
|
-
ref:
|
|
32
|
+
ref: v,
|
|
36
33
|
children: [/* @__PURE__ */ d("button", {
|
|
37
34
|
type: "button",
|
|
38
|
-
onClick: () =>
|
|
35
|
+
onClick: () => _(!g),
|
|
39
36
|
className: "flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-bg-sunken transition-colors",
|
|
40
|
-
"aria-label": "User menu",
|
|
41
|
-
"aria-expanded":
|
|
37
|
+
"aria-label": h("auth.profileMenu.userMenu", "User menu"),
|
|
38
|
+
"aria-expanded": g,
|
|
42
39
|
children: [
|
|
43
40
|
/* @__PURE__ */ u("div", {
|
|
44
41
|
className: "size-8 rounded-full bg-accent-blue flex items-center justify-center text-white text-sm font-medium overflow-hidden",
|
|
45
|
-
children:
|
|
46
|
-
src:
|
|
47
|
-
alt:
|
|
42
|
+
children: b.avatar ? /* @__PURE__ */ u("img", {
|
|
43
|
+
src: b.avatar,
|
|
44
|
+
alt: h("auth.profileMenu.avatarAlt", "Profile picture"),
|
|
48
45
|
className: "size-full object-cover"
|
|
49
|
-
}) :
|
|
46
|
+
}) : w()
|
|
50
47
|
}),
|
|
51
48
|
/* @__PURE__ */ u("span", {
|
|
52
49
|
className: "hidden sm:block text-sm font-medium text-text-secondary",
|
|
53
|
-
children:
|
|
50
|
+
children: T
|
|
54
51
|
}),
|
|
55
|
-
/* @__PURE__ */ u(
|
|
52
|
+
/* @__PURE__ */ u(s, { className: `size-4 text-text-secondary transition-transform ${g ? "rotate-180" : ""}` })
|
|
56
53
|
]
|
|
57
|
-
}),
|
|
54
|
+
}), g && /* @__PURE__ */ d("div", {
|
|
58
55
|
className: `absolute top-full mt-2 w-64 bg-bg-surface rounded-lg shadow-lg border border-border-subtle py-2 z-50 ${m === "right" ? "right-0" : "left-0"}`,
|
|
59
56
|
children: [/* @__PURE__ */ d("div", {
|
|
60
57
|
className: "px-4 py-3 border-b border-border-subtle",
|
|
61
58
|
children: [
|
|
62
59
|
/* @__PURE__ */ u("p", {
|
|
63
60
|
className: "text-sm font-medium text-text-primary truncate",
|
|
64
|
-
children:
|
|
61
|
+
children: T
|
|
65
62
|
}),
|
|
66
63
|
/* @__PURE__ */ u("p", {
|
|
67
64
|
className: "text-xs text-text-secondary truncate",
|
|
68
|
-
children:
|
|
65
|
+
children: b.email
|
|
69
66
|
}),
|
|
70
|
-
|
|
67
|
+
x && /* @__PURE__ */ d("p", {
|
|
71
68
|
className: "text-xs text-text-tertiary mt-1 truncate",
|
|
72
69
|
children: [
|
|
73
|
-
"Workspace:
|
|
74
|
-
|
|
70
|
+
h("auth.profileMenu.workspaceLabel", "Workspace:"),
|
|
71
|
+
" ",
|
|
72
|
+
x.substring(0, 8),
|
|
75
73
|
"..."
|
|
76
74
|
]
|
|
77
75
|
})
|
|
@@ -81,23 +79,23 @@ function f({ onSwitchWorkspace: f, onLogout: p, position: m = "right" }) {
|
|
|
81
79
|
children: [
|
|
82
80
|
f && /* @__PURE__ */ d("button", {
|
|
83
81
|
type: "button",
|
|
84
|
-
onClick:
|
|
82
|
+
onClick: C,
|
|
85
83
|
className: "w-full flex items-center gap-3 px-4 py-2 text-sm text-text-secondary hover:bg-bg-sunken transition-colors",
|
|
86
|
-
children: [/* @__PURE__ */ u(
|
|
84
|
+
children: [/* @__PURE__ */ u(o, { className: "size-4" }), /* @__PURE__ */ u("span", { children: h("auth.profileMenu.switchWorkspace", "Switch Workspace") })]
|
|
87
85
|
}),
|
|
88
86
|
/* @__PURE__ */ d("button", {
|
|
89
87
|
type: "button",
|
|
90
88
|
onClick: () => {
|
|
91
|
-
|
|
89
|
+
_(!1), y(`/auth/login?mode=add-account&returnTo=${encodeURIComponent(window.location.pathname + window.location.search)}`);
|
|
92
90
|
},
|
|
93
91
|
className: "w-full flex items-center gap-3 px-4 py-2 text-sm text-text-secondary hover:bg-bg-sunken transition-colors",
|
|
94
|
-
children: [/* @__PURE__ */ u(
|
|
92
|
+
children: [/* @__PURE__ */ u(l, { className: "size-4" }), /* @__PURE__ */ u("span", { children: h("auth.profileMenu.addAccount", "Add account") })]
|
|
95
93
|
}),
|
|
96
94
|
/* @__PURE__ */ d("button", {
|
|
97
95
|
type: "button",
|
|
98
|
-
onClick:
|
|
96
|
+
onClick: S,
|
|
99
97
|
className: "w-full flex items-center gap-3 px-4 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle transition-colors",
|
|
100
|
-
children: [/* @__PURE__ */ u(
|
|
98
|
+
children: [/* @__PURE__ */ u(c, { className: "size-4" }), /* @__PURE__ */ u("span", { children: h("auth.profileMenu.logout", "Logout") })]
|
|
101
99
|
})
|
|
102
100
|
]
|
|
103
101
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfileMenu.js","names":[],"sources":["../../../../src/auth/components/profile/UserProfileMenu.tsx"],"sourcesContent":["import { useState, useRef, useEffect } from \"react\";\nimport {
|
|
1
|
+
{"version":3,"file":"UserProfileMenu.js","names":[],"sources":["../../../../src/auth/components/profile/UserProfileMenu.tsx"],"sourcesContent":["import { useState, useRef, useEffect } from \"react\";\nimport { useTr } from \"../../../shared/hooks/useTr\";\nimport { LogOut, ChevronDown, Building2, UserPlus } from \"lucide-react\";\nimport { useNavigate } from \"react-router\";\nimport { useAuthStore } from \"../../store/authStore\";\n\nexport interface UserProfileMenuProps {\n /**\n * Callback when workspace switcher should be shown\n */\n onSwitchWorkspace?: () => void;\n\n /**\n * Logout handler (REQUIRED)\n * Should clear auth state and redirect to login\n */\n onLogout: () => void;\n\n /**\n * Position of the dropdown menu\n * @default 'right'\n */\n position?: \"left\" | \"right\";\n}\n\n/**\n * User Profile Menu Component\n *\n * Displays user avatar/icon with dropdown menu containing:\n * - User information\n * - Switch Workspace option\n * - Logout button\n *\n * @example\n * ```tsx\n * import { UserProfileMenu } from '@burdenoff/microfe-auth';\n *\n * function AppHeader() {\n * return (\n * <div className=\"header\">\n * <UserProfileMenu\n * onSwitchWorkspace={() => setShowWorkspaceSwitcher(true)}\n * position=\"right\"\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function UserProfileMenu({\n onSwitchWorkspace,\n onLogout,\n position = \"right\",\n}: UserProfileMenuProps) {\n const tr = useTr();\n\n const [isOpen, setIsOpen] = useState(false);\n const menuRef = useRef<HTMLDivElement>(null);\n const navigate = useNavigate();\n\n const user = useAuthStore((state) => state.user);\n const currentWorkspaceId = useAuthStore((state) => state.currentWorkspaceId);\n\n // Close dropdown when clicking outside\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (menuRef.current && !menuRef.current.contains(event.target as Node)) {\n setIsOpen(false);\n }\n }\n\n if (isOpen) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () =>\n document.removeEventListener(\"mousedown\", handleClickOutside);\n }\n }, [isOpen]);\n\n const handleLogout = () => {\n setIsOpen(false);\n onLogout();\n };\n\n const handleSwitchWorkspace = () => {\n setIsOpen(false);\n onSwitchWorkspace?.();\n };\n\n if (!user) {\n return null;\n }\n\n // Get user initials for avatar\n const getInitials = () => {\n if (user.firstName && user.lastName) {\n return `${user.firstName[0]}${user.lastName[0]}`.toUpperCase();\n }\n if (user.name) {\n const parts = user.name.split(\" \");\n if (parts.length >= 2) {\n return `${parts[0][0]}${parts[1][0]}`.toUpperCase();\n }\n return user.name.substring(0, 2).toUpperCase();\n }\n if (user.username) {\n return user.username.substring(0, 2).toUpperCase();\n }\n return user.email.substring(0, 2).toUpperCase();\n };\n\n const displayName =\n user.name ||\n `${user.firstName || \"\"} ${user.lastName || \"\"}`.trim() ||\n user.username;\n\n return (\n <div className=\"relative\" ref={menuRef}>\n {/* Profile Button */}\n <button\n type=\"button\"\n onClick={() => setIsOpen(!isOpen)}\n className=\"flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-bg-sunken transition-colors\"\n aria-label={tr(\"auth.profileMenu.userMenu\", \"User menu\")}\n aria-expanded={isOpen}\n >\n {/* Avatar */}\n <div className=\"size-8 rounded-full bg-accent-blue flex items-center justify-center text-white text-sm font-medium overflow-hidden\">\n {user.avatar ? (\n <img\n src={user.avatar}\n alt={tr(\"auth.profileMenu.avatarAlt\", \"Profile picture\")}\n className=\"size-full object-cover\"\n />\n ) : (\n getInitials()\n )}\n </div>\n\n {/* User Name (optional, hide on small screens) */}\n <span className=\"hidden sm:block text-sm font-medium text-text-secondary\">\n {displayName}\n </span>\n\n {/* Chevron */}\n <ChevronDown\n className={`size-4 text-text-secondary transition-transform ${\n isOpen ? \"rotate-180\" : \"\"\n }`}\n />\n </button>\n\n {/* Dropdown Menu */}\n {isOpen && (\n <div\n className={`absolute top-full mt-2 w-64 bg-bg-surface rounded-lg shadow-lg border border-border-subtle py-2 z-50 ${\n position === \"right\" ? \"right-0\" : \"left-0\"\n }`}\n >\n {/* User Info Section */}\n <div className=\"px-4 py-3 border-b border-border-subtle\">\n <p className=\"text-sm font-medium text-text-primary truncate\">\n {displayName}\n </p>\n <p className=\"text-xs text-text-secondary truncate\">{user.email}</p>\n {currentWorkspaceId && (\n <p className=\"text-xs text-text-tertiary mt-1 truncate\">\n {tr(\"auth.profileMenu.workspaceLabel\", \"Workspace:\")}{\" \"}\n {currentWorkspaceId.substring(0, 8)}...\n </p>\n )}\n </div>\n\n {/* Menu Items */}\n <div className=\"py-1\">\n {/* Switch Workspace */}\n {onSwitchWorkspace && (\n <button\n type=\"button\"\n onClick={handleSwitchWorkspace}\n className=\"w-full flex items-center gap-3 px-4 py-2 text-sm text-text-secondary hover:bg-bg-sunken transition-colors\"\n >\n <Building2 className=\"size-4\" />\n <span>\n {tr(\"auth.profileMenu.switchWorkspace\", \"Switch Workspace\")}\n </span>\n </button>\n )}\n\n {/* Add Account */}\n <button\n type=\"button\"\n onClick={() => {\n setIsOpen(false);\n const returnTo = encodeURIComponent(\n window.location.pathname + window.location.search,\n );\n navigate(`/auth/login?mode=add-account&returnTo=${returnTo}`);\n }}\n className=\"w-full flex items-center gap-3 px-4 py-2 text-sm text-text-secondary hover:bg-bg-sunken transition-colors\"\n >\n <UserPlus className=\"size-4\" />\n <span>{tr(\"auth.profileMenu.addAccount\", \"Add account\")}</span>\n </button>\n\n {/* Logout */}\n <button\n type=\"button\"\n onClick={handleLogout}\n className=\"w-full flex items-center gap-3 px-4 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle transition-colors\"\n >\n <LogOut className=\"size-4\" />\n <span>{tr(\"auth.profileMenu.logout\", \"Logout\")}</span>\n </button>\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;AAiD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