@micha.bigler/ui-core-micha 4.32.0 → 4.33.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.33.1 - UCM-PRIV-4
4
+
5
+ `AccountPage` now accepts `privacyMode` (default `'legacy'`, unchanged) and forwards it to `ProfileComponent`. With
6
+ `privacyMode="central"` the account profile has no privacy-statement or convenience-cookie checkbox, requests no legacy
7
+ statements and sends neither legacy field; name editing and the central privacy notice link are unchanged, also while the
8
+ manifest loads or fails. Omitting the prop keeps the legacy behaviour until UCM-PRIV-2. This closes the 4.32.0/4.33.0 gap where
9
+ only the standalone profile components could select the central contract.
10
+
11
+ ## 4.33.0 - UCM-PRIV-3
12
+
13
+ Adds the opt-in `PublicFooter` and provider-independent `useLegalEntries` helpers, `UserMenu`'s additive `legal` prop, and
14
+ the `Privacy.LEGAL_*` labels for central documents, host-local legal links and settings. Public footers retain legal links
15
+ without a privacy provider; authenticated consumers can expose the same destinations and app settings through the menu.
16
+ Existing consumers are unchanged when they do not opt in. `PrivacyFooterLinks` remains available for compatibility.
17
+
3
18
  ## 4.32.0 - UCM-PRIV-1
4
19
 
5
20
  Adds opt-in shared privacy choices for hosts on `django-core-micha` >= 3.22.0: `PrivacyProvider`, `usePrivacy`, the
package/README.md CHANGED
@@ -18,8 +18,9 @@ The privacy and cookie consent controls and their submitted values remain availa
18
18
 
19
19
  ## Shared privacy choices (opt-in)
20
20
 
21
- Hosts using `django-core-micha` >= 3.22.0 can adopt `PrivacyProvider`, `PrivacyBanner`, `PrivacySettingsLink` and
22
- `PrivacyNoticeLink`. Create the API once and pass it to the provider when the host mounts the privacy routes elsewhere:
21
+ Hosts using `django-core-micha` >= 3.22.0 can adopt `PrivacyProvider`, `PrivacyBanner`, `PublicFooter`, `UserMenu`'s
22
+ `legal` prop, `PrivacySettingsLink` and `PrivacyNoticeLink`. Create the API once and pass it to the provider when the
23
+ host mounts the privacy routes elsewhere:
23
24
 
24
25
  ```jsx
25
26
  const privacyApi = createPrivacyApi({}, { apiBase: '/api/privacy/', csrfUrl: '/api/csrf/' });
@@ -31,14 +32,35 @@ const privacyApi = createPrivacyApi({}, { apiBase: '/api/privacy/', csrfUrl: '/a
31
32
  </PrivacyProvider>
32
33
  ```
33
34
 
34
- Place `PrivacyProvider` above the router content, render one `PrivacyBanner` in the app shell, and put
35
- `PrivacySettingsLink` in the public footer and account area. The provider owns the settings dialog. Register each app-owned
35
+ Place `PrivacyProvider` above the router content and render one `PrivacyBanner` in the app shell. Use `PublicFooter` on
36
+ public pages, including login and registration, and pass the same `legal` configuration to `UserMenu` for authenticated
37
+ workspaces. This keeps public legal links available without a provider and opens settings for the current app when adopted.
38
+ `PrivacyFooterLinks` remains available for existing consumers; a public footer uses `PublicFooter` instead of it, never both. The provider owns the settings dialog. Register each app-owned
36
39
  optional adapter with `registerPrivacyService({ purposeId, serviceId, activate, deactivate, ownedStorage })`; gate imports,
37
40
  requests and callbacks with `useGrantedPurpose`, `guardedImport` or `createPrivacyGuard`. The package never loads vendors.
38
41
 
42
+ ```jsx
43
+ const legal = {
44
+ legalOrigin: 'https://bigler-consult.ch',
45
+ appId: 'maana',
46
+ documents: ['privacy', 'terms', 'data-processing', 'cancellation'],
47
+ extraLinks: [{ id: 'contract-cancel', label: t('Privacy.LEGAL_CONTRACT_CANCEL'), href: '/contracts/cancel' }],
48
+ };
49
+
50
+ <PublicFooter brand={<MaanaBrand />} copyright={copyrightNode} {...legal} />
51
+ <UserMenu legal={legal} />
52
+ ```
53
+
54
+ Central links use `/legal/<slug>?app=<registered-id>&lang=<document-locale>`; the package chooses a supported document
55
+ language from the UI language and configured fallback. Maana supplies all four documents and its local contract-cancel
56
+ link. Imara uses `appId: 'hram'` and an `/imprint` extra link. Spesix uses the default privacy, terms and data-processing
57
+ documents. Hosts supply each app's applicable destinations and brand/copyright nodes.
58
+
39
59
  Adoption is explicit. `OnboardingProvider` and `ProfileComponent` / `ProfileStepContent` accept `privacyMode="central"` to
