@gntik-ai/blocks 0.10.0 → 0.12.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/dist/index.d.ts +1761 -1231
- package/dist/index.js +3280 -1088
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/ai/PromptEditor/PromptEditor.tsx +2 -2
- package/src/ai/PromptEditor/examples/controlled-variables.tsx +1 -1
- package/src/ai/TraceWaterfall/TraceWaterfall.tsx +2 -2
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.labels.test.tsx +179 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.test.tsx +6 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +63 -25
- package/src/auth/ForgotPasswordForm/block.meta.ts +22 -1
- package/src/auth/ForgotPasswordForm/examples/Labels.tsx +29 -0
- package/src/auth/ForgotPasswordForm/examples/LargeFields.tsx +6 -0
- package/src/auth/MfaChallenge/MfaChallenge.labels.test.tsx +139 -0
- package/src/auth/MfaChallenge/MfaChallenge.test.tsx +9 -0
- package/src/auth/MfaChallenge/MfaChallenge.tsx +74 -25
- package/src/auth/MfaChallenge/block.meta.ts +29 -1
- package/src/auth/MfaChallenge/examples/Labels.tsx +28 -0
- package/src/auth/MfaChallenge/examples/LargeFields.tsx +6 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.labels.test.tsx +104 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.test.tsx +7 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +47 -18
- package/src/auth/ResetPasswordForm/block.meta.ts +17 -1
- package/src/auth/ResetPasswordForm/examples/Labels.tsx +28 -0
- package/src/auth/ResetPasswordForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SignInForm/SignInForm.labels.test.tsx +137 -0
- package/src/auth/SignInForm/SignInForm.test.tsx +7 -0
- package/src/auth/SignInForm/SignInForm.tsx +48 -17
- package/src/auth/SignInForm/block.meta.ts +22 -1
- package/src/auth/SignInForm/examples/Labels.tsx +29 -0
- package/src/auth/SignInForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SignUpForm/SignUpForm.labels.test.tsx +217 -0
- package/src/auth/SignUpForm/SignUpForm.test.tsx +22 -0
- package/src/auth/SignUpForm/SignUpForm.tsx +72 -27
- package/src/auth/SignUpForm/block.meta.ts +27 -1
- package/src/auth/SignUpForm/examples/Labels.tsx +29 -0
- package/src/auth/SignUpForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SsoButtons/SsoButtons.labels.test.tsx +30 -0
- package/src/auth/SsoButtons/SsoButtons.tsx +10 -2
- package/src/auth/SsoButtons/block.meta.ts +8 -1
- package/src/auth/SsoButtons/examples/Labels.tsx +24 -0
- package/src/auth/__snapshots__/field-size.test.tsx.snap +11 -0
- package/src/auth/field-size.test.tsx +21 -0
- package/src/auth/large-examples.test.tsx +30 -0
- package/src/auth/shared.i18n.test.tsx +71 -0
- package/src/auth/shared.tsx +55 -13
- package/src/billing/PaymentMethodCard/PaymentMethodCard.tsx +1 -1
- package/src/billing/PlanCard/PlanCard.baseline.test.tsx +3 -2
- package/src/billing/PlanCard/__snapshots__/PlanCard.baseline.test.tsx.snap +2 -2
- package/src/billing/PlanDefinitionCard/examples/Compact.tsx +1 -4
- package/src/billing/PlanDefinitionCard/examples/Full.tsx +1 -4
- package/src/builders/CodePanel/CodePanel.tsx +2 -2
- package/src/builders/FlowBuilder/FlowBuilder.tsx +4 -19
- package/src/builders/FlowBuilder/parts.tsx +4 -4
- package/src/builders/LogViewer/LogViewer.follow.test.tsx +29 -0
- package/src/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
- package/src/builders/LogViewer/LogViewer.test.tsx +24 -0
- package/src/builders/LogViewer/LogViewer.tsx +96 -28
- package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
- package/src/builders/LogViewer/block.meta.ts +7 -1
- package/src/builders/LogViewer/examples/Spanish.tsx +2 -1
- package/src/builders/LogViewer/examples/Wrap.tsx +62 -0
- package/src/builders/LogViewer/use-wrapped-log-rows.ts +42 -0
- package/src/data-display/ActivityFeed/ActivityFeed.tsx +1 -1
- package/src/data-display/ChartCard/ChartCard.tsx +2 -2
- package/src/data-display/ChartCard/examples/ContainerPanel.tsx +16 -0
- package/src/data-display/CommentThread/CommentThread.test.tsx +70 -1
- package/src/data-display/CommentThread/CommentThread.tsx +22 -6
- package/src/data-display/CommentThread/block.meta.ts +1 -1
- package/src/data-display/CommentThread/examples/RenderedBody.tsx +20 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.test.tsx +24 -1
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +52 -37
- package/src/data-display/DescriptionListCard/block.meta.ts +2 -1
- package/src/data-display/DescriptionListCard/examples/Spanish.tsx +9 -1
- package/src/data-display/KpiRow/KpiRow.doc.ts +14 -0
- package/src/data-display/KpiRow/KpiRow.test.tsx +11 -0
- package/src/data-display/KpiRow/KpiRow.tsx +72 -55
- package/src/data-display/KpiRow/examples/ContainerPanel.tsx +47 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.doc.ts +19 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.test.tsx +13 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.tsx +49 -40
- package/src/data-display/ResourceCardGrid/examples/ContainerPanel.tsx +18 -0
- package/src/data-display/StatusTimeline/StatusTimeline.tsx +1 -1
- package/src/feedback/EmptyStates/EmptyStates.test.tsx +42 -0
- package/src/feedback/EmptyStates/EmptyStates.tsx +37 -17
- package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
- package/src/feedback/EmptyStates/block.meta.ts +1 -1
- package/src/feedback/EmptyStates/examples/HiddenAction.tsx +13 -0
- package/src/feedback/EmptyStates/examples/Spanish.tsx +7 -0
- package/src/feedback/ErrorPanel/ErrorPanel.tsx +13 -15
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.labels.test.tsx +115 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.lifecycle.test.tsx +123 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +153 -122
- package/src/forms/CreateApiKeyDialog/block.meta.ts +34 -2
- package/src/forms/CreateApiKeyDialog/examples/Labels.tsx +29 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.labels.test.tsx +165 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.tsx +31 -8
- package/src/forms/CredentialDisclosureDialog/SecretCopy.tsx +16 -8
- package/src/forms/CredentialDisclosureDialog/block.meta.ts +19 -1
- package/src/forms/CredentialDisclosureDialog/examples/Labels.tsx +38 -0
- package/src/forms/DangerZone/ConfirmDestructiveDialog.tsx +17 -3
- package/src/forms/DangerZone/DangerZone.labels.test.tsx +87 -0
- package/src/forms/DangerZone/DangerZone.tsx +20 -5
- package/src/forms/DangerZone/block.meta.ts +10 -1
- package/src/forms/DangerZone/examples/Labels.tsx +29 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.labels.test.tsx +52 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.tsx +11 -3
- package/src/forms/DateRangeFilter/block.meta.ts +8 -1
- package/src/forms/DateRangeFilter/examples/Labels.tsx +28 -0
- package/src/forms/DialogWizard/DialogWizard.labels.test.tsx +37 -0
- package/src/forms/DialogWizard/DialogWizard.tsx +13 -2
- package/src/forms/DialogWizard/block.meta.ts +7 -1
- package/src/forms/DialogWizard/examples/Labels.tsx +39 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.controlled.test.tsx +482 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.drag.test.tsx +60 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.labels.test.tsx +126 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.lifecycle.test.tsx +165 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.tsx +336 -75
- package/src/forms/FileUploadPanel/block.meta.ts +26 -1
- package/src/forms/FileUploadPanel/examples/AutoCancel.tsx +38 -0
- package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -0
- package/src/forms/FileUploadPanel/examples/ManualForm.tsx +36 -0
- package/src/forms/FileUploadPanel/fixtures.ts +31 -16
- package/src/forms/FileUploadPanel/simulate-upload.test.ts +24 -0
- package/src/forms/FormSection/FormSection.labels.test.tsx +37 -0
- package/src/forms/FormSection/FormSection.test.tsx +11 -0
- package/src/forms/FormSection/FormSection.tsx +34 -25
- package/src/forms/FormSection/block.meta.ts +7 -1
- package/src/forms/FormSection/examples/ContainerPanel.tsx +16 -0
- package/src/forms/FormSection/examples/Labels.tsx +27 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.labels.test.tsx +87 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.lifecycle.test.tsx +80 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +121 -105
- package/src/forms/InviteMembersDialog/block.meta.ts +21 -2
- package/src/forms/InviteMembersDialog/examples/Labels.tsx +28 -0
- package/src/forms/SettingsRow/SettingsRow.labels.test.tsx +33 -0
- package/src/forms/SettingsRow/SettingsRow.tsx +14 -3
- package/src/forms/SettingsRow/block.meta.ts +7 -1
- package/src/forms/SettingsRow/examples/Labels.tsx +27 -0
- package/src/forms/ValidationSummary/ValidationSummary.labels.test.tsx +47 -0
- package/src/forms/ValidationSummary/ValidationSummary.tsx +10 -7
- package/src/forms/ValidationSummary/block.meta.ts +6 -1
- package/src/forms/ValidationSummary/examples/Labels.tsx +24 -0
- package/src/forms/index.ts +5 -1
- package/src/forms/translated-content.tsx +12 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useTableData.integration.test.tsx +89 -0
- package/src/hooks/useTableData.test.tsx +613 -0
- package/src/hooks/useTableData.ts +377 -0
- package/src/index.ts +1 -0
- package/src/marketing/ComparisonTable/ComparisonTable.tsx +2 -2
- package/src/marketing/FeatureGrid/FeatureGrid.tsx +1 -1
- package/src/marketing/LogoCloud/LogoCloud.doc.ts +13 -0
- package/src/marketing/LogoCloud/LogoCloud.test.tsx +155 -0
- package/src/marketing/LogoCloud/LogoCloud.tsx +89 -0
- package/src/marketing/LogoCloud/block.meta.ts +10 -0
- package/src/marketing/LogoCloud/examples/CaptionStart.tsx +6 -0
- package/src/marketing/LogoCloud/examples/Custom.tsx +25 -0
- package/src/marketing/LogoCloud/examples/Empty.tsx +6 -0
- package/src/marketing/LogoCloud/examples/Grid.tsx +13 -0
- package/src/marketing/LogoCloud/examples/Row.tsx +6 -0
- package/src/marketing/LogoCloud/examples/UnderHero.tsx +13 -0
- package/src/marketing/LogoCloud/fixtures.ts +23 -0
- package/src/marketing/PricingTable/PricingTable.tsx +1 -1
- package/src/marketing/SiteFooter/SiteFooter.doc.ts +18 -0
- package/src/marketing/SiteFooter/SiteFooter.test.tsx +236 -0
- package/src/marketing/SiteFooter/SiteFooter.tsx +160 -0
- package/src/marketing/SiteFooter/block.meta.ts +10 -0
- package/src/marketing/SiteFooter/examples/Centered.tsx +15 -0
- package/src/marketing/SiteFooter/examples/Columns.tsx +15 -0
- package/src/marketing/SiteFooter/examples/Custom.tsx +35 -0
- package/src/marketing/SiteFooter/examples/Empty.tsx +6 -0
- package/src/marketing/SiteFooter/examples/Simple.tsx +14 -0
- package/src/marketing/SiteFooter/fixtures.ts +36 -0
- package/src/marketing/index.ts +6 -0
- package/src/page-chrome/PageHeader/EditableTitle.test.tsx +26 -0
- package/src/page-chrome/PageHeader/PageHeader.options.test.tsx +34 -0
- package/src/page-chrome/PageHeader/PageHeader.tsx +11 -5
- package/src/page-chrome/PageHeader/block.meta.ts +1 -1
- package/src/page-chrome/PageHeader/examples/ContainerPanel.tsx +16 -0
- package/src/page-chrome/PageHeader/examples/EditableTitle.tsx +23 -0
- package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
- package/src/page-chrome/StickyActionBar/StickyActionBar.tsx +1 -1
- package/src/scheduling/AgendaList/AgendaList.tsx +39 -15
- package/src/scheduling/AgendaList/AgendaListZone.test.tsx +38 -0
- package/src/scheduling/AgendaList/block.meta.ts +1 -1
- package/src/scheduling/AgendaList/examples/TimeZone.tsx +28 -0
- package/src/scheduling/MonthCalendar/MonthCalendar.tsx +51 -40
- package/src/scheduling/MonthCalendar/MonthCalendarZone.test.tsx +44 -0
- package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
- package/src/scheduling/MonthCalendar/examples/TimeZone.tsx +28 -0
- package/src/scheduling/WeekCalendar/WeekCalendar.tsx +37 -28
- package/src/scheduling/WeekCalendar/WeekCalendarZone.test.tsx +41 -0
- package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
- package/src/scheduling/WeekCalendar/examples/TimeZone.tsx +28 -0
- package/src/scheduling/shared/CalendarHeader.tsx +26 -1
- package/src/scheduling/shared/dates.ts +102 -58
- package/src/scheduling/shared/events.ts +2 -2
- package/src/shell/AppSidebar/AppSidebar.context.test.tsx +175 -0
- package/src/shell/AppSidebar/AppSidebar.doc.ts +29 -0
- package/src/shell/AppSidebar/AppSidebar.tsx +97 -25
- package/src/shell/AppSidebar/block.meta.ts +1 -1
- package/src/shell/GlobalSearch/GlobalSearch.test.tsx +1 -0
- package/src/shell/GlobalSearch/GlobalSearch.tsx +1 -1
- package/src/tables/DataTable/DataTable.cross-page-selection.test.tsx +322 -0
- package/src/tables/DataTable/DataTable.cursor-example.test.tsx +67 -0
- package/src/tables/DataTable/DataTable.export.test.tsx +511 -0
- package/src/tables/DataTable/DataTable.inline-edit-focus.test.tsx +32 -0
- package/src/tables/DataTable/DataTable.labels.test.tsx +74 -0
- package/src/tables/DataTable/DataTable.layout.test.tsx +6 -5
- package/src/tables/DataTable/DataTable.link-actions.test.tsx +18 -0
- package/src/tables/DataTable/DataTable.server-pagination.test.tsx +329 -15
- package/src/tables/DataTable/DataTable.single-select.test.tsx +47 -7
- package/src/tables/DataTable/DataTable.test.tsx +140 -1
- package/src/tables/DataTable/DataTable.tsx +241 -80
- package/src/tables/DataTable/block.meta.ts +31 -3
- package/src/tables/DataTable/column-sizing.ts +2 -2
- package/src/tables/DataTable/data-table-props.ts +43 -6
- package/src/tables/DataTable/data-table-row.tsx +9 -5
- package/src/tables/DataTable/data-table-utils.ts +6 -0
- package/src/tables/DataTable/editable-cell.tsx +20 -79
- package/src/tables/DataTable/examples/client-selection.tsx +33 -0
- package/src/tables/DataTable/examples/csv-export.tsx +74 -0
- package/src/tables/DataTable/examples/cursor-load-more.tsx +87 -0
- package/src/tables/DataTable/examples/paginated-single-selection.tsx +46 -0
- package/src/tables/DataTable/examples/server-pagination.tsx +91 -44
- package/src/tables/DataTable/export-menu.tsx +58 -0
- package/src/tables/DataTable/header-cell.tsx +1 -1
- package/src/tables/DataTable/labels.ts +11 -0
- package/src/tables/DataTable/resize-handle.tsx +2 -2
- package/src/tables/DataTable/selection-strip.tsx +31 -0
- package/src/tables/DataTable/single-selection.tsx +0 -7
- package/src/tables/DataTable/use-multiple-selection.ts +86 -0
- package/src/tables/DataTable/use-table-export.ts +117 -0
- package/src/tables/FilterBar/FilterBar.test.tsx +12 -0
- package/src/tables/FilterBar/FilterBar.tsx +5 -7
- package/src/team/ProfileHeader/ProfileHeader.picker.test.tsx +34 -0
- package/src/team/ProfileHeader/ProfileHeader.test.tsx +2 -2
- package/src/team/ProfileHeader/ProfileHeader.tsx +17 -24
- package/src/team/ProfileHeader/block.meta.ts +1 -1
- package/src/test/OptInDefaults.test.tsx +36 -0
- package/src/test/clipboard-fallback.test.tsx +49 -0
- package/src/test/copy-examples.test.tsx +29 -0
- package/src/test/copy-feedback.test.tsx +166 -0
- package/src/test/fixtures/opt-in-defaults.json +10 -0
- package/src/test/without-forced-colors.test.ts +44 -0
- package/src/test/without-forced-colors.ts +14 -0
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import { Alert, Button, Field, FieldError, FieldLabel, PasswordInput, cn } from '@gntik-ai/ui';
|
|
1
|
+
import { useI18n, Alert, Button, Field, FieldError, FieldLabel, PasswordInput, cn } from '@gntik-ai/ui';
|
|
2
2
|
import { CircleCheck } from '@gntik-ai/icons';
|
|
3
3
|
import { useState, type ReactNode } from 'react';
|
|
4
|
-
import { AuthHeader, authFormClass, useAsyncSubmit } from '../shared';
|
|
4
|
+
import { AuthHeader, authFormClass, useAsyncSubmit, type AuthFieldSizeProps } from '../shared';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface ResetPasswordFormLabels {
|
|
7
|
+
eyebrow: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description: (minimum: number) => string;
|
|
10
|
+
newPassword: string;
|
|
11
|
+
confirmPassword: string;
|
|
12
|
+
passwordTooShort: (minimum: number) => string;
|
|
13
|
+
passwordMismatch: string;
|
|
14
|
+
submit: string;
|
|
15
|
+
successTitle: string;
|
|
16
|
+
successDescription: string;
|
|
17
|
+
successStatus: string;
|
|
18
|
+
continue: string;
|
|
19
|
+
fallbackError: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ResetPasswordFormProps extends AuthFieldSizeProps {
|
|
23
|
+
labels?: Partial<ResetPasswordFormLabels>;
|
|
7
24
|
/** Saves the new password. A returned promise shows the loading state; a rejection shows in the alert. */
|
|
8
25
|
onSubmit?: (password: string) => void | Promise<void>;
|
|
9
26
|
error?: string | null;
|
|
@@ -16,19 +33,23 @@ export interface ResetPasswordFormProps {
|
|
|
16
33
|
|
|
17
34
|
/** New password + confirmation with length and mismatch validation, then a success state. */
|
|
18
35
|
export function ResetPasswordForm({
|
|
36
|
+
labels,
|
|
37
|
+
fieldSize = 'auto',
|
|
19
38
|
onSubmit,
|
|
20
39
|
error: errorProp,
|
|
21
40
|
minPasswordLength = 8,
|
|
22
41
|
onContinue,
|
|
23
|
-
eyebrow
|
|
42
|
+
eyebrow: eyebrowProp,
|
|
24
43
|
className,
|
|
25
44
|
}: ResetPasswordFormProps) {
|
|
45
|
+
const { t } = useI18n();
|
|
46
|
+
const eyebrow = eyebrowProp === undefined ? (labels?.eyebrow ?? t('resetPassword.eyebrow')) : eyebrowProp;
|
|
26
47
|
const [password, setPassword] = useState('');
|
|
27
48
|
const [confirm, setConfirm] = useState('');
|
|
28
49
|
const [confirmTouched, setConfirmTouched] = useState(false);
|
|
29
50
|
const [submitted, setSubmitted] = useState(false);
|
|
30
51
|
const [done, setDone] = useState(false);
|
|
31
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
52
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t('resetPassword.fallbackError'));
|
|
32
53
|
const alert = errorProp ?? error;
|
|
33
54
|
const tooShort = password.length < minPasswordLength;
|
|
34
55
|
const mismatch = confirm !== password;
|
|
@@ -43,14 +64,14 @@ export function ResetPasswordForm({
|
|
|
43
64
|
</span>
|
|
44
65
|
<AuthHeader
|
|
45
66
|
eyebrow={eyebrow}
|
|
46
|
-
title=
|
|
47
|
-
description=
|
|
67
|
+
title={labels?.successTitle ?? t('resetPassword.successTitle')}
|
|
68
|
+
description={labels?.successDescription ?? t('resetPassword.successDescription')}
|
|
48
69
|
/>
|
|
49
70
|
<div role="status" className="sr-only">
|
|
50
|
-
|
|
71
|
+
{labels?.successStatus ?? t('resetPassword.successStatus')}
|
|
51
72
|
</div>
|
|
52
73
|
<Button size="lg" className="w-full" onClick={onContinue}>
|
|
53
|
-
|
|
74
|
+
{labels?.continue ?? t('resetPassword.continue')}
|
|
54
75
|
</Button>
|
|
55
76
|
</div>
|
|
56
77
|
);
|
|
@@ -60,12 +81,14 @@ export function ResetPasswordForm({
|
|
|
60
81
|
<div className={cn(authFormClass, className)}>
|
|
61
82
|
<AuthHeader
|
|
62
83
|
eyebrow={eyebrow}
|
|
63
|
-
title=
|
|
64
|
-
description={
|
|
84
|
+
title={labels?.title ?? t('resetPassword.title')}
|
|
85
|
+
description={
|
|
86
|
+
labels?.description?.(minPasswordLength) ?? t('resetPassword.description', { minimum: minPasswordLength })
|
|
87
|
+
}
|
|
65
88
|
/>
|
|
66
89
|
<form
|
|
67
90
|
noValidate
|
|
68
|
-
aria-label=
|
|
91
|
+
aria-label={labels?.title ?? t('resetPassword.title')}
|
|
69
92
|
className="flex flex-col gap-4"
|
|
70
93
|
onSubmit={(e) => {
|
|
71
94
|
e.preventDefault();
|
|
@@ -76,23 +99,29 @@ export function ResetPasswordForm({
|
|
|
76
99
|
>
|
|
77
100
|
{alert && <Alert tone="destructive" description={alert} />}
|
|
78
101
|
<Field invalid={passwordInvalid}>
|
|
79
|
-
<FieldLabel>
|
|
80
|
-
<PasswordInput showStrength value={password} onValueChange={setPassword} required />
|
|
81
|
-
<FieldError match={passwordInvalid}>
|
|
102
|
+
<FieldLabel>{labels?.newPassword ?? t('resetPassword.newPassword')}</FieldLabel>
|
|
103
|
+
<PasswordInput size={fieldSize} showStrength value={password} onValueChange={setPassword} required />
|
|
104
|
+
<FieldError match={passwordInvalid}>
|
|
105
|
+
{labels?.passwordTooShort?.(minPasswordLength) ??
|
|
106
|
+
t('resetPassword.passwordTooShort', { minimum: minPasswordLength })}
|
|
107
|
+
</FieldError>
|
|
82
108
|
</Field>
|
|
83
109
|
<Field invalid={confirmInvalid}>
|
|
84
|
-
<FieldLabel>
|
|
110
|
+
<FieldLabel>{labels?.confirmPassword ?? t('resetPassword.confirmPassword')}</FieldLabel>
|
|
85
111
|
<PasswordInput
|
|
112
|
+
size={fieldSize}
|
|
86
113
|
autoComplete="new-password"
|
|
87
114
|
value={confirm}
|
|
88
115
|
onValueChange={setConfirm}
|
|
89
116
|
onBlur={() => setConfirmTouched(true)}
|
|
90
117
|
required
|
|
91
118
|
/>
|
|
92
|
-
<FieldError match={confirmInvalid}>
|
|
119
|
+
<FieldError match={confirmInvalid}>
|
|
120
|
+
{labels?.passwordMismatch ?? t('resetPassword.passwordMismatch')}
|
|
121
|
+
</FieldError>
|
|
93
122
|
</Field>
|
|
94
123
|
<Button type="submit" size="lg" loading={loading} className="mt-2 w-full">
|
|
95
|
-
|
|
124
|
+
{labels?.submit ?? t('resetPassword.submit')}
|
|
96
125
|
</Button>
|
|
97
126
|
</form>
|
|
98
127
|
</div>
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { ResetPasswordFormLabels } from './ResetPasswordForm';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Reset password form',
|
|
5
6
|
family: 'auth',
|
|
6
7
|
status: 'stable',
|
|
7
8
|
description:
|
|
8
|
-
'New password with a strength meter and a confirmation field with mismatch validation, then a success state.',
|
|
9
|
+
'New password with a strength meter and a confirmation field with mismatch validation, then a success state. Optional labels?: Partial<ResetPasswordFormLabels> overrides built-in copy; explicit props and validation messages win, then labels, then I18nProvider (en/es). No provider preserves English; fixtures and caller content stay unchanged. Interactive preview: /preview.html?kind=block&id=reset-password-form--labels. Optional fieldSize: auto (default, follows density) or lg (44px fields matching the submit button). Preview: reset-password-form--large-fields.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'eyebrow', type: 'string', state: 'Default content and accessible names' },
|
|
12
|
+
{ key: 'title', type: 'string', state: 'Default content and accessible names' },
|
|
13
|
+
{ key: 'description', type: '(minimum: number) => string', state: 'Default content and accessible names' },
|
|
14
|
+
{ key: 'newPassword', type: 'string', state: 'Default content and accessible names' },
|
|
15
|
+
{ key: 'confirmPassword', type: 'string', state: 'Default content and accessible names' },
|
|
16
|
+
{ key: 'passwordTooShort', type: '(minimum: number) => string', state: 'Validation feedback' },
|
|
17
|
+
{ key: 'passwordMismatch', type: 'string', state: 'Validation feedback' },
|
|
18
|
+
{ key: 'submit', type: 'string', state: 'Default content and accessible names' },
|
|
19
|
+
{ key: 'successTitle', type: 'string', state: 'Async feedback' },
|
|
20
|
+
{ key: 'successDescription', type: 'string', state: 'Async feedback' },
|
|
21
|
+
{ key: 'successStatus', type: 'string', state: 'Async feedback' },
|
|
22
|
+
{ key: 'continue', type: 'string', state: 'Default content and accessible names' },
|
|
23
|
+
{ key: 'fallbackError', type: 'string', state: 'Validation feedback' },
|
|
24
|
+
] satisfies Array<{ key: keyof ResetPasswordFormLabels; type: string; state: string }>,
|
|
9
25
|
uses: ['Field', 'PasswordInput', 'Button', 'Alert'],
|
|
10
26
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Button, I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ResetPasswordForm, type ResetPasswordFormLabels } from '../ResetPasswordForm';
|
|
4
|
+
|
|
5
|
+
export default function Labels() {
|
|
6
|
+
const [spanish, setSpanish] = useState(false);
|
|
7
|
+
const [custom, setCustom] = useState(true);
|
|
8
|
+
const labels: Partial<ResetPasswordFormLabels> = {
|
|
9
|
+
title: 'Choose a password',
|
|
10
|
+
submit: 'Save password',
|
|
11
|
+
passwordTooShort: (minimum) => `Choose at least ${minimum} characters.`,
|
|
12
|
+
};
|
|
13
|
+
return (
|
|
14
|
+
<div className="grid gap-4">
|
|
15
|
+
<div className="flex flex-wrap gap-2">
|
|
16
|
+
<Button variant="secondary" aria-pressed={spanish} onClick={() => setSpanish(!spanish)}>
|
|
17
|
+
Spanish catalog
|
|
18
|
+
</Button>
|
|
19
|
+
<Button variant="secondary" aria-pressed={custom} onClick={() => setCustom(!custom)}>
|
|
20
|
+
Custom labels
|
|
21
|
+
</Button>
|
|
22
|
+
</div>
|
|
23
|
+
<I18nProvider locale={spanish ? 'es' : 'en'}>
|
|
24
|
+
<ResetPasswordForm labels={custom ? labels : undefined} />
|
|
25
|
+
</I18nProvider>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { I18nProvider, es } from '@gntik-ai/ui';
|
|
3
|
+
import { SignInForm, type SignInFormLabels } from './SignInForm';
|
|
4
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
5
|
+
it('preserves every English default and translates the Spanish form and validation', async () => {
|
|
6
|
+
const { rerender } = render(<SignInForm />);
|
|
7
|
+
expect(screen.getByText('Secure access')).toBeVisible();
|
|
8
|
+
expect(screen.getByText('Sign in to your workspace')).toBeVisible();
|
|
9
|
+
expect(screen.getByText('Use your work email to continue.')).toBeVisible();
|
|
10
|
+
expect(screen.getByText('Email')).toBeVisible();
|
|
11
|
+
expect(screen.getByText('Password')).toBeVisible();
|
|
12
|
+
expect(screen.getByText('Forgot password?')).toBeVisible();
|
|
13
|
+
expect(screen.getByText('Keep me signed in')).toBeVisible();
|
|
14
|
+
expect(screen.getByText('Or continue with')).toBeVisible();
|
|
15
|
+
expect(screen.getByText('New here?')).toBeVisible();
|
|
16
|
+
expect(screen.getByText('Create an account')).toBeVisible();
|
|
17
|
+
expect(screen.getByRole('form', { name: 'Sign in' })).toBeVisible();
|
|
18
|
+
expect(screen.getByPlaceholderText('name@company.com')).toBeVisible();
|
|
19
|
+
expect(screen.getByRole('button', { name: 'Sign in' })).toBeVisible();
|
|
20
|
+
rerender(
|
|
21
|
+
<I18nProvider locale="es">
|
|
22
|
+
<SignInForm />
|
|
23
|
+
</I18nProvider>,
|
|
24
|
+
);
|
|
25
|
+
expect(screen.getByText(es['signIn.eyebrow'])).toBeVisible();
|
|
26
|
+
expect(screen.getByText(es['signIn.title'])).toBeVisible();
|
|
27
|
+
expect(screen.getByText(es['signIn.description'])).toBeVisible();
|
|
28
|
+
expect(screen.getByText(es['signIn.identifierLabel'])).toBeVisible();
|
|
29
|
+
expect(screen.getByText(es['signIn.password'])).toBeVisible();
|
|
30
|
+
expect(screen.getByText(es['signIn.forgotPassword'])).toBeVisible();
|
|
31
|
+
expect(screen.getByText(es['signIn.remember'])).toBeVisible();
|
|
32
|
+
expect(screen.getByText(es['signIn.divider'])).toBeVisible();
|
|
33
|
+
expect(screen.getByText(es['signIn.signUpPrompt'])).toBeVisible();
|
|
34
|
+
expect(screen.getByText(es['signIn.signUp'])).toBeVisible();
|
|
35
|
+
expect(screen.getByPlaceholderText(es['signIn.identifierPlaceholder'])).toBeVisible();
|
|
36
|
+
const form = screen.getByRole('form', { name: es['signIn.formLabel'] });
|
|
37
|
+
fireEvent.submit(form);
|
|
38
|
+
expect(screen.getByText('Introduce una dirección de correo válida.')).toBeVisible();
|
|
39
|
+
expect(screen.getByText(es['signIn.passwordRequired'])).toBeVisible();
|
|
40
|
+
await expectNoAxeViolations(form);
|
|
41
|
+
});
|
|
42
|
+
it.each(['en', 'es'])('honours all label overrides and existing explicit props under %s', (locale) => {
|
|
43
|
+
const labels: SignInFormLabels = {
|
|
44
|
+
eyebrow: 'Custom eyebrow',
|
|
45
|
+
title: 'Custom title',
|
|
46
|
+
description: 'Custom description',
|
|
47
|
+
formLabel: 'Custom formLabel',
|
|
48
|
+
identifierLabel: 'Custom identifierLabel',
|
|
49
|
+
identifierPlaceholder: 'Custom identifierPlaceholder',
|
|
50
|
+
password: 'Custom password',
|
|
51
|
+
forgotPassword: 'Custom forgotPassword',
|
|
52
|
+
passwordRequired: 'Custom passwordRequired',
|
|
53
|
+
remember: 'Custom remember',
|
|
54
|
+
submit: 'Custom submit',
|
|
55
|
+
divider: 'Custom divider',
|
|
56
|
+
signUpPrompt: 'Custom signUpPrompt',
|
|
57
|
+
signUp: 'Custom signUp',
|
|
58
|
+
fallbackError: 'Custom fallbackError',
|
|
59
|
+
identifierRequired: 'Custom required',
|
|
60
|
+
identifierInvalid: 'Custom invalid',
|
|
61
|
+
identifierTooShort: 'Custom short',
|
|
62
|
+
};
|
|
63
|
+
const { rerender } = render(
|
|
64
|
+
<I18nProvider locale={locale}>
|
|
65
|
+
<SignInForm labels={labels} />
|
|
66
|
+
</I18nProvider>,
|
|
67
|
+
);
|
|
68
|
+
expect(screen.getByText(labels.eyebrow)).toBeVisible();
|
|
69
|
+
expect(screen.getByText(labels.title)).toBeVisible();
|
|
70
|
+
expect(screen.getByText(labels.description)).toBeVisible();
|
|
71
|
+
expect(screen.getByText(labels.identifierLabel)).toBeVisible();
|
|
72
|
+
expect(screen.getByText(labels.password)).toBeVisible();
|
|
73
|
+
expect(screen.getByText(labels.forgotPassword)).toBeVisible();
|
|
74
|
+
expect(screen.getByText(labels.remember)).toBeVisible();
|
|
75
|
+
expect(screen.getByText(labels.divider)).toBeVisible();
|
|
76
|
+
expect(screen.getByText(labels.signUpPrompt)).toBeVisible();
|
|
77
|
+
expect(screen.getByText(labels.signUp)).toBeVisible();
|
|
78
|
+
expect(screen.getByPlaceholderText(labels.identifierPlaceholder)).toBeVisible();
|
|
79
|
+
fireEvent.submit(screen.getByRole('form', { name: labels.formLabel }));
|
|
80
|
+
expect(screen.getByText(labels.identifierRequired)).toBeVisible();
|
|
81
|
+
expect(screen.getByText(labels.passwordRequired)).toBeVisible();
|
|
82
|
+
rerender(
|
|
83
|
+
<I18nProvider locale={locale}>
|
|
84
|
+
<SignInForm
|
|
85
|
+
labels={labels}
|
|
86
|
+
title="Explicit title"
|
|
87
|
+
description="Explicit description"
|
|
88
|
+
eyebrow="Explicit eyebrow"
|
|
89
|
+
aria-label="Explicit form"
|
|
90
|
+
identifier={{ label: 'Explicit identifier', placeholder: 'Explicit placeholder' }}
|
|
91
|
+
messages={{ identifierRequired: 'Explicit required', passwordRequired: 'Explicit password' }}
|
|
92
|
+
signUpPrompt="Explicit prompt"
|
|
93
|
+
/>
|
|
94
|
+
</I18nProvider>,
|
|
95
|
+
);
|
|
96
|
+
for (const text of [
|
|
97
|
+
'Explicit title',
|
|
98
|
+
'Explicit description',
|
|
99
|
+
'Explicit eyebrow',
|
|
100
|
+
'Explicit identifier',
|
|
101
|
+
'Explicit prompt',
|
|
102
|
+
])
|
|
103
|
+
expect(screen.getByText(text)).toBeVisible();
|
|
104
|
+
expect(screen.getByPlaceholderText('Explicit placeholder')).toBeVisible();
|
|
105
|
+
fireEvent.submit(screen.getByRole('form', { name: 'Explicit form' }));
|
|
106
|
+
expect(screen.getByText('Explicit required')).toBeVisible();
|
|
107
|
+
expect(screen.getByText('Explicit password')).toBeVisible();
|
|
108
|
+
});
|
|
109
|
+
it('uses translated fallback on an async rejection and preserves server messages', async () => {
|
|
110
|
+
render(
|
|
111
|
+
<I18nProvider locale="es">
|
|
112
|
+
<SignInForm defaultEmail="a@example.com" onSubmit={() => Promise.reject(null)} />
|
|
113
|
+
</I18nProvider>,
|
|
114
|
+
);
|
|
115
|
+
fireEvent.change(screen.getByLabelText(es['signIn.password']), { target: { value: 'password' } });
|
|
116
|
+
fireEvent.submit(screen.getByRole('form'));
|
|
117
|
+
expect(await screen.findByText(es['signIn.fallbackError'])).toBeVisible();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it.each(['en', 'es'])('uses custom invalid and short identifier messages under %s', (locale) => {
|
|
121
|
+
const labels = { identifierInvalid: 'Custom invalid identifier', identifierTooShort: 'Custom short identifier' };
|
|
122
|
+
const { rerender } = render(
|
|
123
|
+
<I18nProvider locale={locale}>
|
|
124
|
+
<SignInForm labels={labels} />
|
|
125
|
+
</I18nProvider>,
|
|
126
|
+
);
|
|
127
|
+
fireEvent.change(screen.getByRole('textbox'), { target: { value: 'invalid' } });
|
|
128
|
+
fireEvent.submit(screen.getByRole('form'));
|
|
129
|
+
expect(screen.getByText('Custom invalid identifier')).toBeVisible();
|
|
130
|
+
rerender(
|
|
131
|
+
<I18nProvider locale={locale}>
|
|
132
|
+
<SignInForm labels={labels} identifier={{ type: 'text', minLength: 10 }} />
|
|
133
|
+
</I18nProvider>,
|
|
134
|
+
);
|
|
135
|
+
fireEvent.submit(screen.getByRole('form'));
|
|
136
|
+
expect(screen.getByText('Custom short identifier')).toBeVisible();
|
|
137
|
+
});
|
|
@@ -6,6 +6,13 @@ import { expectNoAxeViolations } from '../../test/a11y';
|
|
|
6
6
|
import { SignInForm, type SignInFormRef } from './SignInForm';
|
|
7
7
|
|
|
8
8
|
describe('SignInForm', () => {
|
|
9
|
+
it('matches large identifier and password fields to the submit button', () => {
|
|
10
|
+
render(<SignInForm fieldSize="lg" sso={null} />);
|
|
11
|
+
expect(screen.getByLabelText('Email').parentElement).toHaveClass('h-11');
|
|
12
|
+
expect(screen.getByLabelText('Password').parentElement).toHaveClass('h-11');
|
|
13
|
+
expect(screen.getByRole('button', { name: 'Sign in' })).toHaveClass('h-11');
|
|
14
|
+
});
|
|
15
|
+
|
|
9
16
|
it('can hide or replace the sign-up prompt alongside the SSO slot', () => {
|
|
10
17
|
const { rerender } = render(<SignInForm sso={null} signUpPrompt={null} />);
|
|
11
18
|
expect(screen.queryByText(/New here/)).not.toBeInTheDocument();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
useI18n,
|
|
2
3
|
Alert,
|
|
3
4
|
Button,
|
|
4
5
|
Checkbox,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
type AuthValidationMessages,
|
|
25
26
|
type AuthFormAccessibilityProps,
|
|
26
27
|
type AuthHeaderProps,
|
|
28
|
+
type AuthFieldSizeProps,
|
|
27
29
|
} from '../shared';
|
|
28
30
|
|
|
29
31
|
export interface SignInValues {
|
|
@@ -38,7 +40,26 @@ export interface SignInFormRef {
|
|
|
38
40
|
focus(field: 'identifier' | 'password'): void;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
export interface
|
|
43
|
+
export interface SignInFormLabels extends Required<AuthValidationMessages> {
|
|
44
|
+
eyebrow: string;
|
|
45
|
+
title: string;
|
|
46
|
+
description: string;
|
|
47
|
+
formLabel: string;
|
|
48
|
+
identifierLabel: string;
|
|
49
|
+
identifierPlaceholder: string;
|
|
50
|
+
password: string;
|
|
51
|
+
forgotPassword: string;
|
|
52
|
+
passwordRequired: string;
|
|
53
|
+
remember: string;
|
|
54
|
+
submit: string;
|
|
55
|
+
divider: string;
|
|
56
|
+
signUpPrompt: string;
|
|
57
|
+
signUp: string;
|
|
58
|
+
fallbackError: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface SignInFormProps extends AuthFormAccessibilityProps, AuthFieldSizeProps {
|
|
62
|
+
labels?: Partial<SignInFormLabels>;
|
|
42
63
|
/** React 19 ref for focus after a server response. */
|
|
43
64
|
ref?: Ref<SignInFormRef>;
|
|
44
65
|
identifier?: AuthIdentifierConfig;
|
|
@@ -79,6 +100,8 @@ const linkHandler = (fn?: () => void) =>
|
|
|
79
100
|
|
|
80
101
|
/** Email + password sign-in with remember me, forgot-password link, SSO slot, error alert and loading. */
|
|
81
102
|
export function SignInForm({
|
|
103
|
+
labels,
|
|
104
|
+
fieldSize = 'auto',
|
|
82
105
|
identifier,
|
|
83
106
|
messages,
|
|
84
107
|
passwordHelp,
|
|
@@ -87,7 +110,7 @@ export function SignInForm({
|
|
|
87
110
|
fieldInvalid,
|
|
88
111
|
feedbackId,
|
|
89
112
|
'aria-describedby': describedBy,
|
|
90
|
-
'aria-label':
|
|
113
|
+
'aria-label': ariaLabelProp,
|
|
91
114
|
'aria-labelledby': labelledBy,
|
|
92
115
|
onSubmit,
|
|
93
116
|
error: errorProp,
|
|
@@ -99,17 +122,23 @@ export function SignInForm({
|
|
|
99
122
|
onSignUp,
|
|
100
123
|
signUpPrompt,
|
|
101
124
|
sso = <SsoButtons />,
|
|
102
|
-
eyebrow
|
|
103
|
-
title
|
|
104
|
-
description
|
|
125
|
+
eyebrow: eyebrowProp,
|
|
126
|
+
title: titleProp,
|
|
127
|
+
description: descriptionProp,
|
|
105
128
|
headingLevel,
|
|
106
129
|
className,
|
|
107
130
|
}: SignInFormProps) {
|
|
131
|
+
const { t } = useI18n();
|
|
132
|
+
const eyebrow = eyebrowProp === undefined ? (labels?.eyebrow ?? t('signIn.eyebrow')) : eyebrowProp;
|
|
133
|
+
const title = titleProp === undefined ? (labels?.title ?? t('signIn.title')) : titleProp;
|
|
134
|
+
const description =
|
|
135
|
+
descriptionProp === undefined ? (labels?.description ?? t('signIn.description')) : descriptionProp;
|
|
136
|
+
const ariaLabel = ariaLabelProp ?? labels?.formLabel ?? t('signIn.formLabel');
|
|
108
137
|
const [email, setEmail] = useState(defaultEmail);
|
|
109
138
|
const [password, setPassword] = useState('');
|
|
110
139
|
const [remember, setRemember] = useState(true);
|
|
111
140
|
const [submitted, setSubmitted] = useState(false);
|
|
112
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
141
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t('signIn.fallbackError'));
|
|
113
142
|
const busy = loadingProp ?? loading;
|
|
114
143
|
const alert = errorProp ?? error;
|
|
115
144
|
const identifierInput = useRef<HTMLInputElement>(null);
|
|
@@ -121,7 +150,7 @@ export function SignInForm({
|
|
|
121
150
|
}),
|
|
122
151
|
[],
|
|
123
152
|
);
|
|
124
|
-
const identifierError = authIdentifierError(email, identifier, messages);
|
|
153
|
+
const identifierError = authIdentifierError(email, identifier, messages, t, labels);
|
|
125
154
|
const emailInvalid = submitted && identifierError !== null;
|
|
126
155
|
const passwordInvalid = submitted && password === '';
|
|
127
156
|
|
|
@@ -157,14 +186,15 @@ export function SignInForm({
|
|
|
157
186
|
>
|
|
158
187
|
{alert && <Alert id={feedbackId} tone="destructive" description={alert} />}
|
|
159
188
|
<Field invalid={emailInvalid || fieldInvalid?.identifier === true}>
|
|
160
|
-
<FieldLabel>{identifier?.label ?? '
|
|
189
|
+
<FieldLabel>{identifier?.label ?? labels?.identifierLabel ?? t('signIn.identifierLabel')}</FieldLabel>
|
|
161
190
|
<Input
|
|
191
|
+
size={fieldSize}
|
|
162
192
|
ref={identifierInput}
|
|
163
193
|
aria-describedby={fieldInvalid?.identifier ? feedbackId : undefined}
|
|
164
194
|
type={identifier?.type ?? 'email'}
|
|
165
195
|
leadingIcon={Mail}
|
|
166
196
|
autoComplete={identifier?.autoComplete ?? 'email'}
|
|
167
|
-
placeholder={identifier?.placeholder ?? '
|
|
197
|
+
placeholder={identifier?.placeholder ?? labels?.identifierPlaceholder ?? t('signIn.identifierPlaceholder')}
|
|
168
198
|
minLength={identifier?.minLength}
|
|
169
199
|
maxLength={identifier?.maxLength}
|
|
170
200
|
value={email}
|
|
@@ -178,12 +208,13 @@ export function SignInForm({
|
|
|
178
208
|
</Field>
|
|
179
209
|
<Field invalid={passwordInvalid || fieldInvalid?.password === true}>
|
|
180
210
|
<div className="flex items-center justify-between gap-3">
|
|
181
|
-
<FieldLabel>
|
|
211
|
+
<FieldLabel>{labels?.password ?? t('signIn.password')}</FieldLabel>
|
|
182
212
|
<Link href={forgotPasswordHref} onClick={linkHandler(onForgotPassword)} className="text-[12.5px]">
|
|
183
|
-
|
|
213
|
+
{labels?.forgotPassword ?? t('signIn.forgotPassword')}
|
|
184
214
|
</Link>
|
|
185
215
|
</div>
|
|
186
216
|
<PasswordInput
|
|
217
|
+
size={fieldSize}
|
|
187
218
|
ref={passwordInput}
|
|
188
219
|
aria-describedby={fieldInvalid?.password ? feedbackId : undefined}
|
|
189
220
|
leadingIcon={Lock}
|
|
@@ -193,17 +224,17 @@ export function SignInForm({
|
|
|
193
224
|
/>
|
|
194
225
|
{passwordHelp != null && <FieldDescription id={passwordHelpId}>{passwordHelp}</FieldDescription>}
|
|
195
226
|
<FieldError role="alert" match={passwordInvalid}>
|
|
196
|
-
{messages?.passwordRequired ??
|
|
227
|
+
{messages?.passwordRequired ?? labels?.passwordRequired ?? t('signIn.passwordRequired')}
|
|
197
228
|
</FieldError>
|
|
198
229
|
</Field>
|
|
199
|
-
<Checkbox label=
|
|
230
|
+
<Checkbox label={labels?.remember ?? t('signIn.remember')} checked={remember} onCheckedChange={setRemember} />
|
|
200
231
|
<Button type="submit" size="lg" loading={busy} className="mt-2 w-full">
|
|
201
|
-
|
|
232
|
+
{labels?.submit ?? t('signIn.submit')}
|
|
202
233
|
</Button>
|
|
203
234
|
</form>
|
|
204
235
|
{sso != null && (
|
|
205
236
|
<>
|
|
206
|
-
<AuthDivider>
|
|
237
|
+
<AuthDivider>{labels?.divider ?? t('signIn.divider')}</AuthDivider>
|
|
207
238
|
{sso}
|
|
208
239
|
</>
|
|
209
240
|
)}
|
|
@@ -211,9 +242,9 @@ export function SignInForm({
|
|
|
211
242
|
<p className="mt-7 text-center text-[13px] text-muted-foreground">
|
|
212
243
|
{signUpPrompt === undefined ? (
|
|
213
244
|
<>
|
|
214
|
-
|
|
245
|
+
{labels?.signUpPrompt ?? t('signIn.signUpPrompt')}{' '}
|
|
215
246
|
<Link href={signUpHref} onClick={linkHandler(onSignUp)}>
|
|
216
|
-
|
|
247
|
+
{labels?.signUp ?? t('signIn.signUp')}
|
|
217
248
|
</Link>
|
|
218
249
|
</>
|
|
219
250
|
) : (
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { SignInFormLabels } from './SignInForm';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Sign-in form',
|
|
5
6
|
family: 'auth',
|
|
6
7
|
status: 'stable',
|
|
7
8
|
description:
|
|
8
|
-
'Email (default) or text identifier and password sign-in. Supports identifier (type, autoComplete, label, help/helpId, placeholder, minLength/maxLength), messages (identifierRequired/identifierInvalid/identifierTooShort/passwordRequired), and React 19 ref.focus. The kit owns inline validation and focuses the first invalid field; consumers supply messages, not a second inline validator. Server errors use error + fieldInvalid + feedbackId; aria-describedby describes the form, while flagged inputs also retain their help and error ids. headingLevel (h1/h2/h3/null) suppresses the heading without losing the form name; aria-label/aria-labelledby override the default name. passwordHelp/passwordHelpId describe the password. Text submissions add values.identifier and retain values.email; email-mode payloads are unchanged. sso and signUpPrompt accept replacements or null. Preview: sign-in-form--username.',
|
|
9
|
+
'Email (default) or text identifier and password sign-in. Supports identifier (type, autoComplete, label, help/helpId, placeholder, minLength/maxLength), messages (identifierRequired/identifierInvalid/identifierTooShort/passwordRequired), and React 19 ref.focus. The kit owns inline validation and focuses the first invalid field; consumers supply messages, not a second inline validator. Server errors use error + fieldInvalid + feedbackId; aria-describedby describes the form, while flagged inputs also retain their help and error ids. headingLevel (h1/h2/h3/null) suppresses the heading without losing the form name; aria-label/aria-labelledby override the default name. passwordHelp/passwordHelpId describe the password. Text submissions add values.identifier and retain values.email; email-mode payloads are unchanged. sso and signUpPrompt accept replacements or null. Preview: sign-in-form--username. Optional labels?: Partial<SignInFormLabels> overrides built-in copy; explicit props and validation messages win, then labels, then I18nProvider (en/es). No provider preserves English; fixtures and caller content stay unchanged. Interactive preview: /preview.html?kind=block&id=sign-in-form--labels. Optional fieldSize: auto (default, follows density) or lg (44px fields matching the submit button). Preview: sign-in-form--large-fields.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'eyebrow', type: 'string', state: 'Default content and accessible names' },
|
|
12
|
+
{ key: 'title', type: 'string', state: 'Default content and accessible names' },
|
|
13
|
+
{ key: 'description', type: 'string', state: 'Default content and accessible names' },
|
|
14
|
+
{ key: 'formLabel', type: 'string', state: 'Default content and accessible names' },
|
|
15
|
+
{ key: 'identifierLabel', type: 'string', state: 'Default content and accessible names' },
|
|
16
|
+
{ key: 'identifierPlaceholder', type: 'string', state: 'Default content and accessible names' },
|
|
17
|
+
{ key: 'password', type: 'string', state: 'Default content and accessible names' },
|
|
18
|
+
{ key: 'forgotPassword', type: 'string', state: 'Default content and accessible names' },
|
|
19
|
+
{ key: 'passwordRequired', type: 'string', state: 'Validation feedback' },
|
|
20
|
+
{ key: 'remember', type: 'string', state: 'Default content and accessible names' },
|
|
21
|
+
{ key: 'submit', type: 'string', state: 'Default content and accessible names' },
|
|
22
|
+
{ key: 'divider', type: 'string', state: 'Default content and accessible names' },
|
|
23
|
+
{ key: 'signUpPrompt', type: 'string', state: 'Default content and accessible names' },
|
|
24
|
+
{ key: 'signUp', type: 'string', state: 'Default content and accessible names' },
|
|
25
|
+
{ key: 'fallbackError', type: 'string', state: 'Validation feedback' },
|
|
26
|
+
{ key: 'identifierRequired', type: 'string', state: 'Validation feedback' },
|
|
27
|
+
{ key: 'identifierInvalid', type: 'string', state: 'Validation feedback' },
|
|
28
|
+
{ key: 'identifierTooShort', type: 'string', state: 'Validation feedback' },
|
|
29
|
+
] satisfies Array<{ key: keyof SignInFormLabels; type: string; state: string }>,
|
|
9
30
|
uses: [
|
|
10
31
|
'Field',
|
|
11
32
|
'FieldLabel',
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button, I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { SignInForm, type SignInFormLabels } from '../SignInForm';
|
|
4
|
+
|
|
5
|
+
export default function Labels() {
|
|
6
|
+
const [spanish, setSpanish] = useState(false);
|
|
7
|
+
const [custom, setCustom] = useState(true);
|
|
8
|
+
const labels: Partial<SignInFormLabels> = {
|
|
9
|
+
title: 'Welcome back',
|
|
10
|
+
submit: 'Continue',
|
|
11
|
+
identifierLabel: 'Account email',
|
|
12
|
+
passwordRequired: 'Provide your password.',
|
|
13
|
+
};
|
|
14
|
+
return (
|
|
15
|
+
<div className="grid gap-4">
|
|
16
|
+
<div className="flex flex-wrap gap-2">
|
|
17
|
+
<Button variant="secondary" aria-pressed={spanish} onClick={() => setSpanish(!spanish)}>
|
|
18
|
+
Spanish catalog
|
|
19
|
+
</Button>
|
|
20
|
+
<Button variant="secondary" aria-pressed={custom} onClick={() => setCustom(!custom)}>
|
|
21
|
+
Custom labels
|
|
22
|
+
</Button>
|
|
23
|
+
</div>
|
|
24
|
+
<I18nProvider locale={spanish ? 'es' : 'en'}>
|
|
25
|
+
<SignInForm labels={custom ? labels : undefined} />
|
|
26
|
+
</I18nProvider>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|