@micha.bigler/ui-core-micha 4.31.0 → 4.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +26 -0
- package/dist/components/ProfileComponent.js +11 -10
- package/dist/components/ProfileStepContent.js +29 -17
- package/dist/i18n/authTranslations.js +7 -0
- package/dist/i18n/privacyTranslations.js +37 -0
- package/dist/i18n/uiCoreTranslations.js +2 -1
- package/dist/index.js +10 -0
- package/dist/onboarding/OnboardingProvider.js +5 -2
- package/dist/onboarding/steps/CookieConsentStep.js +1 -0
- package/dist/privacy/PrivacyBanner.js +60 -0
- package/dist/privacy/PrivacyFooterLinks.js +69 -0
- package/dist/privacy/PrivacyNoticeLink.js +60 -0
- package/dist/privacy/PrivacyProvider.js +470 -0
- package/dist/privacy/PrivacySettings.js +89 -0
- package/dist/privacy/PrivacySettingsLink.js +25 -0
- package/dist/privacy/privacyApi.js +27 -0
- package/dist/privacy/serviceRegistry.js +222 -0
- package/dist/theme/kitSxRegistry.js +5 -0
- package/dist/utils/profileDraft.js +13 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.32.0 - UCM-PRIV-1
|
|
4
|
+
|
|
5
|
+
Adds opt-in shared privacy choices for hosts on `django-core-micha` >= 3.22.0: `PrivacyProvider`, `usePrivacy`, the
|
|
6
|
+
choice banner, purpose settings, notice/settings links, `createPrivacyApi`, and purpose-aware service lifecycle helpers.
|
|
7
|
+
Adoption is explicit; no privacy dialog is mounted in an app unless the host adopts these exports. `OnboardingProvider`
|
|
8
|
+
and the profile components accept `privacyMode="central"` to replace the legacy privacy/cookie prompts while preserving
|
|
9
|
+
name completion and separate terms acceptance. Legacy exports and default behavior remain available and are deprecated
|
|
10
|
+
where replaced. Adds `Privacy.*` translations and the privacy playground entry.
|
|
11
|
+
|
|
3
12
|
## 4.31.0 - UCM-BILL-11
|
|
4
13
|
|
|
5
14
|
Contract status, cancellation and withdrawal declarations, and the full-refund withdrawal view, against the django-core-micha
|
package/README.md
CHANGED
|
@@ -16,6 +16,32 @@ Spread `uiCoreTranslations` into the default i18n namespace as the supported agg
|
|
|
16
16
|
offer privacy/cookie statement text endpoints; this hides their panels and prevents their requests.
|
|
17
17
|
The privacy and cookie consent controls and their submitted values remain available.
|
|
18
18
|
|
|
19
|
+
## Shared privacy choices (opt-in)
|
|
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:
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
const privacyApi = createPrivacyApi({}, { apiBase: '/api/privacy/', csrfUrl: '/api/csrf/' });
|
|
26
|
+
|
|
27
|
+
<PrivacyProvider api={privacyApi}>
|
|
28
|
+
<Router>
|
|
29
|
+
<AppShell><PrivacyBanner /><AppRoutes /></AppShell>
|
|
30
|
+
</Router>
|
|
31
|
+
</PrivacyProvider>
|
|
32
|
+
```
|
|
33
|
+
|
|
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
|
|
36
|
+
optional adapter with `registerPrivacyService({ purposeId, serviceId, activate, deactivate, ownedStorage })`; gate imports,
|
|
37
|
+
requests and callbacks with `useGrantedPurpose`, `guardedImport` or `createPrivacyGuard`. The package never loads vendors.
|
|
38
|
+
|
|
39
|
+
Adoption is explicit. `OnboardingProvider` and `ProfileComponent` / `ProfileStepContent` accept `privacyMode="central"` to
|
|
40
|
+
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
|
|
42
|
+
deprecated. The host manifest supplies actual controllers, purpose details, providers, storage and localized notice links;
|
|
43
|
+
empty optional configuration has no choice banner.
|
|
44
|
+
|
|
19
45
|
## Account page: extra tabs in a navigation group
|
|
20
46
|
|
|
21
47
|
An entry of `AccountPage`'s `extraTabs` (`{ value, label, render, visible? }`) may carry an optional `group` naming one of
|
|
@@ -8,7 +8,8 @@ import { AuthContext } from '../auth/AuthContext';
|
|
|
8
8
|
import { fetchCookieStatement, fetchPrivacyStatement } from '../auth/authApi';
|
|
9
9
|
import { resolveErrorText } from '../utils/resolveErrorText';
|
|
10
10
|
import { refreshProfileDraft } from '../utils/profileDraft';
|
|
11
|
-
|
|
11
|
+
import { PrivacyNoticeLink } from '../privacy/PrivacyNoticeLink';
|
|
12
|
+
export function ProfileComponent({ onSubmit, submitText, showName = true, showPrivacy = true, showCookies = true, showStatements = true, privacyStatementText = null, cookieStatementText = null, privacyMode = 'legacy', }) {
|
|
12
13
|
const { t, i18n } = useTranslation();
|
|
13
14
|
// WICHTIG: Wir holen den User direkt aus dem globalen State
|
|
14
15
|
// Das verhindert den doppelten Request und den ReferenceError
|
|
@@ -33,7 +34,7 @@ export function ProfileComponent({ onSubmit, submitText, showName = true, showPr
|
|
|
33
34
|
useEffect(() => {
|
|
34
35
|
const refreshed = refreshProfileDraft(user, previousUserIdentity.current, editedFields.current, {
|
|
35
36
|
firstName, lastName, acceptedPrivacy, acceptedCookies,
|
|
36
|
-
});
|
|
37
|
+
}, privacyMode);
|
|
37
38
|
previousUserIdentity.current = refreshed.identity;
|
|
38
39
|
editedFields.current = refreshed.editedFields;
|
|
39
40
|
setUsername(refreshed.values.username);
|
|
@@ -42,7 +43,7 @@ export function ProfileComponent({ onSubmit, submitText, showName = true, showPr
|
|
|
42
43
|
setLastName(refreshed.values.lastName);
|
|
43
44
|
setAcceptedPrivacy(refreshed.values.acceptedPrivacy);
|
|
44
45
|
setAcceptedCookies(refreshed.values.acceptedCookies);
|
|
45
|
-
}, [user]);
|
|
46
|
+
}, [user, privacyMode]);
|
|
46
47
|
useEffect(() => {
|
|
47
48
|
if (privacyStatementText !== null && privacyStatementText !== undefined) {
|
|
48
49
|
setPrivacyStatement(String(privacyStatementText));
|
|
@@ -56,7 +57,7 @@ export function ProfileComponent({ onSubmit, submitText, showName = true, showPr
|
|
|
56
57
|
useEffect(() => {
|
|
57
58
|
let cancelled = false;
|
|
58
59
|
const loadStatements = async () => {
|
|
59
|
-
if (!showStatements)
|
|
60
|
+
if (!showStatements || privacyMode === 'central')
|
|
60
61
|
return;
|
|
61
62
|
if (showPrivacy && (privacyStatementText === null || privacyStatementText === undefined)) {
|
|
62
63
|
setLoadingPrivacyStatement(true);
|
|
@@ -95,7 +96,7 @@ export function ProfileComponent({ onSubmit, submitText, showName = true, showPr
|
|
|
95
96
|
return () => {
|
|
96
97
|
cancelled = true;
|
|
97
98
|
};
|
|
98
|
-
}, [showStatements, showPrivacy, showCookies, privacyStatementText, cookieStatementText]);
|
|
99
|
+
}, [showStatements, showPrivacy, showCookies, privacyStatementText, cookieStatementText, privacyMode]);
|
|
99
100
|
const handleSubmit = async (event) => {
|
|
100
101
|
event.preventDefault();
|
|
101
102
|
if (!onSubmit)
|
|
@@ -106,9 +107,9 @@ export function ProfileComponent({ onSubmit, submitText, showName = true, showPr
|
|
|
106
107
|
const payload = Object.assign(Object.assign(Object.assign({}, (showName && {
|
|
107
108
|
first_name: firstName,
|
|
108
109
|
last_name: lastName,
|
|
109
|
-
})), (showPrivacy && {
|
|
110
|
+
})), (privacyMode !== 'central' && showPrivacy && {
|
|
110
111
|
accepted_privacy_statement: acceptedPrivacy,
|
|
111
|
-
})), (showCookies && {
|
|
112
|
+
})), (privacyMode !== 'central' && showCookies && {
|
|
112
113
|
accepted_convenience_cookies: acceptedCookies,
|
|
113
114
|
}));
|
|
114
115
|
try {
|
|
@@ -140,11 +141,11 @@ export function ProfileComponent({ onSubmit, submitText, showName = true, showPr
|
|
|
140
141
|
}, fullWidth: true }), _jsx(TextField, { label: t('Profile.LAST_NAME_LABEL'), value: lastName, onChange: (e) => {
|
|
141
142
|
editedFields.current.add('lastName');
|
|
142
143
|
setLastName(e.target.value);
|
|
143
|
-
}, fullWidth: true })] })), (showPrivacy || showCookies) && (_jsxs(Box, { sx: { mt: 1 }, children: [_jsx(Typography, { variant: "subtitle1", gutterBottom: true, children: t('Profile.PRIVACY_SECTION_TITLE') }), _jsxs(Stack, { spacing: 1, children: [showPrivacy && (_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: acceptedPrivacy, onChange: (e) => {
|
|
144
|
+
}, fullWidth: true })] })), (showPrivacy || showCookies) && (_jsxs(Box, { sx: { mt: 1 }, children: [_jsx(Typography, { variant: "subtitle1", gutterBottom: true, children: t('Profile.PRIVACY_SECTION_TITLE') }), _jsxs(Stack, { spacing: 1, children: [privacyMode === 'central' && _jsx(PrivacyNoticeLink, {}), privacyMode !== 'central' && showPrivacy && (_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: acceptedPrivacy, onChange: (e) => {
|
|
144
145
|
editedFields.current.add('acceptedPrivacy');
|
|
145
146
|
setAcceptedPrivacy(e.target.checked);
|
|
146
|
-
} }), label: t('Profile.ACCEPT_PRIVACY_LABEL') })), showCookies && (_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: acceptedCookies, onChange: (e) => {
|
|
147
|
+
} }), label: t('Profile.ACCEPT_PRIVACY_LABEL') })), privacyMode !== 'central' && showCookies && (_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: acceptedCookies, onChange: (e) => {
|
|
147
148
|
editedFields.current.add('acceptedCookies');
|
|
148
149
|
setAcceptedCookies(e.target.checked);
|
|
149
|
-
} }), label: t('Profile.ACCEPT_COOKIES_LABEL') }))] }), showStatements && (_jsxs(Stack, { spacing: 1.25, sx: { mt: 1.5 }, children: [showPrivacy && (_jsxs(Accordion, { disableGutters: true, children: [_jsx(AccordionSummary, { children: _jsx(Typography, { variant: "body2", fontWeight: 600, children: t('Profile.PRIVACY_STATEMENT_TITLE', 'Privacy statement') }) }), _jsx(AccordionDetails, { children: loadingPrivacyStatement ? (_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Profile.STATEMENT_LOADING', 'Loading statement...') })) : (_jsx(Typography, { variant: "body2", sx: { whiteSpace: 'pre-wrap' }, children: privacyStatement || t('Profile.PRIVACY_STATEMENT_EMPTY', 'Privacy statement is currently unavailable.') })) })] })), showCookies && (_jsxs(Accordion, { disableGutters: true, children: [_jsx(AccordionSummary, { children: _jsx(Typography, { variant: "body2", fontWeight: 600, children: t('Profile.COOKIES_STATEMENT_TITLE', 'Cookie statement') }) }), _jsx(AccordionDetails, { children: loadingCookieStatement ? (_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Profile.STATEMENT_LOADING', 'Loading statement...') })) : (_jsx(Typography, { variant: "body2", sx: { whiteSpace: 'pre-wrap' }, children: cookieStatement || t('Profile.COOKIES_STATEMENT_EMPTY', 'Cookie statement is currently unavailable.') })) })] }))] }))] })), _jsx(Box, { sx: { mt: 2 }, children: _jsx(Button, { type: "submit", variant: "contained", disabled: saving, children: saving ? submitLabelLoading : submitLabel }) })] }));
|
|
150
|
+
} }), label: t('Profile.ACCEPT_COOKIES_LABEL') }))] }), showStatements && privacyMode !== 'central' && (_jsxs(Stack, { spacing: 1.25, sx: { mt: 1.5 }, children: [showPrivacy && (_jsxs(Accordion, { disableGutters: true, children: [_jsx(AccordionSummary, { children: _jsx(Typography, { variant: "body2", fontWeight: 600, children: t('Profile.PRIVACY_STATEMENT_TITLE', 'Privacy statement') }) }), _jsx(AccordionDetails, { children: loadingPrivacyStatement ? (_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Profile.STATEMENT_LOADING', 'Loading statement...') })) : (_jsx(Typography, { variant: "body2", sx: { whiteSpace: 'pre-wrap' }, children: privacyStatement || t('Profile.PRIVACY_STATEMENT_EMPTY', 'Privacy statement is currently unavailable.') })) })] })), showCookies && (_jsxs(Accordion, { disableGutters: true, children: [_jsx(AccordionSummary, { children: _jsx(Typography, { variant: "body2", fontWeight: 600, children: t('Profile.COOKIES_STATEMENT_TITLE', 'Cookie statement') }) }), _jsx(AccordionDetails, { children: loadingCookieStatement ? (_jsx(Typography, { variant: "body2", color: "text.secondary", children: t('Profile.STATEMENT_LOADING', 'Loading statement...') })) : (_jsx(Typography, { variant: "body2", sx: { whiteSpace: 'pre-wrap' }, children: cookieStatement || t('Profile.COOKIES_STATEMENT_EMPTY', 'Cookie statement is currently unavailable.') })) })] }))] }))] })), _jsx(Box, { sx: { mt: 2 }, children: _jsx(Button, { type: "submit", variant: "contained", disabled: saving, children: saving ? submitLabelLoading : submitLabel }) })] }));
|
|
150
151
|
}
|
|
@@ -7,6 +7,7 @@ import { fetchPrivacyStatement, updateUserProfile } from '../auth/authApi';
|
|
|
7
7
|
import { defaultTermsApi } from '../auth/termsApi';
|
|
8
8
|
import { resolveErrorText } from '../utils/resolveErrorText';
|
|
9
9
|
import { profileIdentity, refreshProfileDraft } from '../utils/profileDraft';
|
|
10
|
+
import { PrivacyNoticeLink } from '../privacy/PrivacyNoticeLink';
|
|
10
11
|
export const PROFILE_STEP_OPTION_SX = { alignItems: 'flex-start' };
|
|
11
12
|
export const PROFILE_STEP_CHECKBOX_SX = { mt: -0.5 };
|
|
12
13
|
// Only http(s) documents are linked; the terms URL comes from the server.
|
|
@@ -57,7 +58,7 @@ function termsFromResponse(body) {
|
|
|
57
58
|
* a host action (for example `SetupWizardShell`'s `primaryForm`) submits it.
|
|
58
59
|
* - `submitLabel`, `disabled`, `onBusyChange(busy)`.
|
|
59
60
|
*/
|
|
60
|
-
export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyChange, termsEnabled = false, termsApi = defaultTermsApi, privacyUrl, formId, submitLabel, disabled = false, }) {
|
|
61
|
+
export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyChange, termsEnabled = false, termsApi = defaultTermsApi, privacyMode = 'legacy', privacyUrl, formId, submitLabel, disabled = false, }) {
|
|
61
62
|
var _a;
|
|
62
63
|
const { t, i18n } = useTranslation();
|
|
63
64
|
const { user, login } = useContext(AuthContext) || {};
|
|
@@ -75,13 +76,16 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
75
76
|
const activeDraft = onDraftChange ? draft : internalDraft;
|
|
76
77
|
const draftMatches = Boolean(activeDraft) && activeDraft.identity === identity;
|
|
77
78
|
const editedFields = new Set(draftMatches ? activeDraft.editedFields || [] : []);
|
|
78
|
-
const { values } = refreshProfileDraft(user, identity, editedFields, draftMatches ? activeDraft.values || {} : {});
|
|
79
|
+
const { values } = refreshProfileDraft(user, identity, editedFields, draftMatches ? activeDraft.values || {} : {}, privacyMode);
|
|
79
80
|
const currentTerms = terms && terms.owner === identity ? terms : null;
|
|
80
81
|
const commit = (patch) => {
|
|
81
82
|
Object.keys(patch).forEach((key) => editedFields.add(key));
|
|
82
83
|
const next = {
|
|
83
84
|
identity,
|
|
84
|
-
values: Object.assign({ firstName: values.firstName, lastName: values.lastName,
|
|
85
|
+
values: Object.assign(Object.assign({ firstName: values.firstName, lastName: values.lastName }, (privacyMode !== 'central' ? {
|
|
86
|
+
acceptedPrivacy: values.acceptedPrivacy,
|
|
87
|
+
acceptedCookies: values.acceptedCookies,
|
|
88
|
+
} : {})), patch),
|
|
85
89
|
editedFields: [...editedFields],
|
|
86
90
|
};
|
|
87
91
|
if (onDraftChange)
|
|
@@ -92,9 +96,9 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
92
96
|
const applyTerms = useCallback((body, owner, privacyAccepted) => {
|
|
93
97
|
const next = termsFromResponse(body);
|
|
94
98
|
setTerms(Object.assign({ owner }, next));
|
|
95
|
-
setTermsChecked(next.accepted && Boolean(privacyAccepted));
|
|
99
|
+
setTermsChecked(next.accepted && (privacyMode === 'central' || Boolean(privacyAccepted)));
|
|
96
100
|
return next;
|
|
97
|
-
}, []);
|
|
101
|
+
}, [privacyMode]);
|
|
98
102
|
// Terms evidence is per person: reset and reload whenever the identity changes.
|
|
99
103
|
useEffect(() => {
|
|
100
104
|
setTerms(null);
|
|
@@ -102,7 +106,7 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
102
106
|
if (!termsEnabled || !user)
|
|
103
107
|
return undefined;
|
|
104
108
|
let active = true;
|
|
105
|
-
const privacyAccepted = Boolean(user.accepted_privacy_statement);
|
|
109
|
+
const privacyAccepted = privacyMode === 'central' || Boolean(user.accepted_privacy_statement);
|
|
106
110
|
termsApi.getAcceptance()
|
|
107
111
|
.then((body) => {
|
|
108
112
|
if (active)
|
|
@@ -117,7 +121,7 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
117
121
|
return () => {
|
|
118
122
|
active = false;
|
|
119
123
|
};
|
|
120
|
-
}, [termsEnabled, termsApi, identity]);
|
|
124
|
+
}, [termsEnabled, termsApi, identity, privacyMode]);
|
|
121
125
|
useEffect(() => {
|
|
122
126
|
onBusyChange === null || onBusyChange === void 0 ? void 0 : onBusyChange(saving);
|
|
123
127
|
}, [saving]);
|
|
@@ -139,12 +143,15 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
139
143
|
}
|
|
140
144
|
setPrivacyOpen((previous) => !previous);
|
|
141
145
|
};
|
|
142
|
-
const requiredChecked = termsEnabled
|
|
146
|
+
const requiredChecked = termsEnabled
|
|
147
|
+
? termsChecked
|
|
148
|
+
: privacyMode === 'central' || Boolean(values.acceptedPrivacy);
|
|
143
149
|
const handleRequiredChange = (event) => {
|
|
144
150
|
const { checked } = event.target;
|
|
145
151
|
if (termsEnabled)
|
|
146
152
|
setTermsChecked(checked);
|
|
147
|
-
|
|
153
|
+
if (privacyMode !== 'central')
|
|
154
|
+
commit({ acceptedPrivacy: checked });
|
|
148
155
|
};
|
|
149
156
|
// Returns true when the acceptance is on record for the current version.
|
|
150
157
|
const acceptCurrentTerms = async (version) => {
|
|
@@ -179,8 +186,10 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
179
186
|
setErrorKey(t('Auth.PROFILE_NAME_REQUIRED'));
|
|
180
187
|
return;
|
|
181
188
|
}
|
|
182
|
-
if (!requiredChecked) {
|
|
183
|
-
setErrorKey(t(termsEnabled
|
|
189
|
+
if ((termsEnabled || privacyMode !== 'central') && !requiredChecked) {
|
|
190
|
+
setErrorKey(t(termsEnabled
|
|
191
|
+
? (privacyMode === 'central' ? 'Auth.TERMS_REQUIRED' : 'Auth.TERMS_PRIVACY_REQUIRED')
|
|
192
|
+
: 'Auth.PRIVACY_REQUIRED'));
|
|
184
193
|
return;
|
|
185
194
|
}
|
|
186
195
|
savingRef.current = true;
|
|
@@ -198,12 +207,15 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
198
207
|
throw new Error('terms_not_available');
|
|
199
208
|
}
|
|
200
209
|
stage = 'profile';
|
|
201
|
-
const
|
|
210
|
+
const profileUpdate = {
|
|
202
211
|
first_name: (values.firstName || '').trim(),
|
|
203
212
|
last_name: (values.lastName || '').trim(),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
213
|
+
};
|
|
214
|
+
if (privacyMode !== 'central') {
|
|
215
|
+
profileUpdate.accepted_privacy_statement = true;
|
|
216
|
+
profileUpdate.accepted_convenience_cookies = Boolean(values.acceptedCookies);
|
|
217
|
+
}
|
|
218
|
+
const updatedUser = await updateUserProfile(profileUpdate);
|
|
207
219
|
if (updatedUser)
|
|
208
220
|
login === null || login === void 0 ? void 0 : login(updatedUser);
|
|
209
221
|
if (termsEnabled && !termsState.accepted) {
|
|
@@ -232,6 +244,6 @@ export function ProfileStepContent({ draft, onDraftChange, onComplete, onBusyCha
|
|
|
232
244
|
const busy = disabled || saving;
|
|
233
245
|
const privacyLink = privacyHref ? (_jsx(Link, { href: privacyHref, target: "_blank", rel: "noopener noreferrer", children: t('Auth.PRIVACY_LINK_LABEL') })) : (_jsx(Link, { component: "button", type: "button", variant: "body1", onClick: togglePrivacyText, sx: { verticalAlign: 'baseline' }, children: t('Auth.PRIVACY_LINK_LABEL') }));
|
|
234
246
|
const termsLink = termsHref ? (_jsx(Link, { href: termsHref, target: "_blank", rel: "noopener noreferrer", children: t('Auth.TERMS_LINK_LABEL') })) : t('Auth.TERMS_LINK_LABEL');
|
|
235
|
-
const requiredLabel = termsEnabled ? (_jsxs("span", { children: [t('Auth.TERMS_PRIVACY_PREFIX'), termsLink, t('Auth.TERMS_PRIVACY_AND'), privacyLink, t('Auth.TERMS_PRIVACY_SUFFIX')] })) : (_jsxs("span", { children: [t('Auth.PRIVACY_REQUIRED_LABEL'), ' ', privacyLink, t('Auth.TERMS_PRIVACY_SUFFIX')] }));
|
|
236
|
-
return (_jsxs(Box, { component: "form", id: formId, onSubmit: handleSubmit, noValidate: true, "aria-busy": saving || undefined, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [errorKey && _jsx(Alert, { ref: errorRef, severity: "error", tabIndex: -1, children: errorKey }), _jsx(TextField, { label: t('Profile.FIRST_NAME_LABEL'), value: values.firstName || '', onChange: (event) => commit({ firstName: event.target.value }), autoComplete: "given-name", required: true, fullWidth: true, disabled: busy }), _jsx(TextField, { label: t('Profile.LAST_NAME_LABEL'), value: values.lastName || '', onChange: (event) => commit({ lastName: event.target.value }), autoComplete: "family-name", required: true, fullWidth: true, disabled: busy }), _jsxs(Stack, { spacing: 0.5, children: [_jsx(FormControlLabel, { sx: PROFILE_STEP_OPTION_SX, control: (_jsx(Checkbox, { checked: requiredChecked, onChange: handleRequiredChange, disabled: busy || (termsEnabled && !currentTerms), sx: PROFILE_STEP_CHECKBOX_SX })), label: requiredLabel }), privacyOpen && privacyText && !privacyHref && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { whiteSpace: 'pre-wrap', pl: 4 }, children: privacyText })), _jsx(FormControlLabel, { sx: PROFILE_STEP_OPTION_SX, control: (_jsx(Checkbox, { checked: Boolean(values.acceptedCookies), onChange: (event) => commit({ acceptedCookies: event.target.checked }), disabled: busy, sx: PROFILE_STEP_CHECKBOX_SX })), label: t('Auth.CONVENIENCE_COOKIES_LABEL') })] }), !formId && (_jsx(Box, { children: _jsx(Button, { type: "submit", variant: "contained", disabled: busy, children: submitLabel || t('Profile.SAVE_BUTTON') }) }))] }));
|
|
247
|
+
const requiredLabel = termsEnabled && privacyMode === 'central' ? (_jsxs("span", { children: [t('Auth.TERMS_PRIVACY_PREFIX'), termsLink, t('Auth.TERMS_PRIVACY_SUFFIX')] })) : termsEnabled ? (_jsxs("span", { children: [t('Auth.TERMS_PRIVACY_PREFIX'), termsLink, t('Auth.TERMS_PRIVACY_AND'), privacyLink, t('Auth.TERMS_PRIVACY_SUFFIX')] })) : privacyMode === 'central' ? null : (_jsxs("span", { children: [t('Auth.PRIVACY_REQUIRED_LABEL'), ' ', privacyLink, t('Auth.TERMS_PRIVACY_SUFFIX')] }));
|
|
248
|
+
return (_jsxs(Box, { component: "form", id: formId, onSubmit: handleSubmit, noValidate: true, "aria-busy": saving || undefined, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [errorKey && _jsx(Alert, { ref: errorRef, severity: "error", tabIndex: -1, children: errorKey }), _jsx(TextField, { label: t('Profile.FIRST_NAME_LABEL'), value: values.firstName || '', onChange: (event) => commit({ firstName: event.target.value }), autoComplete: "given-name", required: true, fullWidth: true, disabled: busy }), _jsx(TextField, { label: t('Profile.LAST_NAME_LABEL'), value: values.lastName || '', onChange: (event) => commit({ lastName: event.target.value }), autoComplete: "family-name", required: true, fullWidth: true, disabled: busy }), (termsEnabled || privacyMode !== 'central') && _jsxs(Stack, { spacing: 0.5, children: [(termsEnabled || privacyMode !== 'central') && (_jsx(FormControlLabel, { sx: PROFILE_STEP_OPTION_SX, control: (_jsx(Checkbox, { checked: requiredChecked, onChange: handleRequiredChange, disabled: busy || (termsEnabled && !currentTerms), sx: PROFILE_STEP_CHECKBOX_SX })), label: requiredLabel })), privacyOpen && privacyText && !privacyHref && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { whiteSpace: 'pre-wrap', pl: 4 }, children: privacyText })), privacyMode !== 'central' && _jsx(FormControlLabel, { sx: PROFILE_STEP_OPTION_SX, control: (_jsx(Checkbox, { checked: Boolean(values.acceptedCookies), onChange: (event) => commit({ acceptedCookies: event.target.checked }), disabled: busy, sx: PROFILE_STEP_CHECKBOX_SX })), label: t('Auth.CONVENIENCE_COOKIES_LABEL') })] }), privacyMode === 'central' && _jsx(Box, { children: _jsx(PrivacyNoticeLink, {}) }), !formId && (_jsx(Box, { children: _jsx(Button, { type: "submit", variant: "contained", disabled: busy, children: submitLabel || t('Profile.SAVE_BUTTON') }) }))] }));
|
|
237
249
|
}
|
|
@@ -2675,6 +2675,13 @@ export const authTranslations = {
|
|
|
2675
2675
|
"en": "Please accept the terms of use and the privacy statement.",
|
|
2676
2676
|
"sw": "Tafadhali kubali masharti ya matumizi na taarifa ya faragha."
|
|
2677
2677
|
},
|
|
2678
|
+
"Auth.TERMS_REQUIRED": {
|
|
2679
|
+
"de": "Bitte akzeptieren Sie die Nutzungsbedingungen.",
|
|
2680
|
+
"de_informal": "Bitte akzeptiere die Nutzungsbedingungen.",
|
|
2681
|
+
"fr": "Veuillez accepter les conditions d’utilisation.",
|
|
2682
|
+
"en": "Please accept the terms of use.",
|
|
2683
|
+
"sw": "Tafadhali kubali masharti ya matumizi."
|
|
2684
|
+
},
|
|
2678
2685
|
"Auth.PRIVACY_REQUIRED": {
|
|
2679
2686
|
"de": "Bitte akzeptieren Sie die Datenschutzerklärung.",
|
|
2680
2687
|
"de_informal": "Bitte akzeptiere die Datenschutzerklärung.",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const privacyTranslations = {
|
|
2
|
+
'Privacy.CHOICE_TITLE': { de: 'Datenschutzauswahl', fr: 'Choix de confidentialité', en: 'Privacy choices', sw: 'Chaguo za faragha' },
|
|
3
|
+
'Privacy.CHANGE_ANYTIME': { de: 'Sie können Ihre Auswahl jederzeit hier ändern.', fr: 'Vous pouvez modifier votre choix ici à tout moment.', en: 'You can change your choice here at any time.', sw: 'Unaweza kubadilisha chaguo lako hapa wakati wowote.' },
|
|
4
|
+
'Privacy.CONTROLLER': { de: 'Verantwortliche Stelle', fr: 'Responsable du traitement', en: 'Data controller', sw: 'Mdhibiti wa data' },
|
|
5
|
+
'Privacy.CLOSE': { de: 'Schliessen', fr: 'Fermer', en: 'Close', sw: 'Funga' },
|
|
6
|
+
'Privacy.NECESSARY_ONLY': { de: 'Nur notwendige Funktionen', fr: 'Fonctions nécessaires uniquement', en: 'Necessary only', sw: 'Muhimu pekee' },
|
|
7
|
+
'Privacy.ALLOW_ALL': { de: 'Alle erlauben', fr: 'Tout autoriser', en: 'Allow all', sw: 'Ruhusu yote' },
|
|
8
|
+
'Privacy.SETTINGS': { de: 'Einstellungen', fr: 'Paramètres', en: 'Settings', sw: 'Mipangilio' },
|
|
9
|
+
'Privacy.SETTINGS_TITLE': { de: 'Datenschutzeinstellungen', fr: 'Paramètres de confidentialité', en: 'Privacy settings', sw: 'Mipangilio ya faragha' },
|
|
10
|
+
'Privacy.ALWAYS_ACTIVE': { de: 'Immer aktiv', fr: 'Toujours actives', en: 'Always active', sw: 'Huwashwa kila wakati' },
|
|
11
|
+
'Privacy.REQUIRED_INFORMATION': { de: 'Für Anmeldung, Sicherheit und ausdrücklich angeforderte Funktionen.', fr: 'Pour la connexion, la sécurité et les fonctions expressément demandées.', en: 'For sign-in, security and functions you explicitly request.', sw: 'Kwa kuingia, usalama na vitendaji unavyoomba waziwazi.' },
|
|
12
|
+
'Privacy.NECESSARY_ONLY_ACTIVE': { de: 'Nur notwendige Funktionen sind aktiv.', fr: 'Seules les fonctions nécessaires sont actives.', en: 'Only necessary functions are active.', sw: 'Vitendaji muhimu pekee ndivyo vinavyotumika.' },
|
|
13
|
+
'Privacy.NO_OPTIONAL': { de: 'Diese App verwendet nur notwendige Funktionen.', fr: 'Cette application utilise uniquement les fonctions nécessaires.', en: 'This app uses only necessary functions.', sw: 'Programu hii hutumia vitendaji muhimu pekee.' },
|
|
14
|
+
'Privacy.SAVED': { de: 'Ihre Auswahl ist gespeichert.', fr: 'Votre choix a été enregistré.', en: 'Your selection has been saved.', sw: 'Chaguo lako limehifadhiwa.' },
|
|
15
|
+
'Privacy.SAVE_ERROR': { de: 'Speichern derzeit nicht möglich. Optionale Dienste bleiben ausgeschaltet.', fr: 'Enregistrement impossible pour le moment. Les services facultatifs restent désactivés.', en: 'Unable to save right now. Optional services remain off.', sw: 'Haiwezekani kuhifadhi kwa sasa. Huduma za hiari zitaendelea kuzimwa.' },
|
|
16
|
+
'Privacy.SAVE_ERROR_WITH_GRANTS': { de: 'Speichern derzeit nicht möglich. Die Änderung ist nicht gespeichert; widerrufene Dienste bleiben auf dieser Seite ausgeschaltet.', fr: 'Enregistrement impossible pour le moment. La modification n’est pas enregistrée ; les services retirés restent désactivés sur cette page.', en: 'Unable to save right now. The change is not stored; withdrawn services remain off on this page.', sw: 'Haiwezekani kuhifadhi kwa sasa. Mabadiliko hayajahifadhiwa; huduma zilizoondolewa zitaendelea kuzimwa kwenye ukurasa huu.' },
|
|
17
|
+
'Privacy.NOTICE_LINK': { de: 'Datenschutzerklärung', fr: 'Politique de confidentialité', en: 'Privacy notice', sw: 'Taarifa ya faragha' },
|
|
18
|
+
'Privacy.NOTICE_EXPLANATION': { de: 'Welche Daten wir wofür verwenden, steht in der Datenschutzerklärung.', fr: 'Notre avis de confidentialité explique quelles données nous utilisons et pourquoi.', en: 'Our privacy notice explains which data we use and why.', sw: 'Taarifa yetu ya faragha inaeleza data tunayotumia na sababu zake.' },
|
|
19
|
+
'Privacy.PROVIDER_STORAGE_DETAIL': { de: 'Anbieter: {{provider}}. Speicherart und Laufzeit werden für die tatsächlich eingesetzten Funktionen ausgewiesen.', fr: 'Fournisseur : {{provider}}. Le type de stockage et sa durée sont indiqués pour les fonctions réellement utilisées.', en: 'Provider: {{provider}}. Storage types and duration are listed for the functions actually used.', sw: 'Mtoa huduma: {{provider}}. Aina na muda wa hifadhi vimeorodheshwa kwa vitendaji vinavyotumika.' },
|
|
20
|
+
'Privacy.SERVER_RETENTION': { de: 'Aufbewahrung auf dem Server: {{retention}}', fr: 'Conservation sur le serveur : {{retention}}', en: 'Server retention: {{retention}}', sw: 'Muda wa kuhifadhi kwenye seva: {{retention}}' },
|
|
21
|
+
'Privacy.DATA_CATEGORIES': { de: 'Datenkategorien: {{values}}', fr: 'Catégories de données : {{values}}', en: 'Data categories: {{values}}', sw: 'Aina za data: {{values}}' },
|
|
22
|
+
'Privacy.RECIPIENTS': { de: 'Empfänger: {{values}}', fr: 'Destinataires : {{values}}', en: 'Recipients: {{values}}', sw: 'Wapokeaji: {{values}}' },
|
|
23
|
+
'Privacy.TRANSFERS': { de: 'Übermittlungen: {{values}}', fr: 'Transferts : {{values}}', en: 'Transfers: {{values}}', sw: 'Uhamisho: {{values}}' },
|
|
24
|
+
'Privacy.NECESSARY_STORAGE': { de: 'Notwendiger Speicher', fr: 'Stockage nécessaire', en: 'Necessary storage', sw: 'Hifadhi muhimu' },
|
|
25
|
+
'Privacy.DETAILS': { de: 'Details', fr: 'Détails', en: 'Details', sw: 'Maelezo' },
|
|
26
|
+
'Privacy.SAVE': { de: 'Auswahl speichern', fr: 'Enregistrer le choix', en: 'Save selection', sw: 'Hifadhi chaguo' },
|
|
27
|
+
'Privacy.SAVING': { de: 'Wird gespeichert …', fr: 'Enregistrement…', en: 'Saving…', sw: 'Inahifadhi…' },
|
|
28
|
+
'Privacy.RETRY': { de: 'Erneut versuchen', fr: 'Réessayer', en: 'Retry', sw: 'Jaribu tena' },
|
|
29
|
+
'Privacy.NECESSARY_ALWAYS_ACTIVE': { de: 'Notwendige Funktionen sind immer aktiv.', fr: 'Les fonctions nécessaires sont toujours actives.', en: 'Necessary functions are always active.', sw: 'Vitendaji muhimu huwa vimewashwa kila wakati.' },
|
|
30
|
+
'Privacy.FOOTER_NAV': { de: 'Rechtliches und Datenschutz', fr: 'Mentions légales et confidentialité', en: 'Legal and privacy', sw: 'Kisheria na faragha' },
|
|
31
|
+
'Privacy.FOOTER_PRIVACY': { de: 'Datenschutzerklärung', fr: 'Politique de confidentialité', en: 'Privacy notice', sw: 'Taarifa ya faragha' },
|
|
32
|
+
'Privacy.FOOTER_TERMS': { de: 'Nutzungsbedingungen', fr: 'Conditions d’utilisation', en: 'Terms of use', sw: 'Masharti ya matumizi' },
|
|
33
|
+
'Privacy.FOOTER_DATA_PROCESSING': { de: 'Auftragsverarbeitung', fr: 'Traitement des données', en: 'Data processing', sw: 'Uchakataji wa data' },
|
|
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.LOADING': { de: 'Datenschutzeinstellungen werden geladen.', fr: 'Chargement des paramètres de confidentialité.', en: 'Loading privacy settings.', sw: 'Inapakia mipangilio ya faragha.' },
|
|
36
|
+
'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
|
+
};
|
|
@@ -17,9 +17,10 @@ import { messagingTranslations } from './messagingTranslations';
|
|
|
17
17
|
import { notificationsTranslations } from './notificationsTranslations';
|
|
18
18
|
import { receiptsTranslations } from './receiptsTranslations';
|
|
19
19
|
import { onboardingTranslations } from './onboardingTranslations';
|
|
20
|
+
import { privacyTranslations } from './privacyTranslations';
|
|
20
21
|
import { sectionNavTranslations } from './sectionNavTranslations';
|
|
21
22
|
import { userMenuTranslations } from './userMenuTranslations';
|
|
22
|
-
export const uiCoreTranslations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, authTranslations), billingTranslations), chartsTranslations), chatTranslations), messagingTranslations), notificationsTranslations), receiptsTranslations), onboardingTranslations), sectionNavTranslations), userMenuTranslations);
|
|
23
|
+
export const uiCoreTranslations = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, authTranslations), billingTranslations), chartsTranslations), chatTranslations), messagingTranslations), notificationsTranslations), receiptsTranslations), onboardingTranslations), privacyTranslations), sectionNavTranslations), userMenuTranslations);
|
|
23
24
|
export function createUiCoreTranslations({ germanVariant = 'formal' } = {}) {
|
|
24
25
|
return Object.fromEntries(Object.entries(uiCoreTranslations).map(([key, value]) => {
|
|
25
26
|
const { de_informal } = value, rest = __rest(value, ["de_informal"]);
|
package/dist/index.js
CHANGED
|
@@ -125,3 +125,13 @@ export { createReceiptsApi, defaultReceiptsApi } from './receipts/api';
|
|
|
125
125
|
export { receiptFileProblem, prepareReceiptFile } from './receipts/files';
|
|
126
126
|
export { RECEIPT_ACCEPT, RECEIPT_MAX_BYTES } from './receipts/wire';
|
|
127
127
|
export { createUiCoreTranslations, uiCoreTranslations } from './i18n/uiCoreTranslations';
|
|
128
|
+
// --- 11. Privacy choices (opt-in; requires django-core-micha >= 3.22.0) ---
|
|
129
|
+
export { PrivacyProvider, usePrivacy } from './privacy/PrivacyProvider';
|
|
130
|
+
export { createPrivacyApi, defaultPrivacyApi } from './privacy/privacyApi';
|
|
131
|
+
export { PrivacyBanner } from './privacy/PrivacyBanner';
|
|
132
|
+
export { PrivacySettingsDialog, PrivacySettingsPanel } from './privacy/PrivacySettings';
|
|
133
|
+
export { PrivacySettingsLink } from './privacy/PrivacySettingsLink';
|
|
134
|
+
export { PrivacyFooterLinks, buildLegalReaderUrl, legalDocumentLanguage } from './privacy/PrivacyFooterLinks';
|
|
135
|
+
export { PrivacyNoticeLink, safePrivacyDocumentUrl } from './privacy/PrivacyNoticeLink';
|
|
136
|
+
export { registerPrivacyService, useGrantedPurpose, guardedImport, createPrivacyGuard, isPurposeGranted, } from './privacy/serviceRegistry';
|
|
137
|
+
export { privacyTranslations } from './i18n/privacyTranslations';
|
|
@@ -129,7 +129,7 @@ function getInitialPwaInstallState() {
|
|
|
129
129
|
// consumer even when no extraContext is passed.
|
|
130
130
|
const EMPTY_EXTRA_CONTEXT = {};
|
|
131
131
|
const EMPTY_BROWSER_PUSH = {};
|
|
132
|
-
export function OnboardingProvider({ children, extraSteps = [], extraContext = EMPTY_EXTRA_CONTEXT, pwaInstallEnabled = false, browserPush = EMPTY_BROWSER_PUSH, }) {
|
|
132
|
+
export function OnboardingProvider({ children, extraSteps = [], extraContext = EMPTY_EXTRA_CONTEXT, pwaInstallEnabled = false, browserPush = EMPTY_BROWSER_PUSH, privacyMode = 'legacy', }) {
|
|
133
133
|
const { user } = useContext(AuthContext);
|
|
134
134
|
const [configMap, setConfigMap] = useState({});
|
|
135
135
|
const [configLoaded, setConfigLoaded] = useState(false);
|
|
@@ -139,7 +139,10 @@ export function OnboardingProvider({ children, extraSteps = [], extraContext = E
|
|
|
139
139
|
const [dismissedSet, setDismissedSet] = useState(loadDismissedSteps);
|
|
140
140
|
const seenAtMountRef = useRef(loadSeenSteps());
|
|
141
141
|
const resolvedBrowserPush = useMemo(() => (Object.assign({ nagUntil: 'any-channel', showOnce: false }, browserPush)), [browserPush]);
|
|
142
|
-
const descriptors = useMemo(() => [
|
|
142
|
+
const descriptors = useMemo(() => [
|
|
143
|
+
...UNIVERSAL_STEP_DESCRIPTORS.filter((step) => privacyMode !== 'central' || step.id !== 'cookie_consent'),
|
|
144
|
+
...extraSteps,
|
|
145
|
+
], [extraSteps, privacyMode]);
|
|
143
146
|
useEffect(() => {
|
|
144
147
|
let cancelled = false;
|
|
145
148
|
if (!user) {
|
|
@@ -11,6 +11,7 @@ import Link from '@mui/material/Link';
|
|
|
11
11
|
import Typography from '@mui/material/Typography';
|
|
12
12
|
import PrivacyTipIcon from '@mui/icons-material/PrivacyTip';
|
|
13
13
|
import { fetchCookieStatement, fetchPrivacyStatement, updateUserProfile } from '../../auth/authApi';
|
|
14
|
+
/** @deprecated Adopt PrivacyProvider, PrivacyBanner and PrivacySettingsLink instead. */
|
|
14
15
|
export function CookieConsentStep({ onComplete }) {
|
|
15
16
|
const { t } = useTranslation();
|
|
16
17
|
const [privacyAccepted, setPrivacyAccepted] = useState(false);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { Box, Button, Paper, Stack, Typography } from '@mui/material';
|
|
4
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { usePrivacy } from './PrivacyProvider';
|
|
7
|
+
function localized(value, language) {
|
|
8
|
+
if (!value || typeof value !== 'object')
|
|
9
|
+
return '';
|
|
10
|
+
const normalized = String(language || '').replace('_', '-').toLowerCase();
|
|
11
|
+
const exact = Object.keys(value).find((key) => key.toLowerCase() === normalized);
|
|
12
|
+
if (exact)
|
|
13
|
+
return value[exact];
|
|
14
|
+
const base = normalized.split('-')[0];
|
|
15
|
+
const baseMatch = Object.keys(value).find((key) => key.toLowerCase() === base);
|
|
16
|
+
return value[baseMatch || Object.keys(value)[0]] || '';
|
|
17
|
+
}
|
|
18
|
+
export const PRIVACY_BANNER_PAPER_SX = {
|
|
19
|
+
position: 'fixed',
|
|
20
|
+
zIndex: (theme) => theme.zIndex.snackbar,
|
|
21
|
+
insetInline: 0,
|
|
22
|
+
bottom: 0,
|
|
23
|
+
p: { xs: 2, sm: 3 },
|
|
24
|
+
// Long manifests or translations must never push the choices off a small screen.
|
|
25
|
+
maxHeight: '90dvh',
|
|
26
|
+
overflowY: 'auto',
|
|
27
|
+
};
|
|
28
|
+
// The baseline MuiButton already sets minHeight; only the width and padding of the icon-only target are local.
|
|
29
|
+
export const PRIVACY_BANNER_CLOSE_SX = { minWidth: 44, p: 0, flexShrink: 0 };
|
|
30
|
+
export function PrivacyBanner() {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const privacy = usePrivacy();
|
|
33
|
+
const { t, i18n } = useTranslation();
|
|
34
|
+
const headingRef = useRef(null);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!(privacy === null || privacy === void 0 ? void 0 : privacy.bannerVisible))
|
|
38
|
+
return;
|
|
39
|
+
// The banner is nonmodal and loads asynchronously: move focus only when nothing else holds it,
|
|
40
|
+
// so it never interrupts someone who is already using the page.
|
|
41
|
+
const active = typeof document !== 'undefined' ? document.activeElement : null;
|
|
42
|
+
if (!active || active === document.body)
|
|
43
|
+
(_a = headingRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
44
|
+
}, [privacy === null || privacy === void 0 ? void 0 : privacy.bannerVisible]);
|
|
45
|
+
if (!(privacy === null || privacy === void 0 ? void 0 : privacy.bannerVisible))
|
|
46
|
+
return null;
|
|
47
|
+
const onKeyDown = (event) => {
|
|
48
|
+
if (event.key === 'Escape') {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
privacy.dismissBanner();
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const purposes = ((_b = (_a = privacy.manifest) === null || _a === void 0 ? void 0 : _a.purposes) === null || _b === void 0 ? void 0 : _b.filter((purpose) => !purpose.required)) || [];
|
|
54
|
+
const hasOtherGrant = purposes.some((purpose) => { var _a, _b, _c; return ((_c = (_b = (_a = privacy.choices) === null || _a === void 0 ? void 0 : _a.choices) === null || _b === void 0 ? void 0 : _b[purpose.id]) === null || _c === void 0 ? void 0 : _c.state) === 'granted'; });
|
|
55
|
+
return (_jsx(Paper, { role: "region", "aria-labelledby": "privacy-banner-title",
|
|
56
|
+
// Stays mounted while the settings dialog is open (it sits above modals and would cover the dialog's
|
|
57
|
+
// actions) so the dialog can return focus to the Settings button that opened it.
|
|
58
|
+
hidden: privacy.settingsOpen, onKeyDown: onKeyDown, elevation: 8, sx: PRIVACY_BANNER_PAPER_SX, children: _jsxs(Box, { sx: { maxWidth: 960, mx: 'auto' }, children: [_jsxs(Stack, { direction: "row", alignItems: "flex-start", justifyContent: "space-between", spacing: 2, children: [_jsxs(Box, { children: [_jsx(Typography, { id: "privacy-banner-title", component: "h2", variant: "h6", tabIndex: -1, ref: headingRef, children: t('Privacy.CHOICE_TITLE') }), _jsxs(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 0.75 }, children: [t('Privacy.NECESSARY_ALWAYS_ACTIVE'), " ", t('Privacy.CHANGE_ANYTIME')] })] }), _jsx(Button, { type: "button", "aria-label": t('Privacy.CLOSE'), onClick: privacy.dismissBanner, sx: PRIVACY_BANNER_CLOSE_SX, children: _jsx(CloseIcon, { "aria-hidden": "true" }) })] }), _jsx(Stack, { spacing: 1.25, sx: { mt: 1.5 }, children: purposes.map((purpose) => (_jsxs(Box, { children: [localized(purpose.label, i18n.language) && _jsx(Typography, { variant: "subtitle2", children: localized(purpose.label, i18n.language) }), localized(purpose.summary, i18n.language) && (_jsx(Typography, { variant: "body2", color: "text.secondary", children: localized(purpose.summary, i18n.language) }))] }, purpose.id))) }), privacy.saveState === 'error' && (_jsx(Typography, { role: "alert", color: "error", variant: "body2", sx: { mt: 1.5 }, children: t(hasOtherGrant ? 'Privacy.SAVE_ERROR_WITH_GRANTS' : 'Privacy.SAVE_ERROR') })), _jsxs(Stack, { direction: { xs: 'column', sm: 'row' }, spacing: 1.25, sx: { mt: 2 }, children: [_jsx(Button, { type: "button", variant: "contained", size: "medium", disabled: privacy.saveState === 'saving', onClick: () => privacy.necessaryOnly('banner'), children: t('Privacy.NECESSARY_ONLY') }), _jsx(Button, { type: "button", variant: "contained", size: "medium", disabled: privacy.saveState === 'saving', onClick: () => privacy.acceptAll('banner'), children: t('Privacy.ALLOW_ALL') }), _jsx(Button, { type: "button", variant: "text", onClick: privacy.openSettings, children: t('Privacy.SETTINGS') })] })] }) }));
|
|
59
|
+
}
|
|
60
|
+
export default PrivacyBanner;
|
|
@@ -0,0 +1,69 @@
|
|
|
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 } from '@mui/material';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { PrivacySettingsLink } from './PrivacySettingsLink';
|
|
17
|
+
const LEGAL_SLUGS = ['privacy', 'terms', 'data-processing', 'cancellation'];
|
|
18
|
+
const APP_ID = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
19
|
+
/**
|
|
20
|
+
* Document language for the central legal reader. Only verified DE/EN documents exist: every other UI
|
|
21
|
+
* language links an explicitly supported fallback and never a manufactured translation.
|
|
22
|
+
*/
|
|
23
|
+
export function legalDocumentLanguage(uiLanguage, fallback = 'en') {
|
|
24
|
+
const base = String(uiLanguage || '').toLowerCase().split(/[-_]/)[0];
|
|
25
|
+
if (base === 'de' || base === 'en')
|
|
26
|
+
return base;
|
|
27
|
+
return fallback === 'de' ? 'de' : 'en';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `<origin>/legal/<slug>?app=<id>&lang=<de|en>` — the stable link contract of the bigler-consult legal reader.
|
|
31
|
+
* Pure and static: it needs no privacy API, so legal hyperlinks survive a failed settings request.
|
|
32
|
+
* Returns null for an unsafe origin, unknown slug or malformed application id (no account or page data is ever added).
|
|
33
|
+
*/
|
|
34
|
+
export function buildLegalReaderUrl({ origin, slug, appId, lang }) {
|
|
35
|
+
if (!LEGAL_SLUGS.includes(slug) || !APP_ID.test(String(appId || '')))
|
|
36
|
+
return null;
|
|
37
|
+
let base;
|
|
38
|
+
try {
|
|
39
|
+
base = new URL(String(origin || ''));
|
|
40
|
+
}
|
|
41
|
+
catch (_a) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if ((base.protocol !== 'https:' && base.protocol !== 'http:') || base.username || base.password)
|
|
45
|
+
return null;
|
|
46
|
+
const query = new URLSearchParams({ app: appId, lang: lang === 'de' ? 'de' : 'en' });
|
|
47
|
+
return `${base.origin}/legal/${slug}?${query.toString()}`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Persistent legal footer entries: Privacy notice and Terms (static reader links) plus the local
|
|
51
|
+
* "Privacy settings" action. The settings action opens THIS app's shared settings (never the reader's) and is
|
|
52
|
+
* hidden only when the host has not adopted the privacy module; the legal links are always rendered.
|
|
53
|
+
*/
|
|
54
|
+
export function PrivacyFooterLinks(_a) {
|
|
55
|
+
var { legalOrigin, appId, documents = ['privacy', 'terms'], fallbackLanguage = 'en', showSettings = true, sx } = _a, props = __rest(_a, ["legalOrigin", "appId", "documents", "fallbackLanguage", "showSettings", "sx"]);
|
|
56
|
+
const { t, i18n } = useTranslation();
|
|
57
|
+
const lang = legalDocumentLanguage(i18n === null || i18n === void 0 ? void 0 : i18n.language, fallbackLanguage);
|
|
58
|
+
const labels = {
|
|
59
|
+
privacy: t('Privacy.FOOTER_PRIVACY'),
|
|
60
|
+
terms: t('Privacy.FOOTER_TERMS'),
|
|
61
|
+
'data-processing': t('Privacy.FOOTER_DATA_PROCESSING'),
|
|
62
|
+
cancellation: t('Privacy.FOOTER_CANCELLATION'),
|
|
63
|
+
};
|
|
64
|
+
const links = documents
|
|
65
|
+
.map((slug) => ({ slug, href: buildLegalReaderUrl({ origin: legalOrigin, slug, appId, lang }) }))
|
|
66
|
+
.filter((item) => item.href);
|
|
67
|
+
return (_jsxs(Box, Object.assign({ component: "nav", "aria-label": t('Privacy.FOOTER_NAV'), sx: Object.assign({ display: 'flex', flexWrap: 'wrap', gap: 1.5, alignItems: 'center' }, sx) }, props, { children: [links.map(({ slug, href }) => (_jsx(Link, { href: href, variant: "body2", underline: "hover", children: labels[slug] }, slug))), showSettings ? _jsx(PrivacySettingsLink, { variant: "body2", underline: "hover" }) : null] })));
|
|
68
|
+
}
|
|
69
|
+
export default PrivacyFooterLinks;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { Link } from '@mui/material';
|
|
15
|
+
import { useTranslation } from 'react-i18next';
|
|
16
|
+
import { usePrivacy } from './PrivacyProvider';
|
|
17
|
+
import { localeForManifest } from './PrivacyProvider';
|
|
18
|
+
export function safePrivacyDocumentUrl(value) {
|
|
19
|
+
if (typeof value !== 'string' || !value || /[\u0000-\u001f\\]/.test(value))
|
|
20
|
+
return null;
|
|
21
|
+
const trimmed = value.trim();
|
|
22
|
+
if (/^https?:\/\//i.test(trimmed)) {
|
|
23
|
+
try {
|
|
24
|
+
const parsed = new URL(trimmed);
|
|
25
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
|
|
26
|
+
return null;
|
|
27
|
+
return parsed.href;
|
|
28
|
+
}
|
|
29
|
+
catch (_a) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (trimmed.startsWith('/') && !trimmed.startsWith('//'))
|
|
34
|
+
return trimmed;
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function documentReference(manifest, locale, documentId) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const documents = ((_a = manifest === null || manifest === void 0 ? void 0 : manifest.notice) === null || _a === void 0 ? void 0 : _a.documents) || {};
|
|
40
|
+
const id = documentId && documents[documentId]
|
|
41
|
+
? documentId
|
|
42
|
+
: Object.keys(documents)[0];
|
|
43
|
+
const localized = id ? (_b = documents[id]) === null || _b === void 0 ? void 0 : _b[locale] : null;
|
|
44
|
+
if (typeof localized === 'string')
|
|
45
|
+
return localized;
|
|
46
|
+
return (localized === null || localized === void 0 ? void 0 : localized.url) || (localized === null || localized === void 0 ? void 0 : localized.href) || (localized === null || localized === void 0 ? void 0 : localized.path) || (localized === null || localized === void 0 ? void 0 : localized.reference) || null;
|
|
47
|
+
}
|
|
48
|
+
export function PrivacyNoticeLink(_a) {
|
|
49
|
+
var { documentId, children } = _a, props = __rest(_a, ["documentId", "children"]);
|
|
50
|
+
const privacy = usePrivacy();
|
|
51
|
+
const { t, i18n } = useTranslation();
|
|
52
|
+
if (!privacy || privacy.status !== 'ready' || !privacy.manifest)
|
|
53
|
+
return null;
|
|
54
|
+
const locale = localeForManifest(privacy.manifest, i18n.language);
|
|
55
|
+
const href = safePrivacyDocumentUrl(documentReference(privacy.manifest, locale, documentId));
|
|
56
|
+
if (!href)
|
|
57
|
+
return null;
|
|
58
|
+
return (_jsx(Link, Object.assign({}, props, { href: href, target: "_blank", rel: "noopener noreferrer", children: children || t('Privacy.NOTICE_LINK') })));
|
|
59
|
+
}
|
|
60
|
+
export default PrivacyNoticeLink;
|