40
60
  remove the legacy privacy and convenience-cookie prompts while keeping name completion and actual terms acceptance. The
41
- default remains `privacyMode="legacy"` during rollout. `CookieConsentStep` remains exported for compatibility and is
61
+ default remains `privacyMode="legacy"` during rollout. `AccountPage` takes the same `privacyMode` prop (4.33.1) and
62
+ forwards it to its profile tab; pass `privacyMode="central"` there too, because `showProfileStatements={false}` only hides
63
+ statement text and never selects the central contract. `CookieConsentStep` remains exported for compatibility and is
42
64
  deprecated. The host manifest supplies actual controllers, purpose details, providers, storage and localized notice links;
43
65
  empty optional configuration has no choice banner.
44
66
 
@@ -5,6 +5,8 @@ import { useTheme } from '@mui/material/styles';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { AuthContext } from './AuthContext';
7
7
  import { calculateContrastRatio } from '../theme';
8
+ import { usePrivacy } from '../privacy/PrivacyProvider';
9
+ import { useLegalEntries } from '../privacy/legalEntries';
8
10
  function getInitials(user) {
9
11
  var _a, _b, _c, _d, _e, _f;
10
12
  if (!user)
@@ -21,9 +23,11 @@ function getDisplayName(user) {
21
23
  const name = `${user.first_name || ''} ${user.last_name || ''}`.trim();
22
24
  return name || user.username || '';
23
25
  }
24
- export function UserMenu({ resolveLink, items = [], profileLink = '/account', avatarSrc }) {
26
+ export function UserMenu({ resolveLink, items = [], profileLink = '/account', avatarSrc, legal }) {
25
27
  const { t } = useTranslation();
26
28
  const { user, logout } = useContext(AuthContext);
29
+ const privacy = usePrivacy();
30
+ const legalEntries = useLegalEntries(legal || {});
27
31
  const theme = useTheme();
28
32
  const [anchorEl, setAnchorEl] = useState(null);
29
33
  const open = Boolean(anchorEl);
@@ -60,6 +64,12 @@ export function UserMenu({ resolveLink, items = [], profileLink = '/account', av
60
64
  fontSize: '0.8rem',
61
65
  bgcolor: avatarBackground,
62
66
  color: avatarText,
63
- }, children: avatarSrc ? null : getInitials(user) }) }), _jsxs(Menu, { anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'bottom' }, onClose: handleClose, open: open, transformOrigin: { horizontal: 'right', vertical: 'top' }, children: [_jsxs(Box, { sx: { minWidth: 240, px: 2, py: 1 }, children: [_jsx(Typography, { variant: "subtitle1", noWrap: true, children: getDisplayName(user) }), (user === null || user === void 0 ? void 0 : user.email) && user.email !== getDisplayName(user) && (_jsx(Typography, { variant: "body2", color: "text.secondary", noWrap: true, children: user.email }))] }), _jsx(Divider, {}), _jsx(MenuItem, { onClick: handleProfile, children: t('UserMenu.PROFILE') }), items.length > 0 && _jsx(Divider, {}), items.map((item) => (_jsx(MenuItem, { onClick: () => handleItemSelect(item), children: item.label }, item.id))), _jsx(Divider, {}), _jsx(MenuItem, { onClick: handleLogout, children: t('UserMenu.LOGOUT') })] })] }));
67
+ }, children: avatarSrc ? null : getInitials(user) }) }), _jsxs(Menu, { anchorEl: anchorEl, anchorOrigin: { horizontal: 'right', vertical: 'bottom' }, onClose: handleClose, open: open, transformOrigin: { horizontal: 'right', vertical: 'top' }, children: [_jsxs(Box, { sx: { minWidth: 240, px: 2, py: 1 }, children: [_jsx(Typography, { variant: "subtitle1", noWrap: true, children: getDisplayName(user) }), (user === null || user === void 0 ? void 0 : user.email) && user.email !== getDisplayName(user) && (_jsx(Typography, { variant: "body2", color: "text.secondary", noWrap: true, children: user.email }))] }), _jsx(Divider, {}), _jsx(MenuItem, { onClick: handleProfile, children: t('UserMenu.PROFILE') }), items.length > 0 && _jsx(Divider, {}), items.map((item) => (_jsx(MenuItem, { onClick: () => handleItemSelect(item), children: item.label }, item.id))), legal !== undefined && legal !== null ? ([
68
+ _jsx(Divider, {}, "legal-divider"),
69
+ ...legalEntries.map(({ id, label, href }) => (_jsx(MenuItem, { component: "a", href: href, onClick: handleClose, children: label }, `legal-${id}`))),
70
+ ...(legal.showSettings !== false && privacy && privacy.status !== 'unconfigured'
71
+ ? [_jsx(MenuItem, { onClick: () => { handleClose(); privacy.openSettings(); }, children: t('Privacy.LEGAL_SETTINGS') }, "legal-settings")]
72
+ : []),
73
+ ]) : null, _jsx(Divider, {}), _jsx(MenuItem, { onClick: handleLogout, children: t('UserMenu.LOGOUT') })] })] }));
64
74
  }
