@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gntik-ai/blocks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "gntik-ui blocks: page chrome, data display, tables, forms, feedback, billing, team and builder sections composed from @gntik-ai/ui.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"react-dom": "^19.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@gntik-ai/charts": "0.
|
|
39
|
-
"@gntik-ai/editor": "0.
|
|
40
|
-
"@gntik-ai/flow": "0.
|
|
38
|
+
"@gntik-ai/charts": "0.12.0",
|
|
39
|
+
"@gntik-ai/editor": "0.12.0",
|
|
40
|
+
"@gntik-ai/flow": "0.12.0",
|
|
41
41
|
"@gntik-ai/icons": "0.5.0",
|
|
42
|
-
"@gntik-ai/tokens": "0.
|
|
43
|
-
"@gntik-ai/ui": "0.
|
|
42
|
+
"@gntik-ai/tokens": "0.4.0",
|
|
43
|
+
"@gntik-ai/ui": "0.12.0",
|
|
44
44
|
"lucide-react": "^1.48.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -132,7 +132,7 @@ export function PromptEditor({
|
|
|
132
132
|
</div>
|
|
133
133
|
<div className="flex flex-col gap-5 border-t border-border bg-secondary/20 p-4 md:border-t-0 md:border-s">
|
|
134
134
|
<div>
|
|
135
|
-
<SubTag className="text-[12px] font-semibold tracking-wide text-muted-foreground
|
|
135
|
+
<SubTag className="text-[12px] font-semibold tracking-wide text-muted-foreground label-case">
|
|
136
136
|
Variables
|
|
137
137
|
</SubTag>
|
|
138
138
|
{variables.length === 0 ? (
|
|
@@ -168,7 +168,7 @@ export function PromptEditor({
|
|
|
168
168
|
)}
|
|
169
169
|
</div>
|
|
170
170
|
<div className="flex flex-col gap-4">
|
|
171
|
-
<SubTag className="text-[12px] font-semibold tracking-wide text-muted-foreground
|
|
171
|
+
<SubTag className="text-[12px] font-semibold tracking-wide text-muted-foreground label-case">
|
|
172
172
|
Parameters
|
|
173
173
|
</SubTag>
|
|
174
174
|
<Slider
|
|
@@ -13,7 +13,7 @@ export default function ControlledVariablesPromptEditor() {
|
|
|
13
13
|
<button
|
|
14
14
|
type="button"
|
|
15
15
|
onClick={() => setVariables((prev) => ({ ...prev, ticket: 'Cannot reset my password' }))}
|
|
16
|
-
className="self-start text-[12.5px] text-primary-text underline underline-offset-2 focus-
|
|
16
|
+
className="self-start text-[12.5px] text-primary-text underline underline-offset-2 focus-ring"
|
|
17
17
|
>
|
|
18
18
|
Fill from sample ticket
|
|
19
19
|
</button>
|
|
@@ -212,7 +212,7 @@ export function TraceWaterfall({
|
|
|
212
212
|
aria-expanded={open}
|
|
213
213
|
aria-label={t(open ? 'common.collapseItem' : 'common.expandItem', { label: span.name })}
|
|
214
214
|
onClick={() => setOpen(span.id, !open)}
|
|
215
|
-
className="absolute top-1/2 z-
|
|
215
|
+
className="absolute top-1/2 z-raised grid size-6 -translate-y-1/2 place-items-center rounded text-muted-foreground hover:bg-secondary hover:text-foreground focus-ring"
|
|
216
216
|
style={{ insetInlineStart: indent - 4 }}
|
|
217
217
|
>
|
|
218
218
|
<ChevronRight
|
|
@@ -240,7 +240,7 @@ export function TraceWaterfall({
|
|
|
240
240
|
onKeyDown={(e) => onKeyDown(e, index)}
|
|
241
241
|
className={cn(
|
|
242
242
|
'grid h-8 w-full grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-center pe-3 text-start hover:bg-secondary/50',
|
|
243
|
-
'focus-
|
|
243
|
+
'focus-ring-inset',
|
|
244
244
|
isSelected && 'bg-primary/8 hover:bg-primary/12',
|
|
245
245
|
)}
|
|
246
246
|
>
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { I18nProvider, en, es } from '@gntik-ai/ui';
|
|
4
|
+
import { ForgotPasswordForm, type ForgotPasswordFormLabels } from './ForgotPasswordForm';
|
|
5
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
6
|
+
it('preserves English request labels without a provider', () => {
|
|
7
|
+
render(<ForgotPasswordForm />);
|
|
8
|
+
expect(screen.getByText('Account recovery')).toBeVisible();
|
|
9
|
+
expect(screen.getByText('Forgot your password?')).toBeVisible();
|
|
10
|
+
expect(screen.getByText("Enter the email you sign in with and we'll send you a reset link.")).toBeVisible();
|
|
11
|
+
expect(screen.getByText('Email')).toBeVisible();
|
|
12
|
+
expect(screen.getByText('Back to sign in')).toBeVisible();
|
|
13
|
+
expect(screen.getByRole('form', { name: 'Reset password request' })).toBeVisible();
|
|
14
|
+
expect(screen.getByPlaceholderText('name@company.com')).toBeVisible();
|
|
15
|
+
expect(screen.getByRole('button', { name: 'Send reset link' })).toBeVisible();
|
|
16
|
+
});
|
|
17
|
+
it('translates every request and sent label and parameterised sent text', async () => {
|
|
18
|
+
const { rerender } = render(
|
|
19
|
+
<I18nProvider locale="es">
|
|
20
|
+
<ForgotPasswordForm />
|
|
21
|
+
</I18nProvider>,
|
|
22
|
+
);
|
|
23
|
+
expect(screen.getByText(es['forgotPassword.eyebrow'])).toBeVisible();
|
|
24
|
+
expect(screen.getByText(es['forgotPassword.title'])).toBeVisible();
|
|
25
|
+
expect(screen.getByText(es['forgotPassword.description'])).toBeVisible();
|
|
26
|
+
expect(screen.getByText(es['forgotPassword.identifierLabel'])).toBeVisible();
|
|
27
|
+
expect(screen.getByText(es['forgotPassword.backToSignIn'])).toBeVisible();
|
|
28
|
+
expect(screen.getByPlaceholderText(es['forgotPassword.identifierPlaceholder'])).toBeVisible();
|
|
29
|
+
fireEvent.submit(screen.getByRole('form', { name: es['forgotPassword.formLabel'] }));
|
|
30
|
+
expect(screen.getByText('Introduce una dirección de correo válida.')).toBeVisible();
|
|
31
|
+
fireEvent.change(screen.getByLabelText(es['forgotPassword.identifierLabel']), { target: { value: 'invalid' } });
|
|
32
|
+
fireEvent.submit(screen.getByRole('form'));
|
|
33
|
+
expect(screen.getByText('Introduce una dirección de correo válida.')).toBeVisible();
|
|
34
|
+
await expectNoAxeViolations(screen.getByRole('form'));
|
|
35
|
+
fireEvent.change(screen.getByLabelText(es['forgotPassword.identifierLabel']), { target: { value: 'a@example.com' } });
|
|
36
|
+
await userEvent.click(screen.getByRole('button', { name: es['forgotPassword.submit'] }));
|
|
37
|
+
expect(await screen.findByRole('heading', { name: es['forgotPassword.sentTitle'] })).toBeVisible();
|
|
38
|
+
expect(
|
|
39
|
+
screen.getByText(
|
|
40
|
+
(_, element) =>
|
|
41
|
+
element?.tagName === 'P' &&
|
|
42
|
+
element.textContent ===
|
|
43
|
+
'Si existe una cuenta para a@example.com, recibirás un enlace para restablecer tu contraseña. Caduca en 1 hora.',
|
|
44
|
+
),
|
|
45
|
+
).toBeVisible();
|
|
46
|
+
expect(screen.getByRole('status')).toHaveTextContent(es['forgotPassword.sentStatus']);
|
|
47
|
+
for (const key of ['resend', 'changeEmail'] as const)
|
|
48
|
+
expect(screen.getByRole('button', { name: es[`forgotPassword.${key}`] })).toBeVisible();
|
|
49
|
+
rerender(
|
|
50
|
+
<I18nProvider locale="es">
|
|
51
|
+
<ForgotPasswordForm key="sent" defaultSent onSubmit={() => Promise.reject(null)} />
|
|
52
|
+
</I18nProvider>,
|
|
53
|
+
);
|
|
54
|
+
expect(screen.getByText(es['forgotPassword.addressFallback'])).toBeVisible();
|
|
55
|
+
await userEvent.click(screen.getByRole('button', { name: es['forgotPassword.resend'] }));
|
|
56
|
+
expect(await screen.findByText(es['forgotPassword.fallbackError'])).toBeVisible();
|
|
57
|
+
});
|
|
58
|
+
it.each(['en', 'es'])('honours labels and explicit props under %s', async (locale) => {
|
|
59
|
+
const labels: ForgotPasswordFormLabels = {
|
|
60
|
+
formLabel: 'Custom formLabel',
|
|
61
|
+
eyebrow: 'Custom eyebrow',
|
|
62
|
+
title: 'Custom title',
|
|
63
|
+
description: 'Custom description',
|
|
64
|
+
sentTitle: 'Custom sentTitle',
|
|
65
|
+
sentDescription: (email) => `Custom sent ${email}`,
|
|
66
|
+
addressFallback: 'Custom addressFallback',
|
|
67
|
+
sentStatus: 'Custom sentStatus',
|
|
68
|
+
fallbackError: 'Custom fallbackError',
|
|
69
|
+
backToSignIn: 'Custom backToSignIn',
|
|
70
|
+
resend: 'Custom resend',
|
|
71
|
+
changeEmail: 'Custom changeEmail',
|
|
72
|
+
identifierLabel: 'Custom identifierLabel',
|
|
73
|
+
identifierPlaceholder: 'Custom identifierPlaceholder',
|
|
74
|
+
submit: 'Custom submit',
|
|
75
|
+
identifierRequired: 'Custom required',
|
|
76
|
+
identifierInvalid: 'Custom invalid',
|
|
77
|
+
identifierTooShort: 'Custom short',
|
|
78
|
+
};
|
|
79
|
+
const { rerender } = render(
|
|
80
|
+
<I18nProvider locale={locale}>
|
|
81
|
+
<ForgotPasswordForm labels={labels} />
|
|
82
|
+
</I18nProvider>,
|
|
83
|
+
);
|
|
84
|
+
expect(screen.getByText(labels.eyebrow)).toBeVisible();
|
|
85
|
+
expect(screen.getByText(labels.title)).toBeVisible();
|
|
86
|
+
expect(screen.getByText(labels.description)).toBeVisible();
|
|
87
|
+
expect(screen.getByText(labels.identifierLabel)).toBeVisible();
|
|
88
|
+
expect(screen.getByText(labels.backToSignIn)).toBeVisible();
|
|
89
|
+
expect(screen.getByPlaceholderText(labels.identifierPlaceholder)).toBeVisible();
|
|
90
|
+
fireEvent.submit(screen.getByRole('form', { name: labels.formLabel }));
|
|
91
|
+
expect(screen.getByText(labels.identifierRequired)).toBeVisible();
|
|
92
|
+
rerender(
|
|
93
|
+
<I18nProvider locale={locale}>
|
|
94
|
+
<ForgotPasswordForm
|
|
95
|
+
labels={labels}
|
|
96
|
+
aria-label="Explicit form"
|
|
97
|
+
eyebrow="Explicit eyebrow"
|
|
98
|
+
title="Explicit title"
|
|
99
|
+
description="Explicit description"
|
|
100
|
+
identifier={{ label: 'Explicit identifier', placeholder: 'Explicit placeholder' }}
|
|
101
|
+
messages={{ identifierRequired: 'Explicit required' }}
|
|
102
|
+
/>
|
|
103
|
+
</I18nProvider>,
|
|
104
|
+
);
|
|
105
|
+
for (const text of ['Explicit eyebrow', 'Explicit title', 'Explicit description', 'Explicit identifier'])
|
|
106
|
+
expect(screen.getByText(text)).toBeVisible();
|
|
107
|
+
expect(screen.getByPlaceholderText('Explicit placeholder')).toBeVisible();
|
|
108
|
+
fireEvent.submit(screen.getByRole('form', { name: 'Explicit form' }));
|
|
109
|
+
expect(screen.getByText('Explicit required')).toBeVisible();
|
|
110
|
+
rerender(
|
|
111
|
+
<I18nProvider locale={locale}>
|
|
112
|
+
<ForgotPasswordForm key="sent" labels={labels} defaultSent onSubmit={() => Promise.reject(null)} />
|
|
113
|
+
</I18nProvider>,
|
|
114
|
+
);
|
|
115
|
+
expect(screen.getByRole('heading', { name: labels.sentTitle })).toBeVisible();
|
|
116
|
+
expect(screen.getByText('Custom sent Custom addressFallback')).toBeVisible();
|
|
117
|
+
expect(screen.getByRole('status')).toHaveTextContent(labels.sentStatus);
|
|
118
|
+
expect(screen.getByRole('button', { name: labels.changeEmail })).toBeVisible();
|
|
119
|
+
await userEvent.click(screen.getByRole('button', { name: labels.resend }));
|
|
120
|
+
expect(await screen.findByText(labels.fallbackError)).toBeVisible();
|
|
121
|
+
rerender(
|
|
122
|
+
<I18nProvider locale={locale}>
|
|
123
|
+
<ForgotPasswordForm
|
|
124
|
+
key="sent"
|
|
125
|
+
labels={labels}
|
|
126
|
+
defaultSent
|
|
127
|
+
sentTitle="Explicit sent"
|
|
128
|
+
sentDescription="Explicit sent help"
|
|
129
|
+
sentStatus="Explicit status"
|
|
130
|
+
/>
|
|
131
|
+
</I18nProvider>,
|
|
132
|
+
);
|
|
133
|
+
expect(screen.getByRole('heading', { name: 'Explicit sent' })).toBeVisible();
|
|
134
|
+
expect(screen.getByText('Explicit sent help')).toBeVisible();
|
|
135
|
+
expect(screen.getByRole('status')).toHaveTextContent('Explicit status');
|
|
136
|
+
});
|
|
137
|
+
it('freezes the original English catalog copy', () => {
|
|
138
|
+
expect(en['forgotPassword.formLabel']).toBe('Reset password request');
|
|
139
|
+
expect(en['forgotPassword.eyebrow']).toBe('Account recovery');
|
|
140
|
+
expect(en['forgotPassword.title']).toBe('Forgot your password?');
|
|
141
|
+
expect(en['forgotPassword.description']).toBe("Enter the email you sign in with and we'll send you a reset link.");
|
|
142
|
+
expect(en['forgotPassword.sentTitle']).toBe('Check your email');
|
|
143
|
+
expect(en['forgotPassword.sentDescription']).toBe(
|
|
144
|
+
'If an account exists for {email}, you will receive a link to reset your password. It expires in 1 hour.',
|
|
145
|
+
);
|
|
146
|
+
expect(en['forgotPassword.addressFallback']).toBe('that address');
|
|
147
|
+
expect(en['forgotPassword.sentStatus']).toBe('Reset link sent.');
|
|
148
|
+
expect(en['forgotPassword.fallbackError']).toBe('The reset link could not be sent.');
|
|
149
|
+
expect(en['forgotPassword.backToSignIn']).toBe('Back to sign in');
|
|
150
|
+
expect(en['forgotPassword.resend']).toBe('Resend link');
|
|
151
|
+
expect(en['forgotPassword.changeEmail']).toBe('Use a different email');
|
|
152
|
+
expect(en['forgotPassword.identifierLabel']).toBe('Email');
|
|
153
|
+
expect(en['forgotPassword.identifierPlaceholder']).toBe('name@company.com');
|
|
154
|
+
expect(en['forgotPassword.submit']).toBe('Send reset link');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it.each(['en', 'es'])('uses custom invalid and short identifier messages under %s', (locale) => {
|
|
158
|
+
const labels = {
|
|
159
|
+
submit: 'Custom send',
|
|
160
|
+
identifierInvalid: 'Custom invalid identifier',
|
|
161
|
+
identifierTooShort: 'Custom short identifier',
|
|
162
|
+
};
|
|
163
|
+
const { rerender } = render(
|
|
164
|
+
<I18nProvider locale={locale}>
|
|
165
|
+
<ForgotPasswordForm labels={labels} />
|
|
166
|
+
</I18nProvider>,
|
|
167
|
+
);
|
|
168
|
+
expect(screen.getByRole('button', { name: 'Custom send' })).toBeVisible();
|
|
169
|
+
fireEvent.change(screen.getByRole('textbox'), { target: { value: 'invalid' } });
|
|
170
|
+
fireEvent.submit(screen.getByRole('form'));
|
|
171
|
+
expect(screen.getByText('Custom invalid identifier')).toBeVisible();
|
|
172
|
+
rerender(
|
|
173
|
+
<I18nProvider locale={locale}>
|
|
174
|
+
<ForgotPasswordForm labels={labels} identifier={{ type: 'text', minLength: 10 }} />
|
|
175
|
+
</I18nProvider>,
|
|
176
|
+
);
|
|
177
|
+
fireEvent.submit(screen.getByRole('form'));
|
|
178
|
+
expect(screen.getByText('Custom short identifier')).toBeVisible();
|
|
179
|
+
});
|
|
@@ -6,6 +6,12 @@ import { expectNoAxeViolations } from '../../test/a11y';
|
|
|
6
6
|
import { ForgotPasswordForm, type ForgotPasswordFormRef } from './ForgotPasswordForm';
|
|
7
7
|
|
|
8
8
|
describe('ForgotPasswordForm', () => {
|
|
9
|
+
it('matches the large recovery identifier to the submit button', () => {
|
|
10
|
+
render(<ForgotPasswordForm fieldSize="lg" />);
|
|
11
|
+
expect(screen.getByLabelText('Email').parentElement).toHaveClass('h-11');
|
|
12
|
+
expect(document.querySelector('button[type="submit"]')).toHaveClass('h-11');
|
|
13
|
+
});
|
|
14
|
+
|
|
9
15
|
it('can hide or replace inbox copy and both resend actions', () => {
|
|
10
16
|
const { rerender } = render(
|
|
11
17
|
<ForgotPasswordForm defaultSent sentTitle={null} sentDescription={null} sentStatus={null} resendActions={null} />,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Alert, Button, Field, FieldDescription, FieldError, FieldLabel, Input, Link, cn } from '@gntik-ai/ui';
|
|
1
|
+
import { useI18n, Alert, Button, Field, FieldDescription, FieldError, FieldLabel, Input, Link, cn } from '@gntik-ai/ui';
|
|
2
|
+
import { translatedContent } from '../../forms/translated-content';
|
|
2
3
|
import { ArrowLeft, Mail, MailCheck } from '@gntik-ai/icons';
|
|
3
4
|
import { useImperativeHandle, useRef, useState, type MouseEvent, type ReactNode, type Ref } from 'react';
|
|
4
5
|
import {
|
|
@@ -10,13 +11,33 @@ import {
|
|
|
10
11
|
type AuthValidationMessages,
|
|
11
12
|
type AuthFormAccessibilityProps,
|
|
12
13
|
type AuthHeaderProps,
|
|
14
|
+
type AuthFieldSizeProps,
|
|
13
15
|
} from '../shared';
|
|
14
16
|
|
|
15
17
|
export interface ForgotPasswordFormRef {
|
|
16
18
|
focus(field: 'identifier'): void;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
export interface
|
|
21
|
+
export interface ForgotPasswordFormLabels extends Required<Omit<AuthValidationMessages, 'passwordRequired'>> {
|
|
22
|
+
formLabel: string;
|
|
23
|
+
eyebrow: string;
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
sentTitle: string;
|
|
27
|
+
sentDescription: (email: string) => ReactNode;
|
|
28
|
+
addressFallback: string;
|
|
29
|
+
sentStatus: string;
|
|
30
|
+
fallbackError: string;
|
|
31
|
+
backToSignIn: string;
|
|
32
|
+
resend: string;
|
|
33
|
+
changeEmail: string;
|
|
34
|
+
identifierLabel: string;
|
|
35
|
+
identifierPlaceholder: string;
|
|
36
|
+
submit: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ForgotPasswordFormProps extends AuthFormAccessibilityProps, AuthFieldSizeProps {
|
|
40
|
+
labels?: Partial<ForgotPasswordFormLabels>;
|
|
20
41
|
/** React 19 ref for focus after a server response; available in the request state. */
|
|
21
42
|
ref?: Ref<ForgotPasswordFormRef>;
|
|
22
43
|
identifier?: AuthIdentifierConfig;
|
|
@@ -46,13 +67,15 @@ export interface ForgotPasswordFormProps extends AuthFormAccessibilityProps {
|
|
|
46
67
|
|
|
47
68
|
/** Request a reset link by email, then a "check your inbox" state with resend and a way back. */
|
|
48
69
|
export function ForgotPasswordForm({
|
|
70
|
+
labels,
|
|
71
|
+
fieldSize = 'auto',
|
|
49
72
|
identifier,
|
|
50
73
|
messages,
|
|
51
74
|
ref,
|
|
52
75
|
fieldInvalid,
|
|
53
76
|
feedbackId,
|
|
54
77
|
'aria-describedby': describedBy,
|
|
55
|
-
'aria-label':
|
|
78
|
+
'aria-label': ariaLabelProp,
|
|
56
79
|
'aria-labelledby': labelledBy,
|
|
57
80
|
onSubmit,
|
|
58
81
|
error: errorProp,
|
|
@@ -60,24 +83,33 @@ export function ForgotPasswordForm({
|
|
|
60
83
|
defaultSent = false,
|
|
61
84
|
signInHref = '#',
|
|
62
85
|
onBackToSignIn,
|
|
63
|
-
eyebrow
|
|
64
|
-
title
|
|
65
|
-
description
|
|
66
|
-
sentTitle
|
|
86
|
+
eyebrow: eyebrowProp,
|
|
87
|
+
title: titleProp,
|
|
88
|
+
description: descriptionProp,
|
|
89
|
+
sentTitle: sentTitleProp,
|
|
67
90
|
sentDescription,
|
|
68
|
-
sentStatus
|
|
91
|
+
sentStatus: sentStatusProp,
|
|
69
92
|
resendActions,
|
|
70
93
|
headingLevel,
|
|
71
94
|
className,
|
|
72
95
|
}: ForgotPasswordFormProps) {
|
|
96
|
+
const { t } = useI18n();
|
|
97
|
+
const eyebrow = eyebrowProp === undefined ? (labels?.eyebrow ?? t('forgotPassword.eyebrow')) : eyebrowProp;
|
|
98
|
+
const title = titleProp === undefined ? (labels?.title ?? t('forgotPassword.title')) : titleProp;
|
|
99
|
+
const description =
|
|
100
|
+
descriptionProp === undefined ? (labels?.description ?? t('forgotPassword.description')) : descriptionProp;
|
|
101
|
+
const sentTitle = sentTitleProp === undefined ? (labels?.sentTitle ?? t('forgotPassword.sentTitle')) : sentTitleProp;
|
|
102
|
+
const sentStatus =
|
|
103
|
+
sentStatusProp === undefined ? (labels?.sentStatus ?? t('forgotPassword.sentStatus')) : sentStatusProp;
|
|
104
|
+
const ariaLabel = ariaLabelProp ?? labels?.formLabel ?? t('forgotPassword.formLabel');
|
|
73
105
|
const [email, setEmail] = useState(defaultEmail);
|
|
74
106
|
const [submitted, setSubmitted] = useState(false);
|
|
75
107
|
const [sent, setSent] = useState(defaultSent);
|
|
76
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
108
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t('forgotPassword.fallbackError'));
|
|
77
109
|
const alert = errorProp ?? error;
|
|
78
110
|
const identifierInput = useRef<HTMLInputElement>(null);
|
|
79
111
|
useImperativeHandle(ref, () => ({ focus: () => identifierInput.current?.focus() }), []);
|
|
80
|
-
const identifierError = authIdentifierError(email, identifier, messages);
|
|
112
|
+
const identifierError = authIdentifierError(email, identifier, messages, t, labels);
|
|
81
113
|
const emailInvalid = submitted && identifierError !== null;
|
|
82
114
|
|
|
83
115
|
const send = async () => {
|
|
@@ -100,7 +132,7 @@ export function ForgotPasswordForm({
|
|
|
100
132
|
}
|
|
101
133
|
>
|
|
102
134
|
<ArrowLeft size={14} aria-hidden className="rtl:-scale-x-100" />
|
|
103
|
-
|
|
135
|
+
{labels?.backToSignIn ?? t('forgotPassword.backToSignIn')}
|
|
104
136
|
</Link>
|
|
105
137
|
);
|
|
106
138
|
|
|
@@ -115,15 +147,18 @@ export function ForgotPasswordForm({
|
|
|
115
147
|
title={sentTitle}
|
|
116
148
|
headingLevel={headingLevel}
|
|
117
149
|
description={
|
|
118
|
-
sentDescription === undefined
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
sentDescription === undefined
|
|
151
|
+
? (labels?.sentDescription?.(
|
|
152
|
+
email.trim() || (labels?.addressFallback ?? t('forgotPassword.addressFallback')),
|
|
153
|
+
) ??
|
|
154
|
+
translatedContent(t('forgotPassword.sentDescription'), {
|
|
155
|
+
email: (
|
|
156
|
+
<span className="font-medium text-foreground">
|
|
157
|
+
{email.trim() || (labels?.addressFallback ?? t('forgotPassword.addressFallback'))}
|
|
158
|
+
</span>
|
|
159
|
+
),
|
|
160
|
+
}))
|
|
161
|
+
: sentDescription
|
|
127
162
|
}
|
|
128
163
|
/>
|
|
129
164
|
{sentStatus != null && (
|
|
@@ -137,7 +172,7 @@ export function ForgotPasswordForm({
|
|
|
137
172
|
{resendActions === undefined ? (
|
|
138
173
|
<>
|
|
139
174
|
<Button variant="secondary" size="lg" loading={loading} className="w-full" onClick={() => void send()}>
|
|
140
|
-
|
|
175
|
+
{labels?.resend ?? t('forgotPassword.resend')}
|
|
141
176
|
</Button>
|
|
142
177
|
<Button
|
|
143
178
|
variant="ghost"
|
|
@@ -148,7 +183,7 @@ export function ForgotPasswordForm({
|
|
|
148
183
|
setSubmitted(false);
|
|
149
184
|
}}
|
|
150
185
|
>
|
|
151
|
-
|
|
186
|
+
{labels?.changeEmail ?? t('forgotPassword.changeEmail')}
|
|
152
187
|
</Button>
|
|
153
188
|
</>
|
|
154
189
|
) : (
|
|
@@ -182,14 +217,17 @@ export function ForgotPasswordForm({
|
|
|
182
217
|
>
|
|
183
218
|
{alert && <Alert id={feedbackId} tone="destructive" description={alert} />}
|
|
184
219
|
<Field invalid={emailInvalid || fieldInvalid?.identifier === true}>
|
|
185
|
-
<FieldLabel>{identifier?.label ?? '
|
|
220
|
+
<FieldLabel>{identifier?.label ?? labels?.identifierLabel ?? t('forgotPassword.identifierLabel')}</FieldLabel>
|
|
186
221
|
<Input
|
|
222
|
+
size={fieldSize}
|
|
187
223
|
ref={identifierInput}
|
|
188
224
|
aria-describedby={fieldInvalid?.identifier ? feedbackId : undefined}
|
|
189
225
|
type={identifier?.type ?? 'email'}
|
|
190
226
|
leadingIcon={Mail}
|
|
191
227
|
autoComplete={identifier?.autoComplete ?? 'email'}
|
|
192
|
-
placeholder={
|
|
228
|
+
placeholder={
|
|
229
|
+
identifier?.placeholder ?? labels?.identifierPlaceholder ?? t('forgotPassword.identifierPlaceholder')
|
|
230
|
+
}
|
|
193
231
|
minLength={identifier?.minLength}
|
|
194
232
|
maxLength={identifier?.maxLength}
|
|
195
233
|
value={email}
|
|
@@ -202,7 +240,7 @@ export function ForgotPasswordForm({
|
|
|
202
240
|
</FieldError>
|
|
203
241
|
</Field>
|
|
204
242
|
<Button type="submit" size="lg" loading={loading} className="mt-2 w-full">
|
|
205
|
-
|
|
243
|
+
{labels?.submit ?? t('forgotPassword.submit')}
|
|
206
244
|
</Button>
|
|
207
245
|
</form>
|
|
208
246
|
<p className="mt-7 text-center">{back}</p>
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { ForgotPasswordFormLabels } from './ForgotPasswordForm';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Forgot password form',
|
|
5
6
|
family: 'auth',
|
|
6
7
|
status: 'stable',
|
|
7
8
|
description:
|
|
8
|
-
'Email (default) or username-or-email password recovery; onSubmit receives the trimmed identifier. 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. ref.focus accepts identifier. title/description and sentTitle/sentDescription configure request and sent copy; sentTitle, sentDescription, sentStatus and resendActions accept null to hide inbox copy, announcements and resend/change-identifier actions. Preview: forgot-password-form--username-or-email.',
|
|
9
|
+
'Email (default) or username-or-email password recovery; onSubmit receives the trimmed identifier. 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. ref.focus accepts identifier. title/description and sentTitle/sentDescription configure request and sent copy; sentTitle, sentDescription, sentStatus and resendActions accept null to hide inbox copy, announcements and resend/change-identifier actions. Preview: forgot-password-form--username-or-email. Optional labels?: Partial<ForgotPasswordFormLabels> 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=forgot-password-form--labels. Optional fieldSize: auto (default, follows density) or lg (44px fields matching the submit button). Preview: forgot-password-form--large-fields.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'formLabel', type: 'string', state: 'Default content and accessible names' },
|
|
12
|
+
{ key: 'eyebrow', type: 'string', state: 'Default content and accessible names' },
|
|
13
|
+
{ key: 'title', type: 'string', state: 'Default content and accessible names' },
|
|
14
|
+
{ key: 'description', type: 'string', state: 'Default content and accessible names' },
|
|
15
|
+
{ key: 'sentTitle', type: 'string', state: 'Async feedback' },
|
|
16
|
+
{ key: 'sentDescription', type: '(email: string) => ReactNode', state: 'Async feedback' },
|
|
17
|
+
{ key: 'addressFallback', type: 'string', state: 'Async feedback' },
|
|
18
|
+
{ key: 'sentStatus', type: 'string', state: 'Async feedback' },
|
|
19
|
+
{ key: 'fallbackError', type: 'string', state: 'Validation feedback' },
|
|
20
|
+
{ key: 'backToSignIn', type: 'string', state: 'Default content and accessible names' },
|
|
21
|
+
{ key: 'resend', type: 'string', state: 'Default content and accessible names' },
|
|
22
|
+
{ key: 'changeEmail', type: 'string', state: 'Default content and accessible names' },
|
|
23
|
+
{ key: 'identifierLabel', type: 'string', state: 'Default content and accessible names' },
|
|
24
|
+
{ key: 'identifierPlaceholder', type: 'string', state: 'Default content and accessible names' },
|
|
25
|
+
{ key: 'submit', type: 'string', state: 'Default content and accessible names' },
|
|
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 ForgotPasswordFormLabels; type: string; state: string }>,
|
|
9
30
|
uses: ['Field', 'FieldLabel', 'FieldDescription', 'FieldError', 'Input', 'Button', 'Alert', 'Link'],
|
|
10
31
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button, I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ForgotPasswordForm, type ForgotPasswordFormLabels } from '../ForgotPasswordForm';
|
|
4
|
+
|
|
5
|
+
export default function Labels() {
|
|
6
|
+
const [spanish, setSpanish] = useState(false);
|
|
7
|
+
const [custom, setCustom] = useState(true);
|
|
8
|
+
const labels: Partial<ForgotPasswordFormLabels> = {
|
|
9
|
+
title: 'Recover access',
|
|
10
|
+
submit: 'Email recovery link',
|
|
11
|
+
sentTitle: 'Recovery email requested',
|
|
12
|
+
sentDescription: (email) => `Check ${email} for your recovery link.`,
|
|
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
|
+
<ForgotPasswordForm labels={custom ? labels : undefined} />
|
|
26
|
+
</I18nProvider>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|