@micha.bigler/ui-core-micha 4.37.0 → 4.38.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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.37.1 - UCM-AUTH-16
4
+
5
+ Setup wizard step labels use a wider three-column layout on narrow screens, keeping longer labels readable while retaining the desktop row and existing navigation behavior.
6
+
3
7
  ## 4.37.0 - UCM-CHAT-18
4
8
 
5
9
  `ChatWorkspace` and `ChatThread` accept the optional `showReplyCaption` (default `true`). With `false` the line under a finished
package/README.md CHANGED
@@ -137,7 +137,11 @@ project, import or payment work. Existing pages and the dialog `OnboardingProvid
137
137
  email. `showProviders` adds Google/Microsoft above the form. `preferredSignupMode` (also on `SignUpPage`, e.g.
138
138
  `'self_signup_open'`) shows that mode first and selected when the server offers it; otherwise it is ignored and the
139
139
  server order applies. Open self-signup submits with "Konto anlegen" (`Auth.SIGNUP_SUBMIT_OPEN`); the other modes
140
- keep "Einladung anfordern".
140
+ keep "Einladung anfordern". An embedding app may pass `renderAdditionalField({ disabled })` to render its own optional
141
+ field inside the shared form and `additionalRegistrationData` as a flat object of its request keys and values. The
142
+ app owns field labels, translations, validation and error text. Empty values are omitted, and keys that could replace
143
+ the email, mode, access code, QR token or Turnstile token are ignored. The component does not persist this data or
144
+ place it in a URL or logs; the host should keep it transient as well.
141
145
  - `SignupConfirmContent` — the password form of `SignupConfirmPage`. Pass `token` (from the emailed
142
146
  `/signup/confirm/?token=…` link, which your app routes) and `onSuccess()`; there is no automatic sign-in, show
143
147
  `LoginContent` next.
@@ -350,7 +350,7 @@ export async function sendAdminInvite(email) {
350
350
  throw normaliseApiError(error, 'Auth.INVITE_FAILED');
351
351
  }
352
352
  }
353
- export async function submitRegistrationRequest({ email, mode, accessCode, registrationContextToken, registrationContext, turnstileToken, }) {
353
+ export async function submitRegistrationRequest({ email, mode, accessCode, registrationContextToken, registrationContext, turnstileToken, additionalRegistrationData, }) {
354
354
  const payload = { email, mode };
355
355
  if (accessCode)
356
356
  payload.access_code = accessCode;
@@ -362,6 +362,31 @@ export async function submitRegistrationRequest({ email, mode, accessCode, regis
362
362
  }
363
363
  if (turnstileToken)
364
364
  payload.turnstile_token = turnstileToken;
365
+ const protectedRegistrationFields = new Set([
366
+ 'email',
367
+ 'mode',
368
+ 'accessCode',
369
+ 'access_code',
370
+ 'registrationContextToken',
371
+ 'registration_context_token',
372
+ 'registrationContext',
373
+ 'registration_context',
374
+ 'turnstileToken',
375
+ 'turnstile_token',
376
+ '__proto__',
377
+ 'prototype',
378
+ 'constructor',
379
+ ]);
380
+ if (additionalRegistrationData && typeof additionalRegistrationData === 'object') {
381
+ for (const [key, value] of Object.entries(additionalRegistrationData)) {
382
+ if (!protectedRegistrationFields.has(key)
383
+ && value !== undefined
384
+ && value !== null
385
+ && value !== '') {
386
+ payload[key] = value;
387
+ }
388
+ }
389
+ }
365
390
  try {
366
391
  const res = await apiClient.post(`${USERS_BASE}/register-request/`, payload);
367
392
  return res.data;
@@ -54,9 +54,16 @@ export function orderSignupModes(modes, preferredMode) {
54
54
  * - `showProviders` (default false) and `continuation`: Google/Microsoft entry
55
55
  * above the email form when the app enables it; the validated continuation is
56
56
  * the provider callback URL.
57
+ * - `renderAdditionalField({ disabled })`: optional host-rendered field placed
58
+ * in the form. The host owns its label, translations, validation and error
59
+ * text; `disabled` follows the shared form's submitting state.
60
+ * - `additionalRegistrationData`: optional flat object of app-owned request
61
+ * fields. Empty values are omitted and protected registration fields are
62
+ * ignored by the request helper. Keep this value in transient component state;
63
+ * the shared form does not persist it or add it to a URL or logs.
57
64
  * The access code, QR token and Turnstile token never leave this component.
58
65
  */
59
- export function SignUpContent({ registrationContextToken = '', preferredSignupMode, onModeChange, onSubmitted, showProviders = false, continuation, }) {
66
+ export function SignUpContent({ registrationContextToken = '', preferredSignupMode, onModeChange, onSubmitted, showProviders = false, continuation, renderAdditionalField, additionalRegistrationData, }) {
60
67
  const { t, i18n } = useTranslation();
61
68
  const { authMethods } = useContext(AuthContext) || {};
62
69
  const serverSignupModes = useMemo(() => resolveSignupModes(authMethods), [authMethods]);
@@ -126,13 +133,9 @@ export function SignUpContent({ registrationContextToken = '', preferredSignupMo
126
133
  return;
127
134
  setSubmitting(true);
128
135
  try {
129
- const res = await submitRegistrationRequest({
130
- email,
136
+ const res = await submitRegistrationRequest(Object.assign({ email,
131
137
  mode,
132
- accessCode,
133
- registrationContextToken: mode === 'self_signup_qr' ? registrationContextToken : null,
134
- turnstileToken: turnstileRequired ? turnstileToken : undefined,
135
- });
138
+ accessCode, registrationContextToken: mode === 'self_signup_qr' ? registrationContextToken : null, turnstileToken: turnstileRequired ? turnstileToken : undefined }, (additionalRegistrationData ? { additionalRegistrationData } : {})));
136
139
  // The backend's own response code is already mode-agnostic and accurate
137
140
  // (Auth.INVITE_SENT). Falling back to the access-code-specific "if valid,
138
141
  // an invite was sent" wording here was wrong for open/email-domain/QR
@@ -157,7 +160,7 @@ export function SignUpContent({ registrationContextToken = '', preferredSignupMo
157
160
  if (onSubmitted && successKey) {
158
161
  return (_jsxs(Stack, { spacing: 2, children: [_jsx(Alert, { severity: "success", children: t(successKey, { email }) }), _jsx(Alert, { severity: "info", children: t('Auth.CONFIRMATION_EMAIL_INSTRUCTION') })] }));
159
162
  }
160
- return (_jsxs(_Fragment, { children: [successKey && (_jsx(Alert, { severity: "success", sx: SIGN_UP_PAGE_ALERT_SX, children: t(successKey, { email }) })), errorKey && (_jsx(Alert, { severity: "error", sx: SIGN_UP_PAGE_ALERT_SX, children: errorKey })), providersVisible && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(SocialLoginButtons, { onProviderClick: handleProviderLogin, providers: socialProviders }), providerTransition && (_jsx(Alert, { severity: "info", sx: SIGN_UP_PROVIDER_ALERT_SX, children: t('Auth.PROVIDER_TRANSITION', { provider: PROVIDER_NAMES[providerTransition] || providerTransition }) })), _jsx(Divider, { sx: SIGN_UP_PROVIDER_DIVIDER_SX, children: t('Auth.LOGIN_OR') })] })), signupModes.length > 1 && (_jsx(Stack, { spacing: 1, sx: { mb: 2 }, children: signupModes.map((entry) => (_jsx(Button, { variant: mode === entry ? 'contained' : 'outlined', onClick: () => setMode(entry), disabled: submitting, fullWidth: true, children: t(MODE_LABELS[entry] || entry, entry) }, entry))) })), _jsxs(Box, { component: "form", onSubmit: handleSubmit, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(TextField, { label: t('Auth.EMAIL_LABEL'), type: "email", required: true, fullWidth: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting }), mode === 'self_signup_access_code' && (_jsx(TextField, { label: t('Auth.ACCESS_CODE_LABEL'), type: "text", required: true, fullWidth: true, value: accessCode, onChange: (e) => setAccessCode(e.target.value), disabled: submitting })), turnstileRequired && (_jsx(TurnstileWidget, { ref: turnstileWidgetRef, siteKey: authMethods.turnstile_site_key, onToken: setTurnstileToken })), _jsx(Button, { type: "submit", variant: "contained", disabled: submitting || Boolean(providerTransition) || (turnstileRequired && !turnstileToken), children: submitting
163
+ return (_jsxs(_Fragment, { children: [successKey && (_jsx(Alert, { severity: "success", sx: SIGN_UP_PAGE_ALERT_SX, children: t(successKey, { email }) })), errorKey && (_jsx(Alert, { severity: "error", sx: SIGN_UP_PAGE_ALERT_SX, children: errorKey })), providersVisible && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(SocialLoginButtons, { onProviderClick: handleProviderLogin, providers: socialProviders }), providerTransition && (_jsx(Alert, { severity: "info", sx: SIGN_UP_PROVIDER_ALERT_SX, children: t('Auth.PROVIDER_TRANSITION', { provider: PROVIDER_NAMES[providerTransition] || providerTransition }) })), _jsx(Divider, { sx: SIGN_UP_PROVIDER_DIVIDER_SX, children: t('Auth.LOGIN_OR') })] })), signupModes.length > 1 && (_jsx(Stack, { spacing: 1, sx: { mb: 2 }, children: signupModes.map((entry) => (_jsx(Button, { variant: mode === entry ? 'contained' : 'outlined', onClick: () => setMode(entry), disabled: submitting, fullWidth: true, children: t(MODE_LABELS[entry] || entry, entry) }, entry))) })), _jsxs(Box, { component: "form", onSubmit: handleSubmit, sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsx(TextField, { label: t('Auth.EMAIL_LABEL'), type: "email", required: true, fullWidth: true, value: email, onChange: (e) => setEmail(e.target.value), disabled: submitting }), mode === 'self_signup_access_code' && (_jsx(TextField, { label: t('Auth.ACCESS_CODE_LABEL'), type: "text", required: true, fullWidth: true, value: accessCode, onChange: (e) => setAccessCode(e.target.value), disabled: submitting })), renderAdditionalField === null || renderAdditionalField === void 0 ? void 0 : renderAdditionalField({ disabled: submitting }), turnstileRequired && (_jsx(TurnstileWidget, { ref: turnstileWidgetRef, siteKey: authMethods.turnstile_site_key, onToken: setTurnstileToken })), _jsx(Button, { type: "submit", variant: "contained", disabled: submitting || Boolean(providerTransition) || (turnstileRequired && !turnstileToken), children: submitting
161
164
  ? t('Auth.SIGNUP_SUBMITTING')
162
165
  : t(mode === 'self_signup_open' ? 'Auth.SIGNUP_SUBMIT_OPEN' : 'Auth.SIGNUP_SUBMIT') })] })] }));
163
166
  }
@@ -82,7 +82,16 @@ export function SetupWizardShell({ steps = [], currentStepId, completedStepIds =
82
82
  }
83
83
  };
84
84
  const hasPrimary = Boolean(primaryLabel) && Boolean(onPrimary || primaryForm);
85
- return (_jsxs(Box, { component: "section", "aria-labelledby": titleId, sx: { width: '100%', maxWidth: 600, mx: 'auto', pt: { xs: 3, sm: 4 }, pb: 5 }, children: [_jsxs(Box, { component: "header", sx: { mb: 3.5 }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 2 }, children: [_jsx(Typography, { component: "p", variant: "subtitle2", children: t('Onboarding.SETUP') }), _jsx(Typography, { component: "p", variant: "body2", color: "text.secondary", "aria-live": "polite", children: t('Onboarding.STEP_COUNTER', { current: currentIndex + 1, total }) })] }), _jsx(Box, { component: "nav", "aria-label": t('Onboarding.SETUP'), children: _jsx(Box, { component: "ol", sx: { display: 'flex', listStyle: 'none', gap: { xs: 0, sm: 0.5 }, m: 0, mt: 2.25, p: 0 }, children: steps.map((step, index) => {
85
+ return (_jsxs(Box, { component: "section", "aria-labelledby": titleId, sx: { width: '100%', maxWidth: 600, mx: 'auto', pt: { xs: 3, sm: 4 }, pb: 5 }, children: [_jsxs(Box, { component: "header", sx: { mb: 3.5 }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 2 }, children: [_jsx(Typography, { component: "p", variant: "subtitle2", children: t('Onboarding.SETUP') }), _jsx(Typography, { component: "p", variant: "body2", color: "text.secondary", "aria-live": "polite", children: t('Onboarding.STEP_COUNTER', { current: currentIndex + 1, total }) })] }), _jsx(Box, { component: "nav", "aria-label": t('Onboarding.SETUP'), children: _jsx(Box, { component: "ol", sx: {
86
+ display: { xs: 'grid', sm: 'flex' },
87
+ gridTemplateColumns: { xs: 'repeat(3, minmax(0, 1fr))', sm: 'none' },
88
+ alignItems: 'start',
89
+ listStyle: 'none',
90
+ gap: { xs: 0, sm: 0.5 },
91
+ m: 0,
92
+ mt: 2.25,
93
+ p: 0,
94
+ }, children: steps.map((step, index) => {
86
95
  const isCurrent = index === currentIndex;
87
96
  const isComplete = completedStepIds.includes(step.id) && !isCurrent;
88
97
  const selectable = !isCurrent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.37.0",
3
+ "version": "4.38.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {
@@ -70,6 +70,7 @@
70
70
  "@mui/icons-material": "^7.3.11",
71
71
  "@mui/x-charts": "^8.29.3",
72
72
  "@testing-library/react": "^16.3.3",
73
+ "@testing-library/user-event": "14.6.1",
73
74
  "@vitejs/plugin-react": "^6.2.1",
74
75
  "i18next": "^26.7.1",
75
76
  "jsdom": "^30.1.3",