65
75
  export default UserMenu;
@@ -32,6 +32,13 @@ export const privacyTranslations = {
32
32
  'Privacy.FOOTER_TERMS': { de: 'Nutzungsbedingungen', fr: 'Conditions d’utilisation', en: 'Terms of use', sw: 'Masharti ya matumizi' },
33
33
  'Privacy.FOOTER_DATA_PROCESSING': { de: 'Auftragsverarbeitung', fr: 'Traitement des données', en: 'Data processing', sw: 'Uchakataji wa data' },
34
34
  'Privacy.FOOTER_CANCELLATION': { de: 'Kündigung und Rückerstattung', fr: 'Résiliation et remboursement', en: 'Cancellation and refunds', sw: 'Kughairi na marejesho' },
35
+ 'Privacy.LEGAL_PRIVACY': { de: 'Datenschutz', fr: 'Confidentialité', en: 'Privacy', sw: 'Faragha' },
36
+ 'Privacy.LEGAL_TERMS': { de: 'Nutzungsbedingungen', fr: 'Conditions d’utilisation', en: 'Terms of use', sw: 'Masharti ya matumizi' },
37
+ 'Privacy.LEGAL_DATA_PROCESSING': { de: 'Auftragsverarbeitung', fr: 'Traitement des données', en: 'Data processing', sw: 'Uchakataji wa data' },
38
+ 'Privacy.LEGAL_CANCELLATION': { de: 'Widerruf und Erstattung', fr: 'Rétractation et remboursement', en: 'Cancellation and refunds', sw: 'Kujiondoa na marejesho' },
39
+ 'Privacy.LEGAL_IMPRINT': { de: 'Impressum', fr: 'Mentions légales', en: 'Imprint', sw: 'Taarifa za kisheria' },
40
+ 'Privacy.LEGAL_CONTRACT_CANCEL': { de: 'Verträge hier kündigen', fr: 'Résilier des contrats ici', en: 'Cancel contracts here', sw: 'Sitisha mikataba hapa' },
41
+ 'Privacy.LEGAL_SETTINGS': { de: 'Datenschutzeinstellungen', fr: 'Paramètres de confidentialité', en: 'Privacy settings', sw: 'Mipangilio ya faragha' },
35
42
  'Privacy.LOADING': { de: 'Datenschutzeinstellungen werden geladen.', fr: 'Chargement des paramètres de confidentialité.', en: 'Loading privacy settings.', sw: 'Inapakia mipangilio ya faragha.' },
36
43
  'Privacy.UNAVAILABLE': { de: 'Datenschutzeinstellungen sind derzeit nicht verfügbar. Optionale Dienste bleiben ausgeschaltet.', fr: 'Les paramètres de confidentialité sont indisponibles. Les services facultatifs restent désactivés.', en: 'Privacy settings are unavailable right now. Optional services remain off.', sw: 'Mipangilio ya faragha haipatikani sasa. Huduma za hiari zitaendelea kuzimwa.' },
37
44
  };
package/dist/index.js CHANGED
@@ -132,6 +132,8 @@ export { PrivacyBanner } from './privacy/PrivacyBanner';
132
132
  export { PrivacySettingsDialog, PrivacySettingsPanel } from './privacy/PrivacySettings';
133
133
  export { PrivacySettingsLink } from './privacy/PrivacySettingsLink';
134
134
  export { PrivacyFooterLinks, buildLegalReaderUrl, legalDocumentLanguage } from './privacy/PrivacyFooterLinks';
135
+ export { PublicFooter } from './privacy/PublicFooter';
136
+ export { useLegalEntries } from './privacy/legalEntries';
135
137
  export { PrivacyNoticeLink, safePrivacyDocumentUrl } from './privacy/PrivacyNoticeLink';
136
138
  export { registerPrivacyService, useGrantedPurpose, guardedImport, createPrivacyGuard, isPurposeGranted, } from './privacy/serviceRegistry';
137
139
  export { privacyTranslations } from './i18n/privacyTranslations';
