@gntik-ai/blocks 0.10.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 +301 -40
- package/dist/index.js +1441 -297
- 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/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
- package/src/builders/LogViewer/LogViewer.tsx +29 -8
- package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
- package/src/builders/LogViewer/block.meta.ts +6 -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/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +38 -17
- package/src/data-display/DescriptionListCard/block.meta.ts +1 -1
- package/src/data-display/DescriptionListCard/examples/Spanish.tsx +7 -0
- package/src/feedback/EmptyStates/EmptyStates.tsx +32 -14
- package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
- package/src/feedback/EmptyStates/block.meta.ts +1 -1
- package/src/feedback/EmptyStates/examples/Spanish.tsx +7 -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.tsx +81 -18
- package/src/forms/FileUploadPanel/block.meta.ts +22 -1
- package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -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.options.test.tsx +34 -0
- package/src/page-chrome/PageHeader/PageHeader.tsx +7 -1
- package/src/page-chrome/PageHeader/block.meta.ts +1 -1
- package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
- 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/test/OptInDefaults.test.tsx +27 -0
- package/src/test/fixtures/opt-in-defaults.json +10 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Fragment, createElement, useCallback, useEffect, useEffectEvent, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { Activity, Archive, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, BarChart3, Bookmark, Bot, Boxes, Braces, Building2, CalendarCheck, CalendarDays, Camera, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, CircleAlert, CircleCheck, CircleHelp, CircleX, Clock, Cog, Columns3, Copy, CreditCard, Database, Download, ExternalLink, Eye, FileCode, FileText, FolderKanban, FolderPlus, Gauge, GitBranch, Globe, HardDrive, Home, Inbox, Info, KeyRound, Layers, LayoutGrid, List, ListFilter, Lock, LogOut, Mail, MailCheck, MapPin, Minus, Monitor, MousePointerClick, Pencil, Play, PlugZap, Plus, RefreshCw, Rocket, RotateCcw, RotateCw, Rows2, Rows3, Search, SearchX, Server, ServerCrash, Settings, ShieldCheck, SlidersHorizontal, Smartphone, Sparkles, Table2, Tablet, Trash2, TriangleAlert, Upload, User, UserMinus, UserPlus, Users, Workflow, Wrench, X, Zap } from "@gntik-ai/icons";
|
|
4
|
-
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Avatar, Badge, Breadcrumbs, Button, Card, CardAction, CardBody, CardDescription, CardHeader, CardTitle, Checkbox, CheckboxGroup, ClickableCard, CodeBlock, Collapsible, CollapsiblePanel, CollapsibleTrigger, CommandPalette, CommandPaletteTrigger, CopyButton, CursorPagination, DEFAULT_DATE_RANGE_PRESETS, DateRangePicker, DensityProvider, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EmptyState, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, IconButton, Input, Link, LiveAnnouncer, Logo, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MoreMenu, NavList, NotificationsPopover, OtpInput, Pagination, PasswordInput, Progress, Radio, RadioGroup, ResizablePanel, ResizablePanelGroup, ResizeHandle, SecretField, Select, SelectContent, SelectItem, SelectTrigger, SimpleSelect, Skeleton, Slider, Sparkline, Spinner, StatusDot, StatusTag, Switch, Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Textarea, ThemeCycleButton, ThemeSwitcher, Timestamp, Toggle, ToggleGroup, Token, TokenInput, Toolbar, ToolbarButton, ToolbarEnd, ToolbarInput, ToolbarSeparator, ToolbarStart, UserMenu, WizardLayout, WorkspaceSwitcher, buttonVariants, cn, foldText, localeHourCycle, localeWeekStart, matchRanges, nextSortDirection, tableVariants, toDate, useAnnounce, useDensity, useHasLiveAnnouncer, useI18n, useOptionalI18n } from "@gntik-ai/ui";
|
|
4
|
+
import { Accordion, AccordionItem, AccordionPanel, AccordionTrigger, Alert, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, Avatar, Badge, Breadcrumbs, Button, Card, CardAction, CardBody, CardDescription, CardHeader, CardTitle, Checkbox, CheckboxGroup, ClickableCard, CodeBlock, Collapsible, CollapsiblePanel, CollapsibleTrigger, CommandPalette, CommandPaletteTrigger, CopyButton, CursorPagination, DEFAULT_DATE_RANGE_PRESETS, DateRangePicker, DensityProvider, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EmptyState, Field, FieldDescription, FieldError, FieldLabel, Fieldset, FieldsetLegend, IconButton, Input, Link, LiveAnnouncer, Logo, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger, Meter, MoreMenu, NavList, NotificationsPopover, OtpInput, Pagination, PasswordInput, Progress, Radio, RadioGroup, ResizablePanel, ResizablePanelGroup, ResizeHandle, SecretField, Select, SelectContent, SelectItem, SelectTrigger, SimpleSelect, Skeleton, Slider, Sparkline, Spinner, StatusDot, StatusTag, Switch, Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, Tabs, TabsList, TabsPanel, TabsTab, Textarea, ThemeCycleButton, ThemeSwitcher, Timestamp, Toggle, ToggleGroup, Token, TokenInput, Toolbar, ToolbarButton, ToolbarEnd, ToolbarInput, ToolbarSeparator, ToolbarStart, UserMenu, WizardLayout, WorkspaceSwitcher, buttonVariants, cn, computeOffsets, en, foldText, localeHourCycle, localeWeekStart, matchRanges, nextSortDirection, tableVariants, toDate, useAnnounce, useDensity, useHasLiveAnnouncer, useI18n, useOptionalI18n, useVirtualWindow } from "@gntik-ai/ui";
|
|
5
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { AreaChart, BarChart, CHART_COLORS, ChartLocaleProvider, DonutChart, Heatmap, LineChart, chartFmt } from "@gntik-ai/charts";
|
|
7
7
|
import { FLOW_TONES, FlowCanvas, KIND_CHIP, KindGlyph, useFlowState } from "@gntik-ai/flow";
|
|
@@ -1601,6 +1601,12 @@ const meta$42 = {
|
|
|
1601
1601
|
]
|
|
1602
1602
|
};
|
|
1603
1603
|
//#endregion
|
|
1604
|
+
//#region src/forms/translated-content.tsx
|
|
1605
|
+
/** Keep caller-owned rich content in place while the catalog controls sentence order. */
|
|
1606
|
+
function translatedContent(message, values) {
|
|
1607
|
+
return message.split(/(\{\w+\})/).map((part, index) => /* @__PURE__ */ jsx(Fragment, { children: part.startsWith("{") && part.endsWith("}") ? values[part.slice(1, -1)] ?? part : part }, index));
|
|
1608
|
+
}
|
|
1609
|
+
//#endregion
|
|
1604
1610
|
//#region src/auth/shared.tsx
|
|
1605
1611
|
/** Eyebrow + title + supporting line used at the top of every auth form. */
|
|
1606
1612
|
function AuthHeader({ eyebrow, title, description, headingLevel: Heading = "h1", className }) {
|
|
@@ -1639,7 +1645,8 @@ function AuthDivider({ children }) {
|
|
|
1639
1645
|
}
|
|
1640
1646
|
const authFormClass = "w-full max-w-[392px]";
|
|
1641
1647
|
/** Loading + error state around an async submit handler. A rejection's message becomes the error. */
|
|
1642
|
-
function useAsyncSubmit(fallbackError
|
|
1648
|
+
function useAsyncSubmit(fallbackError) {
|
|
1649
|
+
const { t } = useI18n();
|
|
1643
1650
|
const [loading, setLoading] = useState(false);
|
|
1644
1651
|
const [error, setError] = useState(null);
|
|
1645
1652
|
const run = async (fn) => {
|
|
@@ -1651,7 +1658,7 @@ function useAsyncSubmit(fallbackError = "Something went wrong. Try again.") {
|
|
|
1651
1658
|
return true;
|
|
1652
1659
|
} catch (e) {
|
|
1653
1660
|
setLoading(false);
|
|
1654
|
-
setError(e instanceof Error ? e.message : fallbackError);
|
|
1661
|
+
setError(e instanceof Error ? e.message : fallbackError ?? t("authValidation.fallbackError"));
|
|
1655
1662
|
return false;
|
|
1656
1663
|
}
|
|
1657
1664
|
};
|
|
@@ -1663,32 +1670,39 @@ function useAsyncSubmit(fallbackError = "Something went wrong. Try again.") {
|
|
|
1663
1670
|
};
|
|
1664
1671
|
}
|
|
1665
1672
|
const EMAIL_RE$1 = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1666
|
-
function authIdentifierError(value, config, messages) {
|
|
1673
|
+
function authIdentifierError(value, config, messages, t, labels) {
|
|
1667
1674
|
const trimmed = value.trim();
|
|
1668
|
-
const fallback = config?.type === "text" ? "
|
|
1669
|
-
if (!trimmed) return messages?.identifierRequired ?? fallback;
|
|
1670
|
-
if (config?.minLength !== void 0 && trimmed.length < config.minLength) return messages?.identifierTooShort ?? messages?.identifierInvalid ?? fallback;
|
|
1671
|
-
if ((config?.type ?? "email") === "email" && !EMAIL_RE$1.test(trimmed) || config?.maxLength !== void 0 && trimmed.length > config.maxLength) return messages?.identifierInvalid ?? fallback;
|
|
1675
|
+
const fallback = config?.type === "text" ? t?.("authValidation.identifierInvalid") ?? en["authValidation.identifierInvalid"] : t?.("authValidation.emailInvalid") ?? en["authValidation.emailInvalid"];
|
|
1676
|
+
if (!trimmed) return messages?.identifierRequired ?? labels?.identifierRequired ?? fallback;
|
|
1677
|
+
if (config?.minLength !== void 0 && trimmed.length < config.minLength) return messages?.identifierTooShort ?? messages?.identifierInvalid ?? labels?.identifierTooShort ?? labels?.identifierInvalid ?? fallback;
|
|
1678
|
+
if ((config?.type ?? "email") === "email" && !EMAIL_RE$1.test(trimmed) || config?.maxLength !== void 0 && trimmed.length > config.maxLength) return messages?.identifierInvalid ?? labels?.identifierInvalid ?? fallback;
|
|
1672
1679
|
return null;
|
|
1673
1680
|
}
|
|
1674
|
-
function authSignUpFieldError(value, field) {
|
|
1681
|
+
function authSignUpFieldError(value, field, t, labels) {
|
|
1675
1682
|
const trimmed = value.trim();
|
|
1676
|
-
if (!trimmed) return field.required ? field.messages?.required ??
|
|
1677
|
-
if (field.type === "email" && !EMAIL_RE$1.test(trimmed)) return field.messages?.invalid ??
|
|
1683
|
+
if (!trimmed) return field.required ? field.messages?.required ?? labels?.fieldRequired?.(field.label) ?? t?.("authValidation.fieldRequired", { label: field.label }) ?? en["authValidation.fieldRequired"].replace("{label}", () => field.label) : null;
|
|
1684
|
+
if (field.type === "email" && !EMAIL_RE$1.test(trimmed)) return field.messages?.invalid ?? labels?.fieldInvalid ?? t?.("authValidation.emailInvalid") ?? en["authValidation.emailInvalid"];
|
|
1678
1685
|
return null;
|
|
1679
1686
|
}
|
|
1680
1687
|
//#endregion
|
|
1681
1688
|
//#region src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx
|
|
1682
1689
|
/** Request a reset link by email, then a "check your inbox" state with resend and a way back. */
|
|
1683
|
-
function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackId, "aria-describedby": describedBy, "aria-label":
|
|
1690
|
+
function ForgotPasswordForm({ labels, identifier, messages, ref, fieldInvalid, feedbackId, "aria-describedby": describedBy, "aria-label": ariaLabelProp, "aria-labelledby": labelledBy, onSubmit, error: errorProp, defaultEmail = "", defaultSent = false, signInHref = "#", onBackToSignIn, eyebrow: eyebrowProp, title: titleProp, description: descriptionProp, sentTitle: sentTitleProp, sentDescription, sentStatus: sentStatusProp, resendActions, headingLevel, className }) {
|
|
1691
|
+
const { t } = useI18n();
|
|
1692
|
+
const eyebrow = eyebrowProp === void 0 ? labels?.eyebrow ?? t("forgotPassword.eyebrow") : eyebrowProp;
|
|
1693
|
+
const title = titleProp === void 0 ? labels?.title ?? t("forgotPassword.title") : titleProp;
|
|
1694
|
+
const description = descriptionProp === void 0 ? labels?.description ?? t("forgotPassword.description") : descriptionProp;
|
|
1695
|
+
const sentTitle = sentTitleProp === void 0 ? labels?.sentTitle ?? t("forgotPassword.sentTitle") : sentTitleProp;
|
|
1696
|
+
const sentStatus = sentStatusProp === void 0 ? labels?.sentStatus ?? t("forgotPassword.sentStatus") : sentStatusProp;
|
|
1697
|
+
const ariaLabel = ariaLabelProp ?? labels?.formLabel ?? t("forgotPassword.formLabel");
|
|
1684
1698
|
const [email, setEmail] = useState(defaultEmail);
|
|
1685
1699
|
const [submitted, setSubmitted] = useState(false);
|
|
1686
1700
|
const [sent, setSent] = useState(defaultSent);
|
|
1687
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
1701
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t("forgotPassword.fallbackError"));
|
|
1688
1702
|
const alert = errorProp ?? error;
|
|
1689
1703
|
const identifierInput = useRef(null);
|
|
1690
1704
|
useImperativeHandle(ref, () => ({ focus: () => identifierInput.current?.focus() }), []);
|
|
1691
|
-
const identifierError = authIdentifierError(email, identifier, messages);
|
|
1705
|
+
const identifierError = authIdentifierError(email, identifier, messages, t, labels);
|
|
1692
1706
|
const emailInvalid = submitted && identifierError !== null;
|
|
1693
1707
|
const send = async () => {
|
|
1694
1708
|
if (await run(() => onSubmit?.(email.trim()))) setSent(true);
|
|
@@ -1705,7 +1719,7 @@ function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackI
|
|
|
1705
1719
|
size: 14,
|
|
1706
1720
|
"aria-hidden": true,
|
|
1707
1721
|
className: "rtl:-scale-x-100"
|
|
1708
|
-
}),
|
|
1722
|
+
}), labels?.backToSignIn ?? t("forgotPassword.backToSignIn")]
|
|
1709
1723
|
});
|
|
1710
1724
|
if (sent) return /* @__PURE__ */ jsxs("div", {
|
|
1711
1725
|
className: cn(authFormClass, className),
|
|
@@ -1721,15 +1735,10 @@ function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackI
|
|
|
1721
1735
|
eyebrow,
|
|
1722
1736
|
title: sentTitle,
|
|
1723
1737
|
headingLevel,
|
|
1724
|
-
description: sentDescription === void 0 ? /* @__PURE__ */
|
|
1725
|
-
"
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
className: "font-medium text-foreground",
|
|
1729
|
-
children: email.trim() || "that address"
|
|
1730
|
-
}),
|
|
1731
|
-
", you will receive a link to reset your password. It expires in 1 hour."
|
|
1732
|
-
] }) : sentDescription
|
|
1738
|
+
description: sentDescription === void 0 ? labels?.sentDescription?.(email.trim() || (labels?.addressFallback ?? t("forgotPassword.addressFallback"))) ?? translatedContent(t("forgotPassword.sentDescription"), { email: /* @__PURE__ */ jsx("span", {
|
|
1739
|
+
className: "font-medium text-foreground",
|
|
1740
|
+
children: email.trim() || (labels?.addressFallback ?? t("forgotPassword.addressFallback"))
|
|
1741
|
+
}) }) : sentDescription
|
|
1733
1742
|
}),
|
|
1734
1743
|
sentStatus != null && /* @__PURE__ */ jsx("div", {
|
|
1735
1744
|
role: "status",
|
|
@@ -1750,7 +1759,7 @@ function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackI
|
|
|
1750
1759
|
loading,
|
|
1751
1760
|
className: "w-full",
|
|
1752
1761
|
onClick: () => void send(),
|
|
1753
|
-
children:
|
|
1762
|
+
children: labels?.resend ?? t("forgotPassword.resend")
|
|
1754
1763
|
}), /* @__PURE__ */ jsx(Button, {
|
|
1755
1764
|
variant: "ghost",
|
|
1756
1765
|
size: "lg",
|
|
@@ -1759,7 +1768,7 @@ function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackI
|
|
|
1759
1768
|
setSent(false);
|
|
1760
1769
|
setSubmitted(false);
|
|
1761
1770
|
},
|
|
1762
|
-
children:
|
|
1771
|
+
children: labels?.changeEmail ?? t("forgotPassword.changeEmail")
|
|
1763
1772
|
})] }) : resendActions
|
|
1764
1773
|
}),
|
|
1765
1774
|
/* @__PURE__ */ jsx("p", {
|
|
@@ -1801,14 +1810,14 @@ function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackI
|
|
|
1801
1810
|
/* @__PURE__ */ jsxs(Field, {
|
|
1802
1811
|
invalid: emailInvalid || fieldInvalid?.identifier === true,
|
|
1803
1812
|
children: [
|
|
1804
|
-
/* @__PURE__ */ jsx(FieldLabel, { children: identifier?.label ?? "
|
|
1813
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: identifier?.label ?? labels?.identifierLabel ?? t("forgotPassword.identifierLabel") }),
|
|
1805
1814
|
/* @__PURE__ */ jsx(Input, {
|
|
1806
1815
|
ref: identifierInput,
|
|
1807
1816
|
"aria-describedby": fieldInvalid?.identifier ? feedbackId : void 0,
|
|
1808
1817
|
type: identifier?.type ?? "email",
|
|
1809
1818
|
leadingIcon: Mail,
|
|
1810
1819
|
autoComplete: identifier?.autoComplete ?? "email",
|
|
1811
|
-
placeholder: identifier?.placeholder ?? "
|
|
1820
|
+
placeholder: identifier?.placeholder ?? labels?.identifierPlaceholder ?? t("forgotPassword.identifierPlaceholder"),
|
|
1812
1821
|
minLength: identifier?.minLength,
|
|
1813
1822
|
maxLength: identifier?.maxLength,
|
|
1814
1823
|
value: email,
|
|
@@ -1831,7 +1840,7 @@ function ForgotPasswordForm({ identifier, messages, ref, fieldInvalid, feedbackI
|
|
|
1831
1840
|
size: "lg",
|
|
1832
1841
|
loading,
|
|
1833
1842
|
className: "mt-2 w-full",
|
|
1834
|
-
children:
|
|
1843
|
+
children: labels?.submit ?? t("forgotPassword.submit")
|
|
1835
1844
|
})
|
|
1836
1845
|
]
|
|
1837
1846
|
}),
|
|
@@ -1848,7 +1857,99 @@ const meta$29 = {
|
|
|
1848
1857
|
name: "Forgot password form",
|
|
1849
1858
|
family: "auth",
|
|
1850
1859
|
status: "stable",
|
|
1851
|
-
description: "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.",
|
|
1860
|
+
description: "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.",
|
|
1861
|
+
labels: [
|
|
1862
|
+
{
|
|
1863
|
+
key: "formLabel",
|
|
1864
|
+
type: "string",
|
|
1865
|
+
state: "Default content and accessible names"
|
|
1866
|
+
},
|
|
1867
|
+
{
|
|
1868
|
+
key: "eyebrow",
|
|
1869
|
+
type: "string",
|
|
1870
|
+
state: "Default content and accessible names"
|
|
1871
|
+
},
|
|
1872
|
+
{
|
|
1873
|
+
key: "title",
|
|
1874
|
+
type: "string",
|
|
1875
|
+
state: "Default content and accessible names"
|
|
1876
|
+
},
|
|
1877
|
+
{
|
|
1878
|
+
key: "description",
|
|
1879
|
+
type: "string",
|
|
1880
|
+
state: "Default content and accessible names"
|
|
1881
|
+
},
|
|
1882
|
+
{
|
|
1883
|
+
key: "sentTitle",
|
|
1884
|
+
type: "string",
|
|
1885
|
+
state: "Async feedback"
|
|
1886
|
+
},
|
|
1887
|
+
{
|
|
1888
|
+
key: "sentDescription",
|
|
1889
|
+
type: "(email: string) => ReactNode",
|
|
1890
|
+
state: "Async feedback"
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
key: "addressFallback",
|
|
1894
|
+
type: "string",
|
|
1895
|
+
state: "Async feedback"
|
|
1896
|
+
},
|
|
1897
|
+
{
|
|
1898
|
+
key: "sentStatus",
|
|
1899
|
+
type: "string",
|
|
1900
|
+
state: "Async feedback"
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
key: "fallbackError",
|
|
1904
|
+
type: "string",
|
|
1905
|
+
state: "Validation feedback"
|
|
1906
|
+
},
|
|
1907
|
+
{
|
|
1908
|
+
key: "backToSignIn",
|
|
1909
|
+
type: "string",
|
|
1910
|
+
state: "Default content and accessible names"
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
key: "resend",
|
|
1914
|
+
type: "string",
|
|
1915
|
+
state: "Default content and accessible names"
|
|
1916
|
+
},
|
|
1917
|
+
{
|
|
1918
|
+
key: "changeEmail",
|
|
1919
|
+
type: "string",
|
|
1920
|
+
state: "Default content and accessible names"
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
key: "identifierLabel",
|
|
1924
|
+
type: "string",
|
|
1925
|
+
state: "Default content and accessible names"
|
|
1926
|
+
},
|
|
1927
|
+
{
|
|
1928
|
+
key: "identifierPlaceholder",
|
|
1929
|
+
type: "string",
|
|
1930
|
+
state: "Default content and accessible names"
|
|
1931
|
+
},
|
|
1932
|
+
{
|
|
1933
|
+
key: "submit",
|
|
1934
|
+
type: "string",
|
|
1935
|
+
state: "Default content and accessible names"
|
|
1936
|
+
},
|
|
1937
|
+
{
|
|
1938
|
+
key: "identifierRequired",
|
|
1939
|
+
type: "string",
|
|
1940
|
+
state: "Validation feedback"
|
|
1941
|
+
},
|
|
1942
|
+
{
|
|
1943
|
+
key: "identifierInvalid",
|
|
1944
|
+
type: "string",
|
|
1945
|
+
state: "Validation feedback"
|
|
1946
|
+
},
|
|
1947
|
+
{
|
|
1948
|
+
key: "identifierTooShort",
|
|
1949
|
+
type: "string",
|
|
1950
|
+
state: "Validation feedback"
|
|
1951
|
+
}
|
|
1952
|
+
],
|
|
1852
1953
|
uses: [
|
|
1853
1954
|
"Field",
|
|
1854
1955
|
"FieldLabel",
|
|
@@ -1866,7 +1967,10 @@ const meta$29 = {
|
|
|
1866
1967
|
* Second-factor step: a one-time code (auto-submits when complete), a switch to a backup code,
|
|
1867
1968
|
* and a resend button with a countdown.
|
|
1868
1969
|
*/
|
|
1869
|
-
function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown, length = 6, destination, error: errorProp, loading: loadingProp, onCancel, eyebrow
|
|
1970
|
+
function MfaChallenge({ labels, onVerify, onResend, resendCooldown = 30, initialCooldown, length = 6, destination, error: errorProp, loading: loadingProp, onCancel, eyebrow: eyebrowProp, title: titleProp, className }) {
|
|
1971
|
+
const { t } = useI18n();
|
|
1972
|
+
const eyebrow = eyebrowProp === void 0 ? labels?.eyebrow ?? t("mfaChallenge.eyebrow") : eyebrowProp;
|
|
1973
|
+
const title = titleProp === void 0 ? labels?.title ?? t("mfaChallenge.title") : titleProp;
|
|
1870
1974
|
const [method, setMethod] = useState("code");
|
|
1871
1975
|
const [code, setCode] = useState("");
|
|
1872
1976
|
const [backup, setBackup] = useState("");
|
|
@@ -1875,7 +1979,7 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
1875
1979
|
const [now, setNow] = useState(start);
|
|
1876
1980
|
const [resendAt, setResendAt] = useState(() => start + (initialCooldown ?? resendCooldown) * 1e3);
|
|
1877
1981
|
const [resent, setResent] = useState(false);
|
|
1878
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
1982
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t("mfaChallenge.fallbackError"));
|
|
1879
1983
|
const busy = loadingProp ?? loading;
|
|
1880
1984
|
const alert = errorProp ?? error;
|
|
1881
1985
|
const remaining = Math.max(0, Math.ceil((resendAt - now) / 1e3));
|
|
@@ -1892,24 +1996,27 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
1892
1996
|
run(() => onVerify?.(v, method));
|
|
1893
1997
|
};
|
|
1894
1998
|
const resend = async () => {
|
|
1895
|
-
const
|
|
1896
|
-
setNow(
|
|
1897
|
-
setResendAt(
|
|
1999
|
+
const time = Date.now();
|
|
2000
|
+
setNow(time);
|
|
2001
|
+
setResendAt(time + resendCooldown * 1e3);
|
|
1898
2002
|
setResent(true);
|
|
1899
2003
|
await onResend?.();
|
|
1900
2004
|
};
|
|
1901
|
-
const description = method === "backup" ?
|
|
2005
|
+
const description = method === "backup" ? labels?.backupDescription ?? t("mfaChallenge.backupDescription") : destination ? labels?.destinationDescription?.(length, destination) ?? t("mfaChallenge.destinationDescription", {
|
|
2006
|
+
length,
|
|
2007
|
+
destination
|
|
2008
|
+
}) : labels?.description?.(length) ?? t("mfaChallenge.description", { length });
|
|
1902
2009
|
return /* @__PURE__ */ jsxs("div", {
|
|
1903
2010
|
className: cn(authFormClass, className),
|
|
1904
2011
|
children: [
|
|
1905
2012
|
/* @__PURE__ */ jsx(AuthHeader, {
|
|
1906
2013
|
eyebrow,
|
|
1907
|
-
title: method === "backup" ?
|
|
2014
|
+
title: method === "backup" ? labels?.backupTitle ?? t("mfaChallenge.backupTitle") : title,
|
|
1908
2015
|
description
|
|
1909
2016
|
}),
|
|
1910
2017
|
/* @__PURE__ */ jsxs("form", {
|
|
1911
2018
|
noValidate: true,
|
|
1912
|
-
"aria-label":
|
|
2019
|
+
"aria-label": labels?.formLabel ?? t("mfaChallenge.formLabel"),
|
|
1913
2020
|
className: "flex flex-col gap-5",
|
|
1914
2021
|
onSubmit: (e) => {
|
|
1915
2022
|
e.preventDefault();
|
|
@@ -1923,7 +2030,7 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
1923
2030
|
method === "code" ? /* @__PURE__ */ jsxs(Field, {
|
|
1924
2031
|
invalid,
|
|
1925
2032
|
children: [
|
|
1926
|
-
/* @__PURE__ */ jsx(FieldLabel, { children:
|
|
2033
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.codeLabel ?? t("mfaChallenge.codeLabel") }),
|
|
1927
2034
|
/* @__PURE__ */ jsx(OtpInput, {
|
|
1928
2035
|
length,
|
|
1929
2036
|
value: code,
|
|
@@ -1933,31 +2040,27 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
1933
2040
|
groupSize: length / 2,
|
|
1934
2041
|
disabled: busy
|
|
1935
2042
|
}),
|
|
1936
|
-
/* @__PURE__ */
|
|
2043
|
+
/* @__PURE__ */ jsx(FieldError, {
|
|
1937
2044
|
match: invalid,
|
|
1938
|
-
children:
|
|
1939
|
-
"Enter all ",
|
|
1940
|
-
length,
|
|
1941
|
-
" digits."
|
|
1942
|
-
]
|
|
2045
|
+
children: labels?.codeRequired?.(length) ?? t("mfaChallenge.codeRequired", { length })
|
|
1943
2046
|
})
|
|
1944
2047
|
]
|
|
1945
2048
|
}) : /* @__PURE__ */ jsxs(Field, {
|
|
1946
2049
|
invalid,
|
|
1947
2050
|
children: [
|
|
1948
|
-
/* @__PURE__ */ jsx(FieldLabel, { children:
|
|
2051
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.backupLabel ?? t("mfaChallenge.backupLabel") }),
|
|
1949
2052
|
/* @__PURE__ */ jsx(Input, {
|
|
1950
2053
|
value: backup,
|
|
1951
2054
|
onValueChange: setBackup,
|
|
1952
|
-
placeholder: "
|
|
2055
|
+
placeholder: labels?.backupPlaceholder ?? t("mfaChallenge.backupPlaceholder"),
|
|
1953
2056
|
autoComplete: "one-time-code",
|
|
1954
2057
|
spellCheck: false,
|
|
1955
2058
|
inputClassName: "font-mono tracking-wider"
|
|
1956
2059
|
}),
|
|
1957
|
-
/* @__PURE__ */ jsx(FieldDescription, { children:
|
|
2060
|
+
/* @__PURE__ */ jsx(FieldDescription, { children: labels?.backupHint ?? t("mfaChallenge.backupHint") }),
|
|
1958
2061
|
/* @__PURE__ */ jsx(FieldError, {
|
|
1959
2062
|
match: invalid,
|
|
1960
|
-
children:
|
|
2063
|
+
children: labels?.backupRequired ?? t("mfaChallenge.backupRequired")
|
|
1961
2064
|
})
|
|
1962
2065
|
]
|
|
1963
2066
|
}),
|
|
@@ -1966,7 +2069,7 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
1966
2069
|
size: "lg",
|
|
1967
2070
|
loading: busy,
|
|
1968
2071
|
className: "w-full",
|
|
1969
|
-
children: "
|
|
2072
|
+
children: labels?.submit ?? t("mfaChallenge.submit")
|
|
1970
2073
|
})
|
|
1971
2074
|
]
|
|
1972
2075
|
}),
|
|
@@ -1980,19 +2083,19 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
1980
2083
|
setMethod(method === "code" ? "backup" : "code");
|
|
1981
2084
|
setSubmitted(false);
|
|
1982
2085
|
},
|
|
1983
|
-
children: method === "code" ?
|
|
2086
|
+
children: method === "code" ? labels?.backupTitle ?? t("mfaChallenge.backupTitle") : labels?.useCode ?? t("mfaChallenge.useCode")
|
|
1984
2087
|
}), method === "code" && onResend !== void 0 && /* @__PURE__ */ jsx(Button, {
|
|
1985
2088
|
variant: "ghost",
|
|
1986
2089
|
size: "sm",
|
|
1987
2090
|
disabled: remaining > 0,
|
|
1988
2091
|
onClick: () => void resend(),
|
|
1989
|
-
children: remaining > 0 ?
|
|
2092
|
+
children: remaining > 0 ? labels?.resendIn?.(remaining) ?? t("mfaChallenge.resendIn", { remaining }) : labels?.resend ?? t("mfaChallenge.resend")
|
|
1990
2093
|
})]
|
|
1991
2094
|
}),
|
|
1992
2095
|
/* @__PURE__ */ jsx("span", {
|
|
1993
2096
|
role: "status",
|
|
1994
2097
|
className: "sr-only",
|
|
1995
|
-
children: resent ?
|
|
2098
|
+
children: resent ? labels?.resent ?? t("mfaChallenge.resent") : ""
|
|
1996
2099
|
}),
|
|
1997
2100
|
onCancel && /* @__PURE__ */ jsx("p", {
|
|
1998
2101
|
className: "mt-6 text-center",
|
|
@@ -2000,7 +2103,7 @@ function MfaChallenge({ onVerify, onResend, resendCooldown = 30, initialCooldown
|
|
|
2000
2103
|
variant: "ghost",
|
|
2001
2104
|
size: "sm",
|
|
2002
2105
|
onClick: onCancel,
|
|
2003
|
-
children:
|
|
2106
|
+
children: labels?.backToSignIn ?? t("mfaChallenge.backToSignIn")
|
|
2004
2107
|
})
|
|
2005
2108
|
})
|
|
2006
2109
|
]
|
|
@@ -2012,7 +2115,109 @@ const meta$41 = {
|
|
|
2012
2115
|
name: "MFA challenge",
|
|
2013
2116
|
family: "auth",
|
|
2014
2117
|
status: "stable",
|
|
2015
|
-
description: "Second-factor step with a one-time code (auto-submit), a backup-code mode and resend with a countdown.",
|
|
2118
|
+
description: "Second-factor step with a one-time code (auto-submit), a backup-code mode and resend with a countdown. Optional labels?: Partial<MfaChallengeLabels> 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=mfa-challenge--labels.",
|
|
2119
|
+
labels: [
|
|
2120
|
+
{
|
|
2121
|
+
key: "eyebrow",
|
|
2122
|
+
type: "string",
|
|
2123
|
+
state: "Default content and accessible names"
|
|
2124
|
+
},
|
|
2125
|
+
{
|
|
2126
|
+
key: "title",
|
|
2127
|
+
type: "string",
|
|
2128
|
+
state: "Default content and accessible names"
|
|
2129
|
+
},
|
|
2130
|
+
{
|
|
2131
|
+
key: "backupTitle",
|
|
2132
|
+
type: "string",
|
|
2133
|
+
state: "Default content and accessible names"
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
key: "backupDescription",
|
|
2137
|
+
type: "string",
|
|
2138
|
+
state: "Default content and accessible names"
|
|
2139
|
+
},
|
|
2140
|
+
{
|
|
2141
|
+
key: "destinationDescription",
|
|
2142
|
+
type: "(length: number, destination: string) => string",
|
|
2143
|
+
state: "Default content and accessible names"
|
|
2144
|
+
},
|
|
2145
|
+
{
|
|
2146
|
+
key: "description",
|
|
2147
|
+
type: "(length: number) => string",
|
|
2148
|
+
state: "Default content and accessible names"
|
|
2149
|
+
},
|
|
2150
|
+
{
|
|
2151
|
+
key: "formLabel",
|
|
2152
|
+
type: "string",
|
|
2153
|
+
state: "Default content and accessible names"
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
key: "codeLabel",
|
|
2157
|
+
type: "string",
|
|
2158
|
+
state: "Default content and accessible names"
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
key: "codeRequired",
|
|
2162
|
+
type: "(length: number) => string",
|
|
2163
|
+
state: "Validation feedback"
|
|
2164
|
+
},
|
|
2165
|
+
{
|
|
2166
|
+
key: "backupLabel",
|
|
2167
|
+
type: "string",
|
|
2168
|
+
state: "Default content and accessible names"
|
|
2169
|
+
},
|
|
2170
|
+
{
|
|
2171
|
+
key: "backupPlaceholder",
|
|
2172
|
+
type: "string",
|
|
2173
|
+
state: "Default content and accessible names"
|
|
2174
|
+
},
|
|
2175
|
+
{
|
|
2176
|
+
key: "backupHint",
|
|
2177
|
+
type: "string",
|
|
2178
|
+
state: "Default content and accessible names"
|
|
2179
|
+
},
|
|
2180
|
+
{
|
|
2181
|
+
key: "backupRequired",
|
|
2182
|
+
type: "string",
|
|
2183
|
+
state: "Validation feedback"
|
|
2184
|
+
},
|
|
2185
|
+
{
|
|
2186
|
+
key: "submit",
|
|
2187
|
+
type: "string",
|
|
2188
|
+
state: "Default content and accessible names"
|
|
2189
|
+
},
|
|
2190
|
+
{
|
|
2191
|
+
key: "useCode",
|
|
2192
|
+
type: "string",
|
|
2193
|
+
state: "Default content and accessible names"
|
|
2194
|
+
},
|
|
2195
|
+
{
|
|
2196
|
+
key: "resendIn",
|
|
2197
|
+
type: "(remaining: number) => string",
|
|
2198
|
+
state: "Default content and accessible names"
|
|
2199
|
+
},
|
|
2200
|
+
{
|
|
2201
|
+
key: "resend",
|
|
2202
|
+
type: "string",
|
|
2203
|
+
state: "Default content and accessible names"
|
|
2204
|
+
},
|
|
2205
|
+
{
|
|
2206
|
+
key: "resent",
|
|
2207
|
+
type: "string",
|
|
2208
|
+
state: "Async feedback"
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
key: "backToSignIn",
|
|
2212
|
+
type: "string",
|
|
2213
|
+
state: "Default content and accessible names"
|
|
2214
|
+
},
|
|
2215
|
+
{
|
|
2216
|
+
key: "fallbackError",
|
|
2217
|
+
type: "string",
|
|
2218
|
+
state: "Validation feedback"
|
|
2219
|
+
}
|
|
2220
|
+
],
|
|
2016
2221
|
uses: [
|
|
2017
2222
|
"OtpInput",
|
|
2018
2223
|
"Field",
|
|
@@ -2024,13 +2229,15 @@ const meta$41 = {
|
|
|
2024
2229
|
//#endregion
|
|
2025
2230
|
//#region src/auth/ResetPasswordForm/ResetPasswordForm.tsx
|
|
2026
2231
|
/** New password + confirmation with length and mismatch validation, then a success state. */
|
|
2027
|
-
function ResetPasswordForm({ onSubmit, error: errorProp, minPasswordLength = 8, onContinue, eyebrow
|
|
2232
|
+
function ResetPasswordForm({ labels, onSubmit, error: errorProp, minPasswordLength = 8, onContinue, eyebrow: eyebrowProp, className }) {
|
|
2233
|
+
const { t } = useI18n();
|
|
2234
|
+
const eyebrow = eyebrowProp === void 0 ? labels?.eyebrow ?? t("resetPassword.eyebrow") : eyebrowProp;
|
|
2028
2235
|
const [password, setPassword] = useState("");
|
|
2029
2236
|
const [confirm, setConfirm] = useState("");
|
|
2030
2237
|
const [confirmTouched, setConfirmTouched] = useState(false);
|
|
2031
2238
|
const [submitted, setSubmitted] = useState(false);
|
|
2032
2239
|
const [done, setDone] = useState(false);
|
|
2033
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
2240
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t("resetPassword.fallbackError"));
|
|
2034
2241
|
const alert = errorProp ?? error;
|
|
2035
2242
|
const tooShort = password.length < minPasswordLength;
|
|
2036
2243
|
const mismatch = confirm !== password;
|
|
@@ -2048,19 +2255,19 @@ function ResetPasswordForm({ onSubmit, error: errorProp, minPasswordLength = 8,
|
|
|
2048
2255
|
}),
|
|
2049
2256
|
/* @__PURE__ */ jsx(AuthHeader, {
|
|
2050
2257
|
eyebrow,
|
|
2051
|
-
title:
|
|
2052
|
-
description:
|
|
2258
|
+
title: labels?.successTitle ?? t("resetPassword.successTitle"),
|
|
2259
|
+
description: labels?.successDescription ?? t("resetPassword.successDescription")
|
|
2053
2260
|
}),
|
|
2054
2261
|
/* @__PURE__ */ jsx("div", {
|
|
2055
2262
|
role: "status",
|
|
2056
2263
|
className: "sr-only",
|
|
2057
|
-
children: "
|
|
2264
|
+
children: labels?.successStatus ?? t("resetPassword.successStatus")
|
|
2058
2265
|
}),
|
|
2059
2266
|
/* @__PURE__ */ jsx(Button, {
|
|
2060
2267
|
size: "lg",
|
|
2061
2268
|
className: "w-full",
|
|
2062
2269
|
onClick: onContinue,
|
|
2063
|
-
children:
|
|
2270
|
+
children: labels?.continue ?? t("resetPassword.continue")
|
|
2064
2271
|
})
|
|
2065
2272
|
]
|
|
2066
2273
|
});
|
|
@@ -2068,11 +2275,11 @@ function ResetPasswordForm({ onSubmit, error: errorProp, minPasswordLength = 8,
|
|
|
2068
2275
|
className: cn(authFormClass, className),
|
|
2069
2276
|
children: [/* @__PURE__ */ jsx(AuthHeader, {
|
|
2070
2277
|
eyebrow,
|
|
2071
|
-
title:
|
|
2072
|
-
description:
|
|
2278
|
+
title: labels?.title ?? t("resetPassword.title"),
|
|
2279
|
+
description: labels?.description?.(minPasswordLength) ?? t("resetPassword.description", { minimum: minPasswordLength })
|
|
2073
2280
|
}), /* @__PURE__ */ jsxs("form", {
|
|
2074
2281
|
noValidate: true,
|
|
2075
|
-
"aria-label":
|
|
2282
|
+
"aria-label": labels?.title ?? t("resetPassword.title"),
|
|
2076
2283
|
className: "flex flex-col gap-4",
|
|
2077
2284
|
onSubmit: (e) => {
|
|
2078
2285
|
e.preventDefault();
|
|
@@ -2088,27 +2295,23 @@ function ResetPasswordForm({ onSubmit, error: errorProp, minPasswordLength = 8,
|
|
|
2088
2295
|
/* @__PURE__ */ jsxs(Field, {
|
|
2089
2296
|
invalid: passwordInvalid,
|
|
2090
2297
|
children: [
|
|
2091
|
-
/* @__PURE__ */ jsx(FieldLabel, { children:
|
|
2298
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.newPassword ?? t("resetPassword.newPassword") }),
|
|
2092
2299
|
/* @__PURE__ */ jsx(PasswordInput, {
|
|
2093
2300
|
showStrength: true,
|
|
2094
2301
|
value: password,
|
|
2095
2302
|
onValueChange: setPassword,
|
|
2096
2303
|
required: true
|
|
2097
2304
|
}),
|
|
2098
|
-
/* @__PURE__ */
|
|
2305
|
+
/* @__PURE__ */ jsx(FieldError, {
|
|
2099
2306
|
match: passwordInvalid,
|
|
2100
|
-
children:
|
|
2101
|
-
"Use at least ",
|
|
2102
|
-
minPasswordLength,
|
|
2103
|
-
" characters."
|
|
2104
|
-
]
|
|
2307
|
+
children: labels?.passwordTooShort?.(minPasswordLength) ?? t("resetPassword.passwordTooShort", { minimum: minPasswordLength })
|
|
2105
2308
|
})
|
|
2106
2309
|
]
|
|
2107
2310
|
}),
|
|
2108
2311
|
/* @__PURE__ */ jsxs(Field, {
|
|
2109
2312
|
invalid: confirmInvalid,
|
|
2110
2313
|
children: [
|
|
2111
|
-
/* @__PURE__ */ jsx(FieldLabel, { children:
|
|
2314
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.confirmPassword ?? t("resetPassword.confirmPassword") }),
|
|
2112
2315
|
/* @__PURE__ */ jsx(PasswordInput, {
|
|
2113
2316
|
autoComplete: "new-password",
|
|
2114
2317
|
value: confirm,
|
|
@@ -2118,7 +2321,7 @@ function ResetPasswordForm({ onSubmit, error: errorProp, minPasswordLength = 8,
|
|
|
2118
2321
|
}),
|
|
2119
2322
|
/* @__PURE__ */ jsx(FieldError, {
|
|
2120
2323
|
match: confirmInvalid,
|
|
2121
|
-
children:
|
|
2324
|
+
children: labels?.passwordMismatch ?? t("resetPassword.passwordMismatch")
|
|
2122
2325
|
})
|
|
2123
2326
|
]
|
|
2124
2327
|
}),
|
|
@@ -2127,7 +2330,7 @@ function ResetPasswordForm({ onSubmit, error: errorProp, minPasswordLength = 8,
|
|
|
2127
2330
|
size: "lg",
|
|
2128
2331
|
loading,
|
|
2129
2332
|
className: "mt-2 w-full",
|
|
2130
|
-
children:
|
|
2333
|
+
children: labels?.submit ?? t("resetPassword.submit")
|
|
2131
2334
|
})
|
|
2132
2335
|
]
|
|
2133
2336
|
})]
|
|
@@ -2139,7 +2342,74 @@ const meta$56 = {
|
|
|
2139
2342
|
name: "Reset password form",
|
|
2140
2343
|
family: "auth",
|
|
2141
2344
|
status: "stable",
|
|
2142
|
-
description: "New password with a strength meter and a confirmation field with mismatch validation, then a success state.",
|
|
2345
|
+
description: "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.",
|
|
2346
|
+
labels: [
|
|
2347
|
+
{
|
|
2348
|
+
key: "eyebrow",
|
|
2349
|
+
type: "string",
|
|
2350
|
+
state: "Default content and accessible names"
|
|
2351
|
+
},
|
|
2352
|
+
{
|
|
2353
|
+
key: "title",
|
|
2354
|
+
type: "string",
|
|
2355
|
+
state: "Default content and accessible names"
|
|
2356
|
+
},
|
|
2357
|
+
{
|
|
2358
|
+
key: "description",
|
|
2359
|
+
type: "(minimum: number) => string",
|
|
2360
|
+
state: "Default content and accessible names"
|
|
2361
|
+
},
|
|
2362
|
+
{
|
|
2363
|
+
key: "newPassword",
|
|
2364
|
+
type: "string",
|
|
2365
|
+
state: "Default content and accessible names"
|
|
2366
|
+
},
|
|
2367
|
+
{
|
|
2368
|
+
key: "confirmPassword",
|
|
2369
|
+
type: "string",
|
|
2370
|
+
state: "Default content and accessible names"
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
key: "passwordTooShort",
|
|
2374
|
+
type: "(minimum: number) => string",
|
|
2375
|
+
state: "Validation feedback"
|
|
2376
|
+
},
|
|
2377
|
+
{
|
|
2378
|
+
key: "passwordMismatch",
|
|
2379
|
+
type: "string",
|
|
2380
|
+
state: "Validation feedback"
|
|
2381
|
+
},
|
|
2382
|
+
{
|
|
2383
|
+
key: "submit",
|
|
2384
|
+
type: "string",
|
|
2385
|
+
state: "Default content and accessible names"
|
|
2386
|
+
},
|
|
2387
|
+
{
|
|
2388
|
+
key: "successTitle",
|
|
2389
|
+
type: "string",
|
|
2390
|
+
state: "Async feedback"
|
|
2391
|
+
},
|
|
2392
|
+
{
|
|
2393
|
+
key: "successDescription",
|
|
2394
|
+
type: "string",
|
|
2395
|
+
state: "Async feedback"
|
|
2396
|
+
},
|
|
2397
|
+
{
|
|
2398
|
+
key: "successStatus",
|
|
2399
|
+
type: "string",
|
|
2400
|
+
state: "Async feedback"
|
|
2401
|
+
},
|
|
2402
|
+
{
|
|
2403
|
+
key: "continue",
|
|
2404
|
+
type: "string",
|
|
2405
|
+
state: "Default content and accessible names"
|
|
2406
|
+
},
|
|
2407
|
+
{
|
|
2408
|
+
key: "fallbackError",
|
|
2409
|
+
type: "string",
|
|
2410
|
+
state: "Validation feedback"
|
|
2411
|
+
}
|
|
2412
|
+
],
|
|
2143
2413
|
uses: [
|
|
2144
2414
|
"Field",
|
|
2145
2415
|
"PasswordInput",
|
|
@@ -2169,7 +2439,9 @@ const ssoProviders = [
|
|
|
2169
2439
|
//#endregion
|
|
2170
2440
|
//#region src/auth/SsoButtons/SsoButtons.tsx
|
|
2171
2441
|
/** Neutral single-sign-on buttons: text labels and lucide icons, no brand colours or logos. */
|
|
2172
|
-
function SsoButtons({ providers = ssoProviders, onSelect, loadingId = null, disabled = false, layout = "stack", label
|
|
2442
|
+
function SsoButtons({ labels, providers = ssoProviders, onSelect, loadingId = null, disabled = false, layout = "stack", label: labelProp, className }) {
|
|
2443
|
+
const { t } = useI18n();
|
|
2444
|
+
const label = labelProp ?? labels?.label ?? t("ssoButtons.label");
|
|
2173
2445
|
return /* @__PURE__ */ jsx("div", {
|
|
2174
2446
|
role: "group",
|
|
2175
2447
|
"aria-label": label,
|
|
@@ -2193,18 +2465,23 @@ const linkHandler = (fn) => fn ? (e) => {
|
|
|
2193
2465
|
fn();
|
|
2194
2466
|
} : void 0;
|
|
2195
2467
|
/** Email + password sign-in with remember me, forgot-password link, SSO slot, error alert and loading. */
|
|
2196
|
-
function SignInForm({ identifier, messages, passwordHelp, passwordHelpId, ref, fieldInvalid, feedbackId, "aria-describedby": describedBy, "aria-label":
|
|
2468
|
+
function SignInForm({ labels, identifier, messages, passwordHelp, passwordHelpId, ref, fieldInvalid, feedbackId, "aria-describedby": describedBy, "aria-label": ariaLabelProp, "aria-labelledby": labelledBy, onSubmit, error: errorProp, loading: loadingProp, defaultEmail = "", forgotPasswordHref = "#", onForgotPassword, signUpHref = "#", onSignUp, signUpPrompt, sso = /* @__PURE__ */ jsx(SsoButtons, {}), eyebrow: eyebrowProp, title: titleProp, description: descriptionProp, headingLevel, className }) {
|
|
2469
|
+
const { t } = useI18n();
|
|
2470
|
+
const eyebrow = eyebrowProp === void 0 ? labels?.eyebrow ?? t("signIn.eyebrow") : eyebrowProp;
|
|
2471
|
+
const title = titleProp === void 0 ? labels?.title ?? t("signIn.title") : titleProp;
|
|
2472
|
+
const description = descriptionProp === void 0 ? labels?.description ?? t("signIn.description") : descriptionProp;
|
|
2473
|
+
const ariaLabel = ariaLabelProp ?? labels?.formLabel ?? t("signIn.formLabel");
|
|
2197
2474
|
const [email, setEmail] = useState(defaultEmail);
|
|
2198
2475
|
const [password, setPassword] = useState("");
|
|
2199
2476
|
const [remember, setRemember] = useState(true);
|
|
2200
2477
|
const [submitted, setSubmitted] = useState(false);
|
|
2201
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
2478
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t("signIn.fallbackError"));
|
|
2202
2479
|
const busy = loadingProp ?? loading;
|
|
2203
2480
|
const alert = errorProp ?? error;
|
|
2204
2481
|
const identifierInput = useRef(null);
|
|
2205
2482
|
const passwordInput = useRef(null);
|
|
2206
2483
|
useImperativeHandle(ref, () => ({ focus: (field) => (field === "password" ? passwordInput : identifierInput).current?.focus() }), []);
|
|
2207
|
-
const identifierError = authIdentifierError(email, identifier, messages);
|
|
2484
|
+
const identifierError = authIdentifierError(email, identifier, messages, t, labels);
|
|
2208
2485
|
const emailInvalid = submitted && identifierError !== null;
|
|
2209
2486
|
const passwordInvalid = submitted && password === "";
|
|
2210
2487
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -2249,14 +2526,14 @@ function SignInForm({ identifier, messages, passwordHelp, passwordHelpId, ref, f
|
|
|
2249
2526
|
/* @__PURE__ */ jsxs(Field, {
|
|
2250
2527
|
invalid: emailInvalid || fieldInvalid?.identifier === true,
|
|
2251
2528
|
children: [
|
|
2252
|
-
/* @__PURE__ */ jsx(FieldLabel, { children: identifier?.label ?? "
|
|
2529
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: identifier?.label ?? labels?.identifierLabel ?? t("signIn.identifierLabel") }),
|
|
2253
2530
|
/* @__PURE__ */ jsx(Input, {
|
|
2254
2531
|
ref: identifierInput,
|
|
2255
2532
|
"aria-describedby": fieldInvalid?.identifier ? feedbackId : void 0,
|
|
2256
2533
|
type: identifier?.type ?? "email",
|
|
2257
2534
|
leadingIcon: Mail,
|
|
2258
2535
|
autoComplete: identifier?.autoComplete ?? "email",
|
|
2259
|
-
placeholder: identifier?.placeholder ?? "
|
|
2536
|
+
placeholder: identifier?.placeholder ?? labels?.identifierPlaceholder ?? t("signIn.identifierPlaceholder"),
|
|
2260
2537
|
minLength: identifier?.minLength,
|
|
2261
2538
|
maxLength: identifier?.maxLength,
|
|
2262
2539
|
value: email,
|
|
@@ -2279,11 +2556,11 @@ function SignInForm({ identifier, messages, passwordHelp, passwordHelpId, ref, f
|
|
|
2279
2556
|
children: [
|
|
2280
2557
|
/* @__PURE__ */ jsxs("div", {
|
|
2281
2558
|
className: "flex items-center justify-between gap-3",
|
|
2282
|
-
children: [/* @__PURE__ */ jsx(FieldLabel, { children: "
|
|
2559
|
+
children: [/* @__PURE__ */ jsx(FieldLabel, { children: labels?.password ?? t("signIn.password") }), /* @__PURE__ */ jsx(Link, {
|
|
2283
2560
|
href: forgotPasswordHref,
|
|
2284
2561
|
onClick: linkHandler(onForgotPassword),
|
|
2285
2562
|
className: "text-[12.5px]",
|
|
2286
|
-
children:
|
|
2563
|
+
children: labels?.forgotPassword ?? t("signIn.forgotPassword")
|
|
2287
2564
|
})]
|
|
2288
2565
|
}),
|
|
2289
2566
|
/* @__PURE__ */ jsx(PasswordInput, {
|
|
@@ -2301,12 +2578,12 @@ function SignInForm({ identifier, messages, passwordHelp, passwordHelpId, ref, f
|
|
|
2301
2578
|
/* @__PURE__ */ jsx(FieldError, {
|
|
2302
2579
|
role: "alert",
|
|
2303
2580
|
match: passwordInvalid,
|
|
2304
|
-
children: messages?.passwordRequired ??
|
|
2581
|
+
children: messages?.passwordRequired ?? labels?.passwordRequired ?? t("signIn.passwordRequired")
|
|
2305
2582
|
})
|
|
2306
2583
|
]
|
|
2307
2584
|
}),
|
|
2308
2585
|
/* @__PURE__ */ jsx(Checkbox, {
|
|
2309
|
-
label:
|
|
2586
|
+
label: labels?.remember ?? t("signIn.remember"),
|
|
2310
2587
|
checked: remember,
|
|
2311
2588
|
onCheckedChange: setRemember
|
|
2312
2589
|
}),
|
|
@@ -2315,20 +2592,20 @@ function SignInForm({ identifier, messages, passwordHelp, passwordHelpId, ref, f
|
|
|
2315
2592
|
size: "lg",
|
|
2316
2593
|
loading: busy,
|
|
2317
2594
|
className: "mt-2 w-full",
|
|
2318
|
-
children:
|
|
2595
|
+
children: labels?.submit ?? t("signIn.submit")
|
|
2319
2596
|
})
|
|
2320
2597
|
]
|
|
2321
2598
|
}),
|
|
2322
|
-
sso != null && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AuthDivider, { children:
|
|
2599
|
+
sso != null && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AuthDivider, { children: labels?.divider ?? t("signIn.divider") }), sso] }),
|
|
2323
2600
|
signUpPrompt !== null && /* @__PURE__ */ jsx("p", {
|
|
2324
2601
|
className: "mt-7 text-center text-[13px] text-muted-foreground",
|
|
2325
2602
|
children: signUpPrompt === void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2326
|
-
|
|
2603
|
+
labels?.signUpPrompt ?? t("signIn.signUpPrompt"),
|
|
2327
2604
|
" ",
|
|
2328
2605
|
/* @__PURE__ */ jsx(Link, {
|
|
2329
2606
|
href: signUpHref,
|
|
2330
2607
|
onClick: linkHandler(onSignUp),
|
|
2331
|
-
children:
|
|
2608
|
+
children: labels?.signUp ?? t("signIn.signUp")
|
|
2332
2609
|
})
|
|
2333
2610
|
] }) : signUpPrompt
|
|
2334
2611
|
})
|
|
@@ -2341,7 +2618,99 @@ const meta$61 = {
|
|
|
2341
2618
|
name: "Sign-in form",
|
|
2342
2619
|
family: "auth",
|
|
2343
2620
|
status: "stable",
|
|
2344
|
-
description: "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.",
|
|
2621
|
+
description: "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.",
|
|
2622
|
+
labels: [
|
|
2623
|
+
{
|
|
2624
|
+
key: "eyebrow",
|
|
2625
|
+
type: "string",
|
|
2626
|
+
state: "Default content and accessible names"
|
|
2627
|
+
},
|
|
2628
|
+
{
|
|
2629
|
+
key: "title",
|
|
2630
|
+
type: "string",
|
|
2631
|
+
state: "Default content and accessible names"
|
|
2632
|
+
},
|
|
2633
|
+
{
|
|
2634
|
+
key: "description",
|
|
2635
|
+
type: "string",
|
|
2636
|
+
state: "Default content and accessible names"
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
key: "formLabel",
|
|
2640
|
+
type: "string",
|
|
2641
|
+
state: "Default content and accessible names"
|
|
2642
|
+
},
|
|
2643
|
+
{
|
|
2644
|
+
key: "identifierLabel",
|
|
2645
|
+
type: "string",
|
|
2646
|
+
state: "Default content and accessible names"
|
|
2647
|
+
},
|
|
2648
|
+
{
|
|
2649
|
+
key: "identifierPlaceholder",
|
|
2650
|
+
type: "string",
|
|
2651
|
+
state: "Default content and accessible names"
|
|
2652
|
+
},
|
|
2653
|
+
{
|
|
2654
|
+
key: "password",
|
|
2655
|
+
type: "string",
|
|
2656
|
+
state: "Default content and accessible names"
|
|
2657
|
+
},
|
|
2658
|
+
{
|
|
2659
|
+
key: "forgotPassword",
|
|
2660
|
+
type: "string",
|
|
2661
|
+
state: "Default content and accessible names"
|
|
2662
|
+
},
|
|
2663
|
+
{
|
|
2664
|
+
key: "passwordRequired",
|
|
2665
|
+
type: "string",
|
|
2666
|
+
state: "Validation feedback"
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
key: "remember",
|
|
2670
|
+
type: "string",
|
|
2671
|
+
state: "Default content and accessible names"
|
|
2672
|
+
},
|
|
2673
|
+
{
|
|
2674
|
+
key: "submit",
|
|
2675
|
+
type: "string",
|
|
2676
|
+
state: "Default content and accessible names"
|
|
2677
|
+
},
|
|
2678
|
+
{
|
|
2679
|
+
key: "divider",
|
|
2680
|
+
type: "string",
|
|
2681
|
+
state: "Default content and accessible names"
|
|
2682
|
+
},
|
|
2683
|
+
{
|
|
2684
|
+
key: "signUpPrompt",
|
|
2685
|
+
type: "string",
|
|
2686
|
+
state: "Default content and accessible names"
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
key: "signUp",
|
|
2690
|
+
type: "string",
|
|
2691
|
+
state: "Default content and accessible names"
|
|
2692
|
+
},
|
|
2693
|
+
{
|
|
2694
|
+
key: "fallbackError",
|
|
2695
|
+
type: "string",
|
|
2696
|
+
state: "Validation feedback"
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
key: "identifierRequired",
|
|
2700
|
+
type: "string",
|
|
2701
|
+
state: "Validation feedback"
|
|
2702
|
+
},
|
|
2703
|
+
{
|
|
2704
|
+
key: "identifierInvalid",
|
|
2705
|
+
type: "string",
|
|
2706
|
+
state: "Validation feedback"
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
key: "identifierTooShort",
|
|
2710
|
+
type: "string",
|
|
2711
|
+
state: "Validation feedback"
|
|
2712
|
+
}
|
|
2713
|
+
],
|
|
2345
2714
|
uses: [
|
|
2346
2715
|
"Field",
|
|
2347
2716
|
"FieldLabel",
|
|
@@ -2387,14 +2756,15 @@ const focusField = (fieldId) => {
|
|
|
2387
2756
|
* Error summary for long forms: lists every problem with a link that moves focus to the field.
|
|
2388
2757
|
* After a failed submit it takes focus, so screen readers announce it.
|
|
2389
2758
|
*/
|
|
2390
|
-
function ValidationSummary({ errors = validationIssues, submitCount = 0, title, className }) {
|
|
2759
|
+
function ValidationSummary({ labels, errors = validationIssues, submitCount = 0, title, className }) {
|
|
2760
|
+
const { t } = useI18n();
|
|
2391
2761
|
const ref = useRef(null);
|
|
2392
2762
|
const hasErrors = errors.length > 0;
|
|
2393
2763
|
useEffect(() => {
|
|
2394
2764
|
if (submitCount > 0 && hasErrors) ref.current?.focus();
|
|
2395
2765
|
}, [submitCount, hasErrors]);
|
|
2396
2766
|
if (!hasErrors) return null;
|
|
2397
|
-
const heading = title ??
|
|
2767
|
+
const heading = title ?? labels?.title?.(errors.length) ?? t("validationSummary.title", { count: errors.length });
|
|
2398
2768
|
return /* @__PURE__ */ jsx(Alert, {
|
|
2399
2769
|
ref,
|
|
2400
2770
|
tabIndex: -1,
|
|
@@ -2420,7 +2790,11 @@ function ValidationSummary({ errors = validationIssues, submitCount = 0, title,
|
|
|
2420
2790
|
//#endregion
|
|
2421
2791
|
//#region src/auth/SignUpForm/SignUpForm.tsx
|
|
2422
2792
|
/** Account creation: name, work email, password with a strength meter and a required terms checkbox. */
|
|
2423
|
-
function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSubmit, error: errorProp, loading: loadingProp, minPasswordLength = 8, passwordHelp, terms: termsProp, termsHref = "#", privacyHref = "#", signInHref = "#", onSignIn, sso = /* @__PURE__ */ jsx(SsoButtons, {}), eyebrow
|
|
2793
|
+
function SignUpForm({ labels, fields, messages, unavailable, policyLoading = false, onSubmit, error: errorProp, loading: loadingProp, minPasswordLength = 8, passwordHelp, terms: termsProp, termsHref = "#", privacyHref = "#", signInHref = "#", onSignIn, sso = /* @__PURE__ */ jsx(SsoButtons, {}), eyebrow: eyebrowProp, title: titleProp, description: descriptionProp, className }) {
|
|
2794
|
+
const { t } = useI18n();
|
|
2795
|
+
const eyebrow = eyebrowProp === void 0 ? labels?.eyebrow ?? t("signUp.eyebrow") : eyebrowProp;
|
|
2796
|
+
const title = titleProp === void 0 ? labels?.title ?? t("signUp.title") : titleProp;
|
|
2797
|
+
const description = descriptionProp === void 0 ? labels?.description ?? t("signUp.description") : descriptionProp;
|
|
2424
2798
|
const termsErrorId = useId();
|
|
2425
2799
|
const fieldPrefix = useId();
|
|
2426
2800
|
const passwordId = `${fieldPrefix}-password`;
|
|
@@ -2429,7 +2803,7 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2429
2803
|
const [submitCount, setSubmitCount] = useState(0);
|
|
2430
2804
|
const fieldValue = (id) => Object.hasOwn(fieldValues, id) ? fieldValues[id] ?? "" : "";
|
|
2431
2805
|
const configuredErrors = (fields ?? []).flatMap((field) => {
|
|
2432
|
-
const message = authSignUpFieldError(fieldValue(field.id), field);
|
|
2806
|
+
const message = authSignUpFieldError(fieldValue(field.id), field, t, labels);
|
|
2433
2807
|
return message ? [{
|
|
2434
2808
|
fieldId: `${fieldPrefix}-field-${field.id}`,
|
|
2435
2809
|
label: field.label,
|
|
@@ -2441,25 +2815,33 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2441
2815
|
const [password, setPassword] = useState("");
|
|
2442
2816
|
const [terms, setTerms] = useState(false);
|
|
2443
2817
|
const [submitted, setSubmitted] = useState(false);
|
|
2444
|
-
const { loading, error, run } = useAsyncSubmit(
|
|
2818
|
+
const { loading, error, run } = useAsyncSubmit(labels?.fallbackError ?? t("signUp.fallbackError"));
|
|
2445
2819
|
const busy = loadingProp ?? loading;
|
|
2446
2820
|
const alert = errorProp ?? error;
|
|
2447
2821
|
const nameInvalid = submitted && name.trim() === "";
|
|
2448
2822
|
const emailInvalid = submitted && !EMAIL_RE$1.test(email.trim());
|
|
2449
2823
|
const passwordInvalid = (submitted || fields !== void 0 && password.length > 0) && password.length < minPasswordLength;
|
|
2450
2824
|
const termsInvalid = submitted && termsProp !== false && !terms;
|
|
2451
|
-
const passwordError = messages?.passwordTooShort?.(minPasswordLength) ??
|
|
2452
|
-
const termsError = messages?.termsRequired ??
|
|
2825
|
+
const passwordError = messages?.passwordTooShort?.(minPasswordLength) ?? labels?.passwordTooShort?.(minPasswordLength) ?? t("signUp.passwordTooShort", { minimum: minPasswordLength });
|
|
2826
|
+
const termsError = messages?.termsRequired ?? labels?.termsRequired ?? t("signUp.termsRequired");
|
|
2827
|
+
const termsLink = /* @__PURE__ */ jsx(Link, {
|
|
2828
|
+
href: termsHref,
|
|
2829
|
+
children: labels?.terms ?? t("signUp.terms")
|
|
2830
|
+
});
|
|
2831
|
+
const privacyLink = /* @__PURE__ */ jsx(Link, {
|
|
2832
|
+
href: privacyHref,
|
|
2833
|
+
children: labels?.privacy ?? t("signUp.privacy")
|
|
2834
|
+
});
|
|
2453
2835
|
const summaryErrors = [
|
|
2454
2836
|
...configuredErrors,
|
|
2455
2837
|
...password.length < minPasswordLength ? [{
|
|
2456
2838
|
fieldId: passwordId,
|
|
2457
|
-
label: "
|
|
2839
|
+
label: labels?.password ?? t("signUp.password"),
|
|
2458
2840
|
message: passwordError
|
|
2459
2841
|
}] : [],
|
|
2460
2842
|
...termsProp !== false && !terms ? [{
|
|
2461
2843
|
fieldId: termsId,
|
|
2462
|
-
label: "
|
|
2844
|
+
label: labels?.terms ?? t("signUp.terms"),
|
|
2463
2845
|
message: termsError
|
|
2464
2846
|
}] : []
|
|
2465
2847
|
];
|
|
@@ -2478,7 +2860,7 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2478
2860
|
/* @__PURE__ */ jsx("span", {
|
|
2479
2861
|
role: "status",
|
|
2480
2862
|
className: "sr-only",
|
|
2481
|
-
children:
|
|
2863
|
+
children: labels?.policyLoading ?? t("signUp.policyLoading")
|
|
2482
2864
|
}),
|
|
2483
2865
|
/* @__PURE__ */ jsx(Skeleton, {
|
|
2484
2866
|
"aria-hidden": true,
|
|
@@ -2512,7 +2894,7 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2512
2894
|
}),
|
|
2513
2895
|
/* @__PURE__ */ jsxs("form", {
|
|
2514
2896
|
noValidate: true,
|
|
2515
|
-
"aria-label":
|
|
2897
|
+
"aria-label": labels?.submit ?? t("signUp.submit"),
|
|
2516
2898
|
className: "flex flex-col gap-4",
|
|
2517
2899
|
onSubmit: (e) => {
|
|
2518
2900
|
e.preventDefault();
|
|
@@ -2547,7 +2929,7 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2547
2929
|
className: "bg-background"
|
|
2548
2930
|
}),
|
|
2549
2931
|
fields !== void 0 ? fields.map((field) => {
|
|
2550
|
-
const message = authSignUpFieldError(fieldValue(field.id), field);
|
|
2932
|
+
const message = authSignUpFieldError(fieldValue(field.id), field, t, labels);
|
|
2551
2933
|
const invalid = submitted && message !== null;
|
|
2552
2934
|
return /* @__PURE__ */ jsxs(Field, {
|
|
2553
2935
|
invalid,
|
|
@@ -2575,43 +2957,43 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2575
2957
|
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(Field, {
|
|
2576
2958
|
invalid: nameInvalid,
|
|
2577
2959
|
children: [
|
|
2578
|
-
/* @__PURE__ */ jsx(FieldLabel, { children: "
|
|
2960
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.name ?? t("signUp.name") }),
|
|
2579
2961
|
/* @__PURE__ */ jsx(Input, {
|
|
2580
2962
|
leadingIcon: User,
|
|
2581
2963
|
autoComplete: "name",
|
|
2582
|
-
placeholder:
|
|
2964
|
+
placeholder: labels?.namePlaceholder ?? t("signUp.namePlaceholder"),
|
|
2583
2965
|
value: name,
|
|
2584
2966
|
onValueChange: setName,
|
|
2585
2967
|
required: true
|
|
2586
2968
|
}),
|
|
2587
2969
|
/* @__PURE__ */ jsx(FieldError, {
|
|
2588
2970
|
match: nameInvalid,
|
|
2589
|
-
children:
|
|
2971
|
+
children: labels?.nameRequired ?? t("signUp.nameRequired")
|
|
2590
2972
|
})
|
|
2591
2973
|
]
|
|
2592
2974
|
}), /* @__PURE__ */ jsxs(Field, {
|
|
2593
2975
|
invalid: emailInvalid,
|
|
2594
2976
|
children: [
|
|
2595
|
-
/* @__PURE__ */ jsx(FieldLabel, { children: "
|
|
2977
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.email ?? t("signUp.email") }),
|
|
2596
2978
|
/* @__PURE__ */ jsx(Input, {
|
|
2597
2979
|
type: "email",
|
|
2598
2980
|
leadingIcon: Mail,
|
|
2599
2981
|
autoComplete: "email",
|
|
2600
|
-
placeholder: "
|
|
2982
|
+
placeholder: labels?.emailPlaceholder ?? t("signUp.emailPlaceholder"),
|
|
2601
2983
|
value: email,
|
|
2602
2984
|
onValueChange: setEmail,
|
|
2603
2985
|
required: true
|
|
2604
2986
|
}),
|
|
2605
2987
|
/* @__PURE__ */ jsx(FieldError, {
|
|
2606
2988
|
match: emailInvalid,
|
|
2607
|
-
children:
|
|
2989
|
+
children: labels?.emailInvalid ?? t("authValidation.emailInvalid")
|
|
2608
2990
|
})
|
|
2609
2991
|
]
|
|
2610
2992
|
})] }),
|
|
2611
2993
|
/* @__PURE__ */ jsxs(Field, {
|
|
2612
2994
|
invalid: passwordInvalid,
|
|
2613
2995
|
children: [
|
|
2614
|
-
/* @__PURE__ */ jsx(FieldLabel, { children: "
|
|
2996
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.password ?? t("signUp.password") }),
|
|
2615
2997
|
/* @__PURE__ */ jsx(PasswordInput, {
|
|
2616
2998
|
id: fields !== void 0 ? passwordId : void 0,
|
|
2617
2999
|
showStrength: true,
|
|
@@ -2633,19 +3015,10 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2633
3015
|
onCheckedChange: setTerms,
|
|
2634
3016
|
"aria-invalid": termsInvalid || void 0,
|
|
2635
3017
|
"aria-describedby": termsInvalid ? termsErrorId : void 0,
|
|
2636
|
-
label:
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
children: "Terms"
|
|
2641
|
-
}),
|
|
2642
|
-
" and ",
|
|
2643
|
-
/* @__PURE__ */ jsx(Link, {
|
|
2644
|
-
href: privacyHref,
|
|
2645
|
-
children: "Privacy Policy"
|
|
2646
|
-
}),
|
|
2647
|
-
"."
|
|
2648
|
-
] })
|
|
3018
|
+
label: labels?.termsConsent?.(termsLink, privacyLink) ?? translatedContent(t("signUp.termsConsent"), {
|
|
3019
|
+
terms: termsLink,
|
|
3020
|
+
privacy: privacyLink
|
|
3021
|
+
})
|
|
2649
3022
|
}), termsInvalid && /* @__PURE__ */ jsx("p", {
|
|
2650
3023
|
id: termsErrorId,
|
|
2651
3024
|
className: "mt-1.5 text-[12.5px] text-destructive-text",
|
|
@@ -2656,15 +3029,15 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2656
3029
|
size: "lg",
|
|
2657
3030
|
loading: busy,
|
|
2658
3031
|
className: "mt-2 w-full",
|
|
2659
|
-
children:
|
|
3032
|
+
children: labels?.submit ?? t("signUp.submit")
|
|
2660
3033
|
})
|
|
2661
3034
|
]
|
|
2662
3035
|
}),
|
|
2663
|
-
sso != null && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AuthDivider, { children:
|
|
3036
|
+
sso != null && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(AuthDivider, { children: labels?.divider ?? t("signUp.divider") }), sso] }),
|
|
2664
3037
|
/* @__PURE__ */ jsxs("p", {
|
|
2665
3038
|
className: "mt-7 text-center text-[13px] text-muted-foreground",
|
|
2666
3039
|
children: [
|
|
2667
|
-
|
|
3040
|
+
labels?.signInPrompt ?? t("signUp.signInPrompt"),
|
|
2668
3041
|
" ",
|
|
2669
3042
|
/* @__PURE__ */ jsx(Link, {
|
|
2670
3043
|
href: signInHref,
|
|
@@ -2672,7 +3045,7 @@ function SignUpForm({ fields, messages, unavailable, policyLoading = false, onSu
|
|
|
2672
3045
|
e.preventDefault();
|
|
2673
3046
|
onSignIn();
|
|
2674
3047
|
} : void 0,
|
|
2675
|
-
children:
|
|
3048
|
+
children: labels?.signIn ?? t("signUp.signIn")
|
|
2676
3049
|
})
|
|
2677
3050
|
]
|
|
2678
3051
|
})
|
|
@@ -2685,7 +3058,124 @@ const meta$62 = {
|
|
|
2685
3058
|
name: "Sign-up form",
|
|
2686
3059
|
family: "auth",
|
|
2687
3060
|
status: "stable",
|
|
2688
|
-
description: "Account creation with default name/email fields or ordered text/email fields (values.fields), a password strength meter and required consent (terms=false opts out). minPasswordLength defaults to 8 and drives length validation and the insufficient-length meter; optional passwordHelp can receive the minimum. Configured fields support help, required, autoComplete and validation messages, with a linked validation summary on invalid submit. policyLoading renders skeletons without a form; unavailable replaces the form with consumer title, message and optional action. loading remains submitting; error is form-level feedback. Examples: custom-fields, no-terms, unavailable, loading, submitting and error.",
|
|
3061
|
+
description: "Account creation with default name/email fields or ordered text/email fields (values.fields), a password strength meter and required consent (terms=false opts out). minPasswordLength defaults to 8 and drives length validation and the insufficient-length meter; optional passwordHelp can receive the minimum. Configured fields support help, required, autoComplete and validation messages, with a linked validation summary on invalid submit. policyLoading renders skeletons without a form; unavailable replaces the form with consumer title, message and optional action. loading remains submitting; error is form-level feedback. Examples: custom-fields, no-terms, unavailable, loading, submitting and error. Optional labels?: Partial<SignUpFormLabels> 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-up-form--labels.",
|
|
3062
|
+
labels: [
|
|
3063
|
+
{
|
|
3064
|
+
key: "eyebrow",
|
|
3065
|
+
type: "string",
|
|
3066
|
+
state: "Default content and accessible names"
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
key: "title",
|
|
3070
|
+
type: "string",
|
|
3071
|
+
state: "Default content and accessible names"
|
|
3072
|
+
},
|
|
3073
|
+
{
|
|
3074
|
+
key: "description",
|
|
3075
|
+
type: "string",
|
|
3076
|
+
state: "Default content and accessible names"
|
|
3077
|
+
},
|
|
3078
|
+
{
|
|
3079
|
+
key: "name",
|
|
3080
|
+
type: "string",
|
|
3081
|
+
state: "Default content and accessible names"
|
|
3082
|
+
},
|
|
3083
|
+
{
|
|
3084
|
+
key: "namePlaceholder",
|
|
3085
|
+
type: "string",
|
|
3086
|
+
state: "Default content and accessible names"
|
|
3087
|
+
},
|
|
3088
|
+
{
|
|
3089
|
+
key: "nameRequired",
|
|
3090
|
+
type: "string",
|
|
3091
|
+
state: "Validation feedback"
|
|
3092
|
+
},
|
|
3093
|
+
{
|
|
3094
|
+
key: "email",
|
|
3095
|
+
type: "string",
|
|
3096
|
+
state: "Default content and accessible names"
|
|
3097
|
+
},
|
|
3098
|
+
{
|
|
3099
|
+
key: "emailPlaceholder",
|
|
3100
|
+
type: "string",
|
|
3101
|
+
state: "Default content and accessible names"
|
|
3102
|
+
},
|
|
3103
|
+
{
|
|
3104
|
+
key: "password",
|
|
3105
|
+
type: "string",
|
|
3106
|
+
state: "Default content and accessible names"
|
|
3107
|
+
},
|
|
3108
|
+
{
|
|
3109
|
+
key: "passwordTooShort",
|
|
3110
|
+
type: "(minimum: number) => string",
|
|
3111
|
+
state: "Validation feedback"
|
|
3112
|
+
},
|
|
3113
|
+
{
|
|
3114
|
+
key: "termsRequired",
|
|
3115
|
+
type: "string",
|
|
3116
|
+
state: "Validation feedback"
|
|
3117
|
+
},
|
|
3118
|
+
{
|
|
3119
|
+
key: "terms",
|
|
3120
|
+
type: "string",
|
|
3121
|
+
state: "Default content and accessible names"
|
|
3122
|
+
},
|
|
3123
|
+
{
|
|
3124
|
+
key: "privacy",
|
|
3125
|
+
type: "string",
|
|
3126
|
+
state: "Default content and accessible names"
|
|
3127
|
+
},
|
|
3128
|
+
{
|
|
3129
|
+
key: "termsConsent",
|
|
3130
|
+
type: "(terms: ReactNode, privacy: ReactNode) => ReactNode",
|
|
3131
|
+
state: "Async feedback"
|
|
3132
|
+
},
|
|
3133
|
+
{
|
|
3134
|
+
key: "submit",
|
|
3135
|
+
type: "string",
|
|
3136
|
+
state: "Default content and accessible names"
|
|
3137
|
+
},
|
|
3138
|
+
{
|
|
3139
|
+
key: "divider",
|
|
3140
|
+
type: "string",
|
|
3141
|
+
state: "Default content and accessible names"
|
|
3142
|
+
},
|
|
3143
|
+
{
|
|
3144
|
+
key: "signInPrompt",
|
|
3145
|
+
type: "string",
|
|
3146
|
+
state: "Default content and accessible names"
|
|
3147
|
+
},
|
|
3148
|
+
{
|
|
3149
|
+
key: "signIn",
|
|
3150
|
+
type: "string",
|
|
3151
|
+
state: "Default content and accessible names"
|
|
3152
|
+
},
|
|
3153
|
+
{
|
|
3154
|
+
key: "policyLoading",
|
|
3155
|
+
type: "string",
|
|
3156
|
+
state: "Async feedback"
|
|
3157
|
+
},
|
|
3158
|
+
{
|
|
3159
|
+
key: "fallbackError",
|
|
3160
|
+
type: "string",
|
|
3161
|
+
state: "Validation feedback"
|
|
3162
|
+
},
|
|
3163
|
+
{
|
|
3164
|
+
key: "emailInvalid",
|
|
3165
|
+
type: "string",
|
|
3166
|
+
state: "Validation feedback"
|
|
3167
|
+
},
|
|
3168
|
+
{
|
|
3169
|
+
key: "fieldRequired",
|
|
3170
|
+
type: "(label: string) => string",
|
|
3171
|
+
state: "Validation feedback"
|
|
3172
|
+
},
|
|
3173
|
+
{
|
|
3174
|
+
key: "fieldInvalid",
|
|
3175
|
+
type: "string",
|
|
3176
|
+
state: "Validation feedback"
|
|
3177
|
+
}
|
|
3178
|
+
],
|
|
2689
3179
|
uses: [
|
|
2690
3180
|
"Field",
|
|
2691
3181
|
"Input",
|
|
@@ -2706,7 +3196,12 @@ const meta$65 = {
|
|
|
2706
3196
|
name: "SSO buttons",
|
|
2707
3197
|
family: "auth",
|
|
2708
3198
|
status: "stable",
|
|
2709
|
-
description: "Neutral \"Continue with …\" provider buttons with lucide icons and a per-provider loading state.",
|
|
3199
|
+
description: "Neutral \"Continue with …\" provider buttons with lucide icons and a per-provider loading state. Optional labels?: Partial<SsoButtonsLabels> 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=sso-buttons--labels.",
|
|
3200
|
+
labels: [{
|
|
3201
|
+
key: "label",
|
|
3202
|
+
type: "string",
|
|
3203
|
+
state: "Default content and accessible names"
|
|
3204
|
+
}],
|
|
2710
3205
|
uses: ["Button"]
|
|
2711
3206
|
};
|
|
2712
3207
|
//#endregion
|
|
@@ -5219,6 +5714,38 @@ const meta$7 = {
|
|
|
5219
5714
|
]
|
|
5220
5715
|
};
|
|
5221
5716
|
//#endregion
|
|
5717
|
+
//#region src/builders/LogViewer/use-wrapped-log-rows.ts
|
|
5718
|
+
/** Measurements belong to line IDs, independent of the current filtered indices. */
|
|
5719
|
+
function useWrappedLogRows(enabled, lines, rowHeight, height, overscan, scrollTop, follow) {
|
|
5720
|
+
const [sizes, setSizes] = useState(/* @__PURE__ */ new Map());
|
|
5721
|
+
const count = enabled ? lines.length : 0;
|
|
5722
|
+
const sizeOf = useCallback((index) => sizes.get(lines[index]?.id ?? "") ?? rowHeight, [
|
|
5723
|
+
lines,
|
|
5724
|
+
sizes,
|
|
5725
|
+
rowHeight
|
|
5726
|
+
]);
|
|
5727
|
+
const total = useMemo(() => computeOffsets(count, sizeOf), [count, sizeOf])[count] ?? 0;
|
|
5728
|
+
const maxScroll = Math.max(0, total - height);
|
|
5729
|
+
const win = useVirtualWindow(count, sizeOf, follow ? maxScroll : Math.min(scrollTop, maxScroll), height, overscan);
|
|
5730
|
+
const measureRow = useCallback((node, id) => {
|
|
5731
|
+
if (!node) return;
|
|
5732
|
+
const measure = () => {
|
|
5733
|
+
const measured = node.getBoundingClientRect().height;
|
|
5734
|
+
if (measured > 0) setSizes((previous) => previous.get(id) === measured ? previous : new Map(previous).set(id, measured));
|
|
5735
|
+
};
|
|
5736
|
+
measure();
|
|
5737
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
5738
|
+
const observer = new ResizeObserver(measure);
|
|
5739
|
+
observer.observe(node);
|
|
5740
|
+
return () => observer.disconnect();
|
|
5741
|
+
}, []);
|
|
5742
|
+
return {
|
|
5743
|
+
...win,
|
|
5744
|
+
end: win.end + 1,
|
|
5745
|
+
measureRow
|
|
5746
|
+
};
|
|
5747
|
+
}
|
|
5748
|
+
//#endregion
|
|
5222
5749
|
//#region src/builders/LogViewer/fixtures.ts
|
|
5223
5750
|
const MESSAGES = [
|
|
5224
5751
|
[
|
|
@@ -5343,7 +5870,7 @@ function lineText(line) {
|
|
|
5343
5870
|
* so it stays fast with thousands of lines. Level filter, search with highlighted matches,
|
|
5344
5871
|
* follow-tail and per-line copy.
|
|
5345
5872
|
*/
|
|
5346
|
-
function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, rowHeight = 24, overscan = 8, defaultLevels = LOG_LEVELS, defaultFollow = true, onCopyLine, onSelectLine, selectedLineId, announceLines = true, titleAs: TitleTag = "h3", className }) {
|
|
5873
|
+
function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, rowHeight = 24, wrap = false, overscan = 8, defaultLevels = LOG_LEVELS, defaultFollow = true, onCopyLine, onSelectLine, selectedLineId, announceLines = true, titleAs: TitleTag = "h3", className }) {
|
|
5347
5874
|
const { locale, t } = useI18n();
|
|
5348
5875
|
const title = titleProp ?? labels?.title ?? t("logViewer.title");
|
|
5349
5876
|
const titleId = useId();
|
|
@@ -5378,11 +5905,12 @@ function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, r
|
|
|
5378
5905
|
query,
|
|
5379
5906
|
locale
|
|
5380
5907
|
]);
|
|
5381
|
-
const
|
|
5908
|
+
const wrapped = useWrappedLogRows(wrap, visible, rowHeight, height, overscan, scrollTop, follow);
|
|
5909
|
+
const total = wrap ? wrapped.total : visible.length * rowHeight;
|
|
5382
5910
|
const maxScroll = Math.max(0, total - height);
|
|
5383
5911
|
const offset = follow ? maxScroll : Math.min(scrollTop, maxScroll);
|
|
5384
|
-
const start = Math.max(0, Math.floor(offset / rowHeight) - overscan);
|
|
5385
|
-
const end = Math.min(visible.length, Math.ceil((offset + height) / rowHeight) + overscan);
|
|
5912
|
+
const start = wrap ? wrapped.start : Math.max(0, Math.floor(offset / rowHeight) - overscan);
|
|
5913
|
+
const end = wrap ? wrapped.end : Math.min(visible.length, Math.ceil((offset + height) / rowHeight) + overscan);
|
|
5386
5914
|
const rows = visible.slice(start, end);
|
|
5387
5915
|
useEffect(() => {
|
|
5388
5916
|
if (follow && viewport.current) viewport.current.scrollTop = maxScroll;
|
|
@@ -5429,7 +5957,7 @@ function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, r
|
|
|
5429
5957
|
onValueChange: (v) => setLevels(v),
|
|
5430
5958
|
children: LOG_LEVELS.map((lv) => /* @__PURE__ */ jsxs(Toggle, {
|
|
5431
5959
|
value: lv,
|
|
5432
|
-
children: [lv, /* @__PURE__ */ jsx("span", {
|
|
5960
|
+
children: [labels?.levels?.[lv] ?? t(`logViewer.levelFilterOption.${lv}`), /* @__PURE__ */ jsx("span", {
|
|
5433
5961
|
className: "font-mono text-[10.5px] opacity-70",
|
|
5434
5962
|
children: counts[lv]
|
|
5435
5963
|
})]
|
|
@@ -5472,9 +6000,13 @@ function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, r
|
|
|
5472
6000
|
const lv = LEVEL_STYLE[line.level];
|
|
5473
6001
|
return /* @__PURE__ */ jsxs("div", {
|
|
5474
6002
|
"data-slot": "log-line",
|
|
6003
|
+
ref: wrap ? (node) => wrapped.measureRow(node, line.id) : void 0,
|
|
5475
6004
|
onClick: onSelectLine ? () => onSelectLine(line) : void 0,
|
|
5476
|
-
className: "group absolute inset-x-0 flex items-center gap-2.5 px-3 hover:bg-secondary/50",
|
|
5477
|
-
style: {
|
|
6005
|
+
className: wrap ? "group absolute inset-x-0 flex items-start gap-2.5 px-3 hover:bg-secondary/50" : "group absolute inset-x-0 flex items-center gap-2.5 px-3 hover:bg-secondary/50",
|
|
6006
|
+
style: wrap ? {
|
|
6007
|
+
top: wrapped.offsets[start + i],
|
|
6008
|
+
minHeight: rowHeight
|
|
6009
|
+
} : {
|
|
5478
6010
|
top: (start + i) * rowHeight,
|
|
5479
6011
|
height: rowHeight
|
|
5480
6012
|
},
|
|
@@ -5485,7 +6017,7 @@ function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, r
|
|
|
5485
6017
|
}),
|
|
5486
6018
|
/* @__PURE__ */ jsx("span", {
|
|
5487
6019
|
className: cn("inline-flex h-4 w-12 shrink-0 items-center justify-center rounded text-[10px] font-semibold", lv.className),
|
|
5488
|
-
children:
|
|
6020
|
+
children: labels?.levels?.[line.level] ?? t(`logViewer.level.${line.level}`)
|
|
5489
6021
|
}),
|
|
5490
6022
|
line.source && /* @__PURE__ */ jsxs("span", {
|
|
5491
6023
|
className: "hidden shrink-0 text-muted-foreground sm:inline",
|
|
@@ -5496,7 +6028,7 @@ function LogViewer({ lines = logLines, title: titleProp, labels, height = 360, r
|
|
|
5496
6028
|
]
|
|
5497
6029
|
}),
|
|
5498
6030
|
/* @__PURE__ */ jsx("span", {
|
|
5499
|
-
className: "min-w-0 flex-1 truncate text-foreground",
|
|
6031
|
+
className: wrap ? "min-w-0 flex-1 whitespace-pre-wrap break-words text-foreground" : "min-w-0 flex-1 truncate text-foreground",
|
|
5500
6032
|
children: highlight(line.message, query, locale)
|
|
5501
6033
|
}),
|
|
5502
6034
|
onSelectLine && /* @__PURE__ */ jsx(IconButton, {
|
|
@@ -5533,7 +6065,7 @@ const meta$39 = {
|
|
|
5533
6065
|
name: "Log viewer",
|
|
5534
6066
|
family: "builders",
|
|
5535
6067
|
status: "beta",
|
|
5536
|
-
description: "Windowed log stream (role=\"log\"): level filter, search with highlighted matches, follow-tail and per-line copy. Renders only the visible rows. Optional labels?: Partial<LogViewerLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English.
|
|
6068
|
+
description: "Windowed log stream (role=\"log\"): level filter, search with highlighted matches, follow-tail and per-line copy. Renders only the visible rows. Optional wrap (default false) shows full messages in measured, variable-height rows; rowHeight estimates unmeasured rows. Optional labels?: Partial<LogViewerLabels> overrides each built-in label, including per-level chip and filter names through labels.levels. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Copied log text and imported fixtures stay unchanged. See the Catalog labels and Full messages and level names live previews.",
|
|
5537
6069
|
labels: [
|
|
5538
6070
|
{
|
|
5539
6071
|
key: "title",
|
|
@@ -5545,6 +6077,11 @@ const meta$39 = {
|
|
|
5545
6077
|
type: "string",
|
|
5546
6078
|
state: "Level filter group name"
|
|
5547
6079
|
},
|
|
6080
|
+
{
|
|
6081
|
+
key: "levels",
|
|
6082
|
+
type: "Partial<Record<LogLevel, string>>",
|
|
6083
|
+
state: "Per-level chip and filter names; omitted levels use the catalog"
|
|
6084
|
+
},
|
|
5548
6085
|
{
|
|
5549
6086
|
key: "searchLabel",
|
|
5550
6087
|
type: "string",
|
|
@@ -6353,11 +6890,29 @@ function CopyButton$1({ item, onCopy, labels }) {
|
|
|
6353
6890
|
})] });
|
|
6354
6891
|
}
|
|
6355
6892
|
/** Key–value detail card: label column, values (mono, status or rich), copy buttons and an Edit action. */
|
|
6356
|
-
function DescriptionListCard({ title: titleProp, labels, description: descriptionProp, items = DEPLOYMENT_DETAILS, onEdit, editLabel: editLabelProp, onCopy, titleAs = "h3", className }) {
|
|
6893
|
+
function DescriptionListCard({ title: titleProp, labels, description: descriptionProp, items = DEPLOYMENT_DETAILS, wrap = false, columns = 1, onEdit, editLabel: editLabelProp, onCopy, titleAs = "h3", className }) {
|
|
6357
6894
|
const { t } = useI18n();
|
|
6358
6895
|
const title = titleProp ?? labels?.title ?? t("descriptionList.title");
|
|
6359
6896
|
const description = descriptionProp ?? labels?.description ?? t("descriptionList.description");
|
|
6360
6897
|
const editLabel = editLabelProp ?? labels?.edit ?? t("descriptionList.edit");
|
|
6898
|
+
const renderItem = (item) => /* @__PURE__ */ jsxs("div", {
|
|
6899
|
+
className: cn("grid grid-cols-1 gap-1 py-3.5", columns === 1 && "sm:grid-cols-[160px_minmax(0,1fr)] sm:gap-4"),
|
|
6900
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
6901
|
+
className: "text-[13px] text-muted-foreground",
|
|
6902
|
+
children: item.label
|
|
6903
|
+
}), /* @__PURE__ */ jsxs("dd", {
|
|
6904
|
+
className: "flex min-w-0 items-center gap-2 text-[13px] text-foreground",
|
|
6905
|
+
children: [item.status ? /* @__PURE__ */ jsx(StatusTag, { status: item.status }) : /* @__PURE__ */ jsx("span", {
|
|
6906
|
+
className: cn(wrap ? "min-w-0 wrap-anywhere" : "min-w-0 truncate", item.mono && "font-mono text-[12.5px]"),
|
|
6907
|
+
children: item.render ?? item.value
|
|
6908
|
+
}), item.copyable && /* @__PURE__ */ jsx(CopyButton$1, {
|
|
6909
|
+
item,
|
|
6910
|
+
onCopy,
|
|
6911
|
+
labels
|
|
6912
|
+
})]
|
|
6913
|
+
})]
|
|
6914
|
+
}, item.id);
|
|
6915
|
+
const chunkSize = Math.ceil(items.length / columns);
|
|
6361
6916
|
return /* @__PURE__ */ jsxs(Card, {
|
|
6362
6917
|
className,
|
|
6363
6918
|
children: [/* @__PURE__ */ jsxs(CardHeader, {
|
|
@@ -6376,25 +6931,15 @@ function DescriptionListCard({ title: titleProp, labels, description: descriptio
|
|
|
6376
6931
|
children: editLabel
|
|
6377
6932
|
}) })
|
|
6378
6933
|
]
|
|
6379
|
-
}), /* @__PURE__ */ jsx("dl", {
|
|
6934
|
+
}), columns === 1 ? /* @__PURE__ */ jsx("dl", {
|
|
6380
6935
|
className: "divide-y divide-border px-5",
|
|
6381
|
-
children: items.map(
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
children: [item.status ? /* @__PURE__ */ jsx(StatusTag, { status: item.status }) : /* @__PURE__ */ jsx("span", {
|
|
6389
|
-
className: cn("min-w-0 truncate", item.mono && "font-mono text-[12.5px]"),
|
|
6390
|
-
children: item.render ?? item.value
|
|
6391
|
-
}), item.copyable && /* @__PURE__ */ jsx(CopyButton$1, {
|
|
6392
|
-
item,
|
|
6393
|
-
onCopy,
|
|
6394
|
-
labels
|
|
6395
|
-
})]
|
|
6396
|
-
})]
|
|
6397
|
-
}, item.id))
|
|
6936
|
+
children: items.map(renderItem)
|
|
6937
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
6938
|
+
className: cn("grid grid-cols-1 gap-x-6 px-5", columns === 2 ? "sm:grid-cols-2" : "sm:grid-cols-3"),
|
|
6939
|
+
children: Array.from({ length: columns }, (_, column) => /* @__PURE__ */ jsx("dl", {
|
|
6940
|
+
className: "min-w-0 divide-y divide-border",
|
|
6941
|
+
children: items.slice(column * chunkSize, (column + 1) * chunkSize).map(renderItem)
|
|
6942
|
+
}, column))
|
|
6398
6943
|
})]
|
|
6399
6944
|
});
|
|
6400
6945
|
}
|
|
@@ -6404,7 +6949,7 @@ const meta$18 = {
|
|
|
6404
6949
|
name: "Description list card",
|
|
6405
6950
|
family: "data-display",
|
|
6406
6951
|
status: "beta",
|
|
6407
|
-
description: "Key–value detail card with mono, status and rich values, copy-to-clipboard buttons and an Edit action. Optional labels?: Partial<DescriptionListCardLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview.",
|
|
6952
|
+
description: "Key–value detail card with mono, status and rich values, copy-to-clipboard buttons and an Edit action. Optional labels?: Partial<DescriptionListCardLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview. wrap?: boolean (default false) shows full values and breaks long unbroken strings. columns?: 1 | 2 | 3 (default 1) stacks terms above values in two or three columns from sm, with one column below sm; items fill contiguous top-to-bottom chunks of ceil(item count / columns), and dividers stay within each column. Defaults preserve the original single-column rows. See the Spanish live preview for wrapping and both column layouts.",
|
|
6408
6953
|
labels: [
|
|
6409
6954
|
{
|
|
6410
6955
|
key: "title",
|
|
@@ -7380,7 +7925,7 @@ function NoResultsEmpty({ query = noResultsSample.query, labels, filterCount = n
|
|
|
7380
7925
|
});
|
|
7381
7926
|
}
|
|
7382
7927
|
/** Permission state: the viewer lacks access; explains who can grant it and lets them ask. */
|
|
7383
|
-
function NoAccessEmpty({ resource = noAccessSample.resource, labels, owner = noAccessSample.owner, onRequestAccess, defaultRequested = false, titleAs, bordered = true, className }) {
|
|
7928
|
+
function NoAccessEmpty({ resource = noAccessSample.resource, labels, owner = noAccessSample.owner, onRequestAccess, showRequestAccess = true, action, defaultRequested = false, titleAs, bordered = true, className }) {
|
|
7384
7929
|
const { t } = useI18n();
|
|
7385
7930
|
const [state, setState] = useState(defaultRequested ? "requested" : "idle");
|
|
7386
7931
|
const request = async () => {
|
|
@@ -7392,6 +7937,12 @@ function NoAccessEmpty({ resource = noAccessSample.resource, labels, owner = noA
|
|
|
7392
7937
|
setState("idle");
|
|
7393
7938
|
}
|
|
7394
7939
|
};
|
|
7940
|
+
const actionLink = action ? /* @__PURE__ */ jsx(Link, {
|
|
7941
|
+
underline: "hover",
|
|
7942
|
+
href: action.href,
|
|
7943
|
+
className: "inline-flex h-9 items-center px-2 text-[13px] font-semibold",
|
|
7944
|
+
children: action.label
|
|
7945
|
+
}) : void 0;
|
|
7395
7946
|
return /* @__PURE__ */ jsx(EmptyState, {
|
|
7396
7947
|
icon: Lock,
|
|
7397
7948
|
titleAs,
|
|
@@ -7402,15 +7953,16 @@ function NoAccessEmpty({ resource = noAccessSample.resource, labels, owner = noA
|
|
|
7402
7953
|
resource: resource.toLowerCase(),
|
|
7403
7954
|
owner
|
|
7404
7955
|
}),
|
|
7405
|
-
primaryAction: /* @__PURE__ */ jsx(Button, {
|
|
7956
|
+
primaryAction: showRequestAccess ? /* @__PURE__ */ jsx(Button, {
|
|
7406
7957
|
variant: state === "requested" ? "secondary" : "primary",
|
|
7407
7958
|
icon: state === "requested" ? Check : void 0,
|
|
7408
7959
|
loading: state === "pending",
|
|
7409
7960
|
disabled: state === "requested",
|
|
7410
7961
|
onClick: () => void request(),
|
|
7411
7962
|
children: state === "requested" ? labels?.requested ?? t("emptyState.noAccess.requested") : labels?.request ?? t("emptyState.noAccess.request")
|
|
7412
|
-
}),
|
|
7413
|
-
|
|
7963
|
+
}) : actionLink,
|
|
7964
|
+
secondaryAction: showRequestAccess ? actionLink : void 0,
|
|
7965
|
+
children: showRequestAccess && /* @__PURE__ */ jsx("p", {
|
|
7414
7966
|
role: "status",
|
|
7415
7967
|
className: "sr-only",
|
|
7416
7968
|
children: state === "requested" ? labels?.sent ?? t("emptyState.noAccess.sent") : ""
|
|
@@ -7423,7 +7975,7 @@ const meta$20 = {
|
|
|
7423
7975
|
name: "Empty states",
|
|
7424
7976
|
family: "feedback",
|
|
7425
7977
|
status: "beta",
|
|
7426
|
-
description: "Four canonical empty states: first run (with checklist), no results (clear filters/search), no access (request access) and not found (optional action). FirstRunEmpty, NoResultsEmpty and NoAccessEmpty accept labels?: Partial<FirstRunEmptyLabels>, Partial<NoResultsEmptyLabels> and Partial<NoAccessEmptyLabels> respectively. Each type has its own keys below; explicit title, description, actionLabel and secondary props win. Defaults follow I18nProvider (en/es). NoResultsEmpty keeps the query in a mono span unless queryTitle replaces the heading. NotFoundEmpty and all imported fixtures stay English. See the Catalog labels live preview.",
|
|
7978
|
+
description: "Four canonical empty states: first run (with checklist), no results (clear filters/search), no access (request access) and not found (optional action). FirstRunEmpty, NoResultsEmpty and NoAccessEmpty accept labels?: Partial<FirstRunEmptyLabels>, Partial<NoResultsEmptyLabels> and Partial<NoAccessEmptyLabels> respectively. Each type has its own keys below; explicit title, description, actionLabel and secondary props win. Defaults follow I18nProvider (en/es). NoResultsEmpty keeps the query in a mono span unless queryTitle replaces the heading. NotFoundEmpty and all imported fixtures stay English. See the Catalog labels live preview. NoAccessEmpty accepts showRequestAccess?: boolean (default true): false hides both the request button and its status announcement, so defaultRequested has no visible effect. action?: { label: string; href: string } renders one kit Link, styled like FirstRunEmpty’s secondary link; it is secondaryAction after the request button, or primaryAction when showRequestAccess is false. With showRequestAccess=false and no action, it renders no actions. Omitting onRequestAccess still shows the button by default. See the Spanish live preview for no actions, a link alone, and a link with the request button.",
|
|
7427
7979
|
labels: [
|
|
7428
7980
|
{
|
|
7429
7981
|
key: "FirstRunEmpty.labels.title",
|
|
@@ -8104,7 +8656,8 @@ const meta$22 = {
|
|
|
8104
8656
|
//#endregion
|
|
8105
8657
|
//#region src/forms/DangerZone/ConfirmDestructiveDialog.tsx
|
|
8106
8658
|
/** Destructive confirmation (alertdialog) that can require typing the resource name first. */
|
|
8107
|
-
function ConfirmDestructiveDialog({ open, onOpenChange, title, description, confirmText, confirmLabel, onConfirm }) {
|
|
8659
|
+
function ConfirmDestructiveDialog({ labels, open, onOpenChange, title, description, confirmText, confirmLabel, onConfirm }) {
|
|
8660
|
+
const { t } = useI18n();
|
|
8108
8661
|
const [typed, setTyped] = useState("");
|
|
8109
8662
|
const [loading, setLoading] = useState(false);
|
|
8110
8663
|
const [error, setError] = useState(null);
|
|
@@ -8128,7 +8681,7 @@ function ConfirmDestructiveDialog({ open, onOpenChange, title, description, conf
|
|
|
8128
8681
|
onOpenChange(false);
|
|
8129
8682
|
} catch (e) {
|
|
8130
8683
|
setLoading(false);
|
|
8131
|
-
setError(e instanceof Error ? e.message :
|
|
8684
|
+
setError(e instanceof Error ? e.message : labels?.fallbackError ?? t("dangerZone.fallbackError"));
|
|
8132
8685
|
}
|
|
8133
8686
|
};
|
|
8134
8687
|
return /* @__PURE__ */ jsx(AlertDialog, {
|
|
@@ -8146,14 +8699,10 @@ function ConfirmDestructiveDialog({ open, onOpenChange, title, description, conf
|
|
|
8146
8699
|
confirm();
|
|
8147
8700
|
},
|
|
8148
8701
|
children: [
|
|
8149
|
-
confirmText != null && /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */
|
|
8150
|
-
"
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
children: confirmText
|
|
8154
|
-
}),
|
|
8155
|
-
" to confirm"
|
|
8156
|
-
] }), /* @__PURE__ */ jsx(Input, {
|
|
8702
|
+
confirmText != null && /* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(FieldLabel, { children: labels?.confirmPrompt?.(confirmText) ?? translatedContent(t("dangerZone.confirmPrompt"), { text: /* @__PURE__ */ jsx("span", {
|
|
8703
|
+
className: "font-mono font-semibold text-foreground",
|
|
8704
|
+
children: confirmText
|
|
8705
|
+
}) }) }), /* @__PURE__ */ jsx(Input, {
|
|
8157
8706
|
value: typed,
|
|
8158
8707
|
onValueChange: setTyped,
|
|
8159
8708
|
autoComplete: "off",
|
|
@@ -8168,7 +8717,7 @@ function ConfirmDestructiveDialog({ open, onOpenChange, title, description, conf
|
|
|
8168
8717
|
className: "mt-1",
|
|
8169
8718
|
children: [/* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
8170
8719
|
disabled: loading,
|
|
8171
|
-
children: "
|
|
8720
|
+
children: labels?.cancel ?? t("dangerZone.cancel")
|
|
8172
8721
|
}), /* @__PURE__ */ jsx(Button, {
|
|
8173
8722
|
type: "submit",
|
|
8174
8723
|
variant: "destructive",
|
|
@@ -8213,7 +8762,10 @@ const dangerZoneActions = [
|
|
|
8213
8762
|
* Bordered destructive section. Each action opens a confirmation dialog; actions with
|
|
8214
8763
|
* `confirmText` require typing it (e.g. the project name) before the confirm button enables.
|
|
8215
8764
|
*/
|
|
8216
|
-
function DangerZone({ title
|
|
8765
|
+
function DangerZone({ labels, title: titleProp, description: descriptionProp, actions = dangerZoneActions, onConfirm, headingLevel: Heading = "h2", className }) {
|
|
8766
|
+
const { t } = useI18n();
|
|
8767
|
+
const title = titleProp === void 0 ? labels?.title ?? t("dangerZone.title") : titleProp;
|
|
8768
|
+
const description = descriptionProp === void 0 ? labels?.description ?? t("dangerZone.description") : descriptionProp;
|
|
8217
8769
|
const id = useId();
|
|
8218
8770
|
const [pending, setPending] = useState(null);
|
|
8219
8771
|
const [open, setOpen] = useState(false);
|
|
@@ -8259,7 +8811,8 @@ function DangerZone({ title = "Danger zone", description = "These actions affect
|
|
|
8259
8811
|
pending && /* @__PURE__ */ jsx(ConfirmDestructiveDialog, {
|
|
8260
8812
|
open,
|
|
8261
8813
|
onOpenChange: setOpen,
|
|
8262
|
-
|
|
8814
|
+
labels,
|
|
8815
|
+
title: labels?.confirmationTitle?.(pending.title) ?? t("dangerZone.confirmationTitle", { title: pending.title }),
|
|
8263
8816
|
description: pending.description,
|
|
8264
8817
|
confirmText: pending.confirmText,
|
|
8265
8818
|
confirmLabel: pending.actionLabel,
|
|
@@ -8274,7 +8827,39 @@ const meta$15 = {
|
|
|
8274
8827
|
name: "Danger zone",
|
|
8275
8828
|
family: "forms",
|
|
8276
8829
|
status: "stable",
|
|
8277
|
-
description: "Bordered destructive section whose actions open an alert dialog that can require typing the resource name.",
|
|
8830
|
+
description: "Bordered destructive section whose actions open an alert dialog that can require typing the resource name. Optional labels?: Partial<DangerZoneLabels> 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=danger-zone--labels.",
|
|
8831
|
+
labels: [
|
|
8832
|
+
{
|
|
8833
|
+
key: "title",
|
|
8834
|
+
type: "string",
|
|
8835
|
+
state: "Default content and accessible names"
|
|
8836
|
+
},
|
|
8837
|
+
{
|
|
8838
|
+
key: "description",
|
|
8839
|
+
type: "string",
|
|
8840
|
+
state: "Default content and accessible names"
|
|
8841
|
+
},
|
|
8842
|
+
{
|
|
8843
|
+
key: "confirmationTitle",
|
|
8844
|
+
type: "(title: string) => string",
|
|
8845
|
+
state: "Destructive confirmation dialog"
|
|
8846
|
+
},
|
|
8847
|
+
{
|
|
8848
|
+
key: "confirmPrompt",
|
|
8849
|
+
type: "(text: ReactNode) => ReactNode",
|
|
8850
|
+
state: "Destructive confirmation dialog"
|
|
8851
|
+
},
|
|
8852
|
+
{
|
|
8853
|
+
key: "cancel",
|
|
8854
|
+
type: "string",
|
|
8855
|
+
state: "Destructive confirmation dialog"
|
|
8856
|
+
},
|
|
8857
|
+
{
|
|
8858
|
+
key: "fallbackError",
|
|
8859
|
+
type: "string",
|
|
8860
|
+
state: "Destructive confirmation dialog"
|
|
8861
|
+
}
|
|
8862
|
+
],
|
|
8278
8863
|
uses: [
|
|
8279
8864
|
"Button",
|
|
8280
8865
|
"AlertDialog",
|
|
@@ -8337,7 +8922,8 @@ function generateDemoSecret(prefix = "sk_live_") {
|
|
|
8337
8922
|
* Two-step API key dialog: name, scopes and expiry, then the secret shown once in a CodeBlock
|
|
8338
8923
|
* with copy. Closing the dialog discards the secret; it can't be shown again.
|
|
8339
8924
|
*/
|
|
8340
|
-
function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries, defaultExpiry = "90d", onCreate = () => generateDemoSecret(), open: openProp, defaultOpen = false, onOpenChange, trigger = /* @__PURE__ */ jsx(Button, { icon: KeyRound }) }) {
|
|
8925
|
+
function CreateApiKeyDialog({ labels, scopes = apiKeyScopes, expiries = apiKeyExpiries, defaultExpiry = "90d", onCreate = () => generateDemoSecret(), open: openProp, defaultOpen = false, onOpenChange, trigger = /* @__PURE__ */ jsx(Button, { icon: KeyRound }) }) {
|
|
8926
|
+
const { t } = useI18n();
|
|
8341
8927
|
const [innerOpen, setInnerOpen] = useState(defaultOpen);
|
|
8342
8928
|
const [name, setName] = useState("");
|
|
8343
8929
|
const [selected, setSelected] = useState([]);
|
|
@@ -8375,7 +8961,7 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8375
8961
|
});
|
|
8376
8962
|
setSecret(value);
|
|
8377
8963
|
} catch (e) {
|
|
8378
|
-
setError(e instanceof Error ? e.message :
|
|
8964
|
+
setError(e instanceof Error ? e.message : labels?.fallbackError ?? t("createApiKey.fallbackError"));
|
|
8379
8965
|
}
|
|
8380
8966
|
setLoading(false);
|
|
8381
8967
|
};
|
|
@@ -8384,10 +8970,10 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8384
8970
|
onOpenChange: setOpen,
|
|
8385
8971
|
children: [trigger && /* @__PURE__ */ jsx(DialogTrigger, {
|
|
8386
8972
|
render: trigger,
|
|
8387
|
-
children:
|
|
8973
|
+
children: labels?.title ?? t("createApiKey.title")
|
|
8388
8974
|
}), /* @__PURE__ */ jsx(DialogContent, {
|
|
8389
8975
|
size: "lg",
|
|
8390
|
-
children: secret == null ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children:
|
|
8976
|
+
children: secret == null ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: labels?.title ?? t("createApiKey.title") }), /* @__PURE__ */ jsx(DialogDescription, { children: labels?.description ?? t("createApiKey.description") })] }), /* @__PURE__ */ jsxs("form", {
|
|
8391
8977
|
noValidate: true,
|
|
8392
8978
|
onSubmit: (e) => {
|
|
8393
8979
|
e.preventDefault();
|
|
@@ -8401,18 +8987,18 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8401
8987
|
children: [
|
|
8402
8988
|
/* @__PURE__ */ jsx(FieldLabel, {
|
|
8403
8989
|
required: true,
|
|
8404
|
-
children: "
|
|
8990
|
+
children: labels?.name ?? t("createApiKey.name")
|
|
8405
8991
|
}),
|
|
8406
8992
|
/* @__PURE__ */ jsx(Input, {
|
|
8407
8993
|
value: name,
|
|
8408
8994
|
onValueChange: setName,
|
|
8409
|
-
placeholder: "
|
|
8995
|
+
placeholder: labels?.namePlaceholder ?? t("createApiKey.namePlaceholder"),
|
|
8410
8996
|
required: true,
|
|
8411
8997
|
autoComplete: "off"
|
|
8412
8998
|
}),
|
|
8413
8999
|
/* @__PURE__ */ jsx(FieldError, {
|
|
8414
9000
|
match: nameInvalid,
|
|
8415
|
-
children:
|
|
9001
|
+
children: labels?.nameRequired ?? t("createApiKey.nameRequired")
|
|
8416
9002
|
})
|
|
8417
9003
|
]
|
|
8418
9004
|
}),
|
|
@@ -8423,7 +9009,7 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8423
9009
|
}),
|
|
8424
9010
|
"aria-invalid": scopesInvalid || void 0,
|
|
8425
9011
|
children: [
|
|
8426
|
-
/* @__PURE__ */ jsx(FieldsetLegend, { children: "
|
|
9012
|
+
/* @__PURE__ */ jsx(FieldsetLegend, { children: labels?.scopes ?? t("createApiKey.scopes") }),
|
|
8427
9013
|
scopes.map((s) => /* @__PURE__ */ jsx(Checkbox, {
|
|
8428
9014
|
value: s.value,
|
|
8429
9015
|
label: /* @__PURE__ */ jsx("span", {
|
|
@@ -8434,11 +9020,11 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8434
9020
|
}, s.value)),
|
|
8435
9021
|
scopesInvalid && /* @__PURE__ */ jsx("p", {
|
|
8436
9022
|
className: "text-[12.5px] text-destructive-text",
|
|
8437
|
-
children:
|
|
9023
|
+
children: labels?.scopesRequired ?? t("createApiKey.scopesRequired")
|
|
8438
9024
|
})
|
|
8439
9025
|
]
|
|
8440
9026
|
}),
|
|
8441
|
-
/* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(FieldLabel, { children: "
|
|
9027
|
+
/* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(FieldLabel, { children: labels?.expiration ?? t("createApiKey.expiration") }), /* @__PURE__ */ jsxs(Select, {
|
|
8442
9028
|
value: expiry,
|
|
8443
9029
|
onValueChange: (v) => v != null && setExpiry(v),
|
|
8444
9030
|
items: expiries,
|
|
@@ -8449,7 +9035,7 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8449
9035
|
})] }),
|
|
8450
9036
|
error && /* @__PURE__ */ jsx(Alert, {
|
|
8451
9037
|
tone: "destructive",
|
|
8452
|
-
title:
|
|
9038
|
+
title: labels?.errorTitle ?? t("createApiKey.errorTitle"),
|
|
8453
9039
|
description: error
|
|
8454
9040
|
})
|
|
8455
9041
|
]
|
|
@@ -8458,30 +9044,30 @@ function CreateApiKeyDialog({ scopes = apiKeyScopes, expiries = apiKeyExpiries,
|
|
|
8458
9044
|
variant: "ghost",
|
|
8459
9045
|
disabled: loading
|
|
8460
9046
|
}),
|
|
8461
|
-
children: "
|
|
9047
|
+
children: labels?.cancel ?? t("createApiKey.cancel")
|
|
8462
9048
|
}), /* @__PURE__ */ jsx(Button, {
|
|
8463
9049
|
type: "submit",
|
|
8464
9050
|
loading,
|
|
8465
|
-
children:
|
|
9051
|
+
children: labels?.submit ?? t("createApiKey.submit")
|
|
8466
9052
|
})] })]
|
|
8467
9053
|
})] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
8468
|
-
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children:
|
|
9054
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: labels?.successTitle ?? t("createApiKey.successTitle") }), /* @__PURE__ */ jsx(DialogDescription, { children: labels?.successDescription ?? t("createApiKey.successDescription") })] }),
|
|
8469
9055
|
/* @__PURE__ */ jsxs(DialogBody, {
|
|
8470
9056
|
className: "grid gap-4",
|
|
8471
9057
|
children: [/* @__PURE__ */ jsx(Alert, {
|
|
8472
9058
|
tone: "warning",
|
|
8473
|
-
title:
|
|
8474
|
-
description:
|
|
9059
|
+
title: labels?.warningTitle ?? t("createApiKey.warningTitle"),
|
|
9060
|
+
description: labels?.warningDescription ?? t("createApiKey.warningDescription")
|
|
8475
9061
|
}), /* @__PURE__ */ jsx(CodeBlock, {
|
|
8476
9062
|
code: secret,
|
|
8477
|
-
label:
|
|
9063
|
+
label: labels?.secretLabel ?? t("createApiKey.secretLabel"),
|
|
8478
9064
|
wrapToggle: false,
|
|
8479
9065
|
defaultWrap: true
|
|
8480
9066
|
})]
|
|
8481
9067
|
}),
|
|
8482
9068
|
/* @__PURE__ */ jsx(DialogFooter, { children: /* @__PURE__ */ jsx(DialogClose, {
|
|
8483
9069
|
render: /* @__PURE__ */ jsx(Button, {}),
|
|
8484
|
-
children: "
|
|
9070
|
+
children: labels?.done ?? t("createApiKey.done")
|
|
8485
9071
|
}) })
|
|
8486
9072
|
] })
|
|
8487
9073
|
})]
|
|
@@ -8493,7 +9079,99 @@ const meta$12 = {
|
|
|
8493
9079
|
name: "Create API key dialog",
|
|
8494
9080
|
family: "forms",
|
|
8495
9081
|
status: "stable",
|
|
8496
|
-
description: "Two-step dialog: name, scopes and expiry, then the secret shown once in a copyable CodeBlock with a warning.",
|
|
9082
|
+
description: "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.",
|
|
9083
|
+
labels: [
|
|
9084
|
+
{
|
|
9085
|
+
key: "title",
|
|
9086
|
+
type: "string",
|
|
9087
|
+
state: "Default content and accessible names"
|
|
9088
|
+
},
|
|
9089
|
+
{
|
|
9090
|
+
key: "description",
|
|
9091
|
+
type: "string",
|
|
9092
|
+
state: "Default content and accessible names"
|
|
9093
|
+
},
|
|
9094
|
+
{
|
|
9095
|
+
key: "name",
|
|
9096
|
+
type: "string",
|
|
9097
|
+
state: "Default content and accessible names"
|
|
9098
|
+
},
|
|
9099
|
+
{
|
|
9100
|
+
key: "namePlaceholder",
|
|
9101
|
+
type: "string",
|
|
9102
|
+
state: "Default content and accessible names"
|
|
9103
|
+
},
|
|
9104
|
+
{
|
|
9105
|
+
key: "nameRequired",
|
|
9106
|
+
type: "string",
|
|
9107
|
+
state: "Validation feedback"
|
|
9108
|
+
},
|
|
9109
|
+
{
|
|
9110
|
+
key: "scopes",
|
|
9111
|
+
type: "string",
|
|
9112
|
+
state: "Default content and accessible names"
|
|
9113
|
+
},
|
|
9114
|
+
{
|
|
9115
|
+
key: "scopesRequired",
|
|
9116
|
+
type: "string",
|
|
9117
|
+
state: "Validation feedback"
|
|
9118
|
+
},
|
|
9119
|
+
{
|
|
9120
|
+
key: "expiration",
|
|
9121
|
+
type: "string",
|
|
9122
|
+
state: "Default content and accessible names"
|
|
9123
|
+
},
|
|
9124
|
+
{
|
|
9125
|
+
key: "errorTitle",
|
|
9126
|
+
type: "string",
|
|
9127
|
+
state: "Validation feedback"
|
|
9128
|
+
},
|
|
9129
|
+
{
|
|
9130
|
+
key: "fallbackError",
|
|
9131
|
+
type: "string",
|
|
9132
|
+
state: "Validation feedback"
|
|
9133
|
+
},
|
|
9134
|
+
{
|
|
9135
|
+
key: "cancel",
|
|
9136
|
+
type: "string",
|
|
9137
|
+
state: "Default content and accessible names"
|
|
9138
|
+
},
|
|
9139
|
+
{
|
|
9140
|
+
key: "submit",
|
|
9141
|
+
type: "string",
|
|
9142
|
+
state: "Default content and accessible names"
|
|
9143
|
+
},
|
|
9144
|
+
{
|
|
9145
|
+
key: "successTitle",
|
|
9146
|
+
type: "string",
|
|
9147
|
+
state: "Async feedback"
|
|
9148
|
+
},
|
|
9149
|
+
{
|
|
9150
|
+
key: "successDescription",
|
|
9151
|
+
type: "string",
|
|
9152
|
+
state: "Async feedback"
|
|
9153
|
+
},
|
|
9154
|
+
{
|
|
9155
|
+
key: "warningTitle",
|
|
9156
|
+
type: "string",
|
|
9157
|
+
state: "Default content and accessible names"
|
|
9158
|
+
},
|
|
9159
|
+
{
|
|
9160
|
+
key: "warningDescription",
|
|
9161
|
+
type: "string",
|
|
9162
|
+
state: "Default content and accessible names"
|
|
9163
|
+
},
|
|
9164
|
+
{
|
|
9165
|
+
key: "secretLabel",
|
|
9166
|
+
type: "string",
|
|
9167
|
+
state: "Default content and accessible names"
|
|
9168
|
+
},
|
|
9169
|
+
{
|
|
9170
|
+
key: "done",
|
|
9171
|
+
type: "string",
|
|
9172
|
+
state: "Async feedback"
|
|
9173
|
+
}
|
|
9174
|
+
],
|
|
8497
9175
|
uses: [
|
|
8498
9176
|
"Dialog",
|
|
8499
9177
|
"Field",
|
|
@@ -8512,7 +9190,7 @@ const meta$12 = {
|
|
|
8512
9190
|
function SecretCopy({ secret, options, grouped = false, masked = true, warning }) {
|
|
8513
9191
|
const { t } = useI18n();
|
|
8514
9192
|
const [pending, setPending] = useState(false);
|
|
8515
|
-
const copied = options.copiedLabel ?? t("credentialDisclosure.copied");
|
|
9193
|
+
const copied = options.copiedLabel ?? options.labels?.copiedLabel ?? t("credentialDisclosure.copied");
|
|
8516
9194
|
const content = /* @__PURE__ */ jsxs(LiveAnnouncer, { children: [
|
|
8517
9195
|
warning,
|
|
8518
9196
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -8521,8 +9199,8 @@ function SecretCopy({ secret, options, grouped = false, masked = true, warning }
|
|
|
8521
9199
|
value: secret.value,
|
|
8522
9200
|
copyable: false,
|
|
8523
9201
|
"aria-label": secret.label,
|
|
8524
|
-
showLabel: options.showLabel ?? t("credentialDisclosure.show"),
|
|
8525
|
-
hideLabel: options.hideLabel ?? t("credentialDisclosure.hide")
|
|
9202
|
+
showLabel: options.showLabel ?? options.labels?.showLabel ?? t("credentialDisclosure.show"),
|
|
9203
|
+
hideLabel: options.hideLabel ?? options.labels?.hideLabel ?? t("credentialDisclosure.hide")
|
|
8526
9204
|
}) : /* @__PURE__ */ jsx(CodeBlock, {
|
|
8527
9205
|
code: secret.value,
|
|
8528
9206
|
copyable: false,
|
|
@@ -8538,11 +9216,14 @@ function SecretCopy({ secret, options, grouped = false, masked = true, warning }
|
|
|
8538
9216
|
},
|
|
8539
9217
|
loading: grouped && pending,
|
|
8540
9218
|
display: "label",
|
|
8541
|
-
label: options.copyLabel ?? t("credentialDisclosure.copy"),
|
|
9219
|
+
label: options.copyLabel ?? options.labels?.copyLabel ?? t("credentialDisclosure.copy"),
|
|
8542
9220
|
copiedLabel: copied,
|
|
8543
|
-
announcement: grouped ? options.copiedAnnouncementFor?.(secret.label) ??
|
|
8544
|
-
|
|
8545
|
-
|
|
9221
|
+
announcement: grouped ? options.copiedAnnouncementFor?.(secret.label) ?? options.labels?.copiedAnnouncementFor?.(secret.label, copied) ?? t("credentialDisclosure.copiedFor", {
|
|
9222
|
+
label: secret.label,
|
|
9223
|
+
copied
|
|
9224
|
+
}) : options.successAnnouncement ?? options.labels?.successAnnouncement ?? t("credentialDisclosure.success"),
|
|
9225
|
+
failureLabel: options.failureAnnouncement ?? options.labels?.failureAnnouncement ?? t("credentialDisclosure.failure"),
|
|
9226
|
+
failureAnnouncement: options.failureAnnouncement ?? options.labels?.failureAnnouncement ?? t("credentialDisclosure.failure"),
|
|
8546
9227
|
failurePoliteness: "polite",
|
|
8547
9228
|
onCopy: () => {
|
|
8548
9229
|
if (grouped) setPending(false);
|
|
@@ -8676,15 +9357,15 @@ function DisclosureSession(props) {
|
|
|
8676
9357
|
setOpen(false);
|
|
8677
9358
|
props.onClose();
|
|
8678
9359
|
};
|
|
8679
|
-
const closeLabel = props.closeLabel ?? t("credentialDisclosure.close");
|
|
8680
|
-
const title = props.title ?? t("credentialDisclosure.title");
|
|
8681
|
-
const description = props.description ?? t("credentialDisclosure.description");
|
|
8682
|
-
const secretLabel = props.secretLabel ?? t("credentialDisclosure.secret");
|
|
9360
|
+
const closeLabel = props.closeLabel ?? props.labels?.closeLabel ?? t("credentialDisclosure.close");
|
|
9361
|
+
const title = props.title ?? props.labels?.title ?? t("credentialDisclosure.title");
|
|
9362
|
+
const description = props.description ?? props.labels?.description ?? t("credentialDisclosure.description");
|
|
9363
|
+
const secretLabel = props.secretLabel ?? props.labels?.secretLabel ?? t("credentialDisclosure.secret");
|
|
8683
9364
|
const warning = disclosure.variant === "fresh" ? /* @__PURE__ */ jsx(Alert, {
|
|
8684
9365
|
role: presentation === "inline" ? "note" : "alert",
|
|
8685
9366
|
tone: "warning",
|
|
8686
|
-
title: props.warningTitle ?? t("credentialDisclosure.warningTitle"),
|
|
8687
|
-
description: props.warningText ?? t("credentialDisclosure.warningText")
|
|
9367
|
+
title: props.warningTitle ?? props.labels?.warningTitle ?? t("credentialDisclosure.warningTitle"),
|
|
9368
|
+
description: props.warningText ?? props.labels?.warningText ?? t("credentialDisclosure.warningText")
|
|
8688
9369
|
}) : null;
|
|
8689
9370
|
const body = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
8690
9371
|
/* @__PURE__ */ jsxs("dl", {
|
|
@@ -8692,7 +9373,7 @@ function DisclosureSession(props) {
|
|
|
8692
9373
|
children: [
|
|
8693
9374
|
/* @__PURE__ */ jsx("dt", {
|
|
8694
9375
|
className: "text-muted-foreground",
|
|
8695
|
-
children: props.credentialIdLabel ?? t("credentialDisclosure.credentialId")
|
|
9376
|
+
children: props.credentialIdLabel ?? props.labels?.credentialIdLabel ?? t("credentialDisclosure.credentialId")
|
|
8696
9377
|
}),
|
|
8697
9378
|
/* @__PURE__ */ jsx("dd", {
|
|
8698
9379
|
className: "break-all font-mono",
|
|
@@ -8700,7 +9381,7 @@ function DisclosureSession(props) {
|
|
|
8700
9381
|
}),
|
|
8701
9382
|
/* @__PURE__ */ jsx("dt", {
|
|
8702
9383
|
className: "text-muted-foreground",
|
|
8703
|
-
children: props.expiryLabel ?? t("credentialDisclosure.expiry")
|
|
9384
|
+
children: props.expiryLabel ?? props.labels?.expiryLabel ?? t("credentialDisclosure.expiry")
|
|
8704
9385
|
}),
|
|
8705
9386
|
/* @__PURE__ */ jsx("dd", { children: disclosure.expiresAt })
|
|
8706
9387
|
]
|
|
@@ -8780,7 +9461,84 @@ const meta$13 = {
|
|
|
8780
9461
|
name: "Credential disclosure dialog",
|
|
8781
9462
|
family: "forms",
|
|
8782
9463
|
status: "beta",
|
|
8783
|
-
description: "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.",
|
|
9464
|
+
description: "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.",
|
|
9465
|
+
labels: [
|
|
9466
|
+
{
|
|
9467
|
+
key: "title",
|
|
9468
|
+
type: "string",
|
|
9469
|
+
state: "Default content and accessible names"
|
|
9470
|
+
},
|
|
9471
|
+
{
|
|
9472
|
+
key: "description",
|
|
9473
|
+
type: "string",
|
|
9474
|
+
state: "Default content and accessible names"
|
|
9475
|
+
},
|
|
9476
|
+
{
|
|
9477
|
+
key: "credentialIdLabel",
|
|
9478
|
+
type: "string",
|
|
9479
|
+
state: "Default content and accessible names"
|
|
9480
|
+
},
|
|
9481
|
+
{
|
|
9482
|
+
key: "expiryLabel",
|
|
9483
|
+
type: "string",
|
|
9484
|
+
state: "Default content and accessible names"
|
|
9485
|
+
},
|
|
9486
|
+
{
|
|
9487
|
+
key: "secretLabel",
|
|
9488
|
+
type: "string",
|
|
9489
|
+
state: "Default content and accessible names"
|
|
9490
|
+
},
|
|
9491
|
+
{
|
|
9492
|
+
key: "showLabel",
|
|
9493
|
+
type: "string",
|
|
9494
|
+
state: "Default content and accessible names"
|
|
9495
|
+
},
|
|
9496
|
+
{
|
|
9497
|
+
key: "hideLabel",
|
|
9498
|
+
type: "string",
|
|
9499
|
+
state: "Default content and accessible names"
|
|
9500
|
+
},
|
|
9501
|
+
{
|
|
9502
|
+
key: "copyLabel",
|
|
9503
|
+
type: "string",
|
|
9504
|
+
state: "Default content and accessible names"
|
|
9505
|
+
},
|
|
9506
|
+
{
|
|
9507
|
+
key: "copiedLabel",
|
|
9508
|
+
type: "string",
|
|
9509
|
+
state: "Async feedback"
|
|
9510
|
+
},
|
|
9511
|
+
{
|
|
9512
|
+
key: "successAnnouncement",
|
|
9513
|
+
type: "string",
|
|
9514
|
+
state: "Async feedback"
|
|
9515
|
+
},
|
|
9516
|
+
{
|
|
9517
|
+
key: "failureAnnouncement",
|
|
9518
|
+
type: "string",
|
|
9519
|
+
state: "Async feedback"
|
|
9520
|
+
},
|
|
9521
|
+
{
|
|
9522
|
+
key: "warningTitle",
|
|
9523
|
+
type: "string",
|
|
9524
|
+
state: "Default content and accessible names"
|
|
9525
|
+
},
|
|
9526
|
+
{
|
|
9527
|
+
key: "warningText",
|
|
9528
|
+
type: "string",
|
|
9529
|
+
state: "Default content and accessible names"
|
|
9530
|
+
},
|
|
9531
|
+
{
|
|
9532
|
+
key: "closeLabel",
|
|
9533
|
+
type: "string",
|
|
9534
|
+
state: "Default content and accessible names"
|
|
9535
|
+
},
|
|
9536
|
+
{
|
|
9537
|
+
key: "copiedAnnouncementFor",
|
|
9538
|
+
type: "(label: string, copied: string) => string",
|
|
9539
|
+
state: "Async feedback"
|
|
9540
|
+
}
|
|
9541
|
+
],
|
|
8784
9542
|
uses: [
|
|
8785
9543
|
"Dialog",
|
|
8786
9544
|
"SecretField",
|
|
@@ -8802,10 +9560,10 @@ const SHORT = {
|
|
|
8802
9560
|
day: "numeric"
|
|
8803
9561
|
};
|
|
8804
9562
|
/** Compact DateRangePicker for toolbars: small trigger, short dates, presets and a clear button. */
|
|
8805
|
-
function DateRangeFilter({ value, defaultValue, onValueChange, presets = DEFAULT_DATE_RANGE_PRESETS, today, label: labelProp, placeholder: placeholderProp, clearable = true, disabled, className }) {
|
|
9563
|
+
function DateRangeFilter({ labels, value, defaultValue, onValueChange, presets = DEFAULT_DATE_RANGE_PRESETS, today, label: labelProp, placeholder: placeholderProp, clearable = true, disabled, className }) {
|
|
8806
9564
|
const { t } = useI18n();
|
|
8807
|
-
const label = labelProp ?? t("dateRange.label");
|
|
8808
|
-
const placeholder = placeholderProp ?? t("dateRange.any");
|
|
9565
|
+
const label = labelProp ?? labels?.label ?? t("dateRange.label");
|
|
9566
|
+
const placeholder = placeholderProp ?? labels?.placeholder ?? t("dateRange.any");
|
|
8809
9567
|
const [inner, setInner] = useState(() => defaultValue ?? presets.find((p) => p.id === "last-7")?.range?.(today ?? /* @__PURE__ */ new Date()) ?? EMPTY);
|
|
8810
9568
|
const range = value ?? inner;
|
|
8811
9569
|
const set = (next) => {
|
|
@@ -8828,7 +9586,7 @@ function DateRangeFilter({ value, defaultValue, onValueChange, presets = DEFAULT
|
|
|
8828
9586
|
}), clearable && range.start && /* @__PURE__ */ jsx(IconButton, {
|
|
8829
9587
|
icon: X,
|
|
8830
9588
|
size: "sm",
|
|
8831
|
-
label: t("common.clearItem", { label: label.toLowerCase() }),
|
|
9589
|
+
label: labels?.clear?.(label.toLowerCase()) ?? t("common.clearItem", { label: label.toLowerCase() }),
|
|
8832
9590
|
disabled,
|
|
8833
9591
|
onClick: () => set(EMPTY)
|
|
8834
9592
|
})]
|
|
@@ -8840,7 +9598,24 @@ const meta$17 = {
|
|
|
8840
9598
|
name: "Date range filter",
|
|
8841
9599
|
family: "forms",
|
|
8842
9600
|
status: "stable",
|
|
8843
|
-
description: "Compact date range picker for toolbars: small trigger with short dates, presets and a clear button.",
|
|
9601
|
+
description: "Compact date range picker for toolbars: small trigger with short dates, presets and a clear button. Optional labels?: Partial<DateRangeFilterLabels> 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=date-range-filter--labels.",
|
|
9602
|
+
labels: [
|
|
9603
|
+
{
|
|
9604
|
+
key: "label",
|
|
9605
|
+
type: "string",
|
|
9606
|
+
state: "Default content and accessible names"
|
|
9607
|
+
},
|
|
9608
|
+
{
|
|
9609
|
+
key: "placeholder",
|
|
9610
|
+
type: "string",
|
|
9611
|
+
state: "Default content and accessible names"
|
|
9612
|
+
},
|
|
9613
|
+
{
|
|
9614
|
+
key: "clear",
|
|
9615
|
+
type: "(label: string) => string",
|
|
9616
|
+
state: "Default content and accessible names"
|
|
9617
|
+
}
|
|
9618
|
+
],
|
|
8844
9619
|
uses: ["DateRangePicker", "IconButton"]
|
|
8845
9620
|
};
|
|
8846
9621
|
//#endregion
|
|
@@ -8897,16 +9672,16 @@ const nextId = () => `upload-${++uid}`;
|
|
|
8897
9672
|
* Drop zone with a Browse button, accept and size validation, and a file list with progress,
|
|
8898
9673
|
* retry and remove. Rejected files stay in the list with the reason.
|
|
8899
9674
|
*/
|
|
8900
|
-
function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25e6, multiple = true, defaultFiles = uploadItems, onUpload = simulateUpload, onRemove, label: labelProp, hint, disabled = false, className }) {
|
|
9675
|
+
function FileUploadPanel({ labels, accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25e6, multiple = true, defaultFiles = uploadItems, onUpload = simulateUpload, onRemove, label: labelProp, hint, disabled = false, className }) {
|
|
8901
9676
|
const { t, formatBytes } = useI18n();
|
|
8902
|
-
const label = labelProp ?? t("upload.label");
|
|
9677
|
+
const label = labelProp ?? labels?.label ?? t("upload.label");
|
|
8903
9678
|
const id = useId();
|
|
8904
9679
|
const inputRef = useRef(null);
|
|
8905
9680
|
const [sources, setSources] = useState({});
|
|
8906
9681
|
const [items, setItems] = useState(defaultFiles);
|
|
8907
9682
|
const [dragging, setDragging] = useState(false);
|
|
8908
9683
|
const [announcement, setAnnouncement] = useState("");
|
|
8909
|
-
const hintText = hint ?? t("upload.hint", {
|
|
9684
|
+
const hintText = hint ?? labels?.hint?.(accept.split(",").map((a) => a.replace(".", "").toUpperCase()).join(" · "), formatBytes(maxSize)) ?? t("upload.hint", {
|
|
8910
9685
|
types: accept.split(",").map((a) => a.replace(".", "").toUpperCase()).join(" · "),
|
|
8911
9686
|
size: formatBytes(maxSize)
|
|
8912
9687
|
});
|
|
@@ -8925,13 +9700,13 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
8925
9700
|
status: "done",
|
|
8926
9701
|
progress: 100
|
|
8927
9702
|
});
|
|
8928
|
-
setAnnouncement(t("upload.done", { name: file.name }));
|
|
9703
|
+
setAnnouncement(labels?.done?.(file.name) ?? t("upload.done", { name: file.name }));
|
|
8929
9704
|
}, (e) => {
|
|
8930
9705
|
patch(itemId, {
|
|
8931
9706
|
status: "error",
|
|
8932
|
-
error: e instanceof Error ? e.message : t("upload.failed")
|
|
9707
|
+
error: e instanceof Error ? e.message : labels?.failed ?? t("upload.failed")
|
|
8933
9708
|
});
|
|
8934
|
-
setAnnouncement(t("upload.error", { name: file.name }));
|
|
9709
|
+
setAnnouncement(labels?.error?.(file.name) ?? t("upload.error", { name: file.name }));
|
|
8935
9710
|
});
|
|
8936
9711
|
};
|
|
8937
9712
|
const addFiles = (list) => {
|
|
@@ -8941,7 +9716,7 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
8941
9716
|
const kept = {};
|
|
8942
9717
|
for (const file of files) {
|
|
8943
9718
|
const itemId = nextId();
|
|
8944
|
-
const error = !acceptsFile(file, accept) ? t("upload.typeRejected") : file.size > maxSize ? t("upload.tooLarge", { size: formatBytes(maxSize) }) : void 0;
|
|
9719
|
+
const error = !acceptsFile(file, accept) ? labels?.typeRejected ?? t("upload.typeRejected") : file.size > maxSize ? labels?.tooLarge?.(formatBytes(maxSize)) ?? t("upload.tooLarge", { size: formatBytes(maxSize) }) : void 0;
|
|
8945
9720
|
added.push({
|
|
8946
9721
|
id: itemId,
|
|
8947
9722
|
name: file.name,
|
|
@@ -8961,13 +9736,13 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
8961
9736
|
...kept
|
|
8962
9737
|
}));
|
|
8963
9738
|
const rejected = added.filter((a) => a.error).length;
|
|
8964
|
-
setAnnouncement([t("upload.added", { count: added.length - rejected }), rejected ? t("upload.rejected", { count: rejected }) : ""].filter(Boolean).join(" "));
|
|
9739
|
+
setAnnouncement([labels?.added?.(added.length - rejected) ?? t("upload.added", { count: added.length - rejected }), rejected ? labels?.rejected?.(rejected) ?? t("upload.rejected", { count: rejected }) : ""].filter(Boolean).join(" "));
|
|
8965
9740
|
for (const [itemId, file] of toStart) start(itemId, file);
|
|
8966
9741
|
};
|
|
8967
9742
|
const remove = (item) => {
|
|
8968
9743
|
setSources((current) => Object.fromEntries(Object.entries(current).filter(([k]) => k !== item.id)));
|
|
8969
9744
|
setItems((list) => list.filter((x) => x.id !== item.id));
|
|
8970
|
-
setAnnouncement(t("upload.removed", { name: item.name }));
|
|
9745
|
+
setAnnouncement(labels?.removed?.(item.name) ?? t("upload.removed", { name: item.name }));
|
|
8971
9746
|
onRemove?.(item);
|
|
8972
9747
|
};
|
|
8973
9748
|
const retryFor = (itemId) => {
|
|
@@ -9009,7 +9784,7 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
9009
9784
|
}),
|
|
9010
9785
|
/* @__PURE__ */ jsx("p", {
|
|
9011
9786
|
className: "mt-4 text-[13.5px] text-foreground",
|
|
9012
|
-
children: t("upload.drop")
|
|
9787
|
+
children: labels?.drop ?? t("upload.drop")
|
|
9013
9788
|
}),
|
|
9014
9789
|
/* @__PURE__ */ jsx(Button, {
|
|
9015
9790
|
variant: "secondary",
|
|
@@ -9018,7 +9793,7 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
9018
9793
|
disabled,
|
|
9019
9794
|
onClick: () => inputRef.current?.click(),
|
|
9020
9795
|
"aria-describedby": `${id}-hint`,
|
|
9021
|
-
children: t("upload.browse")
|
|
9796
|
+
children: labels?.browse ?? t("upload.browse")
|
|
9022
9797
|
}),
|
|
9023
9798
|
/* @__PURE__ */ jsx("p", {
|
|
9024
9799
|
id: `${id}-hint`,
|
|
@@ -9040,9 +9815,10 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
9040
9815
|
]
|
|
9041
9816
|
}),
|
|
9042
9817
|
items.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
9043
|
-
"aria-label": t("upload.files"),
|
|
9818
|
+
"aria-label": labels?.files ?? t("upload.files"),
|
|
9044
9819
|
className: "mt-4 space-y-2",
|
|
9045
9820
|
children: items.map((item) => /* @__PURE__ */ jsx(FileRow, {
|
|
9821
|
+
labels,
|
|
9046
9822
|
item,
|
|
9047
9823
|
onRemove: () => remove(item),
|
|
9048
9824
|
onRetry: retryFor(item.id)
|
|
@@ -9056,7 +9832,7 @@ function FileUploadPanel({ accept = ".csv,.json,.jsonl,.yaml,.pdf", maxSize = 25
|
|
|
9056
9832
|
]
|
|
9057
9833
|
});
|
|
9058
9834
|
}
|
|
9059
|
-
function FileRow({ item, onRemove, onRetry }) {
|
|
9835
|
+
function FileRow({ item, onRemove, onRetry, labels }) {
|
|
9060
9836
|
const { t, formatBytes } = useI18n();
|
|
9061
9837
|
const err = item.status === "error";
|
|
9062
9838
|
const done = item.status === "done";
|
|
@@ -9081,11 +9857,11 @@ function FileRow({ item, onRemove, onRetry }) {
|
|
|
9081
9857
|
}), item.status === "uploading" ? /* @__PURE__ */ jsx(Progress, {
|
|
9082
9858
|
value: item.progress,
|
|
9083
9859
|
size: "sm",
|
|
9084
|
-
"aria-label": t("upload.uploading", { name: item.name }),
|
|
9860
|
+
"aria-label": labels?.uploading?.(item.name) ?? t("upload.uploading", { name: item.name }),
|
|
9085
9861
|
className: "mt-1.5"
|
|
9086
9862
|
}) : /* @__PURE__ */ jsx("div", {
|
|
9087
9863
|
className: cn("mt-0.5 font-mono text-[11px]", err ? "text-destructive-text" : "text-muted-foreground"),
|
|
9088
|
-
children: err ? t("upload.notUploaded", { error: item.error ?? t("upload.failed") }) : t("upload.uploaded", { size: formatBytes(item.size) })
|
|
9864
|
+
children: err ? labels?.notUploaded?.(item.error ?? labels?.failed ?? t("upload.failed")) ?? t("upload.notUploaded", { error: item.error ?? labels?.failed ?? t("upload.failed") }) : labels?.uploaded?.(formatBytes(item.size)) ?? t("upload.uploaded", { size: formatBytes(item.size) })
|
|
9089
9865
|
})]
|
|
9090
9866
|
}),
|
|
9091
9867
|
item.status === "uploading" && /* @__PURE__ */ jsxs("span", {
|
|
@@ -9095,13 +9871,13 @@ function FileRow({ item, onRemove, onRetry }) {
|
|
|
9095
9871
|
err && onRetry && /* @__PURE__ */ jsx(IconButton, {
|
|
9096
9872
|
icon: RotateCcw,
|
|
9097
9873
|
size: "sm",
|
|
9098
|
-
label: t("upload.retry", { name: item.name }),
|
|
9874
|
+
label: labels?.retry?.(item.name) ?? t("upload.retry", { name: item.name }),
|
|
9099
9875
|
onClick: onRetry
|
|
9100
9876
|
}),
|
|
9101
9877
|
/* @__PURE__ */ jsx(IconButton, {
|
|
9102
9878
|
icon: X,
|
|
9103
9879
|
size: "sm",
|
|
9104
|
-
label: t("common.removeItem", { label: item.name }),
|
|
9880
|
+
label: labels?.remove?.(item.name) ?? t("common.removeItem", { label: item.name }),
|
|
9105
9881
|
onClick: onRemove
|
|
9106
9882
|
})
|
|
9107
9883
|
]
|
|
@@ -9113,7 +9889,99 @@ const meta$26 = {
|
|
|
9113
9889
|
name: "File upload panel",
|
|
9114
9890
|
family: "forms",
|
|
9115
9891
|
status: "stable",
|
|
9116
|
-
description: "Drag-and-drop zone with a Browse button, type and size validation, and a file list with progress, retry and remove.",
|
|
9892
|
+
description: "Drag-and-drop zone with a Browse button, type and size validation, and a file list with progress, retry and remove. Optional labels?: Partial<FileUploadPanelLabels> 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=file-upload-panel--labels.",
|
|
9893
|
+
labels: [
|
|
9894
|
+
{
|
|
9895
|
+
key: "label",
|
|
9896
|
+
type: "string",
|
|
9897
|
+
state: "Default content and accessible names"
|
|
9898
|
+
},
|
|
9899
|
+
{
|
|
9900
|
+
key: "drop",
|
|
9901
|
+
type: "string",
|
|
9902
|
+
state: "Default content and accessible names"
|
|
9903
|
+
},
|
|
9904
|
+
{
|
|
9905
|
+
key: "browse",
|
|
9906
|
+
type: "string",
|
|
9907
|
+
state: "Default content and accessible names"
|
|
9908
|
+
},
|
|
9909
|
+
{
|
|
9910
|
+
key: "files",
|
|
9911
|
+
type: "string",
|
|
9912
|
+
state: "Default content and accessible names"
|
|
9913
|
+
},
|
|
9914
|
+
{
|
|
9915
|
+
key: "failed",
|
|
9916
|
+
type: "string",
|
|
9917
|
+
state: "Default content and accessible names"
|
|
9918
|
+
},
|
|
9919
|
+
{
|
|
9920
|
+
key: "typeRejected",
|
|
9921
|
+
type: "string",
|
|
9922
|
+
state: "Default content and accessible names"
|
|
9923
|
+
},
|
|
9924
|
+
{
|
|
9925
|
+
key: "hint",
|
|
9926
|
+
type: "(types: string, size: string) => string",
|
|
9927
|
+
state: "Default content and accessible names"
|
|
9928
|
+
},
|
|
9929
|
+
{
|
|
9930
|
+
key: "tooLarge",
|
|
9931
|
+
type: "(size: string) => string",
|
|
9932
|
+
state: "Default content and accessible names"
|
|
9933
|
+
},
|
|
9934
|
+
{
|
|
9935
|
+
key: "done",
|
|
9936
|
+
type: "(name: string) => string",
|
|
9937
|
+
state: "Async feedback"
|
|
9938
|
+
},
|
|
9939
|
+
{
|
|
9940
|
+
key: "error",
|
|
9941
|
+
type: "(name: string) => string",
|
|
9942
|
+
state: "Validation feedback"
|
|
9943
|
+
},
|
|
9944
|
+
{
|
|
9945
|
+
key: "added",
|
|
9946
|
+
type: "(count: number) => string",
|
|
9947
|
+
state: "Default content and accessible names"
|
|
9948
|
+
},
|
|
9949
|
+
{
|
|
9950
|
+
key: "rejected",
|
|
9951
|
+
type: "(count: number) => string",
|
|
9952
|
+
state: "Default content and accessible names"
|
|
9953
|
+
},
|
|
9954
|
+
{
|
|
9955
|
+
key: "removed",
|
|
9956
|
+
type: "(name: string) => string",
|
|
9957
|
+
state: "Default content and accessible names"
|
|
9958
|
+
},
|
|
9959
|
+
{
|
|
9960
|
+
key: "uploading",
|
|
9961
|
+
type: "(name: string) => string",
|
|
9962
|
+
state: "Async feedback"
|
|
9963
|
+
},
|
|
9964
|
+
{
|
|
9965
|
+
key: "notUploaded",
|
|
9966
|
+
type: "(error: string) => string",
|
|
9967
|
+
state: "Async feedback"
|
|
9968
|
+
},
|
|
9969
|
+
{
|
|
9970
|
+
key: "uploaded",
|
|
9971
|
+
type: "(size: string) => string",
|
|
9972
|
+
state: "Async feedback"
|
|
9973
|
+
},
|
|
9974
|
+
{
|
|
9975
|
+
key: "retry",
|
|
9976
|
+
type: "(name: string) => string",
|
|
9977
|
+
state: "Default content and accessible names"
|
|
9978
|
+
},
|
|
9979
|
+
{
|
|
9980
|
+
key: "remove",
|
|
9981
|
+
type: "(name: string) => string",
|
|
9982
|
+
state: "Default content and accessible names"
|
|
9983
|
+
}
|
|
9984
|
+
],
|
|
9117
9985
|
uses: [
|
|
9118
9986
|
"Button",
|
|
9119
9987
|
"IconButton",
|
|
@@ -9145,7 +10013,10 @@ function SampleFields() {
|
|
|
9145
10013
|
* Two-column form section: title and help on the left, fields on the right. Stacks into a
|
|
9146
10014
|
* single column on small screens.
|
|
9147
10015
|
*/
|
|
9148
|
-
function FormSection({ title
|
|
10016
|
+
function FormSection({ labels, title: titleProp, description: descriptionProp, children, actions, headingLevel: Heading = "h2", divided = false, className, ...props }) {
|
|
10017
|
+
const { t } = useI18n();
|
|
10018
|
+
const title = titleProp === void 0 ? labels?.title ?? t("formSection.title") : titleProp;
|
|
10019
|
+
const description = descriptionProp === void 0 ? labels?.description ?? t("formSection.description") : descriptionProp;
|
|
9149
10020
|
const id = useId();
|
|
9150
10021
|
return /* @__PURE__ */ jsxs("section", {
|
|
9151
10022
|
"aria-labelledby": title != null ? `${id}-title` : void 0,
|
|
@@ -9176,7 +10047,16 @@ const meta$30 = {
|
|
|
9176
10047
|
name: "Form section",
|
|
9177
10048
|
family: "forms",
|
|
9178
10049
|
status: "stable",
|
|
9179
|
-
description: "Two-column settings section: title and help on the left, fields on the right; stacks on small screens.",
|
|
10050
|
+
description: "Two-column settings section: title and help on the left, fields on the right; stacks on small screens. Optional labels?: Partial<FormSectionLabels> 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=form-section--labels.",
|
|
10051
|
+
labels: [{
|
|
10052
|
+
key: "title",
|
|
10053
|
+
type: "string",
|
|
10054
|
+
state: "Default content and accessible names"
|
|
10055
|
+
}, {
|
|
10056
|
+
key: "description",
|
|
10057
|
+
type: "string",
|
|
10058
|
+
state: "Default content and accessible names"
|
|
10059
|
+
}],
|
|
9180
10060
|
uses: [
|
|
9181
10061
|
"Field",
|
|
9182
10062
|
"Input",
|
|
@@ -9210,9 +10090,12 @@ const memberRoles = [
|
|
|
9210
10090
|
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
9211
10091
|
//#endregion
|
|
9212
10092
|
//#region src/forms/InviteMembersDialog/InviteMembersDialog.tsx
|
|
9213
|
-
const emailError = (t) => EMAIL_RE.test(t) ? null : `${t} is not a valid email address`;
|
|
9214
10093
|
/** Invite dialog: email chips with validation, a role and an optional message; submit with loading. */
|
|
9215
|
-
function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onInvite, maxInvites = 20, open: openProp, defaultOpen = false, onOpenChange, trigger = /* @__PURE__ */ jsx(Button, { icon: UserPlus }), title
|
|
10094
|
+
function InviteMembersDialog({ labels, roles = memberRoles, defaultRole = "member", onInvite, maxInvites = 20, open: openProp, defaultOpen = false, onOpenChange, trigger = /* @__PURE__ */ jsx(Button, { icon: UserPlus }), title: titleProp, description: descriptionProp }) {
|
|
10095
|
+
const { t } = useI18n();
|
|
10096
|
+
const title = titleProp ?? labels?.title ?? t("inviteMembers.title");
|
|
10097
|
+
const description = descriptionProp ?? labels?.description ?? t("inviteMembers.description");
|
|
10098
|
+
const emailError = (email) => EMAIL_RE.test(email) ? null : labels?.emailInvalid?.(email) ?? t("inviteMembers.emailInvalid", { email });
|
|
9216
10099
|
const [innerOpen, setInnerOpen] = useState(defaultOpen);
|
|
9217
10100
|
const [emails, setEmails] = useState([]);
|
|
9218
10101
|
const [role, setRole] = useState(defaultRole);
|
|
@@ -9222,7 +10105,7 @@ function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onIn
|
|
|
9222
10105
|
const [error, setError] = useState(null);
|
|
9223
10106
|
const open = openProp ?? innerOpen;
|
|
9224
10107
|
const invalidCount = emails.filter((e) => emailError(e)).length;
|
|
9225
|
-
const emailsProblem = emails.length === 0 ?
|
|
10108
|
+
const emailsProblem = emails.length === 0 ? labels?.emailRequired ?? t("inviteMembers.emailRequired") : invalidCount > 0 ? labels?.fixInvalid?.(invalidCount) ?? t("inviteMembers.fixInvalid", { count: invalidCount }) : null;
|
|
9226
10109
|
const showEmailError = submitted && emailsProblem != null;
|
|
9227
10110
|
const setOpen = (next) => {
|
|
9228
10111
|
if (loading && !next) return;
|
|
@@ -9251,7 +10134,7 @@ function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onIn
|
|
|
9251
10134
|
setOpen(false);
|
|
9252
10135
|
} catch (e) {
|
|
9253
10136
|
setLoading(false);
|
|
9254
|
-
setError(e instanceof Error ? e.message :
|
|
10137
|
+
setError(e instanceof Error ? e.message : labels?.fallbackError ?? t("inviteMembers.fallbackError"));
|
|
9255
10138
|
}
|
|
9256
10139
|
};
|
|
9257
10140
|
const roleLabel = roles.find((r) => r.value === role)?.description;
|
|
@@ -9277,15 +10160,15 @@ function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onIn
|
|
|
9277
10160
|
children: [
|
|
9278
10161
|
/* @__PURE__ */ jsx(FieldLabel, {
|
|
9279
10162
|
required: true,
|
|
9280
|
-
children:
|
|
10163
|
+
children: labels?.emails ?? t("inviteMembers.emails")
|
|
9281
10164
|
}),
|
|
9282
10165
|
/* @__PURE__ */ jsx(TokenInput, {
|
|
9283
10166
|
value: emails,
|
|
9284
10167
|
onValueChange: setEmails,
|
|
9285
10168
|
validate: emailError,
|
|
9286
10169
|
maxItems: maxInvites,
|
|
9287
|
-
placeholder: "
|
|
9288
|
-
listLabel:
|
|
10170
|
+
placeholder: labels?.placeholder ?? t("inviteMembers.placeholder"),
|
|
10171
|
+
listLabel: labels?.listLabel ?? t("inviteMembers.listLabel"),
|
|
9289
10172
|
invalid: showEmailError
|
|
9290
10173
|
}),
|
|
9291
10174
|
/* @__PURE__ */ jsx(FieldError, {
|
|
@@ -9295,7 +10178,7 @@ function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onIn
|
|
|
9295
10178
|
]
|
|
9296
10179
|
}),
|
|
9297
10180
|
/* @__PURE__ */ jsxs(Field, { children: [
|
|
9298
|
-
/* @__PURE__ */ jsx(FieldLabel, { children: "
|
|
10181
|
+
/* @__PURE__ */ jsx(FieldLabel, { children: labels?.role ?? t("inviteMembers.role") }),
|
|
9299
10182
|
/* @__PURE__ */ jsxs(Select, {
|
|
9300
10183
|
value: role,
|
|
9301
10184
|
onValueChange: (v) => v != null && setRole(v),
|
|
@@ -9310,15 +10193,15 @@ function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onIn
|
|
|
9310
10193
|
}),
|
|
9311
10194
|
roleLabel && /* @__PURE__ */ jsx(FieldDescription, { children: roleLabel })
|
|
9312
10195
|
] }),
|
|
9313
|
-
/* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(FieldLabel, { children:
|
|
10196
|
+
/* @__PURE__ */ jsxs(Field, { children: [/* @__PURE__ */ jsx(FieldLabel, { children: labels?.message ?? t("inviteMembers.message") }), /* @__PURE__ */ jsx(Textarea, {
|
|
9314
10197
|
rows: 3,
|
|
9315
10198
|
value: message,
|
|
9316
10199
|
onValueChange: setMessage,
|
|
9317
|
-
placeholder:
|
|
10200
|
+
placeholder: labels?.messagePlaceholder ?? t("inviteMembers.messagePlaceholder")
|
|
9318
10201
|
})] }),
|
|
9319
10202
|
error && /* @__PURE__ */ jsx(Alert, {
|
|
9320
10203
|
tone: "destructive",
|
|
9321
|
-
title:
|
|
10204
|
+
title: labels?.errorTitle ?? t("inviteMembers.errorTitle"),
|
|
9322
10205
|
description: error
|
|
9323
10206
|
})
|
|
9324
10207
|
]
|
|
@@ -9327,11 +10210,11 @@ function InviteMembersDialog({ roles = memberRoles, defaultRole = "member", onIn
|
|
|
9327
10210
|
variant: "ghost",
|
|
9328
10211
|
disabled: loading
|
|
9329
10212
|
}),
|
|
9330
|
-
children: "
|
|
10213
|
+
children: labels?.cancel ?? t("inviteMembers.cancel")
|
|
9331
10214
|
}), /* @__PURE__ */ jsx(Button, {
|
|
9332
10215
|
type: "submit",
|
|
9333
10216
|
loading,
|
|
9334
|
-
children: emails.length > 1 ?
|
|
10217
|
+
children: emails.length > 1 ? labels?.submitMany?.(emails.length) ?? t("inviteMembers.submitMany", { count: emails.length }) : labels?.submit ?? t("inviteMembers.submit")
|
|
9335
10218
|
})] })]
|
|
9336
10219
|
})]
|
|
9337
10220
|
})]
|
|
@@ -9343,7 +10226,89 @@ const meta$35 = {
|
|
|
9343
10226
|
name: "Invite members dialog",
|
|
9344
10227
|
family: "forms",
|
|
9345
10228
|
status: "stable",
|
|
9346
|
-
description: "Dialog to invite people by email (validated chips) with a role and an optional message; submits with a loading state.",
|
|
10229
|
+
description: "Dialog to invite people by email (validated chips) with a role and an optional message; submits with a loading state. Optional labels?: Partial<InviteMembersDialogLabels> 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=invite-members-dialog--labels.",
|
|
10230
|
+
labels: [
|
|
10231
|
+
{
|
|
10232
|
+
key: "title",
|
|
10233
|
+
type: "string",
|
|
10234
|
+
state: "Default content and accessible names"
|
|
10235
|
+
},
|
|
10236
|
+
{
|
|
10237
|
+
key: "description",
|
|
10238
|
+
type: "string",
|
|
10239
|
+
state: "Default content and accessible names"
|
|
10240
|
+
},
|
|
10241
|
+
{
|
|
10242
|
+
key: "emails",
|
|
10243
|
+
type: "string",
|
|
10244
|
+
state: "Default content and accessible names"
|
|
10245
|
+
},
|
|
10246
|
+
{
|
|
10247
|
+
key: "placeholder",
|
|
10248
|
+
type: "string",
|
|
10249
|
+
state: "Default content and accessible names"
|
|
10250
|
+
},
|
|
10251
|
+
{
|
|
10252
|
+
key: "listLabel",
|
|
10253
|
+
type: "string",
|
|
10254
|
+
state: "Default content and accessible names"
|
|
10255
|
+
},
|
|
10256
|
+
{
|
|
10257
|
+
key: "role",
|
|
10258
|
+
type: "string",
|
|
10259
|
+
state: "Default content and accessible names"
|
|
10260
|
+
},
|
|
10261
|
+
{
|
|
10262
|
+
key: "message",
|
|
10263
|
+
type: "string",
|
|
10264
|
+
state: "Default content and accessible names"
|
|
10265
|
+
},
|
|
10266
|
+
{
|
|
10267
|
+
key: "messagePlaceholder",
|
|
10268
|
+
type: "string",
|
|
10269
|
+
state: "Default content and accessible names"
|
|
10270
|
+
},
|
|
10271
|
+
{
|
|
10272
|
+
key: "emailRequired",
|
|
10273
|
+
type: "string",
|
|
10274
|
+
state: "Validation feedback"
|
|
10275
|
+
},
|
|
10276
|
+
{
|
|
10277
|
+
key: "emailInvalid",
|
|
10278
|
+
type: "(email: string) => string",
|
|
10279
|
+
state: "Validation feedback"
|
|
10280
|
+
},
|
|
10281
|
+
{
|
|
10282
|
+
key: "fixInvalid",
|
|
10283
|
+
type: "(count: number) => string",
|
|
10284
|
+
state: "Validation feedback"
|
|
10285
|
+
},
|
|
10286
|
+
{
|
|
10287
|
+
key: "errorTitle",
|
|
10288
|
+
type: "string",
|
|
10289
|
+
state: "Validation feedback"
|
|
10290
|
+
},
|
|
10291
|
+
{
|
|
10292
|
+
key: "fallbackError",
|
|
10293
|
+
type: "string",
|
|
10294
|
+
state: "Validation feedback"
|
|
10295
|
+
},
|
|
10296
|
+
{
|
|
10297
|
+
key: "cancel",
|
|
10298
|
+
type: "string",
|
|
10299
|
+
state: "Default content and accessible names"
|
|
10300
|
+
},
|
|
10301
|
+
{
|
|
10302
|
+
key: "submit",
|
|
10303
|
+
type: "string",
|
|
10304
|
+
state: "Default content and accessible names"
|
|
10305
|
+
},
|
|
10306
|
+
{
|
|
10307
|
+
key: "submitMany",
|
|
10308
|
+
type: "(count: number) => string",
|
|
10309
|
+
state: "Default content and accessible names"
|
|
10310
|
+
}
|
|
10311
|
+
],
|
|
9347
10312
|
uses: [
|
|
9348
10313
|
"Dialog",
|
|
9349
10314
|
"TokenInput",
|
|
@@ -9357,7 +10322,10 @@ const meta$35 = {
|
|
|
9357
10322
|
//#endregion
|
|
9358
10323
|
//#region src/forms/SettingsRow/SettingsRow.tsx
|
|
9359
10324
|
/** One setting: label and description on the left, its control (a Switch by default) on the right. */
|
|
9360
|
-
function SettingsRow({ label
|
|
10325
|
+
function SettingsRow({ labels, label: labelProp, description: descriptionProp, control, checked, defaultChecked = true, onCheckedChange, disabled, children, className }) {
|
|
10326
|
+
const { t } = useI18n();
|
|
10327
|
+
const label = labelProp === void 0 ? labels?.label ?? t("settingsRow.label") : labelProp;
|
|
10328
|
+
const description = descriptionProp === void 0 ? labels?.description ?? t("settingsRow.description") : descriptionProp;
|
|
9361
10329
|
const id = useId();
|
|
9362
10330
|
const labelId = `${id}-label`;
|
|
9363
10331
|
const descriptionId = description != null ? `${id}-desc` : void 0;
|
|
@@ -9401,22 +10369,31 @@ const meta$60 = {
|
|
|
9401
10369
|
name: "Settings row",
|
|
9402
10370
|
family: "forms",
|
|
9403
10371
|
status: "stable",
|
|
9404
|
-
description: "A setting with its label and description on the left and a control (Switch by default) on the right.",
|
|
10372
|
+
description: "A setting with its label and description on the left and a control (Switch by default) on the right. Optional labels?: Partial<SettingsRowLabels> 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=settings-row--labels.",
|
|
10373
|
+
labels: [{
|
|
10374
|
+
key: "label",
|
|
10375
|
+
type: "string",
|
|
10376
|
+
state: "Default content and accessible names"
|
|
10377
|
+
}, {
|
|
10378
|
+
key: "description",
|
|
10379
|
+
type: "string",
|
|
10380
|
+
state: "Default content and accessible names"
|
|
10381
|
+
}],
|
|
9405
10382
|
uses: ["Switch"]
|
|
9406
10383
|
};
|
|
9407
10384
|
//#endregion
|
|
9408
10385
|
//#region src/forms/DialogWizard/DialogWizard.tsx
|
|
9409
10386
|
/** Modal variant of create-wizard for a flow over its parent page. State stays consumer-owned. */
|
|
9410
|
-
function DialogWizard({ steps, current = 0, size = "dialog", stepError, reviewStep, children, title, ...props }) {
|
|
10387
|
+
function DialogWizard({ labels, steps, current = 0, size = "dialog", stepError, reviewStep, children, title, ...props }) {
|
|
9411
10388
|
const { t } = useI18n();
|
|
9412
|
-
const items = steps ?? [{ label: t("wizard.details") }, { label: t("wizard.review") }];
|
|
10389
|
+
const items = steps ?? [{ label: labels?.details ?? t("wizard.details") }, { label: labels?.review ?? t("wizard.review") }];
|
|
9413
10390
|
return /* @__PURE__ */ jsxs(WizardLayout, {
|
|
9414
10391
|
...props,
|
|
9415
10392
|
mode: "overlay",
|
|
9416
10393
|
size,
|
|
9417
10394
|
steps: items,
|
|
9418
10395
|
current,
|
|
9419
|
-
title: title ?? t("wizard.title"),
|
|
10396
|
+
title: title ?? labels?.title ?? t("wizard.title"),
|
|
9420
10397
|
children: [stepError, current >= items.length - 1 && reviewStep != null ? reviewStep : children]
|
|
9421
10398
|
});
|
|
9422
10399
|
}
|
|
@@ -9426,7 +10403,24 @@ const meta$19 = {
|
|
|
9426
10403
|
name: "Dialog wizard",
|
|
9427
10404
|
family: "forms",
|
|
9428
10405
|
status: "beta",
|
|
9429
|
-
description: "Modal variant of create-wizard for create flows over their parent page, without a route change. Defaults to dialog size (fullscreen on mobile); size=\"fullscreen\" fills every viewport. Consumer-controlled step state survives closing. Use the create-wizard page template for a dedicated page flow, or WizardLayout mode=\"overlay\" for a fullscreen flow. Supply all labels, pendingLabel and stepAnnouncement from your own i18n; stepError accepts ValidationSummary and reviewStep accepts DescriptionListCard.",
|
|
10406
|
+
description: "Modal variant of create-wizard for create flows over their parent page, without a route change. Defaults to dialog size (fullscreen on mobile); size=\"fullscreen\" fills every viewport. Consumer-controlled step state survives closing. Use the create-wizard page template for a dedicated page flow, or WizardLayout mode=\"overlay\" for a fullscreen flow. Supply all labels, pendingLabel and stepAnnouncement from your own i18n; stepError accepts ValidationSummary and reviewStep accepts DescriptionListCard. Optional labels?: Partial<DialogWizardLabels> 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=dialog-wizard--labels.",
|
|
10407
|
+
labels: [
|
|
10408
|
+
{
|
|
10409
|
+
key: "title",
|
|
10410
|
+
type: "string",
|
|
10411
|
+
state: "Default content and accessible names"
|
|
10412
|
+
},
|
|
10413
|
+
{
|
|
10414
|
+
key: "details",
|
|
10415
|
+
type: "string",
|
|
10416
|
+
state: "Default content and accessible names"
|
|
10417
|
+
},
|
|
10418
|
+
{
|
|
10419
|
+
key: "review",
|
|
10420
|
+
type: "string",
|
|
10421
|
+
state: "Default content and accessible names"
|
|
10422
|
+
}
|
|
10423
|
+
],
|
|
9430
10424
|
uses: [
|
|
9431
10425
|
"WizardLayout",
|
|
9432
10426
|
"Dialog",
|
|
@@ -9465,7 +10459,12 @@ const meta$75 = {
|
|
|
9465
10459
|
name: "Validation summary",
|
|
9466
10460
|
family: "forms",
|
|
9467
10461
|
status: "stable",
|
|
9468
|
-
description: "Error summary that lists every problem with a link to its field and takes focus after a failed submit.",
|
|
10462
|
+
description: "Error summary that lists every problem with a link to its field and takes focus after a failed submit. Optional labels?: Partial<ValidationSummaryLabels> 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=validation-summary--labels.",
|
|
10463
|
+
labels: [{
|
|
10464
|
+
key: "title",
|
|
10465
|
+
type: "(count: number) => string",
|
|
10466
|
+
state: "Default content and accessible names"
|
|
10467
|
+
}],
|
|
9469
10468
|
uses: ["Alert", "Link"]
|
|
9470
10469
|
};
|
|
9471
10470
|
//#endregion
|
|
@@ -10506,7 +11505,7 @@ const pageHeaderTabs = [
|
|
|
10506
11505
|
//#endregion
|
|
10507
11506
|
//#region src/page-chrome/PageHeader/PageHeader.tsx
|
|
10508
11507
|
/** Screen header: breadcrumb, title + status, description, meta row, actions and optional tabs. */
|
|
10509
|
-
function PageHeader({ as: Root = "header", breadcrumbs = pageHeaderBreadcrumbs, title: titleProp, labels, titleRef, description: descriptionProp, status = "active", statuses, meta = pageHeaderMeta, actions = pageHeaderActions, tabs = pageHeaderTabs, tab, defaultTab, onTabChange, className }) {
|
|
11508
|
+
function PageHeader({ as: Root = "header", breadcrumbs = pageHeaderBreadcrumbs, title: titleProp, wrapTitle = false, labels, titleRef, description: descriptionProp, status = "active", statuses, meta = pageHeaderMeta, actions = pageHeaderActions, tabs = pageHeaderTabs, tab, defaultTab, onTabChange, className }) {
|
|
10510
11509
|
const { t } = useI18n();
|
|
10511
11510
|
const title = titleProp === void 0 ? labels?.title ?? t("pageHeader.title") : titleProp;
|
|
10512
11511
|
const description = descriptionProp === void 0 ? labels?.description ?? t("pageHeader.description") : descriptionProp;
|
|
@@ -10539,7 +11538,7 @@ function PageHeader({ as: Root = "header", breadcrumbs = pageHeaderBreadcrumbs,
|
|
|
10539
11538
|
children: [/* @__PURE__ */ jsx("h1", {
|
|
10540
11539
|
ref: titleRef,
|
|
10541
11540
|
tabIndex: titleRef != null ? -1 : void 0,
|
|
10542
|
-
className: "min-w-0 truncate text-2xl font-bold tracking-tight text-foreground",
|
|
11541
|
+
className: cn(wrapTitle ? "min-w-0 wrap-anywhere" : "min-w-0 truncate", "text-2xl font-bold tracking-tight text-foreground"),
|
|
10543
11542
|
children: title
|
|
10544
11543
|
}), status && /* @__PURE__ */ jsx(StatusTag, {
|
|
10545
11544
|
status,
|
|
@@ -10606,7 +11605,7 @@ const meta$45 = {
|
|
|
10606
11605
|
name: "Page header",
|
|
10607
11606
|
family: "page-chrome",
|
|
10608
11607
|
status: "beta",
|
|
10609
|
-
description: "Screen header with breadcrumb, title and status, description, meta row, actions that fold into a MoreMenu on small screens, and optional navigation tabs. titleRef targets the h1 for titleRef.current.focus(), adding tabIndex=-1 only when supplied so the title stays outside the Tab order. In a StatusLayout heading slot use as=\"div\" and disable breadcrumb, meta, tabs, actions, status and description fixtures; the slot supplies the page’s only h1. The tablist name follows I18nProvider (en/es); the Spanish preview keeps caller content unchanged. Optional labels?: Partial<PageHeaderLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview.",
|
|
11608
|
+
description: "Screen header with breadcrumb, title and status, description, meta row, actions that fold into a MoreMenu on small screens, and optional navigation tabs. titleRef targets the h1 for titleRef.current.focus(), adding tabIndex=-1 only when supplied so the title stays outside the Tab order. In a StatusLayout heading slot use as=\"div\" and disable breadcrumb, meta, tabs, actions, status and description fixtures; the slot supplies the page’s only h1. The tablist name follows I18nProvider (en/es); the Spanish preview keeps caller content unchanged. Optional labels?: Partial<PageHeaderLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview. wrapTitle?: boolean (default false) wraps the full title, including long words, while preserving titleRef focus behavior. The default title remains truncated. See the Spanish live preview for a wrapping title.",
|
|
10610
11609
|
labels: [
|
|
10611
11610
|
{
|
|
10612
11611
|
key: "title",
|
|
@@ -13172,7 +14171,7 @@ function isCellEditable(column, row) {
|
|
|
13172
14171
|
}
|
|
13173
14172
|
//#endregion
|
|
13174
14173
|
//#region src/tables/DataTable/data-table-row.tsx
|
|
13175
|
-
function DataTableRow({ labels, row, columns, getRowId, getRowLabel, selectable, selected, singleSelection, onToggleRow, rowActions, layout, onCellEdit, editHintId, ariaRowIndex, style }) {
|
|
14174
|
+
function DataTableRow({ labels, row, columns, getRowId, getRowLabel, selectable, isRowDisabled, selected, singleSelection, onToggleRow, rowActions, layout, onCellEdit, editHintId, ariaRowIndex, style }) {
|
|
13176
14175
|
const { t } = useI18n();
|
|
13177
14176
|
const locale = useOptionalI18n()?.locale;
|
|
13178
14177
|
const id = getRowId(row);
|
|
@@ -13199,6 +14198,7 @@ function DataTableRow({ labels, row, columns, getRowId, getRowLabel, selectable,
|
|
|
13199
14198
|
}) : /* @__PURE__ */ jsx(Checkbox, {
|
|
13200
14199
|
"aria-label": labels?.selectRow?.(label) ?? t("table.selectRow", { label }),
|
|
13201
14200
|
checked: isSelected,
|
|
14201
|
+
disabled: isRowDisabled?.(row),
|
|
13202
14202
|
onCheckedChange: () => onToggleRow(id)
|
|
13203
14203
|
})
|
|
13204
14204
|
}),
|
|
@@ -13243,7 +14243,7 @@ const groupHeadClass = "h-9 bg-secondary/50 text-[12.5px] font-semibold tracking
|
|
|
13243
14243
|
/** The header row of a group: group checkbox, collapse button, label and count. */
|
|
13244
14244
|
function GroupHeaderRow({ labels, group, open, selectable, selected, span, collapsible, onToggle, onToggleRows, ariaRowIndex, style }) {
|
|
13245
14245
|
const { t } = useI18n();
|
|
13246
|
-
const state = selectionState(group.
|
|
14246
|
+
const state = selectionState(group.selectableIds, selected);
|
|
13247
14247
|
const count = group.ids.length;
|
|
13248
14248
|
const heading = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
13249
14249
|
/* @__PURE__ */ jsx("span", {
|
|
@@ -13272,8 +14272,8 @@ function GroupHeaderRow({ labels, group, open, selectable, selected, span, colla
|
|
|
13272
14272
|
"aria-label": labels?.selectGroup?.(group.name) ?? t("table.selectRow", { label: `all in ${group.name}` }),
|
|
13273
14273
|
checked: state.checked,
|
|
13274
14274
|
indeterminate: state.indeterminate,
|
|
13275
|
-
disabled:
|
|
13276
|
-
onCheckedChange: () => onToggleRows?.(group.
|
|
14275
|
+
disabled: group.selectableIds.length === 0,
|
|
14276
|
+
onCheckedChange: () => onToggleRows?.(group.selectableIds)
|
|
13277
14277
|
})
|
|
13278
14278
|
}), /* @__PURE__ */ jsx(TableHead, {
|
|
13279
14279
|
scope: "rowgroup",
|
|
@@ -13783,10 +14783,7 @@ function useSingleSelection(options) {
|
|
|
13783
14783
|
}
|
|
13784
14784
|
};
|
|
13785
14785
|
}
|
|
13786
|
-
function useSingleSelectionWarnings({ single, selectionName,
|
|
13787
|
-
useEffect(() => {
|
|
13788
|
-
if (single && paginated === true && process.env.NODE_ENV === "development") console.warn("DataTable single selection: paginated=true is unsupported; rendering all rows without pagination.");
|
|
13789
|
-
}, [single, paginated]);
|
|
14786
|
+
function useSingleSelectionWarnings({ single, selectionName, hasLabel }) {
|
|
13790
14787
|
useEffect(() => {
|
|
13791
14788
|
if (!single || process.env.NODE_ENV !== "development") return;
|
|
13792
14789
|
if (!hasLabel) console.warn("DataTable single selection: supply legend, aria-label or aria-labelledby.");
|
|
@@ -13815,6 +14812,24 @@ function SelectionGroup({ single, legend, children, ...label }) {
|
|
|
13815
14812
|
});
|
|
13816
14813
|
}
|
|
13817
14814
|
//#endregion
|
|
14815
|
+
//#region src/tables/DataTable/selection-strip.tsx
|
|
14816
|
+
/** The same button stays mounted as the announcement and action change. */
|
|
14817
|
+
function SelectionStrip({ all, message, total, onSelectAll, onClear, labels }) {
|
|
14818
|
+
const { t, formatNumber } = useI18n();
|
|
14819
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
14820
|
+
className: "flex flex-wrap items-center gap-2 border-b border-border bg-secondary/30 px-3 py-2 text-sm text-foreground",
|
|
14821
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
14822
|
+
"aria-hidden": "true",
|
|
14823
|
+
children: message
|
|
14824
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
14825
|
+
variant: "soft",
|
|
14826
|
+
size: "sm",
|
|
14827
|
+
onClick: all ? onClear : onSelectAll,
|
|
14828
|
+
children: all ? labels?.clearSelection ?? t("common.clearSelection") : labels?.selectAllMatching?.(total) ?? t("table.selectAllMatching", { count: formatNumber(total) })
|
|
14829
|
+
})]
|
|
14830
|
+
});
|
|
14831
|
+
}
|
|
14832
|
+
//#endregion
|
|
13818
14833
|
//#region src/tables/DataTable/views.tsx
|
|
13819
14834
|
const norm = (s) => JSON.stringify({
|
|
13820
14835
|
filters: s.filters ?? null,
|
|
@@ -14015,6 +15030,83 @@ function useTableViews({ views: viewsProp, defaultViews = [], onViewsChange, act
|
|
|
14015
15030
|
};
|
|
14016
15031
|
}
|
|
14017
15032
|
//#endregion
|
|
15033
|
+
//#region src/tables/DataTable/use-multiple-selection.ts
|
|
15034
|
+
/** Owns include/exclude selection independently of the currently supplied server page. */
|
|
15035
|
+
function useMultipleSelection(options) {
|
|
15036
|
+
const needsModelCallback = options.serverMode && options.selectAllMatching && !options.onSelectionModelChange;
|
|
15037
|
+
useEffect(() => {
|
|
15038
|
+
if (needsModelCallback && process.env.NODE_ENV === "development") console.warn("DataTable selectAllMatching with server pagination requires onSelectionModelChange.");
|
|
15039
|
+
}, [needsModelCallback]);
|
|
15040
|
+
const [inner, setInner] = useState(() => ({
|
|
15041
|
+
type: "include",
|
|
15042
|
+
ids: [...options.defaultSelectedIds]
|
|
15043
|
+
}));
|
|
15044
|
+
const model = options.selectionModel ?? (options.selectedIds ? {
|
|
15045
|
+
type: "include",
|
|
15046
|
+
ids: [...options.selectedIds]
|
|
15047
|
+
} : inner);
|
|
15048
|
+
const modelIds = new Set(model.ids);
|
|
15049
|
+
const selected = new Set(model.type === "exclude" ? options.enabledIds.filter((id) => !modelIds.has(id)) : model.ids);
|
|
15050
|
+
const report = (next) => {
|
|
15051
|
+
const ids = new Set(next.ids);
|
|
15052
|
+
if (next.type === "exclude") return options.enabledIds.filter((id) => !ids.has(id));
|
|
15053
|
+
return options.preserveSelection ? [...next.ids] : options.rowIds.filter((id) => ids.has(id));
|
|
15054
|
+
};
|
|
15055
|
+
const selectedList = report(model);
|
|
15056
|
+
const change = (next) => {
|
|
15057
|
+
setInner(next);
|
|
15058
|
+
options.onSelectionChange?.(report(next));
|
|
15059
|
+
options.onSelectionModelChange?.(next);
|
|
15060
|
+
};
|
|
15061
|
+
const filterKey = JSON.stringify(options.filters);
|
|
15062
|
+
const previousFilters = useRef(filterKey);
|
|
15063
|
+
const resetForFilters = useEffectEvent(() => {
|
|
15064
|
+
if (model.type === "exclude") change({
|
|
15065
|
+
type: "include",
|
|
15066
|
+
ids: []
|
|
15067
|
+
});
|
|
15068
|
+
});
|
|
15069
|
+
useEffect(() => {
|
|
15070
|
+
if (previousFilters.current !== filterKey) {
|
|
15071
|
+
previousFilters.current = filterKey;
|
|
15072
|
+
resetForFilters();
|
|
15073
|
+
}
|
|
15074
|
+
}, [filterKey]);
|
|
15075
|
+
return {
|
|
15076
|
+
selected,
|
|
15077
|
+
selectedList,
|
|
15078
|
+
model,
|
|
15079
|
+
selectedCount: model.type === "exclude" ? Math.max(0, options.total - model.ids.length) : selectedList.length,
|
|
15080
|
+
allMatchingSelected: model.type === "exclude" || options.enabledIds.length > 0 && options.enabledIds.every((id) => selected.has(id)),
|
|
15081
|
+
selectAllMatching: () => change(options.serverMode ? {
|
|
15082
|
+
type: "exclude",
|
|
15083
|
+
ids: options.rowIds.filter((id) => !options.enabledIds.includes(id))
|
|
15084
|
+
} : {
|
|
15085
|
+
type: "include",
|
|
15086
|
+
ids: options.enabledIds
|
|
15087
|
+
}),
|
|
15088
|
+
clear: () => change({
|
|
15089
|
+
type: "include",
|
|
15090
|
+
ids: []
|
|
15091
|
+
}),
|
|
15092
|
+
setSelected: (next) => {
|
|
15093
|
+
if (model.type === "include") change({
|
|
15094
|
+
type: "include",
|
|
15095
|
+
ids: [...next]
|
|
15096
|
+
});
|
|
15097
|
+
else {
|
|
15098
|
+
const excluded = new Set(model.ids);
|
|
15099
|
+
for (const id of options.enabledIds) if (next.has(id)) excluded.delete(id);
|
|
15100
|
+
else excluded.add(id);
|
|
15101
|
+
change({
|
|
15102
|
+
type: "exclude",
|
|
15103
|
+
ids: [...excluded]
|
|
15104
|
+
});
|
|
15105
|
+
}
|
|
15106
|
+
}
|
|
15107
|
+
};
|
|
15108
|
+
}
|
|
15109
|
+
//#endregion
|
|
14018
15110
|
//#region src/tables/DataTable/use-virtual-rows.ts
|
|
14019
15111
|
/** Computes a virtual window from the table container's scroll position. */
|
|
14020
15112
|
function windowFor(count, scrollTop, viewport, rowHeight, overscan) {
|
|
@@ -14086,25 +15178,25 @@ const ROW_HEIGHT = {
|
|
|
14086
15178
|
* and empty states, client-side sort + pagination, optional collapsible row groups (`groupBy`),
|
|
14087
15179
|
* column resize and pinning, row virtualization, inline cell editing and saved views.
|
|
14088
15180
|
*/
|
|
14089
|
-
function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRowId = defaultRowId, getRowLabel, caption = "Deployments", showCaption = false, selectable: selectableProp = true, selectionMode, selectionName, legend, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, selectedId, defaultSelectedId, onSelectedIdChange, isRowDisabled, selectedIds, defaultSelectedIds = [], onSelectionChange, bulkActions, selectionSummary = true, rowActions, sort: sortProp, defaultSort = null, onSortChange, manualSorting = false, paginated: paginatedProp, paginationMode = "client", rowCount, page: controlledPage, pageSize: controlledPageSize, onPageChange, onPageSizeChange, defaultPageSize = 10, pageSizeOptions = [
|
|
15181
|
+
function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRowId = defaultRowId, getRowLabel, caption = "Deployments", showCaption = false, selectable: selectableProp = true, selectionMode, selectionName, legend, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, selectedId, defaultSelectedId, onSelectedIdChange, isRowDisabled, selectedIds, defaultSelectedIds = [], onSelectionChange, preserveSelection, selectAllMatching = false, hideSelectAll = false, selectionModel, onSelectionModelChange, bulkActions, selectionSummary = true, rowActions, sort: sortProp, defaultSort = null, onSortChange, manualSorting = false, paginated: paginatedProp, paginationMode = "client", rowCount, page: controlledPage, pageSize: controlledPageSize, onPageChange, onPageSizeChange, defaultPageSize = 10, pageSizeOptions = [
|
|
14090
15182
|
10,
|
|
14091
15183
|
25,
|
|
14092
15184
|
50
|
|
14093
15185
|
], density: densityProp, defaultDensity, onDensityChange, showDensityToggle = true, showColumnMenu = true, loading = false, loadingRows = 5, emptyState, groupBy, groupLabel, collapsibleGroups = true, collapsedGroups: collapsedProp, defaultCollapsedGroups = [], onCollapsedGroupsChange, onGroupByChange, hiddenColumns: hiddenProp, onHiddenColumnsChange, resizable = false, columnWidths: widthsProp, defaultColumnWidths = EMPTY_WIDTHS, onColumnWidthsChange, pinnedColumns: pinnedProp, defaultPinnedColumns = EMPTY_PINNED, onPinnedColumnsChange, showPinMenu, virtualize = "auto", virtualizeThreshold = 100, rowHeight: rowHeightProp, virtualContainerClassName = "max-h-[32rem]", onCellEdit, views: viewsProp, defaultViews, onViewsChange, activeViewId, defaultActiveViewId, onActiveViewChange, showViewSwitcher, filters, onFiltersChange, toolbar, className, labels }) {
|
|
14094
|
-
const { t } = useI18n();
|
|
15186
|
+
const { t, formatNumber } = useI18n();
|
|
14095
15187
|
const singleMode = selectionMode === "single";
|
|
14096
15188
|
const serverMode = paginationMode === "server";
|
|
14097
15189
|
const selectable = selectionMode === void 0 ? selectableProp : selectionMode === "multiple";
|
|
14098
15190
|
const selectionColumn = selectable || singleMode;
|
|
14099
|
-
const paginated =
|
|
15191
|
+
const paginated = paginatedProp ?? (serverMode || !singleMode);
|
|
14100
15192
|
const editHintId = useId();
|
|
14101
15193
|
const tableRef = useRef(null);
|
|
15194
|
+
const pageCheckboxRef = useRef(null);
|
|
14102
15195
|
const [initialView] = useState(() => (viewsProp ?? defaultViews ?? []).find((v) => v.id === (activeViewId ?? defaultActiveViewId)));
|
|
14103
15196
|
const [initialFilters] = useState(() => filters);
|
|
14104
15197
|
const seed = initialView?.state ?? {};
|
|
14105
15198
|
const defaultHidden = columns.filter((c) => c.defaultHidden).map((c) => c.id);
|
|
14106
15199
|
const [innerSort, setInnerSort] = useState(seed.sort !== void 0 ? seed.sort : defaultSort);
|
|
14107
|
-
const [innerSelected, setInnerSelected] = useState(() => new Set(defaultSelectedIds));
|
|
14108
15200
|
const [innerDensity, setInnerDensity] = useState(defaultDensity ?? null);
|
|
14109
15201
|
const contextDensity = useDensity();
|
|
14110
15202
|
const [hiddenList, setHiddenList] = useControllable(hiddenProp, () => seed.hiddenColumns ?? defaultHidden, (ids) => onHiddenColumnsChange?.([...ids]));
|
|
@@ -14116,7 +15208,21 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14116
15208
|
const hidden = new Set(hiddenList);
|
|
14117
15209
|
const effectiveGroupBy = groupOverride === void 0 ? groupBy : groupOverride ?? void 0;
|
|
14118
15210
|
const sort = sortProp === void 0 ? innerSort : sortProp;
|
|
14119
|
-
const
|
|
15211
|
+
const enabledIds = rows.filter((row) => !isRowDisabled?.(row)).map(getRowId);
|
|
15212
|
+
const { selected, selectedList, setSelected, model, selectedCount, allMatchingSelected, selectAllMatching: selectMatching, clear } = useMultipleSelection({
|
|
15213
|
+
rowIds: rows.map(getRowId),
|
|
15214
|
+
selectedIds,
|
|
15215
|
+
defaultSelectedIds,
|
|
15216
|
+
onSelectionChange,
|
|
15217
|
+
preserveSelection: preserveSelection ?? serverMode,
|
|
15218
|
+
enabledIds,
|
|
15219
|
+
selectionModel,
|
|
15220
|
+
onSelectionModelChange,
|
|
15221
|
+
serverMode,
|
|
15222
|
+
selectAllMatching: selectable && selectAllMatching,
|
|
15223
|
+
total: rowCount ?? rows.length,
|
|
15224
|
+
filters
|
|
15225
|
+
});
|
|
14120
15226
|
const density = densityProp ?? innerDensity ?? contextDensity;
|
|
14121
15227
|
const visibleColumns = orderColumns(columns.filter((c) => !hidden.has(c.id)), pinned);
|
|
14122
15228
|
const labelOf = getRowLabel ?? ((row) => {
|
|
@@ -14129,13 +15235,8 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14129
15235
|
const allGroups = effectiveGroupBy ? groupRows(sortedRows, effectiveGroupBy, rows) : null;
|
|
14130
15236
|
const sorted = allGroups ? allGroups.flatMap((g) => g.rows) : sortedRows;
|
|
14131
15237
|
const pageRows = serverMode ? rows : paginated ? paginate(sorted, page, pageSize) : sorted;
|
|
14132
|
-
const pageIds = (effectiveGroupBy ? pageRows.filter((row) => !collapsed.has(groupKeyOf(row, effectiveGroupBy))) : pageRows).map(getRowId);
|
|
15238
|
+
const pageIds = (effectiveGroupBy ? pageRows.filter((row) => !collapsed.has(groupKeyOf(row, effectiveGroupBy))) : pageRows).filter((row) => !isRowDisabled?.(row)).map(getRowId);
|
|
14133
15239
|
const header = selectionState(pageIds, selected);
|
|
14134
|
-
const selectedList = rows.map(getRowId).filter((id) => selected.has(id));
|
|
14135
|
-
const setSelected = (next) => {
|
|
14136
|
-
setInnerSelected(next);
|
|
14137
|
-
onSelectionChange?.(rows.map(getRowId).filter((id) => next.has(id)));
|
|
14138
|
-
};
|
|
14139
15240
|
const changeSort = (columnId, direction) => {
|
|
14140
15241
|
if (serverMode) return;
|
|
14141
15242
|
const next = {
|
|
@@ -14159,7 +15260,8 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14159
15260
|
label: groupLabel ? groupLabel(g.key, g.rows) : nameOf(g.key),
|
|
14160
15261
|
name: nameOf(g.key),
|
|
14161
15262
|
rows: pageRows.filter((row) => groupKeyOf(row, effectiveGroupBy) === g.key),
|
|
14162
|
-
ids: g.rows.map(getRowId)
|
|
15263
|
+
ids: g.rows.map(getRowId),
|
|
15264
|
+
selectableIds: g.rows.filter((row) => !isRowDisabled?.(row)).map(getRowId)
|
|
14163
15265
|
})).filter((g) => g.rows.length > 0) : void 0;
|
|
14164
15266
|
const groupsForBody = bodyGroups && bodyGroups.length > 0 ? bodyGroups : void 0;
|
|
14165
15267
|
const singleSelection = useSingleSelection({
|
|
@@ -14175,7 +15277,6 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14175
15277
|
useSingleSelectionWarnings({
|
|
14176
15278
|
single: singleMode,
|
|
14177
15279
|
selectionName,
|
|
14178
|
-
paginated: paginatedProp,
|
|
14179
15280
|
hasLabel: Boolean(legend || ariaLabel?.trim() || ariaLabelledBy?.trim()) || typeof legend === "number" || typeof legend === "bigint"
|
|
14180
15281
|
});
|
|
14181
15282
|
const changeDensity = (next) => {
|
|
@@ -14247,28 +15348,37 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14247
15348
|
tableRef,
|
|
14248
15349
|
viewportHeight: 512
|
|
14249
15350
|
});
|
|
14250
|
-
const hasSelection = selectable &&
|
|
15351
|
+
const hasSelection = selectable && selectedCount > 0 && (selectionSummary || bulkActions != null);
|
|
14251
15352
|
const showToolbar = toolbar != null || showDensityToggle || showColumnMenu || showViews || hasSelection;
|
|
14252
15353
|
const anyEditable = onCellEdit != null && columns.some((c) => c.editable);
|
|
15354
|
+
const showSelectionStrip = selectable && selectAllMatching && (!serverMode || !!onSelectionModelChange) && (header.checked || model.type === "exclude" || !serverMode && allMatchingSelected) && (serverMode ? (rowCount ?? 0) > rows.length : enabledIds.length > pageIds.length);
|
|
15355
|
+
const allMatching = serverMode ? model.type === "exclude" : allMatchingSelected;
|
|
15356
|
+
const matchingCount = serverMode ? selectedCount : enabledIds.length;
|
|
15357
|
+
const stripMessage = allMatching ? labels?.allMatchingSelected?.(matchingCount) ?? t("table.allMatchingSelected", { count: formatNumber(matchingCount) }) : labels?.pageSelected?.(pageIds.length) ?? t("table.pageSelected", { count: formatNumber(pageIds.length) });
|
|
15358
|
+
const selectionCount = labels?.selectionCount ? labels.selectionCount(selectedCount) : /* @__PURE__ */ jsxs(Fragment$1, { children: [selectedCount, " selected"] });
|
|
14253
15359
|
return /* @__PURE__ */ jsxs("div", {
|
|
14254
15360
|
className: cn("overflow-hidden rounded-xl border border-border bg-card shadow-sm", className),
|
|
14255
15361
|
children: [
|
|
14256
|
-
|
|
14257
|
-
className: cn("flex min-h-12 flex-wrap items-center gap-2 border-b border-border px-3 py-2 transition-colors motion-reduce:transition-none", hasSelection ? "bg-primary/8" : "bg-secondary/30"),
|
|
14258
|
-
children: [/* @__PURE__ */
|
|
15362
|
+
/* @__PURE__ */ jsxs("div", {
|
|
15363
|
+
className: cn(!showToolbar && "sr-only", "flex min-h-12 flex-wrap items-center gap-2 border-b border-border px-3 py-2 transition-colors motion-reduce:transition-none", hasSelection ? "bg-primary/8" : "bg-secondary/30"),
|
|
15364
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
14259
15365
|
className: "flex min-w-0 flex-1 flex-wrap items-center gap-2",
|
|
14260
|
-
children: hasSelection
|
|
14261
|
-
selectionSummary &&
|
|
15366
|
+
children: [selectable && (selectAllMatching || hasSelection && selectionSummary) && /* @__PURE__ */ jsx("span", {
|
|
15367
|
+
className: hasSelection && selectionSummary && !showSelectionStrip ? "text-[12.5px] font-semibold text-foreground" : "sr-only",
|
|
15368
|
+
"aria-live": "polite",
|
|
15369
|
+
"aria-atomic": "true",
|
|
15370
|
+
children: showSelectionStrip ? stripMessage : hasSelection && selectionSummary ? selectionCount : null
|
|
15371
|
+
}), hasSelection ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
15372
|
+
selectionSummary && showSelectionStrip && /* @__PURE__ */ jsx("span", {
|
|
14262
15373
|
className: "text-[12.5px] font-semibold text-foreground",
|
|
14263
|
-
|
|
14264
|
-
children: labels?.selectionCount ? labels.selectionCount(selectedList.length) : /* @__PURE__ */ jsxs(Fragment$1, { children: [selectedList.length, " selected"] })
|
|
15374
|
+
children: selectionCount
|
|
14265
15375
|
}),
|
|
14266
15376
|
selectionSummary && bulkActions && /* @__PURE__ */ jsx("span", {
|
|
14267
15377
|
"aria-hidden": true,
|
|
14268
15378
|
className: "h-4 w-px bg-border"
|
|
14269
15379
|
}),
|
|
14270
|
-
bulkActions?.(selectedList)
|
|
14271
|
-
] }) : toolbar
|
|
15380
|
+
bulkActions?.(selectedList, model)
|
|
15381
|
+
] }) : toolbar]
|
|
14272
15382
|
}), /* @__PURE__ */ jsxs("div", {
|
|
14273
15383
|
className: "flex items-center gap-2",
|
|
14274
15384
|
children: [
|
|
@@ -14300,6 +15410,17 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14300
15410
|
]
|
|
14301
15411
|
})]
|
|
14302
15412
|
}),
|
|
15413
|
+
showSelectionStrip && /* @__PURE__ */ jsx(SelectionStrip, {
|
|
15414
|
+
labels,
|
|
15415
|
+
all: allMatching,
|
|
15416
|
+
message: stripMessage,
|
|
15417
|
+
total: serverMode ? rowCount ?? 0 : enabledIds.length,
|
|
15418
|
+
onSelectAll: selectMatching,
|
|
15419
|
+
onClear: () => {
|
|
15420
|
+
(hideSelectAll || loading || pageIds.length === 0 ? tableRef : pageCheckboxRef).current?.focus();
|
|
15421
|
+
clear();
|
|
15422
|
+
}
|
|
15423
|
+
}),
|
|
14303
15424
|
anyEditable && /* @__PURE__ */ jsx("span", {
|
|
14304
15425
|
id: editHintId,
|
|
14305
15426
|
className: "sr-only",
|
|
@@ -14314,12 +15435,13 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14314
15435
|
density,
|
|
14315
15436
|
children: /* @__PURE__ */ jsxs(Table, {
|
|
14316
15437
|
ref: tableRef,
|
|
15438
|
+
tabIndex: selectable && selectAllMatching ? -1 : void 0,
|
|
14317
15439
|
"aria-busy": loading || void 0,
|
|
14318
15440
|
"aria-rowcount": virtual ? items + 1 : void 0,
|
|
14319
15441
|
stickyHeader: virtualOn,
|
|
14320
15442
|
containerClassName: virtualOn ? virtualContainerClassName : void 0,
|
|
14321
15443
|
containerLabel: virtualOn ? caption : labels?.scrollRegion,
|
|
14322
|
-
className: cn(layout.tableClassName, singleMode && "[&_[data-column-resizer]]:end-0 [&_[data-column-resizer]]:justify-end"),
|
|
15444
|
+
className: cn(layout.tableClassName, selectable && selectAllMatching && "focus-visible:outline-2 focus-visible:outline-focus-ring", singleMode && "[&_[data-column-resizer]]:end-0 [&_[data-column-resizer]]:justify-end"),
|
|
14323
15445
|
style: layout.tableStyle,
|
|
14324
15446
|
"data-virtualized": virtualOn || void 0,
|
|
14325
15447
|
children: [
|
|
@@ -14334,10 +15456,11 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14334
15456
|
selectionColumn && /* @__PURE__ */ jsxs(TableHead, {
|
|
14335
15457
|
className: cn("w-10 pe-0", layout.lead.className, layout.lead.pinned && "z-[11] bg-card", stickyTint(layout.lead, { head: true })),
|
|
14336
15458
|
style: layout.lead.style,
|
|
14337
|
-
children: [singleMode && /* @__PURE__ */ jsx("span", {
|
|
15459
|
+
children: [(singleMode || hideSelectAll) && /* @__PURE__ */ jsx("span", {
|
|
14338
15460
|
className: "sr-only",
|
|
14339
15461
|
children: labels?.selection ?? t("table.selection")
|
|
14340
|
-
}), selectable && /* @__PURE__ */ jsx(Checkbox, {
|
|
15462
|
+
}), selectable && !hideSelectAll && /* @__PURE__ */ jsx(Checkbox, {
|
|
15463
|
+
ref: pageCheckboxRef,
|
|
14341
15464
|
"aria-label": labels?.selectAll ?? t("table.selectAllPage"),
|
|
14342
15465
|
checked: header.checked,
|
|
14343
15466
|
indeterminate: header.indeterminate,
|
|
@@ -14381,6 +15504,7 @@ function DataTable({ rows = DEPLOYMENT_ROWS, columns = DEPLOYMENT_COLUMNS, getRo
|
|
|
14381
15504
|
getRowId,
|
|
14382
15505
|
getRowLabel: labelOf,
|
|
14383
15506
|
selectable,
|
|
15507
|
+
isRowDisabled,
|
|
14384
15508
|
selected,
|
|
14385
15509
|
singleSelection: singleMode ? singleSelection : void 0,
|
|
14386
15510
|
onToggleRow: (id) => setSelected(toggleOne(id, selected)),
|
|
@@ -14431,7 +15555,7 @@ const meta$16 = {
|
|
|
14431
15555
|
name: "Data table",
|
|
14432
15556
|
family: "tables",
|
|
14433
15557
|
status: "beta",
|
|
14434
|
-
description: "Generic typed table: sortable headers with aria-sort, row selection with select-all and indeterminate by default (selectionMode=\"multiple\"), selectionMode=\"none\" to hide selection, column visibility menu, density toggle, row actions, loading and empty states, client-side sort and pagination, optional row groups (groupBy) with rowgroup header rows, counts, keyboard-accessible collapse buttons and group selection; column resize (pointer drag or a focusable role=\"separator\" handle with arrow keys, min/max widths, controlled columnWidths), column pinning to either edge with sticky cells (column menu or pinnedColumns), row virtualization for large datasets (aria-rowcount/aria-rowindex, works with selection and grouping), inline cell editing (text, number and select editors; Enter/F2 to edit, Enter/Tab to commit, Escape to cancel, onCellEdit can reject with an inline error) and saved views (filters, sort, visible columns, widths, pinning and grouping) with a view switcher to save as, rename, delete and reset. Opt-in selectionMode=\"single\" uses native radios in a labelled fieldset (never
|
|
15558
|
+
description: "Generic typed table: sortable headers with aria-sort, row selection with select-all and indeterminate by default (selectionMode=\"multiple\"), selectionMode=\"none\" to hide selection, column visibility menu, density toggle, row actions, loading and empty states, client-side sort and pagination, optional row groups (groupBy) with rowgroup header rows, counts, keyboard-accessible collapse buttons and group selection; column resize (pointer drag or a focusable role=\"separator\" handle with arrow keys, min/max widths, controlled columnWidths), column pinning to either edge with sticky cells (column menu or pinnedColumns), row virtualization for large datasets (aria-rowcount/aria-rowindex, works with selection and grouping), inline cell editing (text, number and select editors; Enter/F2 to edit, Enter/Tab to commit, Escape to cancel, onCellEdit can reject with an inline error) and saved views (filters, sort, visible columns, widths, pinning and grouping) with a view switcher to save as, rename, delete and reset. Opt-in selectionMode=\"single\" uses native radios in a labelled fieldset (never virtualized; client pagination defaults to false, and paginated=true or paginationMode=\"server\" enables pagination). Single mode uses selectedId/onSelectedIdChange or defaultSelectedId; isRowDisabled skips unavailable rows and preserves a checked disabled choice without callbacks. Supply legend, aria-label or aria-labelledby for the group and getRowLabel for each radio (otherwise the first column labels it). selectionName is used verbatim and must be unique per page; omitted names use an instance-unique useId name, and duplicate supplied names or missing group labels warn in development. Tab enters once on the checked enabled row or first enabled row; arrows wrap and skip disabled rows, Space selects, Shift+Tab exits, and all-disabled groups have no tab stop. No select-all, group checkboxes, bulk actions or selection summary appear in single mode. Examples in examples/single-selection.tsx: an uncontrolled non-paginated list with legend=\"Available items\" and a controlled versions table with legend=\"Available versions\", selectedId=\"v2\" and a checked disabled version. Opt-in paginationMode=\"server\" accepts a controlled 1-based page, pageSize and required rowCount (known total), with onPageChange/onPageSizeChange requests. Supplied rows render in order without client sorting or slicing, and headers have no sort affordance. Single selection keeps its chosen id across pages. Off-page choices leave every visible radio unchecked and the first enabled radio is the tab stop; name the current choice in the legend. See examples/paginated-single-selection.tsx for client and server pagination. The footer stays visible for empty results, clamps stale pages for display without callbacks, and hides during loading. Page-size changes may also request a page to keep the first visible row on screen. The consumer owns fetching and reconciles stale pages. See examples/server-pagination.tsx for an items/total/page/pageSize envelope consumer that handles both callbacks. Multiple selection preserves ids from other server pages by default; preserveSelection=false restores page-only reporting, and client tables can opt in with preserveSelection=true. selectedIds remains supported. A controlled selectionModel takes precedence and uses { type: \"include\", ids: string[] } for selected ids or { type: \"exclude\", ids: string[] } for every match except those ids. bulkActions(ids, model) receives the full include list; in exclude mode ids contains enabled selections in the current rows and the model is authoritative. One-argument actions remain compatible. selectAllMatching defaults to false and offers a strip after the page is fully selected: client mode includes every enabled row, while server mode requires onSelectionModelChange and reports an exclude model. The same button becomes Clear selection without moving focus; clearing returns focus to the page checkbox, or to the table when the checkbox is hidden or unavailable. An exclude model resets through both callbacks when filters changes by JSON value; filters must include every narrowing input, including search text. Paging, page size and sorting preserve selection. An exclude action covers the matching result set at action time, including later-created rows; the consumer executes it. isRowDisabled disables multiple-selection checkboxes and page/group/all-matching toggles skip known disabled rows. Server counts use rowCount minus explicit excluded ids, including disabled ids on the page where Select all is activated. isRowDisabled cannot evaluate unloaded rows, so the server must enforce eligibility for the complete matching result set; return only eligible matches and their rowCount when counts must exclude all unavailable rows. hideSelectAll defaults to false and hides just the header checkbox, retaining an accessible Selection heading. See examples/client-selection.tsx for client preservation, disabled rows and select-all-matching, and examples/server-pagination.tsx for controlled models, cross-page actions and the preservation/header options.",
|
|
14435
15559
|
labels: [
|
|
14436
15560
|
{
|
|
14437
15561
|
key: "booleanTrue",
|
|
@@ -14453,6 +15577,26 @@ const meta$16 = {
|
|
|
14453
15577
|
type: "(count: number) => string",
|
|
14454
15578
|
state: "Multiple selection: toolbar count and polite live region"
|
|
14455
15579
|
},
|
|
15580
|
+
{
|
|
15581
|
+
key: "pageSelected",
|
|
15582
|
+
type: "(count: number) => string",
|
|
15583
|
+
state: "Matching-selection strip: selected page announcement"
|
|
15584
|
+
},
|
|
15585
|
+
{
|
|
15586
|
+
key: "selectAllMatching",
|
|
15587
|
+
type: "(count: number) => string",
|
|
15588
|
+
state: "Matching-selection strip: select every enabled match"
|
|
15589
|
+
},
|
|
15590
|
+
{
|
|
15591
|
+
key: "allMatchingSelected",
|
|
15592
|
+
type: "(count: number) => string",
|
|
15593
|
+
state: "Matching-selection strip: all-matching announcement"
|
|
15594
|
+
},
|
|
15595
|
+
{
|
|
15596
|
+
key: "clearSelection",
|
|
15597
|
+
type: "string",
|
|
15598
|
+
state: "Matching-selection strip: clear action"
|
|
15599
|
+
},
|
|
14456
15600
|
{
|
|
14457
15601
|
key: "columns",
|
|
14458
15602
|
type: "string",
|
|
@@ -14601,7 +15745,7 @@ const meta$16 = {
|
|
|
14601
15745
|
{
|
|
14602
15746
|
key: "selection",
|
|
14603
15747
|
type: "string",
|
|
14604
|
-
state: "Single selection: screen reader column heading"
|
|
15748
|
+
state: "Single selection or hideSelectAll: screen reader column heading"
|
|
14605
15749
|
},
|
|
14606
15750
|
{
|
|
14607
15751
|
key: "selectAll",
|