@gntik-ai/blocks 0.9.0 → 0.11.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 +426 -55
- package/dist/index.js +2275 -639
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.labels.test.tsx +179 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +59 -24
- package/src/auth/ForgotPasswordForm/block.meta.ts +22 -1
- package/src/auth/ForgotPasswordForm/examples/Labels.tsx +29 -0
- package/src/auth/MfaChallenge/MfaChallenge.labels.test.tsx +139 -0
- package/src/auth/MfaChallenge/MfaChallenge.tsx +69 -23
- package/src/auth/MfaChallenge/block.meta.ts +29 -1
- package/src/auth/MfaChallenge/examples/Labels.tsx +28 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.labels.test.tsx +104 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +42 -15
- package/src/auth/ResetPasswordForm/block.meta.ts +17 -1
- package/src/auth/ResetPasswordForm/examples/Labels.tsx +28 -0
- package/src/auth/SignInForm/SignInForm.labels.test.tsx +137 -0
- package/src/auth/SignInForm/SignInForm.tsx +43 -16
- package/src/auth/SignInForm/block.meta.ts +22 -1
- package/src/auth/SignInForm/examples/Labels.tsx +29 -0
- package/src/auth/SignUpForm/SignUpForm.labels.test.tsx +217 -0
- package/src/auth/SignUpForm/SignUpForm.tsx +65 -26
- package/src/auth/SignUpForm/block.meta.ts +27 -1
- package/src/auth/SignUpForm/examples/Labels.tsx +29 -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/shared.i18n.test.tsx +71 -0
- package/src/auth/shared.tsx +48 -11
- package/src/billing/CostBreakdown/CostBreakdown.test.tsx +10 -0
- package/src/billing/CostBreakdown/CostBreakdown.tsx +50 -43
- package/src/billing/SpendVsBudget/SpendVsBudget.test.tsx +10 -0
- package/src/billing/SpendVsBudget/SpendVsBudget.tsx +35 -31
- package/src/builders/FlowBuilder/FlowBuilder.test.tsx +237 -2
- package/src/builders/FlowBuilder/FlowBuilder.tsx +101 -29
- package/src/builders/FlowBuilder/block.meta.ts +1 -1
- package/src/builders/FlowBuilder/connections.ts +30 -12
- package/src/builders/FlowBuilder/examples/ControlledGraph.tsx +8 -0
- package/src/builders/FlowBuilder/graph-state.ts +78 -0
- package/src/builders/LogViewer/LogViewer.labels.test.tsx +90 -0
- package/src/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
- package/src/builders/LogViewer/LogViewer.tsx +72 -18
- package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
- package/src/builders/LogViewer/block.meta.ts +19 -1
- package/src/builders/LogViewer/examples/Spanish.tsx +30 -0
- package/src/builders/LogViewer/examples/Wrap.tsx +62 -0
- package/src/builders/LogViewer/use-wrapped-log-rows.ts +42 -0
- package/src/data-display/ChartCard/ChartCard.locale.test.tsx +15 -0
- package/src/data-display/ChartCard/ChartCard.test.tsx +9 -0
- package/src/data-display/ChartCard/ChartCard.tsx +81 -67
- package/src/data-display/ChartCard/block.meta.ts +1 -1
- package/src/data-display/DescriptionListCard/DescriptionListCard.labels.test.tsx +73 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +74 -23
- package/src/data-display/DescriptionListCard/block.meta.ts +11 -1
- package/src/data-display/DescriptionListCard/examples/Spanish.tsx +29 -0
- package/src/feedback/EmptyStates/EmptyStates.labels.test.tsx +185 -0
- package/src/feedback/EmptyStates/EmptyStates.tsx +101 -30
- package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
- package/src/feedback/EmptyStates/block.meta.ts +73 -1
- package/src/feedback/EmptyStates/examples/Spanish.tsx +48 -0
- package/src/feedback/ErrorPanel/ErrorPanel.labels.test.tsx +99 -0
- package/src/feedback/ErrorPanel/ErrorPanel.tsx +38 -9
- package/src/feedback/ErrorPanel/block.meta.ts +19 -1
- package/src/feedback/ErrorPanel/examples/Spanish.tsx +30 -0
- package/src/feedback/InlineCallout/InlineCallout.labels.test.tsx +62 -0
- package/src/feedback/InlineCallout/InlineCallout.tsx +22 -9
- package/src/feedback/InlineCallout/block.meta.ts +9 -1
- package/src/feedback/InlineCallout/examples/Spanish.tsx +19 -0
- package/src/feedback/Skeletons/Skeletons.labels.test.tsx +24 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.labels.test.tsx +115 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +63 -21
- package/src/forms/CreateApiKeyDialog/block.meta.ts +22 -1
- 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.labels.test.tsx +126 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.test.tsx +22 -1
- package/src/forms/FileUploadPanel/FileUploadPanel.tsx +85 -22
- package/src/forms/FileUploadPanel/block.meta.ts +22 -1
- package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -0
- package/src/forms/FileUploadPanel/fixtures.ts +0 -12
- package/src/forms/FileUploadPanel/format-bytes.test.ts +8 -0
- package/src/forms/FormSection/FormSection.labels.test.tsx +37 -0
- package/src/forms/FormSection/FormSection.tsx +14 -3
- package/src/forms/FormSection/block.meta.ts +7 -1
- package/src/forms/FormSection/examples/Labels.tsx +27 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.labels.test.tsx +87 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +51 -16
- package/src/forms/InviteMembersDialog/block.meta.ts +20 -1
- 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 +9 -3
- 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/page-chrome/PageHeader/PageHeader.labels.test.tsx +56 -0
- package/src/page-chrome/PageHeader/PageHeader.options.test.tsx +34 -0
- package/src/page-chrome/PageHeader/PageHeader.tsx +26 -5
- package/src/page-chrome/PageHeader/block.meta.ts +8 -1
- package/src/page-chrome/PageHeader/examples/Labels.tsx +16 -0
- package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
- package/src/scheduling/AgendaList/AgendaList.test.tsx +25 -0
- package/src/scheduling/AgendaList/AgendaList.tsx +7 -2
- package/src/scheduling/AgendaList/AgendaListLocale.test.tsx +11 -0
- package/src/scheduling/AgendaList/block.meta.ts +1 -1
- package/src/scheduling/AgendaList/examples/Locale.tsx +29 -0
- package/src/scheduling/MonthCalendar/MonthCalendar.test.tsx +111 -1
- package/src/scheduling/MonthCalendar/MonthCalendar.tsx +19 -9
- package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
- package/src/scheduling/MonthCalendar/examples/Locale.tsx +19 -0
- package/src/scheduling/WeekCalendar/WeekCalendar.test.tsx +73 -2
- package/src/scheduling/WeekCalendar/WeekCalendar.tsx +26 -12
- package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
- package/src/scheduling/WeekCalendar/examples/Locale.tsx +19 -0
- package/src/scheduling/shared/dates.test.ts +75 -0
- package/src/scheduling/shared/dates.ts +46 -22
- package/src/scheduling/shared/useSchedulingClock.ts +13 -0
- package/src/shell/GlobalSearch/GlobalSearch.test.tsx +12 -0
- package/src/shell/GlobalSearch/fixtures.ts +2 -2
- package/src/tables/DataTable/DataTable.cross-page-selection.test.tsx +322 -0
- package/src/tables/DataTable/DataTable.labels.test.tsx +74 -0
- package/src/tables/DataTable/DataTable.server-pagination.test.tsx +1 -1
- package/src/tables/DataTable/DataTable.single-select.test.tsx +47 -7
- package/src/tables/DataTable/DataTable.test.tsx +55 -0
- package/src/tables/DataTable/DataTable.tsx +134 -67
- package/src/tables/DataTable/block.meta.ts +21 -3
- package/src/tables/DataTable/data-table-props.ts +14 -5
- package/src/tables/DataTable/data-table-row.tsx +7 -3
- package/src/tables/DataTable/data-table-utils.ts +2 -0
- package/src/tables/DataTable/examples/client-selection.tsx +33 -0
- package/src/tables/DataTable/examples/paginated-single-selection.tsx +46 -0
- package/src/tables/DataTable/examples/server-pagination.tsx +55 -15
- package/src/tables/DataTable/labels.ts +4 -0
- 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/PaginationFooter/PaginationFooter.i18n.test.tsx +26 -0
- package/src/test/OptInDefaults.test.tsx +27 -0
- package/src/test/fixtures/opt-in-defaults.json +10 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
useI18n,
|
|
2
3
|
Alert,
|
|
3
4
|
Button,
|
|
4
5
|
Checkbox,
|
|
@@ -36,7 +37,29 @@ export interface CreateApiKeyInput {
|
|
|
36
37
|
expiry: string;
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
export interface CreateApiKeyDialogLabels {
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
name: string;
|
|
44
|
+
namePlaceholder: string;
|
|
45
|
+
nameRequired: string;
|
|
46
|
+
scopes: string;
|
|
47
|
+
scopesRequired: string;
|
|
48
|
+
expiration: string;
|
|
49
|
+
errorTitle: string;
|
|
50
|
+
fallbackError: string;
|
|
51
|
+
cancel: string;
|
|
52
|
+
submit: string;
|
|
53
|
+
successTitle: string;
|
|
54
|
+
successDescription: string;
|
|
55
|
+
warningTitle: string;
|
|
56
|
+
warningDescription: string;
|
|
57
|
+
secretLabel: string;
|
|
58
|
+
done: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
39
61
|
export interface CreateApiKeyDialogProps {
|
|
62
|
+
labels?: Partial<CreateApiKeyDialogLabels>;
|
|
40
63
|
scopes?: ApiKeyScope[];
|
|
41
64
|
expiries?: ApiKeyExpiry[];
|
|
42
65
|
defaultExpiry?: string;
|
|
@@ -54,6 +77,7 @@ export interface CreateApiKeyDialogProps {
|
|
|
54
77
|
* with copy. Closing the dialog discards the secret; it can't be shown again.
|
|
55
78
|
*/
|
|
56
79
|
export function CreateApiKeyDialog({
|
|
80
|
+
labels,
|
|
57
81
|
scopes = apiKeyScopes,
|
|
58
82
|
expiries = apiKeyExpiries,
|
|
59
83
|
defaultExpiry = '90d',
|
|
@@ -63,6 +87,7 @@ export function CreateApiKeyDialog({
|
|
|
63
87
|
onOpenChange,
|
|
64
88
|
trigger = <Button icon={KeyRound} />,
|
|
65
89
|
}: CreateApiKeyDialogProps) {
|
|
90
|
+
const { t } = useI18n();
|
|
66
91
|
const [innerOpen, setInnerOpen] = useState(defaultOpen);
|
|
67
92
|
const [name, setName] = useState('');
|
|
68
93
|
const [selected, setSelected] = useState<string[]>([]);
|
|
@@ -98,22 +123,20 @@ export function CreateApiKeyDialog({
|
|
|
98
123
|
const value = await onCreate({ name: name.trim(), scopes: selected, expiry });
|
|
99
124
|
setSecret(value);
|
|
100
125
|
} catch (e) {
|
|
101
|
-
setError(e instanceof Error ? e.message :
|
|
126
|
+
setError(e instanceof Error ? e.message : (labels?.fallbackError ?? t('createApiKey.fallbackError')));
|
|
102
127
|
}
|
|
103
128
|
setLoading(false);
|
|
104
129
|
};
|
|
105
130
|
|
|
106
131
|
return (
|
|
107
132
|
<Dialog open={open} onOpenChange={setOpen}>
|
|
108
|
-
{trigger && <DialogTrigger render={trigger}>
|
|
133
|
+
{trigger && <DialogTrigger render={trigger}>{labels?.title ?? t('createApiKey.title')}</DialogTrigger>}
|
|
109
134
|
<DialogContent size="lg">
|
|
110
135
|
{secret == null ? (
|
|
111
136
|
<>
|
|
112
137
|
<DialogHeader>
|
|
113
|
-
<DialogTitle>
|
|
114
|
-
<DialogDescription>
|
|
115
|
-
Keys act on behalf of this workspace. Grant only the scopes the integration needs.
|
|
116
|
-
</DialogDescription>
|
|
138
|
+
<DialogTitle>{labels?.title ?? t('createApiKey.title')}</DialogTitle>
|
|
139
|
+
<DialogDescription>{labels?.description ?? t('createApiKey.description')}</DialogDescription>
|
|
117
140
|
</DialogHeader>
|
|
118
141
|
<form
|
|
119
142
|
noValidate
|
|
@@ -124,21 +147,21 @@ export function CreateApiKeyDialog({
|
|
|
124
147
|
>
|
|
125
148
|
<DialogBody className="grid gap-5">
|
|
126
149
|
<Field invalid={nameInvalid}>
|
|
127
|
-
<FieldLabel required>
|
|
150
|
+
<FieldLabel required>{labels?.name ?? t('createApiKey.name')}</FieldLabel>
|
|
128
151
|
<Input
|
|
129
152
|
value={name}
|
|
130
153
|
onValueChange={setName}
|
|
131
|
-
placeholder=
|
|
154
|
+
placeholder={labels?.namePlaceholder ?? t('createApiKey.namePlaceholder')}
|
|
132
155
|
required
|
|
133
156
|
autoComplete="off"
|
|
134
157
|
/>
|
|
135
|
-
<FieldError match={nameInvalid}>
|
|
158
|
+
<FieldError match={nameInvalid}>{labels?.nameRequired ?? t('createApiKey.nameRequired')}</FieldError>
|
|
136
159
|
</Field>
|
|
137
160
|
<Fieldset
|
|
138
161
|
render={<CheckboxGroup value={selected} onValueChange={setSelected} />}
|
|
139
162
|
aria-invalid={scopesInvalid || undefined}
|
|
140
163
|
>
|
|
141
|
-
<FieldsetLegend>
|
|
164
|
+
<FieldsetLegend>{labels?.scopes ?? t('createApiKey.scopes')}</FieldsetLegend>
|
|
142
165
|
{scopes.map((s) => (
|
|
143
166
|
<Checkbox
|
|
144
167
|
key={s.value}
|
|
@@ -147,10 +170,14 @@ export function CreateApiKeyDialog({
|
|
|
147
170
|
description={s.description}
|
|
148
171
|
/>
|
|
149
172
|
))}
|
|
150
|
-
{scopesInvalid &&
|
|
173
|
+
{scopesInvalid && (
|
|
174
|
+
<p className="text-[12.5px] text-destructive-text">
|
|
175
|
+
{labels?.scopesRequired ?? t('createApiKey.scopesRequired')}
|
|
176
|
+
</p>
|
|
177
|
+
)}
|
|
151
178
|
</Fieldset>
|
|
152
179
|
<Field>
|
|
153
|
-
<FieldLabel>
|
|
180
|
+
<FieldLabel>{labels?.expiration ?? t('createApiKey.expiration')}</FieldLabel>
|
|
154
181
|
<Select value={expiry} onValueChange={(v) => v != null && setExpiry(v)} items={expiries}>
|
|
155
182
|
<SelectTrigger className="w-full sm:w-56" />
|
|
156
183
|
<SelectContent>
|
|
@@ -162,12 +189,20 @@ export function CreateApiKeyDialog({
|
|
|
162
189
|
</SelectContent>
|
|
163
190
|
</Select>
|
|
164
191
|
</Field>
|
|
165
|
-
{error &&
|
|
192
|
+
{error && (
|
|
193
|
+
<Alert
|
|
194
|
+
tone="destructive"
|
|
195
|
+
title={labels?.errorTitle ?? t('createApiKey.errorTitle')}
|
|
196
|
+
description={error}
|
|
197
|
+
/>
|
|
198
|
+
)}
|
|
166
199
|
</DialogBody>
|
|
167
200
|
<DialogFooter>
|
|
168
|
-
<DialogClose render={<Button variant="ghost" disabled={loading} />}>
|
|
201
|
+
<DialogClose render={<Button variant="ghost" disabled={loading} />}>
|
|
202
|
+
{labels?.cancel ?? t('createApiKey.cancel')}
|
|
203
|
+
</DialogClose>
|
|
169
204
|
<Button type="submit" loading={loading}>
|
|
170
|
-
|
|
205
|
+
{labels?.submit ?? t('createApiKey.submit')}
|
|
171
206
|
</Button>
|
|
172
207
|
</DialogFooter>
|
|
173
208
|
</form>
|
|
@@ -175,19 +210,26 @@ export function CreateApiKeyDialog({
|
|
|
175
210
|
) : (
|
|
176
211
|
<>
|
|
177
212
|
<DialogHeader>
|
|
178
|
-
<DialogTitle>
|
|
179
|
-
<DialogDescription>
|
|
213
|
+
<DialogTitle>{labels?.successTitle ?? t('createApiKey.successTitle')}</DialogTitle>
|
|
214
|
+
<DialogDescription>
|
|
215
|
+
{labels?.successDescription ?? t('createApiKey.successDescription')}
|
|
216
|
+
</DialogDescription>
|
|
180
217
|
</DialogHeader>
|
|
181
218
|
<DialogBody className="grid gap-4">
|
|
182
219
|
<Alert
|
|
183
220
|
tone="warning"
|
|
184
|
-
title=
|
|
185
|
-
description=
|
|
221
|
+
title={labels?.warningTitle ?? t('createApiKey.warningTitle')}
|
|
222
|
+
description={labels?.warningDescription ?? t('createApiKey.warningDescription')}
|
|
223
|
+
/>
|
|
224
|
+
<CodeBlock
|
|
225
|
+
code={secret}
|
|
226
|
+
label={labels?.secretLabel ?? t('createApiKey.secretLabel')}
|
|
227
|
+
wrapToggle={false}
|
|
228
|
+
defaultWrap
|
|
186
229
|
/>
|
|
187
|
-
<CodeBlock code={secret} label="New API key" wrapToggle={false} defaultWrap />
|
|
188
230
|
</DialogBody>
|
|
189
231
|
<DialogFooter>
|
|
190
|
-
<DialogClose render={<Button />}>
|
|
232
|
+
<DialogClose render={<Button />}>{labels?.done ?? t('createApiKey.done')}</DialogClose>
|
|
191
233
|
</DialogFooter>
|
|
192
234
|
</>
|
|
193
235
|
)}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { CreateApiKeyDialogLabels } from './CreateApiKeyDialog';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Create API key dialog',
|
|
5
6
|
family: 'forms',
|
|
6
7
|
status: 'stable',
|
|
7
8
|
description:
|
|
8
|
-
'Two-step dialog: name, scopes and expiry, then the secret shown once in a copyable CodeBlock with a warning.',
|
|
9
|
+
'Two-step dialog: name, scopes and expiry, then the secret shown once in a copyable CodeBlock with a warning. Optional labels?: Partial<CreateApiKeyDialogLabels> 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=create-api-key-dialog--labels.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'title', type: 'string', state: 'Default content and accessible names' },
|
|
12
|
+
{ key: 'description', type: 'string', state: 'Default content and accessible names' },
|
|
13
|
+
{ key: 'name', type: 'string', state: 'Default content and accessible names' },
|
|
14
|
+
{ key: 'namePlaceholder', type: 'string', state: 'Default content and accessible names' },
|
|
15
|
+
{ key: 'nameRequired', type: 'string', state: 'Validation feedback' },
|
|
16
|
+
{ key: 'scopes', type: 'string', state: 'Default content and accessible names' },
|
|
17
|
+
{ key: 'scopesRequired', type: 'string', state: 'Validation feedback' },
|
|
18
|
+
{ key: 'expiration', type: 'string', state: 'Default content and accessible names' },
|
|
19
|
+
{ key: 'errorTitle', type: 'string', state: 'Validation feedback' },
|
|
20
|
+
{ key: 'fallbackError', type: 'string', state: 'Validation feedback' },
|
|
21
|
+
{ key: 'cancel', type: 'string', state: 'Default content and accessible names' },
|
|
22
|
+
{ key: 'submit', type: 'string', state: 'Default content and accessible names' },
|
|
23
|
+
{ key: 'successTitle', type: 'string', state: 'Async feedback' },
|
|
24
|
+
{ key: 'successDescription', type: 'string', state: 'Async feedback' },
|
|
25
|
+
{ key: 'warningTitle', type: 'string', state: 'Default content and accessible names' },
|
|
26
|
+
{ key: 'warningDescription', type: 'string', state: 'Default content and accessible names' },
|
|
27
|
+
{ key: 'secretLabel', type: 'string', state: 'Default content and accessible names' },
|
|
28
|
+
{ key: 'done', type: 'string', state: 'Async feedback' },
|
|
29
|
+
] satisfies Array<{ key: keyof CreateApiKeyDialogLabels; type: string; state: string }>,
|
|
9
30
|
uses: ['Dialog', 'Field', 'Input', 'CheckboxGroup', 'Checkbox', 'Select', 'CodeBlock', 'Alert', 'Button'],
|
|
10
31
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Button, I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { CreateApiKeyDialog, type CreateApiKeyDialogLabels } from '../CreateApiKeyDialog';
|
|
4
|
+
|
|
5
|
+
export default function Labels() {
|
|
6
|
+
const [spanish, setSpanish] = useState(false);
|
|
7
|
+
const [custom, setCustom] = useState(true);
|
|
8
|
+
const labels: Partial<CreateApiKeyDialogLabels> = {
|
|
9
|
+
title: 'New integration key',
|
|
10
|
+
name: 'Integration name',
|
|
11
|
+
submit: 'Generate key',
|
|
12
|
+
successTitle: 'Integration key ready',
|
|
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
|
+
<CreateApiKeyDialog labels={custom ? labels : undefined} />
|
|
26
|
+
</I18nProvider>
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { I18nProvider, es } from '@gntik-ai/ui';
|
|
4
|
+
import { CredentialDisclosureDialog, type CredentialDisclosureDialogLabels } from './CredentialDisclosureDialog';
|
|
5
|
+
import { storedDisclosure } from './fixtures';
|
|
6
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
7
|
+
it('preserves English and translates every default including copy feedback', async () => {
|
|
8
|
+
const user = userEvent.setup();
|
|
9
|
+
const writeText = vi.fn().mockResolvedValue(undefined);
|
|
10
|
+
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
|
|
11
|
+
const { rerender } = render(<CredentialDisclosureDialog disclosure={storedDisclosure} onClose={() => {}} />);
|
|
12
|
+
expect(await screen.findByRole('dialog', { name: 'Credential secret' })).toHaveAccessibleDescription(
|
|
13
|
+
'Copy this value and store it securely.',
|
|
14
|
+
);
|
|
15
|
+
for (const text of ['Credential ID', 'Expires']) expect(screen.getByText(text)).toBeVisible();
|
|
16
|
+
expect(screen.getByRole('button', { name: 'Show secret' })).toBeVisible();
|
|
17
|
+
expect(screen.getByRole('button', { name: 'Copy secret' })).toBeVisible();
|
|
18
|
+
rerender(
|
|
19
|
+
<I18nProvider locale="es">
|
|
20
|
+
<CredentialDisclosureDialog disclosure={{ ...storedDisclosure, variant: 'fresh' }} maskFresh onClose={() => {}} />
|
|
21
|
+
</I18nProvider>,
|
|
22
|
+
);
|
|
23
|
+
const dialog = await screen.findByRole('dialog', { name: es['credentialDisclosure.title'] });
|
|
24
|
+
expect(dialog).toHaveAccessibleDescription(es['credentialDisclosure.description']);
|
|
25
|
+
for (const key of ['credentialId', 'expiry', 'warningTitle', 'warningText'] as const)
|
|
26
|
+
expect(screen.getByText(es[`credentialDisclosure.${key}`])).toBeVisible();
|
|
27
|
+
await user.click(screen.getByRole('button', { name: es['credentialDisclosure.show'] }));
|
|
28
|
+
expect(screen.getByRole('button', { name: es['credentialDisclosure.hide'] })).toBeVisible();
|
|
29
|
+
expect(screen.getByRole('textbox', { name: es['credentialDisclosure.secret'] })).toHaveValue(storedDisclosure.secret);
|
|
30
|
+
await user.click(screen.getByRole('button', { name: es['credentialDisclosure.copy'] }));
|
|
31
|
+
expect(screen.getByRole('button', { name: es['credentialDisclosure.copied'] })).toBeVisible();
|
|
32
|
+
expect(screen.getByRole('status')).toHaveTextContent(es['credentialDisclosure.success']);
|
|
33
|
+
expect(screen.getByRole('button', { name: es['credentialDisclosure.close'] })).toBeVisible();
|
|
34
|
+
await expectNoAxeViolations(dialog);
|
|
35
|
+
});
|
|
36
|
+
it.each(['en', 'es'])('honours all label overrides and explicit props under %s', async (locale) => {
|
|
37
|
+
const user = userEvent.setup();
|
|
38
|
+
const writeText = vi.fn().mockResolvedValue(undefined);
|
|
39
|
+
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
|
|
40
|
+
const labels: CredentialDisclosureDialogLabels = {
|
|
41
|
+
title: 'Custom title',
|
|
42
|
+
description: 'Custom help',
|
|
43
|
+
credentialIdLabel: 'Custom ID',
|
|
44
|
+
expiryLabel: 'Custom expiry',
|
|
45
|
+
secretLabel: 'Custom secret',
|
|
46
|
+
showLabel: 'Custom show',
|
|
47
|
+
hideLabel: 'Custom hide',
|
|
48
|
+
copyLabel: 'Custom copy',
|
|
49
|
+
copiedLabel: 'Custom copied',
|
|
50
|
+
successAnnouncement: 'Custom success',
|
|
51
|
+
failureAnnouncement: 'Custom failure',
|
|
52
|
+
warningTitle: 'Custom warning',
|
|
53
|
+
warningText: 'Custom caution',
|
|
54
|
+
closeLabel: 'Custom close',
|
|
55
|
+
copiedAnnouncementFor: (label, copied) => `Custom ${label} ${copied}`,
|
|
56
|
+
};
|
|
57
|
+
const props = { disclosure: { ...storedDisclosure, variant: 'fresh' as const }, maskFresh: true, onClose: () => {} };
|
|
58
|
+
const { rerender } = render(
|
|
59
|
+
<I18nProvider locale={locale}>
|
|
60
|
+
<CredentialDisclosureDialog {...props} labels={labels} />
|
|
61
|
+
</I18nProvider>,
|
|
62
|
+
);
|
|
63
|
+
expect(await screen.findByRole('dialog', { name: labels.title })).toHaveAccessibleDescription(labels.description);
|
|
64
|
+
for (const text of [labels.credentialIdLabel, labels.expiryLabel, labels.warningTitle, labels.warningText])
|
|
65
|
+
expect(screen.getByText(text)).toBeVisible();
|
|
66
|
+
await user.click(screen.getByRole('button', { name: labels.showLabel }));
|
|
67
|
+
expect(screen.getByRole('textbox', { name: labels.secretLabel })).toHaveValue(storedDisclosure.secret);
|
|
68
|
+
expect(screen.getByRole('button', { name: labels.hideLabel })).toBeVisible();
|
|
69
|
+
await user.click(screen.getByRole('button', { name: labels.copyLabel }));
|
|
70
|
+
expect(screen.getByRole('button', { name: labels.copiedLabel })).toBeVisible();
|
|
71
|
+
expect(screen.getByRole('status')).toHaveTextContent(labels.successAnnouncement);
|
|
72
|
+
rerender(
|
|
73
|
+
<I18nProvider locale={locale}>
|
|
74
|
+
<CredentialDisclosureDialog
|
|
75
|
+
{...props}
|
|
76
|
+
labels={labels}
|
|
77
|
+
title="Explicit title"
|
|
78
|
+
description="Explicit description"
|
|
79
|
+
secretLabel="Explicit secret"
|
|
80
|
+
showLabel="Explicit show"
|
|
81
|
+
hideLabel="Explicit hide"
|
|
82
|
+
credentialIdLabel="Explicit ID"
|
|
83
|
+
expiryLabel="Explicit expiry"
|
|
84
|
+
warningTitle="Explicit warning"
|
|
85
|
+
warningText="Explicit caution"
|
|
86
|
+
copiedLabel="Explicit copied"
|
|
87
|
+
copyLabel="Explicit copy"
|
|
88
|
+
successAnnouncement="Explicit success"
|
|
89
|
+
failureAnnouncement="Explicit failure"
|
|
90
|
+
closeLabel="Explicit close"
|
|
91
|
+
/>
|
|
92
|
+
</I18nProvider>,
|
|
93
|
+
);
|
|
94
|
+
expect(screen.getByRole('dialog', { name: 'Explicit title' })).toHaveAccessibleDescription('Explicit description');
|
|
95
|
+
for (const text of ['Explicit ID', 'Explicit expiry', 'Explicit warning', 'Explicit caution'])
|
|
96
|
+
expect(screen.getByText(text)).toBeVisible();
|
|
97
|
+
expect(screen.getByRole('button', { name: 'Explicit hide' })).toBeVisible();
|
|
98
|
+
await user.click(screen.getByRole('button', { name: 'Explicit hide' }));
|
|
99
|
+
expect(screen.getByRole('button', { name: 'Explicit show' })).toBeVisible();
|
|
100
|
+
expect(screen.getByRole('textbox', { name: 'Explicit secret' })).toBeVisible();
|
|
101
|
+
writeText.mockRejectedValueOnce(new Error('Clipboard denied'));
|
|
102
|
+
await user.click(screen.getByRole('button', { name: 'Explicit copied' }));
|
|
103
|
+
expect(screen.getByRole('status')).toHaveTextContent('Explicit failure');
|
|
104
|
+
expect(screen.getByRole('button', { name: 'Explicit failure' })).toBeVisible();
|
|
105
|
+
expect(screen.getByRole('button', { name: 'Explicit close' })).toBeVisible();
|
|
106
|
+
});
|
|
107
|
+
it('uses a hand-written Spanish label-only announcement for multiple secrets', async () => {
|
|
108
|
+
const user = userEvent.setup();
|
|
109
|
+
Object.defineProperty(navigator, 'clipboard', {
|
|
110
|
+
value: { writeText: vi.fn().mockResolvedValue(undefined) },
|
|
111
|
+
configurable: true,
|
|
112
|
+
});
|
|
113
|
+
render(
|
|
114
|
+
<I18nProvider locale="es">
|
|
115
|
+
<CredentialDisclosureDialog
|
|
116
|
+
disclosure={storedDisclosure}
|
|
117
|
+
onClose={() => {}}
|
|
118
|
+
additionalSecrets={[{ id: 'other', label: 'Otro', value: 'synthetic_other' }]}
|
|
119
|
+
/>
|
|
120
|
+
</I18nProvider>,
|
|
121
|
+
);
|
|
122
|
+
await screen.findByRole('dialog');
|
|
123
|
+
await user.click(screen.getAllByRole('button', { name: es['credentialDisclosure.copy'] })[0]!);
|
|
124
|
+
expect(screen.getAllByRole('status')[0]).toHaveTextContent('Secreto: Copiado');
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it.each(['en', 'es'])('honours custom clipboard failure and group announcements under %s', async (locale) => {
|
|
128
|
+
const user = userEvent.setup();
|
|
129
|
+
const writeText = vi.fn().mockRejectedValueOnce(new Error('Clipboard denied')).mockResolvedValue(undefined);
|
|
130
|
+
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
|
|
131
|
+
const props = {
|
|
132
|
+
disclosure: storedDisclosure,
|
|
133
|
+
onClose: () => {},
|
|
134
|
+
additionalSecrets: [{ id: 'other', label: 'Other', value: 'synthetic_other' }],
|
|
135
|
+
};
|
|
136
|
+
const labels = {
|
|
137
|
+
failureAnnouncement: 'Custom failure',
|
|
138
|
+
copiedAnnouncementFor: (label: string, copied: string) => `Custom ${label} ${copied}`,
|
|
139
|
+
copiedLabel: 'Custom saved',
|
|
140
|
+
};
|
|
141
|
+
const { rerender } = render(
|
|
142
|
+
<I18nProvider locale={locale}>
|
|
143
|
+
<CredentialDisclosureDialog {...props} labels={labels} />
|
|
144
|
+
</I18nProvider>,
|
|
145
|
+
);
|
|
146
|
+
await screen.findByRole('dialog');
|
|
147
|
+
const copyName = locale === 'es' ? es['credentialDisclosure.copy'] : 'Copy secret';
|
|
148
|
+
await user.click(screen.getAllByRole('button', { name: copyName })[0]!);
|
|
149
|
+
expect(screen.getAllByRole('status')[0]).toHaveTextContent('Custom failure');
|
|
150
|
+
await user.click(screen.getByRole('button', { name: 'Custom failure' }));
|
|
151
|
+
expect(screen.getAllByRole('status')[0]).toHaveTextContent(
|
|
152
|
+
locale === 'es' ? 'Custom Secreto Custom saved' : 'Custom Secret Custom saved',
|
|
153
|
+
);
|
|
154
|
+
rerender(
|
|
155
|
+
<I18nProvider locale={locale}>
|
|
156
|
+
<CredentialDisclosureDialog
|
|
157
|
+
{...props}
|
|
158
|
+
labels={labels}
|
|
159
|
+
copiedAnnouncementFor={() => 'Explicit group announcement'}
|
|
160
|
+
/>
|
|
161
|
+
</I18nProvider>,
|
|
162
|
+
);
|
|
163
|
+
await user.click(screen.getByRole('button', { name: 'Custom saved' }));
|
|
164
|
+
expect(screen.getAllByRole('status')[0]).toHaveTextContent('Explicit group announcement');
|
|
165
|
+
});
|
|
@@ -26,7 +26,26 @@ export interface CredentialDisclosure {
|
|
|
26
26
|
secret: string;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
export interface CredentialDisclosureDialogLabels {
|
|
30
|
+
title: string;
|
|
31
|
+
description: string;
|
|
32
|
+
credentialIdLabel: string;
|
|
33
|
+
expiryLabel: string;
|
|
34
|
+
secretLabel: string;
|
|
35
|
+
showLabel: string;
|
|
36
|
+
hideLabel: string;
|
|
37
|
+
copyLabel: string;
|
|
38
|
+
copiedLabel: string;
|
|
39
|
+
successAnnouncement: string;
|
|
40
|
+
failureAnnouncement: string;
|
|
41
|
+
warningTitle: string;
|
|
42
|
+
warningText: string;
|
|
43
|
+
closeLabel: string;
|
|
44
|
+
copiedAnnouncementFor: (label: string, copied: string) => string;
|
|
45
|
+
}
|
|
46
|
+
|
|
29
47
|
export interface CredentialDisclosureDialogProps {
|
|
48
|
+
labels?: Partial<CredentialDisclosureDialogLabels>;
|
|
30
49
|
/** Additional masked values; ids must be unique, non-empty and not "secret". */
|
|
31
50
|
additionalSecrets?: readonly CredentialSecret[];
|
|
32
51
|
/** Mask a fresh primary secret; read at the start of each session. */
|
|
@@ -181,25 +200,29 @@ function DisclosureSession(props: OpeningProps & FocusScope & { returnFocus: ()
|
|
|
181
200
|
setOpen(false);
|
|
182
201
|
props.onClose();
|
|
183
202
|
};
|
|
184
|
-
const closeLabel = props.closeLabel ?? t('credentialDisclosure.close');
|
|
185
|
-
const title = props.title ?? t('credentialDisclosure.title');
|
|
186
|
-
const description = props.description ?? t('credentialDisclosure.description');
|
|
187
|
-
const secretLabel = props.secretLabel ?? t('credentialDisclosure.secret');
|
|
203
|
+
const closeLabel = props.closeLabel ?? props.labels?.closeLabel ?? t('credentialDisclosure.close');
|
|
204
|
+
const title = props.title ?? props.labels?.title ?? t('credentialDisclosure.title');
|
|
205
|
+
const description = props.description ?? props.labels?.description ?? t('credentialDisclosure.description');
|
|
206
|
+
const secretLabel = props.secretLabel ?? props.labels?.secretLabel ?? t('credentialDisclosure.secret');
|
|
188
207
|
const warning =
|
|
189
208
|
disclosure.variant === 'fresh' ? (
|
|
190
209
|
<Alert
|
|
191
210
|
role={presentation === 'inline' ? 'note' : 'alert'}
|
|
192
211
|
tone="warning"
|
|
193
|
-
title={props.warningTitle ?? t('credentialDisclosure.warningTitle')}
|
|
194
|
-
description={props.warningText ?? t('credentialDisclosure.warningText')}
|
|
212
|
+
title={props.warningTitle ?? props.labels?.warningTitle ?? t('credentialDisclosure.warningTitle')}
|
|
213
|
+
description={props.warningText ?? props.labels?.warningText ?? t('credentialDisclosure.warningText')}
|
|
195
214
|
/>
|
|
196
215
|
) : null;
|
|
197
216
|
const body = (
|
|
198
217
|
<>
|
|
199
218
|
<dl className="grid grid-cols-2 gap-2 text-sm">
|
|
200
|
-
<dt className="text-muted-foreground">
|
|
219
|
+
<dt className="text-muted-foreground">
|
|
220
|
+
{props.credentialIdLabel ?? props.labels?.credentialIdLabel ?? t('credentialDisclosure.credentialId')}
|
|
221
|
+
</dt>
|
|
201
222
|
<dd className="break-all font-mono">{disclosure.credentialId}</dd>
|
|
202
|
-
<dt className="text-muted-foreground">
|
|
223
|
+
<dt className="text-muted-foreground">
|
|
224
|
+
{props.expiryLabel ?? props.labels?.expiryLabel ?? t('credentialDisclosure.expiry')}
|
|
225
|
+
</dt>
|
|
203
226
|
<dd>{disclosure.expiresAt}</dd>
|
|
204
227
|
</dl>
|
|
205
228
|
<SecretCopy
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { CodeBlock, CopyButton, LiveAnnouncer, SecretField, useI18n } from '@gntik-ai/ui';
|
|
2
2
|
import { useState, type ReactNode } from 'react';
|
|
3
3
|
import type { CredentialSecret } from './types';
|
|
4
|
+
import type { CredentialDisclosureDialogLabels } from './CredentialDisclosureDialog';
|
|
4
5
|
|
|
5
6
|
interface SecretCopyOptions {
|
|
7
|
+
labels?: Partial<CredentialDisclosureDialogLabels>;
|
|
6
8
|
showLabel?: string;
|
|
7
9
|
hideLabel?: string;
|
|
8
10
|
copyLabel?: string;
|
|
@@ -29,7 +31,7 @@ export function SecretCopy({
|
|
|
29
31
|
}) {
|
|
30
32
|
const { t } = useI18n();
|
|
31
33
|
const [pending, setPending] = useState(false);
|
|
32
|
-
const copied = options.copiedLabel ?? t('credentialDisclosure.copied');
|
|
34
|
+
const copied = options.copiedLabel ?? options.labels?.copiedLabel ?? t('credentialDisclosure.copied');
|
|
33
35
|
const content = (
|
|
34
36
|
<LiveAnnouncer>
|
|
35
37
|
{warning}
|
|
@@ -39,8 +41,8 @@ export function SecretCopy({
|
|
|
39
41
|
value={secret.value}
|
|
40
42
|
copyable={false}
|
|
41
43
|
aria-label={secret.label}
|
|
42
|
-
showLabel={options.showLabel ?? t('credentialDisclosure.show')}
|
|
43
|
-
hideLabel={options.hideLabel ?? t('credentialDisclosure.hide')}
|
|
44
|
+
showLabel={options.showLabel ?? options.labels?.showLabel ?? t('credentialDisclosure.show')}
|
|
45
|
+
hideLabel={options.hideLabel ?? options.labels?.hideLabel ?? t('credentialDisclosure.hide')}
|
|
44
46
|
/>
|
|
45
47
|
) : (
|
|
46
48
|
<CodeBlock code={secret.value} copyable={false} label={secret.label} wrapToggle={false} defaultWrap />
|
|
@@ -53,15 +55,21 @@ export function SecretCopy({
|
|
|
53
55
|
}}
|
|
54
56
|
loading={grouped && pending}
|
|
55
57
|
display="label"
|
|
56
|
-
label={options.copyLabel ?? t('credentialDisclosure.copy')}
|
|
58
|
+
label={options.copyLabel ?? options.labels?.copyLabel ?? t('credentialDisclosure.copy')}
|
|
57
59
|
copiedLabel={copied}
|
|
58
60
|
announcement={
|
|
59
61
|
grouped
|
|
60
|
-
? (options.copiedAnnouncementFor?.(secret.label) ??
|
|
61
|
-
|
|
62
|
+
? (options.copiedAnnouncementFor?.(secret.label) ??
|
|
63
|
+
options.labels?.copiedAnnouncementFor?.(secret.label, copied) ??
|
|
64
|
+
t('credentialDisclosure.copiedFor', { label: secret.label, copied }))
|
|
65
|
+
: (options.successAnnouncement ?? options.labels?.successAnnouncement ?? t('credentialDisclosure.success'))
|
|
66
|
+
}
|
|
67
|
+
failureLabel={
|
|
68
|
+
options.failureAnnouncement ?? options.labels?.failureAnnouncement ?? t('credentialDisclosure.failure')
|
|
69
|
+
}
|
|
70
|
+
failureAnnouncement={
|
|
71
|
+
options.failureAnnouncement ?? options.labels?.failureAnnouncement ?? t('credentialDisclosure.failure')
|
|
62
72
|
}
|
|
63
|
-
failureLabel={options.failureAnnouncement ?? t('credentialDisclosure.failure')}
|
|
64
|
-
failureAnnouncement={options.failureAnnouncement ?? t('credentialDisclosure.failure')}
|
|
65
73
|
failurePoliteness="polite"
|
|
66
74
|
onCopy={() => {
|
|
67
75
|
if (grouped) setPending(false);
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
import type { BlockMeta } from '../../meta';
|
|
2
|
+
import type { CredentialDisclosureDialogLabels } from './CredentialDisclosureDialog';
|
|
2
3
|
|
|
3
4
|
export const meta: BlockMeta = {
|
|
4
5
|
name: 'Credential disclosure dialog',
|
|
5
6
|
family: 'forms',
|
|
6
7
|
status: 'beta',
|
|
7
8
|
description:
|
|
8
|
-
'Controlled disclosure for an existing credential. Set disclosure ({variant: stored | fresh, credentialId, expiresAt: caller-formatted ReactNode, secret}) only after a successful response; null renders nothing while pending or on failure. Clear disclosure, additionalSecrets and secret-bearing revealContent in onClose to drop every secret; a fresh secret requires a new successful response before showing it again. No pending/error state or internal secret retention. Stored values start masked; each null-to-value opening or changed credentialId/secret resets masking and copy feedback. Fresh values use a non-copyable CodeBlock with a kit CopyButton and a replacement warning, or a masked SecretField when maskFresh is set at session start. Optional additionalSecrets ({id, label, value}) are always masked and use independent toggles and serialized copy actions; ids must be non-empty, unique and not secret, with the first duplicate winning. Multi-secret groups announce label plus copiedLabel, or copiedAnnouncementFor(label); onCopy(id) never receives a value. Every secret and the optional revealContent slot have data-kit-redact. The session key includes additional ids and values. presentation is dialog by default or inline, fixed until the next opening: inline is a named section, never traps focus or handles Escape, and its warning is a non-live note. Surviving focus stays; removing the focused slot or session control focuses the popup or inline heading. Focused inline unmounts return focus through the same resolvers. Dismissed retained props stay hidden; clear and re-set or change a session value to reopen. Optional English defaults through en/es i18n for title, description, credentialIdLabel, expiryLabel, secretLabel, showLabel, hideLabel, copyLabel, copiedLabel, successAnnouncement, failureAnnouncement, warningTitle, warningText and closeLabel. Copy results are announced politely, including manual-selection fallback. Popup initial focus and focus trapping use Base UI; at close, resolveReturnFocus() is validated for connection, visibility, enabled state and focusability, then fallbackFocus(), then the original opener. Synthetic fixtures only; the default Stored preview is masked and the Fresh preview starts closed.',
|
|
9
|
+
'Controlled disclosure for an existing credential. Set disclosure ({variant: stored | fresh, credentialId, expiresAt: caller-formatted ReactNode, secret}) only after a successful response; null renders nothing while pending or on failure. Clear disclosure, additionalSecrets and secret-bearing revealContent in onClose to drop every secret; a fresh secret requires a new successful response before showing it again. No pending/error state or internal secret retention. Stored values start masked; each null-to-value opening or changed credentialId/secret resets masking and copy feedback. Fresh values use a non-copyable CodeBlock with a kit CopyButton and a replacement warning, or a masked SecretField when maskFresh is set at session start. Optional additionalSecrets ({id, label, value}) are always masked and use independent toggles and serialized copy actions; ids must be non-empty, unique and not secret, with the first duplicate winning. Multi-secret groups announce label plus copiedLabel, or copiedAnnouncementFor(label); onCopy(id) never receives a value. Every secret and the optional revealContent slot have data-kit-redact. The session key includes additional ids and values. presentation is dialog by default or inline, fixed until the next opening: inline is a named section, never traps focus or handles Escape, and its warning is a non-live note. Surviving focus stays; removing the focused slot or session control focuses the popup or inline heading. Focused inline unmounts return focus through the same resolvers. Dismissed retained props stay hidden; clear and re-set or change a session value to reopen. Optional English defaults through en/es i18n for title, description, credentialIdLabel, expiryLabel, secretLabel, showLabel, hideLabel, copyLabel, copiedLabel, successAnnouncement, failureAnnouncement, warningTitle, warningText and closeLabel. Copy results are announced politely, including manual-selection fallback. Popup initial focus and focus trapping use Base UI; at close, resolveReturnFocus() is validated for connection, visibility, enabled state and focusability, then fallbackFocus(), then the original opener. Synthetic fixtures only; the default Stored preview is masked and the Fresh preview starts closed. Optional labels?: Partial<CredentialDisclosureDialogLabels> 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=credential-disclosure-dialog--labels.',
|
|
10
|
+
labels: [
|
|
11
|
+
{ key: 'title', type: 'string', state: 'Default content and accessible names' },
|
|
12
|
+
{ key: 'description', type: 'string', state: 'Default content and accessible names' },
|
|
13
|
+
{ key: 'credentialIdLabel', type: 'string', state: 'Default content and accessible names' },
|
|
14
|
+
{ key: 'expiryLabel', type: 'string', state: 'Default content and accessible names' },
|
|
15
|
+
{ key: 'secretLabel', type: 'string', state: 'Default content and accessible names' },
|
|
16
|
+
{ key: 'showLabel', type: 'string', state: 'Default content and accessible names' },
|
|
17
|
+
{ key: 'hideLabel', type: 'string', state: 'Default content and accessible names' },
|
|
18
|
+
{ key: 'copyLabel', type: 'string', state: 'Default content and accessible names' },
|
|
19
|
+
{ key: 'copiedLabel', type: 'string', state: 'Async feedback' },
|
|
20
|
+
{ key: 'successAnnouncement', type: 'string', state: 'Async feedback' },
|
|
21
|
+
{ key: 'failureAnnouncement', type: 'string', state: 'Async feedback' },
|
|
22
|
+
{ key: 'warningTitle', type: 'string', state: 'Default content and accessible names' },
|
|
23
|
+
{ key: 'warningText', type: 'string', state: 'Default content and accessible names' },
|
|
24
|
+
{ key: 'closeLabel', type: 'string', state: 'Default content and accessible names' },
|
|
25
|
+
{ key: 'copiedAnnouncementFor', type: '(label: string, copied: string) => string', state: 'Async feedback' },
|
|
26
|
+
] satisfies Array<{ key: keyof CredentialDisclosureDialogLabels; type: string; state: string }>,
|
|
9
27
|
uses: ['Dialog', 'SecretField', 'CodeBlock', 'CopyButton', 'Alert', 'LiveAnnouncer', 'Button'],
|
|
10
28
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Button, I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { CredentialDisclosureDialog, type CredentialDisclosureDialogLabels } from '../CredentialDisclosureDialog';
|
|
4
|
+
import { storedDisclosure } from '../fixtures';
|
|
5
|
+
|
|
6
|
+
export default function Labels() {
|
|
7
|
+
const [spanish, setSpanish] = useState(false);
|
|
8
|
+
const [custom, setCustom] = useState(true);
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
10
|
+
const labels: Partial<CredentialDisclosureDialogLabels> = {
|
|
11
|
+
title: 'Connection credential',
|
|
12
|
+
description: 'Save this value securely.',
|
|
13
|
+
showLabel: 'Reveal credential',
|
|
14
|
+
hideLabel: 'Mask credential',
|
|
15
|
+
copyLabel: 'Copy credential',
|
|
16
|
+
closeLabel: 'Dismiss',
|
|
17
|
+
};
|
|
18
|
+
return (
|
|
19
|
+
<div className="grid gap-4">
|
|
20
|
+
<div className="flex flex-wrap gap-2">
|
|
21
|
+
<Button variant="secondary" aria-pressed={spanish} onClick={() => setSpanish(!spanish)}>
|
|
22
|
+
Spanish catalog
|
|
23
|
+
</Button>
|
|
24
|
+
<Button variant="secondary" aria-pressed={custom} onClick={() => setCustom(!custom)}>
|
|
25
|
+
Custom labels
|
|
26
|
+
</Button>
|
|
27
|
+
</div>
|
|
28
|
+
<I18nProvider locale={spanish ? 'es' : 'en'}>
|
|
29
|
+
<Button onClick={() => setOpen(true)}>Show credential</Button>
|
|
30
|
+
<CredentialDisclosureDialog
|
|
31
|
+
labels={custom ? labels : undefined}
|
|
32
|
+
disclosure={open ? storedDisclosure : null}
|
|
33
|
+
onClose={() => setOpen(false)}
|
|
34
|
+
/>
|
|
35
|
+
</I18nProvider>
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
}
|