@@ -31,11 +31,15 @@ import { useBillingUsersColumn } from '../billing/useBillingUsersColumn';
31
31
  * `billingOperator({ user, account }) => boolean` (optional, UCM-BILL-10): the app's operator rule for the billing
32
32
  * users columns built when `billingUsers` is set (status, badge and the "Ohne Abo" switch). Without it superusers are
33
33
  * the operators. A new function on each render only recomputes the columns; it does not refetch the accounts.
34
+ * `privacyMode` (optional, UCM-PRIV-4): `'legacy'` (default, unchanged) or `'central'`. `'central'` is forwarded to
35
+ * ProfileComponent: the profile drops the privacy-statement and convenience-cookie checkboxes and sends neither legacy
36
+ * field; name editing is unchanged and the central privacy notice link is shown. It never depends on provider presence,
37
+ * and stays central while the privacy manifest loads or fails. `showProfileStatements` only hides statement text.
34
38
  * `groups` (optional): app-defined account navigation groups with `{ key, label, order?, tabs?, visible? }`. Labels
35
39
  * may be strings or `(context) => string`; `tabs` assigns built-in tab values, and `visible(context)` can hide a group
36
40
  * and its tabs. Without this prop, the default groups and placement are unchanged.
37
41
  */
38
- export function AccountPage({ userListExtraColumns = [], userListExtraRowActions = [], userListExtraContext = null, userListRefreshTrigger = 0, userListCanEditUser = null, userListShowNewColumn = true, userListShowSuccessfulLoginColumn = true, userListShowRoleColumn = true, userListOnChangeRole = null, userListShowDeleteAction = true, userListCanDeleteUser = null, userListOnDeleteUser = null, showBulkInviteCsvTab = false, bulkInviteCsvProps = {}, extraTabs = [], showProfileStatements = true, billingUsers = false, billingOperator, groups: groupsProp, }) {
42
+ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions = [], userListExtraContext = null, userListRefreshTrigger = 0, userListCanEditUser = null, userListShowNewColumn = true, userListShowSuccessfulLoginColumn = true, userListShowRoleColumn = true, userListOnChangeRole = null, userListShowDeleteAction = true, userListCanDeleteUser = null, userListOnDeleteUser = null, showBulkInviteCsvTab = false, bulkInviteCsvProps = {}, extraTabs = [], showProfileStatements = true, privacyMode = 'legacy', billingUsers = false, billingOperator, groups: groupsProp, }) {
39
43
  var _a;
40
44
  const { t, i18n } = useTranslation();
41
45
  const { user, login, loading } = useContext(AuthContext);
@@ -251,5 +255,5 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
251
255
  const activeExtraTab = builtInTabValues.has(safeTab)
252
256
  ? null
253
257
  : extraTabs.find((tab) => tab.value === safeTab);
254
- return (_jsxs(WidePage, { title: t('Account.TITLE', 'Account & Administration'), children: [_jsx("title", { children: `${t('Account.PAGE_TITLE', 'Account')} – ${user.email}` }), _jsxs(SectionNav, { mode: isMobile ? 'mobile' : 'desktop', groups: groups, activeKey: safeTab, onSelect: (key) => handleTabChange(null, key), children: [safeTab === 'profile' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(ProfileComponent, { onSubmit: handleProfileSubmit, showName: true, showPrivacy: true, showCookies: true, showStatements: showProfileStatements }) })), safeTab === 'security' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(SecurityComponent, { fromRecovery: fromRecovery, fromWeakLogin: fromWeakLogin }) })), safeTab === 'users' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(UserListComponent, { roles: activeRoles, currentUser: user, extraColumns: [...userListExtraColumns, ...billing.extraColumns], extraRowActions: userListExtraRowActions, extraContext: userListExtraContext, refreshTrigger: userListRefreshTrigger, canEditUser: userListCanEditUser, showNewColumn: userListShowNewColumn, showSuccessfulLoginColumn: userListShowSuccessfulLoginColumn, showRoleColumn: userListShowRoleColumn, onChangeRole: userListOnChangeRole, showDeleteAction: userListShowDeleteAction, canDeleteUser: userListCanDeleteUser, onDeleteUser: userListOnDeleteUser }) })), safeTab === 'invite' && (_jsx(Box, { sx: { mt: 2 }, children: _jsxs(Stack, { spacing: 2.5, children: [canViewAuthPolicy && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(AuthFactorRequirementCard, { canEdit: canWriteAuthPolicy, policy: authPolicy }) })), canViewAuthPolicy && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(RegistrationMethodsManager, { policy: authPolicy, error: authPolicyError, onPolicyChange: setAuthPolicy, canEdit: canWriteAuthPolicy }) })), canSendInvites && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_admin_invite) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(UserInviteComponent, {}) })), canManageAccessCodes && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_access_code) && (_jsxs(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: [_jsx(Typography, { variant: "h6", gutterBottom: true, children: t('Auth.ACCESS_CODE_MANAGER_TITLE', 'Access Codes') }), _jsx(Typography, { variant: "body2", sx: { mb: 2, color: 'text.secondary' }, children: t('Account.ACCESS_CODES_HINT', 'Manage access codes for self-registration.') }), _jsx(AccessCodeManager, {})] })), canManageAccessCodes && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_access_code) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(AccessCodeSingleUseToggle, { canEdit: canWriteAuthPolicy, policy: authPolicy, onPolicyChange: setAuthPolicy }) })), canSendInvites && showBulkInviteCsvTab && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_admin_invite) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(BulkInviteCsvTab, Object.assign({}, bulkInviteCsvProps)) })), canViewAuthPolicy && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_email_domain) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(AllowedEmailDomainsManager, { enabled: Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_email_domain), domains: (authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allowed_email_domains) || [], onPolicyChange: setAuthPolicy, canEdit: canWriteAuthPolicy }) })), canViewAuthPolicy && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(QrSignupValidityManager, { enabled: Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr), expiryDays: authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.signup_qr_expiry_days, onPolicyChange: setAuthPolicy, canEdit: canWriteAuthPolicy }) })), canManageSignupQr && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(QrSignupManager, { enabled: Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr), expiryDays: authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.signup_qr_expiry_days }) }))] }) })), safeTab === 'support' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(SupportRecoveryRequestsTab, {}) })), activeExtraTab && (_jsx(Box, { sx: { mt: 2 }, children: (_a = activeExtraTab.render) === null || _a === void 0 ? void 0 : _a.call(activeExtraTab, { user, perms, isSuperUser, t }) }))] })] }));
258
+ return (_jsxs(WidePage, { title: t('Account.TITLE', 'Account & Administration'), children: [_jsx("title", { children: `${t('Account.PAGE_TITLE', 'Account')} – ${user.email}` }), _jsxs(SectionNav, { mode: isMobile ? 'mobile' : 'desktop', groups: groups, activeKey: safeTab, onSelect: (key) => handleTabChange(null, key), children: [safeTab === 'profile' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(ProfileComponent, { onSubmit: handleProfileSubmit, showName: true, showPrivacy: true, showCookies: true, showStatements: showProfileStatements, privacyMode: privacyMode }) })), safeTab === 'security' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(SecurityComponent, { fromRecovery: fromRecovery, fromWeakLogin: fromWeakLogin }) })), safeTab === 'users' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(UserListComponent, { roles: activeRoles, currentUser: user, extraColumns: [...userListExtraColumns, ...billing.extraColumns], extraRowActions: userListExtraRowActions, extraContext: userListExtraContext, refreshTrigger: userListRefreshTrigger, canEditUser: userListCanEditUser, showNewColumn: userListShowNewColumn, showSuccessfulLoginColumn: userListShowSuccessfulLoginColumn, showRoleColumn: userListShowRoleColumn, onChangeRole: userListOnChangeRole, showDeleteAction: userListShowDeleteAction, canDeleteUser: userListCanDeleteUser, onDeleteUser: userListOnDeleteUser }) })), safeTab === 'invite' && (_jsx(Box, { sx: { mt: 2 }, children: _jsxs(Stack, { spacing: 2.5, children: [canViewAuthPolicy && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(AuthFactorRequirementCard, { canEdit: canWriteAuthPolicy, policy: authPolicy }) })), canViewAuthPolicy && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(RegistrationMethodsManager, { policy: authPolicy, error: authPolicyError, onPolicyChange: setAuthPolicy, canEdit: canWriteAuthPolicy }) })), canSendInvites && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_admin_invite) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(UserInviteComponent, {}) })), canManageAccessCodes && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_access_code) && (_jsxs(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: [_jsx(Typography, { variant: "h6", gutterBottom: true, children: t('Auth.ACCESS_CODE_MANAGER_TITLE', 'Access Codes') }), _jsx(Typography, { variant: "body2", sx: { mb: 2, color: 'text.secondary' }, children: t('Account.ACCESS_CODES_HINT', 'Manage access codes for self-registration.') }), _jsx(AccessCodeManager, {})] })), canManageAccessCodes && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_access_code) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(AccessCodeSingleUseToggle, { canEdit: canWriteAuthPolicy, policy: authPolicy, onPolicyChange: setAuthPolicy }) })), canSendInvites && showBulkInviteCsvTab && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_admin_invite) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(BulkInviteCsvTab, Object.assign({}, bulkInviteCsvProps)) })), canViewAuthPolicy && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_email_domain) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(AllowedEmailDomainsManager, { enabled: Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_email_domain), domains: (authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allowed_email_domains) || [], onPolicyChange: setAuthPolicy, canEdit: canWriteAuthPolicy }) })), canViewAuthPolicy && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(QrSignupValidityManager, { enabled: Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr), expiryDays: authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.signup_qr_expiry_days, onPolicyChange: setAuthPolicy, canEdit: canWriteAuthPolicy }) })), canManageSignupQr && Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr) && (_jsx(Paper, { variant: "outlined", sx: ACCOUNT_PAGE_SECTION_PAPER_SX, children: _jsx(QrSignupManager, { enabled: Boolean(authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.allow_self_signup_qr), expiryDays: authPolicy === null || authPolicy === void 0 ? void 0 : authPolicy.signup_qr_expiry_days }) }))] }) })), safeTab === 'support' && (_jsx(Box, { sx: { mt: 2 }, children: _jsx(SupportRecoveryRequestsTab, {}) })), activeExtraTab && (_jsx(Box, { sx: { mt: 2 }, children: (_a = activeExtraTab.render) === null || _a === void 0 ? void 0 : _a.call(activeExtraTab, { user, perms, isSuperUser, t }) }))] })] }));
255
259
  }
@@ -0,0 +1,101 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import React from 'react';
14
+ import { Box, Link, Typography } from '@mui/material';
15
+ import TuneIcon from '@mui/icons-material/Tune';
16
+ import { useTranslation } from 'react-i18next';
17
+ import { usePrivacy } from './PrivacyProvider';
18
+ import { PrivacySettingsLink } from './PrivacySettingsLink';
19
+ import { useLegalEntries } from './legalEntries';
20
+ export const PUBLIC_FOOTER_ROOT_SX = {
21
+ boxSizing: 'border-box',
22
+ width: '100%',
23
+ borderTop: 1,
24
+ borderColor: 'divider',
25
+ px: { xs: 2, sm: 4 },
26
+ pt: 3,
27
+ pb: 2.5,
28
+ bgcolor: 'background.paper',
29
+ };
30
+ export const PUBLIC_FOOTER_TOP_ROW_SX = {
31
+ display: 'flex',
32
+ flexDirection: { xs: 'column', sm: 'row' },
33
+ alignItems: { xs: 'stretch', sm: 'center' },
34
+ justifyContent: 'space-between',
35
+ gap: { xs: 0, sm: 3 },
36
+ };
37
+ export const PUBLIC_FOOTER_IDENTITY_SX = {
38
+ display: 'flex',
39
+ flexDirection: 'column',
40
+ gap: 0.5,
41
+ flexShrink: 0,
42
+ mb: { xs: 2, sm: 0 },
43
+ };
44
+ export const PUBLIC_FOOTER_COPYRIGHT_SX = {
45
+ color: 'text.secondary',
46
+ fontSize: '0.75rem',
47
+ lineHeight: 1.4,
48
+ };
49
+ export const PUBLIC_FOOTER_NAV_SX = {
50
+ display: { xs: 'grid', sm: 'flex' },
51
+ gridTemplateColumns: { xs: 'repeat(2, minmax(0, 1fr))', sm: 'none' },
52
+ justifyContent: { xs: 'start', sm: 'flex-end' },
53
+ flexWrap: 'wrap',
54
+ alignItems: 'center',
55
+ gap: { xs: '4px 16px', sm: '8px 22px' },
56
+ minWidth: 0,
57
+ };
58
+ export const PUBLIC_FOOTER_LEGAL_LINK_SX = {
59
+ display: 'inline-flex',
60
+ alignItems: 'center',
61
+ minWidth: 0,
62
+ minHeight: { xs: 44, sm: 36 },
63
+ color: 'text.secondary',
64
+ fontSize: { xs: '0.75rem', sm: '0.8125rem' },
65
+ lineHeight: 1.35,
66
+ overflowWrap: 'anywhere',
67
+ textDecoration: 'none',
68
+ '&:hover': {
69
+ color: 'primary.main',
70
+ textDecoration: 'underline',
71
+ },
72
+ };
73
+ export const PUBLIC_FOOTER_SETTINGS_ROW_SX = {
74
+ display: 'flex',
75
+ justifyContent: { xs: 'flex-start', sm: 'flex-end' },
76
+ mt: { xs: 2, sm: 1 },
77
+ pt: { xs: 1.5, sm: 0 },
78
+ borderTop: { xs: '1px solid', sm: 0 },
79
+ borderColor: 'divider',
80
+ };
81
+ export const PUBLIC_FOOTER_SETTINGS_LINK_SX = {
82
+ display: 'inline-flex',
83
+ alignItems: 'center',
84
+ gap: 1,
85
+ minHeight: { xs: 44, sm: 36 },
86
+ px: 0,
87
+ color: 'primary.main',
88
+ fontSize: '0.8125rem',
89
+ textDecoration: 'none',
90
+ '&:hover': { textDecoration: 'underline' },
91
+ };
92
+ export function PublicFooter(_a) {
93
+ var { brand, copyright, legalOrigin, appId, documents, extraLinks, fallbackLanguage = 'en', showSettings = true } = _a, props = __rest(_a, ["brand", "copyright", "legalOrigin", "appId", "documents", "extraLinks", "fallbackLanguage", "showSettings"]);
94
+ const { t } = useTranslation();
95
+ const privacy = usePrivacy();
96
+ const entries = useLegalEntries({ legalOrigin, appId, documents, extraLinks, fallbackLanguage });
97
+ const { className, sx } = props, footerProps = __rest(props, ["className", "sx"]);
98
+ const canOpenSettings = showSettings && privacy && privacy.status !== 'unconfigured';
99
+ return (_jsxs(Box, Object.assign({}, footerProps, { component: "footer", className: className, sx: sx ? [PUBLIC_FOOTER_ROOT_SX, sx] : PUBLIC_FOOTER_ROOT_SX, children: [_jsxs(Box, { sx: PUBLIC_FOOTER_TOP_ROW_SX, children: [_jsxs(Box, { sx: PUBLIC_FOOTER_IDENTITY_SX, children: [brand, copyright !== undefined && copyright !== null ? (_jsx(Typography, { component: "small", sx: PUBLIC_FOOTER_COPYRIGHT_SX, children: copyright })) : null] }), _jsx(Box, { component: "nav", "aria-label": t('Privacy.FOOTER_NAV'), sx: PUBLIC_FOOTER_NAV_SX, children: entries.map(({ id, label, href }) => (_jsx(Link, { href: href, underline: "none", sx: PUBLIC_FOOTER_LEGAL_LINK_SX, children: label }, id))) })] }), canOpenSettings ? (_jsx(Box, { sx: PUBLIC_FOOTER_SETTINGS_ROW_SX, children: _jsxs(PrivacySettingsLink, { sx: PUBLIC_FOOTER_SETTINGS_LINK_SX, children: [_jsx(TuneIcon, { fontSize: "small", "aria-hidden": "true" }), t('Privacy.LEGAL_SETTINGS')] }) })) : null] })));
100
+ }
101
+ export default PublicFooter;
@@ -0,0 +1,39 @@
1
+ import { useTranslation } from 'react-i18next';
2
+ import { buildLegalReaderUrl, legalDocumentLanguage } from './PrivacyFooterLinks';
3
+ const DOCUMENT_LABEL_KEYS = {
4
+ privacy: 'Privacy.LEGAL_PRIVACY',
5
+ terms: 'Privacy.LEGAL_TERMS',
6
+ 'data-processing': 'Privacy.LEGAL_DATA_PROCESSING',
7
+ cancellation: 'Privacy.LEGAL_CANCELLATION',
8
+ };
9
+ function isSafeExtraHref(href) {
10
+ if (typeof href !== 'string')
11
+ return false;
12
+ // Backslashes and control characters are URL separators/ignored characters in browsers ("/\host" leaves the app).
13
+ // eslint-disable-next-line no-control-regex
14
+ if (/[\\\u0000-\u001f\u007f]/.test(href))
15
+ return false;
16
+ if (href.startsWith('/'))
17
+ return !href.startsWith('//');
18
+ return /^https?:\/\//i.test(href);
19
+ }
20
+ /**
21
+ * Ordered legal destinations for the current host. Central-reader links are static and do not
22
+ * depend on a PrivacyProvider; app-local links are accepted only as relative paths or HTTP(S) URLs.
23
+ */
24
+ export function useLegalEntries({ legalOrigin, appId, documents = ['privacy', 'terms', 'data-processing'], extraLinks = [], fallbackLanguage = 'en', } = {}) {
25
+ const { t, i18n } = useTranslation();
26
+ const lang = legalDocumentLanguage(i18n === null || i18n === void 0 ? void 0 : i18n.language, fallbackLanguage);
27
+ const builtIn = documents
28
+ .map((slug) => ({
29
+ id: slug,
30
+ label: DOCUMENT_LABEL_KEYS[slug] ? t(DOCUMENT_LABEL_KEYS[slug]) : '',
31
+ href: buildLegalReaderUrl({ origin: legalOrigin, slug, appId, lang }),
32
+ }))
33
+ .filter((entry) => entry.href);
34
+ const local = extraLinks
35
+ .filter((entry) => entry && isSafeExtraHref(entry.href))
36
+ .map(({ id, label, href }) => ({ id, label, href }));
37
+ return [...builtIn, ...local];
38
+ }
39
+ export default useLegalEntries;
@@ -36,6 +36,7 @@ import { PROFILE_STEP_CHECKBOX_SX, PROFILE_STEP_OPTION_SX } from '../components/
36
36
  import { SETUP_WIZARD_CARD_SX } from '../onboarding/SetupWizardShell';
37
37
  import { REAUTH_MODAL_ALERT_SX, REAUTH_MODAL_TEXT_FIELD_SX } from '../auth/ReauthModal';
38
38
  import { PRIVACY_BANNER_CLOSE_SX, PRIVACY_BANNER_PAPER_SX } from '../privacy/PrivacyBanner';
39
+ import { PUBLIC_FOOTER_COPYRIGHT_SX, PUBLIC_FOOTER_IDENTITY_SX, PUBLIC_FOOTER_LEGAL_LINK_SX, PUBLIC_FOOTER_NAV_SX, PUBLIC_FOOTER_ROOT_SX, PUBLIC_FOOTER_SETTINGS_LINK_SX, PUBLIC_FOOTER_SETTINGS_ROW_SX, PUBLIC_FOOTER_TOP_ROW_SX, } from '../privacy/PublicFooter';
39
40
  import { createKitSxEntry } from './kitSxEntry';
40
41
  import { ACCESS_ENDED_BANNER_ALERT_SX } from '../billing/AccessEndedBanner';
41
42
  import { BILLING_ACCESS_BADGE_SX } from '../billing/BillingAccessCell';
@@ -54,6 +55,14 @@ import { RECEIPT_REVIEW_ACTIONS_SX, RECEIPT_REVIEW_ACTION_BUTTON_SX, RECEIPT_REV
54
55
  const SX_EXPORTS = {
55
56
  PRIVACY_BANNER_CLOSE_SX,
56
57
  PRIVACY_BANNER_PAPER_SX,
58
+ PUBLIC_FOOTER_ROOT_SX,
59
+ PUBLIC_FOOTER_TOP_ROW_SX,
60
+ PUBLIC_FOOTER_IDENTITY_SX,
61
+ PUBLIC_FOOTER_COPYRIGHT_SX,
62
+ PUBLIC_FOOTER_NAV_SX,
63
+ PUBLIC_FOOTER_LEGAL_LINK_SX,
64
+ PUBLIC_FOOTER_SETTINGS_ROW_SX,
65
+ PUBLIC_FOOTER_SETTINGS_LINK_SX,
57
66
  ACCESS_CODE_ACTION_SX,
58
67
  ACCESS_ENDED_BANNER_ALERT_SX,
59
68
  BILLING_ACCESS_BADGE_SX,
@@ -179,6 +188,14 @@ export { createKitSxEntry };
179
188
  export const KIT_COMPONENT_SX_REGISTRY = [
180
189
  entry('PrivacyBanner.paper', 'MuiPaper', PRIVACY_BANNER_PAPER_SX),
181
190
  entry('PrivacyBanner.close', 'MuiButton', PRIVACY_BANNER_CLOSE_SX),
191
+ entry('PublicFooter.root', 'MuiBox', PUBLIC_FOOTER_ROOT_SX),
192
+ entry('PublicFooter.topRow', 'MuiBox', PUBLIC_FOOTER_TOP_ROW_SX),
193
+ entry('PublicFooter.identity', 'MuiBox', PUBLIC_FOOTER_IDENTITY_SX),
194
+ entry('PublicFooter.copyright', 'MuiTypography', PUBLIC_FOOTER_COPYRIGHT_SX),
195
+ entry('PublicFooter.nav', 'MuiBox', PUBLIC_FOOTER_NAV_SX),
196
+ entry('PublicFooter.legalLink', 'MuiLink', PUBLIC_FOOTER_LEGAL_LINK_SX),
197
+ entry('PublicFooter.settingsRow', 'MuiBox', PUBLIC_FOOTER_SETTINGS_ROW_SX),
198
+ entry('PublicFooter.settingsLink', 'MuiLink', PUBLIC_FOOTER_SETTINGS_LINK_SX),
182
199
  entry('AccessCodeManager.action', 'MuiButton', ACCESS_CODE_ACTION_SX),
183
200
  entry('AccessCodeManager.primaryAction', 'MuiButton', ACCESS_CODE_PRIMARY_ACTION_SX),
184
201
  entry('AccessCodeManager.alert', 'MuiAlert', ACCESS_CODE_ALERT_SX),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.32.0",
3
+ "version": "4.33.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {