@rexezuge/web 1.1.0 → 1.3.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/README.md +28 -13
- package/dist/AppPage.d.ts +33 -0
- package/dist/AppPage.d.ts.map +1 -0
- package/dist/AppPage.js +7 -0
- package/dist/AppPage.js.map +1 -0
- package/dist/Badge.js +1 -1
- package/dist/Badge.js.map +1 -1
- package/dist/Button.js +2 -2
- package/dist/Button.js.map +1 -1
- package/dist/Card.js +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/ContextBar.d.ts +43 -0
- package/dist/ContextBar.d.ts.map +1 -0
- package/dist/ContextBar.js +7 -0
- package/dist/ContextBar.js.map +1 -0
- package/dist/FocusInput.js +2 -2
- package/dist/FocusInput.js.map +1 -1
- package/dist/Input.js +1 -1
- package/dist/Input.js.map +1 -1
- package/dist/LanguageSelector.d.ts +57 -0
- package/dist/LanguageSelector.d.ts.map +1 -0
- package/dist/LanguageSelector.js +12 -0
- package/dist/LanguageSelector.js.map +1 -0
- package/dist/LoadingButton.d.ts +1 -1
- package/dist/LoadingButton.d.ts.map +1 -1
- package/dist/LoadingButton.js +1 -1
- package/dist/LoadingButton.js.map +1 -1
- package/dist/NoticeBar.d.ts +50 -0
- package/dist/NoticeBar.d.ts.map +1 -0
- package/dist/NoticeBar.js +12 -0
- package/dist/NoticeBar.js.map +1 -0
- package/dist/PageHeaderCard.d.ts +40 -0
- package/dist/PageHeaderCard.d.ts.map +1 -0
- package/dist/PageHeaderCard.js +7 -0
- package/dist/PageHeaderCard.js.map +1 -0
- package/dist/PageState.js +1 -1
- package/dist/PageState.js.map +1 -1
- package/dist/Pagination.js +2 -2
- package/dist/Pagination.js.map +1 -1
- package/dist/ReadOnlyField.d.ts +49 -0
- package/dist/ReadOnlyField.d.ts.map +1 -0
- package/dist/ReadOnlyField.js +17 -0
- package/dist/ReadOnlyField.js.map +1 -0
- package/dist/RefreshButton.d.ts +36 -0
- package/dist/RefreshButton.d.ts.map +1 -0
- package/dist/RefreshButton.js +8 -0
- package/dist/RefreshButton.js.map +1 -0
- package/dist/Spinner.js +1 -1
- package/dist/Spinner.js.map +1 -1
- package/dist/TypeToConfirmModal.d.ts +47 -0
- package/dist/TypeToConfirmModal.d.ts.map +1 -0
- package/dist/TypeToConfirmModal.js +24 -0
- package/dist/TypeToConfirmModal.js.map +1 -0
- package/dist/Unauthorized.d.ts +45 -0
- package/dist/Unauthorized.d.ts.map +1 -0
- package/dist/Unauthorized.js +11 -0
- package/dist/Unauthorized.js.map +1 -0
- package/dist/index.d.ts +72 -32
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -18
- package/dist/index.js.map +1 -1
- package/dist/useCopyToClipboard.d.ts +54 -0
- package/dist/useCopyToClipboard.d.ts.map +1 -0
- package/dist/useCopyToClipboard.js +40 -0
- package/dist/useCopyToClipboard.js.map +1 -0
- package/dist/useCurrentUser.d.ts +1 -1
- package/dist/useCurrentUser.d.ts.map +1 -1
- package/dist/useCurrentUser.js.map +1 -1
- package/dist/useNotice.js +1 -1
- package/dist/useNotice.js.map +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The standard page-title header.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* `components/layout/PageHeaderCard.tsx` in **Durable-DAV**, **Durable-DAV-Router**
|
|
8
|
+
* and **Edge-Git** — three copies, byte-identical apart from which views each
|
|
9
|
+
* doc comment listed.
|
|
10
|
+
*
|
|
11
|
+
* It replaced the four ad-hoc title-`Card` variants those repos had grown, one
|
|
12
|
+
* per page, which is how a header bar came to sit at four different heights.
|
|
13
|
+
*/
|
|
14
|
+
interface PageHeaderCardProps {
|
|
15
|
+
/** Leading avatar. Omitted renders no avatar slot at all, not an empty one. */
|
|
16
|
+
icon?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* The page's name.
|
|
19
|
+
*
|
|
20
|
+
* **Required.** An optional title would render a header bar with no text in
|
|
21
|
+
* it — a silent no-op that looks deliberate. Forcing it means the compiler
|
|
22
|
+
* asks rather than letting a page ship a nameless header.
|
|
23
|
+
*/
|
|
24
|
+
title: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* The line under the title.
|
|
27
|
+
*
|
|
28
|
+
* **Required**, though it may be an empty fragment. Same reason: the three
|
|
29
|
+
* copies all rendered a description slot, and the ones that omitted it had
|
|
30
|
+
* each re-derived the vertical rhythm with a different ad-hoc fix. Declaring
|
|
31
|
+
* it means the layout is the same whether or not there is something to say.
|
|
32
|
+
*/
|
|
33
|
+
description: ReactNode;
|
|
34
|
+
/** Right-aligned. Omitted renders no actions slot. */
|
|
35
|
+
actions?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
declare function PageHeaderCard({ icon, title, description, actions }: Readonly<PageHeaderCardProps>): import("react").JSX.Element;
|
|
38
|
+
export { PageHeaderCard };
|
|
39
|
+
export type { PageHeaderCardProps };
|
|
40
|
+
//# sourceMappingURL=PageHeaderCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageHeaderCard.d.ts","sourceRoot":"","sources":["../src/PageHeaderCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC;;;;;;;;;;;GAWG;AAEH,UAAU,mBAAmB;IAC3B,+EAA+E;IAC/E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;;;OAMG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;;;;;OAOG;IACH,WAAW,EAAE,SAAS,CAAC;IACvB,sDAAsD;IACtD,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB;AAED,iBAAS,cAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,QAAQ,CAAC,mBAAmB,CAAC,+BAa3F;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card } from "./Card.js";
|
|
3
|
+
function PageHeaderCard({ icon, title, description, actions }) {
|
|
4
|
+
return (_jsxs(Card, { className: "flex flex-col lg:flex-row lg:items-center justify-between gap-4 py-4", children: [_jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [icon && _jsx("div", { className: "flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-surface-3)] shrink-0", children: icon }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-xl font-semibold text-[var(--color-text-primary)] truncate", children: title }), description && _jsx("div", { className: "text-sm text-[var(--color-text-muted)] truncate", children: description })] })] }), actions && _jsx("div", { className: "flex flex-wrap items-center gap-3 shrink-0", children: actions })] }));
|
|
5
|
+
}
|
|
6
|
+
export { PageHeaderCard };
|
|
7
|
+
//# sourceMappingURL=PageHeaderCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageHeaderCard.js","sourceRoot":"","sources":["../src/PageHeaderCard.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAY,CAAC;AAuClC,SAAS,cAAc,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAiC;IAC1F,OAAO,CACL,MAAC,IAAI,IAAC,SAAS,EAAC,sEAAsE,aACpF,eAAK,SAAS,EAAC,iCAAiC,aAC7C,IAAI,IAAI,cAAK,SAAS,EAAC,8FAA8F,YAAE,IAAI,GAAO,EACnI,eAAK,SAAS,EAAC,SAAS,aACtB,aAAI,SAAS,EAAC,iEAAiE,YAAE,KAAK,GAAM,EAC3F,WAAW,IAAI,cAAK,SAAS,EAAC,iDAAiD,YAAE,WAAW,GAAO,IAChG,IACF,EACL,OAAO,IAAI,cAAK,SAAS,EAAC,4CAA4C,YAAE,OAAO,GAAO,IAClF,CACR,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { ReactNode } from 'react';\nimport { Card } from './Card.tsx';\n\n/**\n * The standard page-title header.\n *\n * ## Provenance\n *\n * `components/layout/PageHeaderCard.tsx` in **Durable-DAV**, **Durable-DAV-Router**\n * and **Edge-Git** — three copies, byte-identical apart from which views each\n * doc comment listed.\n *\n * It replaced the four ad-hoc title-`Card` variants those repos had grown, one\n * per page, which is how a header bar came to sit at four different heights.\n */\n\ninterface PageHeaderCardProps {\n /** Leading avatar. Omitted renders no avatar slot at all, not an empty one. */\n icon?: ReactNode;\n /**\n * The page's name.\n *\n * **Required.** An optional title would render a header bar with no text in\n * it — a silent no-op that looks deliberate. Forcing it means the compiler\n * asks rather than letting a page ship a nameless header.\n */\n title: ReactNode;\n /**\n * The line under the title.\n *\n * **Required**, though it may be an empty fragment. Same reason: the three\n * copies all rendered a description slot, and the ones that omitted it had\n * each re-derived the vertical rhythm with a different ad-hoc fix. Declaring\n * it means the layout is the same whether or not there is something to say.\n */\n description: ReactNode;\n /** Right-aligned. Omitted renders no actions slot. */\n actions?: ReactNode;\n}\n\nfunction PageHeaderCard({ icon, title, description, actions }: Readonly<PageHeaderCardProps>) {\n return (\n <Card className=\"flex flex-col lg:flex-row lg:items-center justify-between gap-4 py-4\">\n <div className=\"flex items-center gap-3 min-w-0\">\n {icon && <div className=\"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-surface-3)] shrink-0\">{icon}</div>}\n <div className=\"min-w-0\">\n <h1 className=\"text-xl font-semibold text-[var(--color-text-primary)] truncate\">{title}</h1>\n {description && <div className=\"text-sm text-[var(--color-text-muted)] truncate\">{description}</div>}\n </div>\n </div>\n {actions && <div className=\"flex flex-wrap items-center gap-3 shrink-0\">{actions}</div>}\n </Card>\n );\n}\n\nexport { PageHeaderCard };\nexport type { PageHeaderCardProps };\n"]}
|
package/dist/PageState.js
CHANGED
package/dist/PageState.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageState.js","sourceRoot":"","sources":["../src/PageState.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"PageState.js","sourceRoot":"","sources":["../src/PageState.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAE9C;;;;;;;;;;GAUG;AAEH,kFAAkF;AAClF,SAAS,cAAc,CAAC,EAAE,KAAK,GAAG,UAAU,EAAsB;IAChE,OAAO,CACL,cAAK,SAAS,EAAC,2CAA2C,EAAC,IAAI,EAAC,QAAQ,gBAAa,KAAK,YACxF,cAAK,SAAS,EAAC,gGAAgG,GAAG,GAC9G,CACP,CAAC;AACJ,CAAC;AAED,yEAAyE;AACzE,SAAS,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAA4C;IAC7E,OAAO,CACL,eAAK,SAAS,EAAC,0DAA0D,aACtE,IAAI,IAAI,cAAK,SAAS,EAAC,0BAA0B,YAAE,IAAI,GAAO,EAC9D,OAAO,IACJ,CACP,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAS,kBAAkB,CAAC,EAC1B,OAAO,EACP,YAAY,EACZ,WAAW,EACX,SAAS,EACT,SAAS,EACT,QAAQ,GAST;IACC,OAAO,CACL,KAAC,UAAU,IAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,EAAC,SAAS,EAAE,SAAS,YACnE,eAAK,SAAS,EAAC,KAAK,aAClB,YAAG,SAAS,EAAC,6DAA6D,YAAE,OAAO,GAAK,EACxF,eAAK,SAAS,EAAC,YAAY,aACzB,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gCACjB,KAAK,CAAC,eAAe,EAAE,CAAC;gCACxB,QAAQ,EAAE,CAAC;4BACb,CAAC,YAEA,WAAW,GACL,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,QAAQ,EAClB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gCACjB,KAAK,CAAC,eAAe,EAAE,CAAC;gCACxB,SAAS,EAAE,CAAC;4BACd,CAAC,YAEA,YAAY,GACN,IACL,IACF,GACK,CACd,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { ReactNode } from 'react';\nimport { ModalShell } from './ModalShell.tsx';\n\n/**\n * The shared loading / empty / error states.\n *\n * Converged from `components/layout/PageState.tsx` (Durable-DAV,\n * Durable-DAV-Router) and `EmptyState` (CalDAV-Bridge), which were the same two\n * components under two names.\n *\n * Same reasoning as `ModalShell`: the label arrives as a prop rather than from\n * `useTranslation`, so a consumer is not required to run a translation library\n * to render a spinner.\n */\n\n/** The shared spinner. `label` is announced, so it should say what is loading. */\nfunction LoadingSpinner({ label = 'Loading…' }: { label?: string }) {\n return (\n <div className=\"min-h-64 flex items-center justify-center\" role=\"status\" aria-label={label}>\n <div className=\"h-10 w-10 rounded-full border-2 border-[var(--color-accent)] border-t-transparent animate-spin\" />\n </div>\n );\n}\n\n/** The shared centered empty message, with an optional icon above it. */\nfunction EmptyState({ icon, message }: { icon?: ReactNode; message: ReactNode }) {\n return (\n <div className=\"text-center text-[var(--color-text-muted)] py-10 text-sm\">\n {icon && <div className=\"mb-3 flex justify-center\">{icon}</div>}\n {message}\n </div>\n );\n}\n\n/**\n * A confirmation for a destructive action.\n *\n * `message` is required to **name the thing being deleted**, not to say \"this\n * item\" — the operator is the only one who can tell whether they meant to\n * delete it, so the dialog has to be specific. That is a contract on the\n * caller, not something the component can enforce, which is why `message` is a\n * `ReactNode` the caller composes rather than a template this fills in.\n *\n * No confirm timer: a dialog that arms itself makes the operator wait for a\n * decision they were already qualified to make.\n *\n * Both handlers stop propagation, because a confirm that fires twice deletes\n * two things.\n */\nfunction ConfirmDeleteModal({\n message,\n confirmLabel,\n cancelLabel,\n ariaLabel,\n onConfirm,\n onCancel,\n}: {\n /** The full question, naming what will be deleted. */\n message: ReactNode;\n confirmLabel: string;\n cancelLabel: string;\n ariaLabel: string;\n onConfirm: () => void;\n onCancel: () => void;\n}) {\n return (\n <ModalShell onClose={onCancel} widthClass=\"w-80\" ariaLabel={ariaLabel}>\n <div className=\"p-6\">\n <p className=\"text-sm text-[var(--color-text-secondary)] text-center mb-6\">{message}</p>\n <div className=\"flex gap-3\">\n <button\n type=\"button\"\n className=\"flex-1\"\n onClick={(event) => {\n event.stopPropagation();\n onCancel();\n }}\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n className=\"flex-1\"\n onClick={(event) => {\n event.stopPropagation();\n onConfirm();\n }}\n >\n {confirmLabel}\n </button>\n </div>\n </div>\n </ModalShell>\n );\n}\n\nexport { ConfirmDeleteModal, EmptyState, LoadingSpinner };\n"]}
|
package/dist/Pagination.js
CHANGED
package/dist/Pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAc,CAAC;AACtC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,sGAAsG;AACtG,SAAS,YAAY,CAAC,KAAa,EAAE,QAAgB;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,IAAI,CAAC,IAA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\n * Pager controls.\n *\n * ## Provenance\n *\n * `components/ui/Pagination.tsx` in **AWS-AccessBridge**, with the arithmetic\n * (`totalPages`, `clampPage`, `pageNumbers`) that this component reached for\n * across `lib/pagination.ts` and `lib/presentation.ts` inlined, because a\n * consumer importing the pager should not have to import two more modules to\n * understand it. The DAV repos' `VolumeFilePager` (Durable-DAV and\n * Durable-DAV-Router) is the family's other pager and informs two decisions: it\n * gates on the rows actually being present, and it renders nothing at all when\n * the collection fits on one page.\n *\n * The API is normalized away from the AWS names (`currentPage`, `totalPages`,\n * `onPageChange`) to `page`, `pageCount`, `onChange`. `pageCount` may be\n * derived instead of passed: give `total` and `pageSize` and the pager does the\n * arithmetic, which is what the DAV pager did by hand at its call site.\n *\n * `full` shows a window of page numbers (AWS's default); `compact` shows\n * \"Page X of Y\" (AWS's other variant, and what the DAV pager renders). Both\n * render `null` for a single page.\n */\n\n/** How many pages `total` items occupy. A non-positive page size yields 1, never `Infinity`/`NaN`. */\nfunction pageCountFor(total: number, pageSize: number): number {\n if (!Number.isFinite(total) || !Number.isFinite(pageSize) || pageSize <= 0 || total <= 0) {\n return 1;\n }\n return Math.ceil(total / pageSize);\n}\n\n/** Pins `page` into `[1, pageCount]`, rounding to the first page when it cannot be read. */\nfunction clampPage(page: number, pageCount: number): number {\n const upper = Math.max(1, Math.trunc(Number.isFinite(pageCount) ? pageCount : 1));\n const wanted = Number.isFinite(page) ? Math.trunc(page) : 1;\n return Math.min(upper, Math.max(1, wanted));\n}\n\n/**\n * The 1-based page numbers to show, keeping the current page as close to the\n * middle of the window as the ends allow. The window is clamped against\n * `windowSize` rather than a fixed `pageCount - 2`, so a non-default window\n * cannot emit page numbers past the last page.\n */\nfunction pageWindow(currentPage: number, pageCount: number, windowSize = 5): number[] {\n const count = Math.min(windowSize, pageCount);\n if (count <= 0) {\n return [];\n }\n const start = Math.max(1, Math.min(currentPage - Math.floor(windowSize / 2), pageCount - count + 1));\n return Array.from({ length: count }, (_, index) => start + index);\n}\n\n/** Overridable text, so an i18next app is not stuck with the English defaults. */\ninterface PaginationLabels {\n /** Prev-button accessible name / label. */\n previous?: string;\n /** Next-button accessible name / label. */\n next?: string;\n /** The \"Page X of Y\" summary in `compact` (and as the pager's `aria-label` in `full`). */\n summary?: (page: number, pageCount: number) => string;\n}\n\ninterface PaginationProps {\n /** The page being displayed, 1-based. Clamped into range for rendering. */\n page: number;\n /** Total pages. Omit to derive it from `total` and `pageSize`. */\n pageCount?: number;\n /** Total item count across every page. */\n total?: number;\n /** Items per page. */\n pageSize?: number;\n /** Called with the 1-based page to move to; already clamped into range. */\n onChange: (page: number) => void;\n /** `full` shows page numbers, `compact` shows a summary. */\n variant?: 'full' | 'compact';\n labels?: PaginationLabels;\n}\n\nfunction Pagination({\n page,\n pageCount,\n total,\n pageSize,\n onChange,\n variant = 'full',\n labels = {},\n}: Readonly<PaginationProps>): ReactElement | null {\n const derivedPageCount = pageCount ?? (total !== undefined && pageSize !== undefined ? pageCountFor(total, pageSize) : 1);\n const pages = Math.max(1, Math.trunc(Number.isFinite(derivedPageCount) ? derivedPageCount : 1));\n const current = clampPage(page, pages);\n const previousLabel = labels.previous ?? 'Previous';\n const nextLabel = labels.next ?? 'Next';\n const summaryLabel = labels.summary ?? ((page: number, count: number) => `Page ${page} of ${count}`);\n\n // Nothing to page: a single-page list shows no pager rather than a disabled one.\n if (pages <= 1) {\n return null;\n }\n\n const step = (next: number): void => {\n const target = clampPage(next, pages);\n if (target !== current) {\n onChange(target);\n }\n };\n\n const summary = <span className=\"text-xs text-[var(--color-text-muted)] tabular-nums\">{summaryLabel(current, pages)}</span>;\n\n return (\n <nav className=\"flex flex-wrap items-center gap-2\" aria-label={summaryLabel(current, pages)}>\n <Button variant=\"secondary\" size=\"sm\" disabled={current <= 1} onClick={() => step(current - 1)} aria-label={previousLabel}>\n {previousLabel}\n </Button>\n {variant === 'compact' ? (\n summary\n ) : (\n <div className=\"flex items-center gap-1\">\n {pageWindow(current, pages).map((pageNumber) => (\n <Button\n key={pageNumber}\n variant=\"secondary\"\n size=\"sm\"\n className={cn(pageNumber === current && 'bg-[var(--color-accent)] text-[#0d1008]')}\n aria-current={pageNumber === current ? 'page' : undefined}\n onClick={() => step(pageNumber)}\n >\n {pageNumber}\n </Button>\n ))}\n </div>\n )}\n <Button variant=\"secondary\" size=\"sm\" disabled={current >= pages} onClick={() => step(current + 1)} aria-label={nextLabel}>\n {nextLabel}\n </Button>\n </nav>\n );\n}\n\nexport { Pagination, clampPage, pageCountFor, pageWindow };\nexport type { PaginationLabels, PaginationProps };\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A labelled, read-only value with an optional copy button.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `components/shared/ReadOnlyField.tsx` in **Durable-DAV**, **Durable-DAV-Router**,
|
|
7
|
+
* **Edge-Git** and **Mail-Otter** — four copies in two shapes. The three outside
|
|
8
|
+
* Durable-DAV inlined the clipboard handler; Durable-DAV's called its
|
|
9
|
+
* `useCopyToClipboard` hook, which is the version that converged into
|
|
10
|
+
* `@rexezuge/web` and is the one this uses.
|
|
11
|
+
*
|
|
12
|
+
* ## The third bug, which all four copies carried
|
|
13
|
+
*
|
|
14
|
+
* Every copy rendered `<Label>{label}</Label>` with no `htmlFor`, so the value
|
|
15
|
+
* input had **no accessible name** — announced as a bare "edit text" for a field
|
|
16
|
+
* whose contents are, in every call site in the family, a credential or an
|
|
17
|
+
* identifier. The click target and the name both depend on the `for`, and
|
|
18
|
+
* neither is visible in the markup that omits it. `useId` pairs them here so a
|
|
19
|
+
* caller cannot forget.
|
|
20
|
+
*
|
|
21
|
+
* The difference was not cosmetic. The inlined three called
|
|
22
|
+
* `navigator.clipboard.writeText` unguarded, so on a plain-HTTP deployment the
|
|
23
|
+
* handler threw synchronously before reporting anything — and where they did
|
|
24
|
+
* guard it, a denied permission still showed the checkmark for a copy that never
|
|
25
|
+
* happened. Every value this component is pointed at in the family is a secret
|
|
26
|
+
* or an identifier, so the false success sends the operator away believing they
|
|
27
|
+
* have something they do not. See `useCopyToClipboard` for both failures.
|
|
28
|
+
*/
|
|
29
|
+
interface ReadOnlyFieldProps {
|
|
30
|
+
/** The field's label. */
|
|
31
|
+
label: string;
|
|
32
|
+
/** The value, shown verbatim and selectable. */
|
|
33
|
+
value: string;
|
|
34
|
+
/** Show the copy button. Defaults to false. */
|
|
35
|
+
showCopy?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* The copy button's accessible name and tooltip.
|
|
38
|
+
*
|
|
39
|
+
* Required whenever `showCopy` is set — a copy button carrying only an icon is
|
|
40
|
+
* announced as "button" with nothing else.
|
|
41
|
+
*/
|
|
42
|
+
copyLabel?: string;
|
|
43
|
+
/** Merged last onto the value's `<input>`. */
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
declare function ReadOnlyField({ label, value, showCopy, copyLabel, className }: Readonly<ReadOnlyFieldProps>): import("react").JSX.Element;
|
|
47
|
+
export { ReadOnlyField };
|
|
48
|
+
export type { ReadOnlyFieldProps };
|
|
49
|
+
//# sourceMappingURL=ReadOnlyField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadOnlyField.d.ts","sourceRoot":"","sources":["../src/ReadOnlyField.tsx"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,UAAU,kBAAkB;IAC1B,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iBAAS,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,+BA8C5G;AAED,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { Check, Copy } from 'lucide-react';
|
|
4
|
+
import { Label } from "./Input.js";
|
|
5
|
+
import { cn } from "./utils.js";
|
|
6
|
+
import { useCopyToClipboard } from "./useCopyToClipboard.js";
|
|
7
|
+
function ReadOnlyField({ label, value, showCopy = false, copyLabel, className }) {
|
|
8
|
+
const { copied, copy } = useCopyToClipboard();
|
|
9
|
+
// The four copies rendered `<Label>{label}</Label>` with no `htmlFor`, so the
|
|
10
|
+
// value input had **no accessible name** — a screen reader announced a bare
|
|
11
|
+
// "edit text" for a field holding a secret. The kit's own `Input.tsx` records
|
|
12
|
+
// this hazard; `useId` pairs the label without asking a caller for an id.
|
|
13
|
+
const inputId = useId();
|
|
14
|
+
return (_jsxs("div", { children: [_jsx(Label, { className: "mb-1.5", htmlFor: inputId, children: label }), _jsxs("div", { className: "flex", children: [_jsx("input", { id: inputId, readOnly: true, value: value, className: cn('min-w-0 px-3 py-2 bg-[var(--color-surface-base)] border border-[var(--color-border)] text-[var(--color-text-secondary)] text-sm flex-1', showCopy ? 'rounded-l-lg border-r-0' : 'rounded-lg', className) }), showCopy && (_jsx("button", { type: "button", onClick: () => copy(value), title: copyLabel, "aria-label": copyLabel, "aria-live": "polite", className: "px-3 py-2 rounded-r-lg bg-[var(--color-surface-3)] hover:bg-[var(--color-surface-4)] border border-[var(--color-border)] text-[var(--color-text-secondary)] transition-colors duration-150", children: copied ? (_jsx(Check, { className: "h-3.5 w-3.5 text-[var(--color-success-text)]", "aria-hidden": "true" })) : (_jsx(Copy, { className: "h-3.5 w-3.5", "aria-hidden": "true" })) }))] })] }));
|
|
15
|
+
}
|
|
16
|
+
export { ReadOnlyField };
|
|
17
|
+
//# sourceMappingURL=ReadOnlyField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadOnlyField.js","sourceRoot":"","sources":["../src/ReadOnlyField.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAY,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAa,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAiD7D,SAAS,aAAa,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,SAAS,EAAE,SAAS,EAAgC;IAC3G,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,kBAAkB,EAAE,CAAC;IAC9C,8EAA8E;IAC9E,4EAA4E;IAC5E,8EAA8E;IAC9E,0EAA0E;IAC1E,MAAM,OAAO,GAAG,KAAK,EAAE,CAAC;IAExB,OAAO,CACL,0BACE,KAAC,KAAK,IAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAE,OAAO,YACvC,KAAK,GACA,EACR,eAAK,SAAS,EAAC,MAAM,aACnB,gBACE,EAAE,EAAE,OAAO,EACX,QAAQ,QACR,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,EAAE,CACX,wIAAwI,EACxI,QAAQ,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,YAAY,EACnD,SAAS,CACV,GACD,EACD,QAAQ,IAAI,CACX,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,SAAS,gBACJ,SAAS,eAIX,QAAQ,EAClB,SAAS,EAAC,4LAA4L,YAErM,MAAM,CAAC,CAAC,CAAC,CACR,KAAC,KAAK,IAAC,SAAS,EAAC,8CAA8C,iBAAa,MAAM,GAAG,CACtF,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,CACpD,GACM,CACV,IACG,IACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { useId, useState } from 'react';\nimport { Check, Copy } from 'lucide-react';\nimport { Label } from './Input.tsx';\nimport { cn } from './utils.ts';\nimport { useCopyToClipboard } from './useCopyToClipboard.ts';\n\n/**\n * A labelled, read-only value with an optional copy button.\n *\n * ## Provenance\n *\n * `components/shared/ReadOnlyField.tsx` in **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git** and **Mail-Otter** — four copies in two shapes. The three outside\n * Durable-DAV inlined the clipboard handler; Durable-DAV's called its\n * `useCopyToClipboard` hook, which is the version that converged into\n * `@rexezuge/web` and is the one this uses.\n *\n * ## The third bug, which all four copies carried\n *\n * Every copy rendered `<Label>{label}</Label>` with no `htmlFor`, so the value\n * input had **no accessible name** — announced as a bare \"edit text\" for a field\n * whose contents are, in every call site in the family, a credential or an\n * identifier. The click target and the name both depend on the `for`, and\n * neither is visible in the markup that omits it. `useId` pairs them here so a\n * caller cannot forget.\n *\n * The difference was not cosmetic. The inlined three called\n * `navigator.clipboard.writeText` unguarded, so on a plain-HTTP deployment the\n * handler threw synchronously before reporting anything — and where they did\n * guard it, a denied permission still showed the checkmark for a copy that never\n * happened. Every value this component is pointed at in the family is a secret\n * or an identifier, so the false success sends the operator away believing they\n * have something they do not. See `useCopyToClipboard` for both failures.\n */\n\ninterface ReadOnlyFieldProps {\n /** The field's label. */\n label: string;\n /** The value, shown verbatim and selectable. */\n value: string;\n /** Show the copy button. Defaults to false. */\n showCopy?: boolean;\n /**\n * The copy button's accessible name and tooltip.\n *\n * Required whenever `showCopy` is set — a copy button carrying only an icon is\n * announced as \"button\" with nothing else.\n */\n copyLabel?: string;\n /** Merged last onto the value's `<input>`. */\n className?: string;\n}\n\nfunction ReadOnlyField({ label, value, showCopy = false, copyLabel, className }: Readonly<ReadOnlyFieldProps>) {\n const { copied, copy } = useCopyToClipboard();\n // The four copies rendered `<Label>{label}</Label>` with no `htmlFor`, so the\n // value input had **no accessible name** — a screen reader announced a bare\n // \"edit text\" for a field holding a secret. The kit's own `Input.tsx` records\n // this hazard; `useId` pairs the label without asking a caller for an id.\n const inputId = useId();\n\n return (\n <div>\n <Label className=\"mb-1.5\" htmlFor={inputId}>\n {label}\n </Label>\n <div className=\"flex\">\n <input\n id={inputId}\n readOnly\n value={value}\n className={cn(\n 'min-w-0 px-3 py-2 bg-[var(--color-surface-base)] border border-[var(--color-border)] text-[var(--color-text-secondary)] text-sm flex-1',\n showCopy ? 'rounded-l-lg border-r-0' : 'rounded-lg',\n className,\n )}\n />\n {showCopy && (\n <button\n type=\"button\"\n onClick={() => copy(value)}\n title={copyLabel}\n aria-label={copyLabel}\n // `aria-live` so the confirmation is announced. The icon swap alone\n // is invisible to a screen reader, which would make the success\n // state silent for exactly the users copying a secret by hand.\n aria-live=\"polite\"\n className=\"px-3 py-2 rounded-r-lg bg-[var(--color-surface-3)] hover:bg-[var(--color-surface-4)] border border-[var(--color-border)] text-[var(--color-text-secondary)] transition-colors duration-150\"\n >\n {copied ? (\n <Check className=\"h-3.5 w-3.5 text-[var(--color-success-text)]\" aria-hidden=\"true\" />\n ) : (\n <Copy className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n )}\n </button>\n )}\n </div>\n </div>\n );\n}\n\nexport { ReadOnlyField };\nexport type { ReadOnlyFieldProps };\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The refresh control.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `components/shared/RefreshButton.tsx` in **Durable-DAV**, **Durable-DAV-Router**,
|
|
7
|
+
* **Edge-Git** and **Mail-Otter** — four byte-identical copies.
|
|
8
|
+
*
|
|
9
|
+
* ## Why the icon stays but the label does not
|
|
10
|
+
*
|
|
11
|
+
* This is the one place the kit takes `lucide-react` as a peer, and the split is
|
|
12
|
+
* deliberate. `RefreshCw` is iconography: reimplementing its path data in this
|
|
13
|
+
* package would fork lucide's artwork and freeze it at whatever version the kit
|
|
14
|
+
* vendored it. A label, by contrast, is the consuming app's string catalogue —
|
|
15
|
+
* the app knows whether this reads "Refresh" or "Neu laden", and a kit that
|
|
16
|
+
* hard-codes English text for it has taken over something it should not own.
|
|
17
|
+
*
|
|
18
|
+
* So: glyph in, string out. That is also why the kit's own `Button` keeps
|
|
19
|
+
* using its own `Spinner` rather than lucide's `Loader2` — chrome is cheap to
|
|
20
|
+
* draw, iconography is not.
|
|
21
|
+
*
|
|
22
|
+
* `loading` is passed straight through to `Button`, which already blocks
|
|
23
|
+
* activation while busy, so a caller does not also thread `disabled`.
|
|
24
|
+
*/
|
|
25
|
+
interface RefreshButtonProps {
|
|
26
|
+
onRefresh: () => void;
|
|
27
|
+
/** Shows the spinner and blocks activation until the caller's work clears. */
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
/** The button's text. */
|
|
30
|
+
label: string;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
declare function RefreshButton({ onRefresh, loading, label, className }: Readonly<RefreshButtonProps>): import("react").JSX.Element;
|
|
34
|
+
export { RefreshButton };
|
|
35
|
+
export type { RefreshButtonProps };
|
|
36
|
+
//# sourceMappingURL=RefreshButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshButton.d.ts","sourceRoot":"","sources":["../src/RefreshButton.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,UAAU,kBAAkB;IAC1B,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iBAAS,aAAa,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,+BAO5F;AAED,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RefreshCw } from 'lucide-react';
|
|
3
|
+
import { Button } from "./Button.js";
|
|
4
|
+
function RefreshButton({ onRefresh, loading, label, className }) {
|
|
5
|
+
return (_jsxs(Button, { variant: "secondary", size: "sm", onClick: onRefresh, loading: loading, className: className, children: [_jsx(RefreshCw, { className: "h-3.5 w-3.5", "aria-hidden": "true" }), label] }));
|
|
6
|
+
}
|
|
7
|
+
export { RefreshButton };
|
|
8
|
+
//# sourceMappingURL=RefreshButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RefreshButton.js","sourceRoot":"","sources":["../src/RefreshButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAc,CAAC;AAoCtC,SAAS,aAAa,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAgC;IAC3F,OAAO,CACL,MAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,aAC9F,KAAC,SAAS,IAAC,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EACvD,KAAK,IACC,CACV,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { RefreshCw } from 'lucide-react';\nimport { Button } from './Button.tsx';\n\n/**\n * The refresh control.\n *\n * ## Provenance\n *\n * `components/shared/RefreshButton.tsx` in **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git** and **Mail-Otter** — four byte-identical copies.\n *\n * ## Why the icon stays but the label does not\n *\n * This is the one place the kit takes `lucide-react` as a peer, and the split is\n * deliberate. `RefreshCw` is iconography: reimplementing its path data in this\n * package would fork lucide's artwork and freeze it at whatever version the kit\n * vendored it. A label, by contrast, is the consuming app's string catalogue —\n * the app knows whether this reads \"Refresh\" or \"Neu laden\", and a kit that\n * hard-codes English text for it has taken over something it should not own.\n *\n * So: glyph in, string out. That is also why the kit's own `Button` keeps\n * using its own `Spinner` rather than lucide's `Loader2` — chrome is cheap to\n * draw, iconography is not.\n *\n * `loading` is passed straight through to `Button`, which already blocks\n * activation while busy, so a caller does not also thread `disabled`.\n */\n\ninterface RefreshButtonProps {\n onRefresh: () => void;\n /** Shows the spinner and blocks activation until the caller's work clears. */\n loading?: boolean;\n /** The button's text. */\n label: string;\n className?: string;\n}\n\nfunction RefreshButton({ onRefresh, loading, label, className }: Readonly<RefreshButtonProps>) {\n return (\n <Button variant=\"secondary\" size=\"sm\" onClick={onRefresh} loading={loading} className={className}>\n <RefreshCw className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n {label}\n </Button>\n );\n}\n\nexport { RefreshButton };\nexport type { RefreshButtonProps };\n"]}
|
package/dist/Spinner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { theme } from
|
|
2
|
+
import { theme } from "./theme.js";
|
|
3
3
|
function Spinner({ size = 24, color = theme.spinnerBlue, label, padding = '16px 0', style }) {
|
|
4
4
|
return (_jsxs("div", { style: { textAlign: 'center', padding, ...style }, children: [_jsx("div", { className: "animate-spin", "aria-hidden": "true", style: {
|
|
5
5
|
width: `${size}px`,
|
package/dist/Spinner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../src/Spinner.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../src/Spinner.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA8BnC,SAAS,OAAO,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,GAAG,QAAQ,EAAE,KAAK,EAA0B;IACjH,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,aACpD,cACE,SAAS,EAAC,cAAc,iBACZ,MAAM,EAClB,KAAK,EAAE;oBACL,KAAK,EAAE,GAAG,IAAI,IAAI;oBAClB,MAAM,EAAE,GAAG,IAAI,IAAI;oBACnB,YAAY,EAAE,KAAK;oBACnB,MAAM,EAAE,aAAa,KAAK,EAAE;oBAC5B,cAAc,EAAE,aAAa;oBAC7B,MAAM,EAAE,QAAQ;iBACjB,GACD,EACD,KAAK,CAAC,CAAC,CAAC,YAAG,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,YAAG,KAAK,GAAK,CAAC,CAAC,CAAC,IAAI,IAC1E,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import type { CSSProperties } from 'react';\nimport { theme } from './theme.ts';\n\n/**\n * The loading ring.\n *\n * ## Provenance\n *\n * `components/ui/Spinner.tsx` in **AWS-AccessBridge** — the only named spinner\n * in the family. The other repos inline the same ring into their buttons as a\n * `Loader2` icon from `lucide-react`, which the kit does not depend on, so this\n * component *is* the kit's spinner vocabulary: `Button` and `LoadingButton`\n * render it while busy.\n *\n * The ring is a bordered circle with one transparent edge, animated by\n * Tailwind's `animate-spin` (present in every consuming app's stylesheet).\n */\n\ninterface SpinnerProps {\n /** Diameter in pixels. */\n size?: number;\n /** Border colour; `currentColor` inherits from the surrounding text. */\n color?: string;\n /** Optional caption under the ring. */\n label?: string;\n /** Padding around the whole block, as a CSS shorthand. */\n padding?: string;\n /** Extra styles for the outer wrapper. */\n style?: CSSProperties;\n}\n\nfunction Spinner({ size = 24, color = theme.spinnerBlue, label, padding = '16px 0', style }: Readonly<SpinnerProps>): React.JSX.Element {\n return (\n <div style={{ textAlign: 'center', padding, ...style }}>\n <div\n className=\"animate-spin\"\n aria-hidden=\"true\"\n style={{\n width: `${size}px`,\n height: `${size}px`,\n borderRadius: '50%',\n border: `2px solid ${color}`,\n borderTopColor: 'transparent',\n margin: '0 auto',\n }}\n />\n {label ? <p style={{ color: '#9ca3af', marginTop: '12px' }}>{label}</p> : null}\n </div>\n );\n}\n\nexport { Spinner };\nexport type { SpinnerProps };\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "type the name to confirm this destructive action" dialog.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `components/modals/TypeToConfirmModal.tsx` in **Durable-DAV**,
|
|
7
|
+
* **Durable-DAV-Router**, **Edge-Git** and **Mail-Otter** — four copies that
|
|
8
|
+
* agreed on the interaction and each carried its own clipboard handler.
|
|
9
|
+
*
|
|
10
|
+
* ## Why this exists alongside `ConfirmDeleteModal`
|
|
11
|
+
*
|
|
12
|
+
* The two are not interchangeable, and merging them would lose the distinction
|
|
13
|
+
* that makes either useful. A confirmation whose button is always armed asks
|
|
14
|
+
* nothing of the operator; this one requires typing the exact name, which is
|
|
15
|
+
* the right price for deleting a volume, a branch, or a credential. A repo
|
|
16
|
+
* that wants the cheap one uses {@link ConfirmDeleteModal}; a repo that wants
|
|
17
|
+
* this one names the thing twice.
|
|
18
|
+
*
|
|
19
|
+
* ## The match is exact, not case-insensitive
|
|
20
|
+
*
|
|
21
|
+
* All four copies compared `input.trim() === expectedName`. That is
|
|
22
|
+
* intentional and is kept: a confirmation the operator has to get exactly right
|
|
23
|
+
* is a confirmation they read. Trimming is allowed because it is invisible; case
|
|
24
|
+
* folding is not, because a name differing only in case may well be a different
|
|
25
|
+
* resource on a case-insensitive backend.
|
|
26
|
+
*/
|
|
27
|
+
interface TypeToConfirmModalProps {
|
|
28
|
+
/** The dialog's heading, and its accessible name. */
|
|
29
|
+
title: string;
|
|
30
|
+
/** The line under the heading, explaining what happens on confirm. */
|
|
31
|
+
description: string;
|
|
32
|
+
/** The string the operator must type. Shown, and offered as a copy. */
|
|
33
|
+
expectedName: string;
|
|
34
|
+
confirmLabel: string;
|
|
35
|
+
cancelLabel: string;
|
|
36
|
+
/** The copy button's accessible name and tooltip. */
|
|
37
|
+
copyLabel: string;
|
|
38
|
+
/** The prompt over the input. Name the thing: `Type "prod" to confirm`. */
|
|
39
|
+
promptLabel: string;
|
|
40
|
+
onConfirm: () => void;
|
|
41
|
+
onCancel: () => void;
|
|
42
|
+
loading?: boolean;
|
|
43
|
+
}
|
|
44
|
+
declare function TypeToConfirmModal({ title, description, expectedName, confirmLabel, cancelLabel, copyLabel, promptLabel, onConfirm, onCancel, loading, }: Readonly<TypeToConfirmModalProps>): import("react").JSX.Element;
|
|
45
|
+
export { TypeToConfirmModal };
|
|
46
|
+
export type { TypeToConfirmModalProps };
|
|
47
|
+
//# sourceMappingURL=TypeToConfirmModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeToConfirmModal.d.ts","sourceRoot":"","sources":["../src/TypeToConfirmModal.tsx"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,UAAU,uBAAuB;IAC/B,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,WAAW,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,iBAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,OAAe,GAChB,EAAE,QAAQ,CAAC,uBAAuB,CAAC,+BA2EnC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { AlertTriangle, Check, Copy } from 'lucide-react';
|
|
4
|
+
import { Button } from "./Button.js";
|
|
5
|
+
import { Input, Label } from "./Input.js";
|
|
6
|
+
import { ModalShell } from "./ModalShell.js";
|
|
7
|
+
import { useCopyToClipboard } from "./useCopyToClipboard.js";
|
|
8
|
+
function TypeToConfirmModal({ title, description, expectedName, confirmLabel, cancelLabel, copyLabel, promptLabel, onConfirm, onCancel, loading = false, }) {
|
|
9
|
+
const [input, setInput] = useState('');
|
|
10
|
+
const { copied, copy } = useCopyToClipboard();
|
|
11
|
+
const matched = input.trim() === expectedName;
|
|
12
|
+
return (_jsx(ModalShell, { onClose: onCancel, widthClass: "w-full max-w-md mx-4", ariaLabel: title, children: _jsxs("div", { className: "p-6", children: [_jsx("div", { className: "flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-error-bg)] mb-4 mx-auto", children: _jsx(AlertTriangle, { className: "h-5 w-5 text-[var(--color-error-text)]", "aria-hidden": "true" }) }), _jsx("h2", { className: "text-base font-semibold text-[var(--color-text-primary)] text-center mb-2", children: title }), _jsx("p", { className: "text-sm text-[var(--color-text-secondary)] text-center mb-4", children: description }), _jsxs("div", { className: "flex items-center justify-center gap-2 mb-4", children: [_jsx("code", { className: "px-2.5 py-1.5 rounded-lg bg-[var(--color-surface-base)] border border-[var(--color-border)] text-sm font-mono text-[var(--color-text-primary)] break-all", children: expectedName }), _jsx("button", { type: "button", onClick: () => copy(expectedName), title: copyLabel, "aria-label": copyLabel, className: "px-2.5 py-2 rounded-lg bg-[var(--color-surface-3)] hover:bg-[var(--color-surface-4)] border border-[var(--color-border)] text-[var(--color-text-secondary)] transition-colors duration-150", children: copied ? (_jsx(Check, { className: "h-3.5 w-3.5 text-[var(--color-success-text)]", "aria-hidden": "true" })) : (_jsx(Copy, { className: "h-3.5 w-3.5", "aria-hidden": "true" })) })] }), _jsxs("div", { className: "space-y-1.5 mb-6", children: [_jsx(Label, { htmlFor: "danger-confirm-input", children: promptLabel }), _jsx(Input, { id: "danger-confirm-input", value: input, onChange: (event) => setInput(event.target.value), placeholder: expectedName, autoComplete: "off", autoFocus: true })] }), _jsxs("div", { className: "flex gap-3", children: [_jsx(Button, { variant: "ghost", className: "flex-1", onClick: (event) => {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
onCancel();
|
|
15
|
+
}, children: cancelLabel }), _jsx(Button, { variant: "danger", className: "flex-1",
|
|
16
|
+
// Armed only on an exact match. `loading` is forwarded separately
|
|
17
|
+
// so a confirm already in flight cannot be fired a second time.
|
|
18
|
+
disabled: !matched, loading: loading, onClick: (event) => {
|
|
19
|
+
event.stopPropagation();
|
|
20
|
+
onConfirm();
|
|
21
|
+
}, children: confirmLabel })] })] }) }));
|
|
22
|
+
}
|
|
23
|
+
export { TypeToConfirmModal };
|
|
24
|
+
//# s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EA,YAAY,GACN,IACL,IACF,GACK,CACd,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import { useState } from 'react';\nimport { AlertTriangle, Check, Copy } from 'lucide-react';\nimport { Button } from './Button.tsx';\nimport { Input, Label } from './Input.tsx';\nimport { ModalShell } from './ModalShell.tsx';\nimport { useCopyToClipboard } from './useCopyToClipboard.ts';\n\n/**\n * The \"type the name to confirm this destructive action\" dialog.\n *\n * ## Provenance\n *\n * `components/modals/TypeToConfirmModal.tsx` in **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git** and **Mail-Otter** — four copies that\n * agreed on the interaction and each carried its own clipboard handler.\n *\n * ## Why this exists alongside `ConfirmDeleteModal`\n *\n * The two are not interchangeable, and merging them would lose the distinction\n * that makes either useful. A confirmation whose button is always armed asks\n * nothing of the operator; this one requires typing the exact name, which is\n * the right price for deleting a volume, a branch, or a credential. A repo\n * that wants the cheap one uses {@link ConfirmDeleteModal}; a repo that wants\n * this one names the thing twice.\n *\n * ## The match is exact, not case-insensitive\n *\n * All four copies compared `input.trim() === expectedName`. That is\n * intentional and is kept: a confirmation the operator has to get exactly right\n * is a confirmation they read. Trimming is allowed because it is invisible; case\n * folding is not, because a name differing only in case may well be a different\n * resource on a case-insensitive backend.\n */\n\ninterface TypeToConfirmModalProps {\n /** The dialog's heading, and its accessible name. */\n title: string;\n /** The line under the heading, explaining what happens on confirm. */\n description: string;\n /** The string the operator must type. Shown, and offered as a copy. */\n expectedName: string;\n confirmLabel: string;\n cancelLabel: string;\n /** The copy button's accessible name and tooltip. */\n copyLabel: string;\n /** The prompt over the input. Name the thing: `Type \"prod\" to confirm`. */\n promptLabel: string;\n onConfirm: () => void;\n onCancel: () => void;\n loading?: boolean;\n}\n\nfunction TypeToConfirmModal({\n title,\n description,\n expectedName,\n confirmLabel,\n cancelLabel,\n copyLabel,\n promptLabel,\n onConfirm,\n onCancel,\n loading = false,\n}: Readonly<TypeToConfirmModalProps>) {\n const [input, setInput] = useState('');\n const { copied, copy } = useCopyToClipboard();\n\n const matched = input.trim() === expectedName;\n\n return (\n // `closeLabel` is deliberately not `cancelLabel`: a dialog whose corner\n // close button and body cancel button share a name is announced as two\n // identical buttons. `ModalShell` defaults it to \"Close\" for that reason.\n <ModalShell onClose={onCancel} widthClass=\"w-full max-w-md mx-4\" ariaLabel={title}>\n <div className=\"p-6\">\n <div className=\"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-error-bg)] mb-4 mx-auto\">\n <AlertTriangle className=\"h-5 w-5 text-[var(--color-error-text)]\" aria-hidden=\"true\" />\n </div>\n <h2 className=\"text-base font-semibold text-[var(--color-text-primary)] text-center mb-2\">{title}</h2>\n <p className=\"text-sm text-[var(--color-text-secondary)] text-center mb-4\">{description}</p>\n <div className=\"flex items-center justify-center gap-2 mb-4\">\n <code className=\"px-2.5 py-1.5 rounded-lg bg-[var(--color-surface-base)] border border-[var(--color-border)] text-sm font-mono text-[var(--color-text-primary)] break-all\">\n {expectedName}\n </code>\n <button\n type=\"button\"\n onClick={() => copy(expectedName)}\n title={copyLabel}\n aria-label={copyLabel}\n className=\"px-2.5 py-2 rounded-lg bg-[var(--color-surface-3)] hover:bg-[var(--color-surface-4)] border border-[var(--color-border)] text-[var(--color-text-secondary)] transition-colors duration-150\"\n >\n {copied ? (\n <Check className=\"h-3.5 w-3.5 text-[var(--color-success-text)]\" aria-hidden=\"true\" />\n ) : (\n <Copy className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n )}\n </button>\n </div>\n <div className=\"space-y-1.5 mb-6\">\n <Label htmlFor=\"danger-confirm-input\">{promptLabel}</Label>\n <Input\n id=\"danger-confirm-input\"\n value={input}\n onChange={(event) => setInput(event.target.value)}\n placeholder={expectedName}\n autoComplete=\"off\"\n autoFocus\n />\n </div>\n <div className=\"flex gap-3\">\n <Button\n variant=\"ghost\"\n className=\"flex-1\"\n onClick={(event) => {\n event.stopPropagation();\n onCancel();\n }}\n >\n {cancelLabel}\n </Button>\n <Button\n variant=\"danger\"\n className=\"flex-1\"\n // Armed only on an exact match. `loading` is forwarded separately\n // so a confirm already in flight cannot be fired a second time.\n disabled={!matched}\n loading={loading}\n onClick={(event) => {\n event.stopPropagation();\n onConfirm();\n }}\n >\n {confirmLabel}\n </Button>\n </div>\n </div>\n </ModalShell>\n );\n}\n\nexport { TypeToConfirmModal };\nexport type { TypeToConfirmModalProps };\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The "you are not signed in" page.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `components/layout/Unauthorized.tsx` in **Durable-DAV**, **Durable-DAV-Router**,
|
|
7
|
+
* **Edge-Git**, **Mail-Otter** and **Edge-Sonic** — five copies, byte-identical
|
|
8
|
+
* apart from the doc comment — plus `Unauthorized.tsx` at the components root
|
|
9
|
+
* in **AWS-AccessBridge** and **CalDAV-Bridge**.
|
|
10
|
+
*
|
|
11
|
+
* ## Why `onAuthenticate` is an argument and not a fixed `location.assign`
|
|
12
|
+
*
|
|
13
|
+
* All seven copies hard-coded `globalThis.location.assign(ZERO_TRUST_AUTHENTICATION_PATH)`.
|
|
14
|
+
* That is untestable — jsdom refuses to navigate, so the one branch that
|
|
15
|
+
* matters (what happens when the operator actually clicks the button) had no
|
|
16
|
+
* assertions at all — and it hard-codes a routing assumption into a component
|
|
17
|
+
* that a repo may not share.
|
|
18
|
+
*
|
|
19
|
+
* The default keeps the original behaviour for a repo that wants it, and a
|
|
20
|
+
* caller with a different sign-in route passes its own.
|
|
21
|
+
*/
|
|
22
|
+
interface UnauthorizedProps {
|
|
23
|
+
/** The heading. Required: this is the page's only `h1`. */
|
|
24
|
+
title: string;
|
|
25
|
+
/**
|
|
26
|
+
* Why they are being stopped.
|
|
27
|
+
*
|
|
28
|
+
* Optional, and `null`/omitted renders no paragraph rather than an empty one.
|
|
29
|
+
* A blank line under the heading reads as a rendering bug.
|
|
30
|
+
*/
|
|
31
|
+
message?: string;
|
|
32
|
+
/** The sign-in button's label. Required. */
|
|
33
|
+
actionLabel: string;
|
|
34
|
+
/**
|
|
35
|
+
* What the button does.
|
|
36
|
+
*
|
|
37
|
+
* Defaults to navigating to {@link ZERO_TRUST_AUTHENTICATION_PATH}, which is
|
|
38
|
+
* what every copy in the family did.
|
|
39
|
+
*/
|
|
40
|
+
onAuthenticate?: () => void;
|
|
41
|
+
}
|
|
42
|
+
declare function Unauthorized({ title, message, actionLabel, onAuthenticate }: Readonly<UnauthorizedProps>): import("react").JSX.Element;
|
|
43
|
+
export { Unauthorized };
|
|
44
|
+
export type { UnauthorizedProps };
|
|
45
|
+
//# sourceMappingURL=Unauthorized.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Unauthorized.d.ts","sourceRoot":"","sources":["../src/Unauthorized.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,UAAU,iBAAiB;IACzB,2DAA2D;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,iBAAS,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE,QAAQ,CAAC,iBAAiB,CAAC,+BAsBjG;AAED,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ZERO_TRUST_AUTHENTICATION_PATH } from "./constants.js";
|
|
3
|
+
function Unauthorized({ title, message, actionLabel, onAuthenticate }) {
|
|
4
|
+
const authenticate = onAuthenticate ??
|
|
5
|
+
(() => {
|
|
6
|
+
globalThis.location.assign(ZERO_TRUST_AUTHENTICATION_PATH);
|
|
7
|
+
});
|
|
8
|
+
return (_jsx("div", { className: "bg-[var(--color-surface-base)] text-[var(--color-text-primary)] flex items-center justify-center py-16", children: _jsxs("div", { className: "text-center px-6", children: [_jsx("h1", { className: "text-lg font-medium mt-4 mb-1", children: title }), message && _jsx("p", { className: "text-[var(--color-text-secondary)] text-sm", children: message }), _jsx("button", { type: "button", onClick: authenticate, className: "mt-6 inline-flex items-center justify-center rounded-xl bg-[var(--color-accent)] px-5 py-2.5 text-sm font-medium text-[#0d1008] transition-colors hover:bg-[var(--color-accent-dim)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-accent)]", children: actionLabel })] }) }));
|
|
9
|
+
}
|
|
10
|
+
export { Unauthorized };
|
|
11
|
+
//# sourceMappingURL=Unauthorized.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Unauthorized.js","sourceRoot":"","sources":["../src/Unauthorized.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AA6ChE,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAA+B;IAChG,MAAM,YAAY,GAChB,cAAc;QACd,CAAC,GAAS,EAAE;YACV,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IAEL,OAAO,CACL,cAAK,SAAS,EAAC,wGAAwG,YACrH,eAAK,SAAS,EAAC,kBAAkB,aAC/B,aAAI,SAAS,EAAC,+BAA+B,YAAE,KAAK,GAAM,EACzD,OAAO,IAAI,YAAG,SAAS,EAAC,4CAA4C,YAAE,OAAO,GAAK,EACnF,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,YAAY,EACrB,SAAS,EAAC,+SAA+S,YAExT,WAAW,GACL,IACL,GACF,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { ZERO_TRUST_AUTHENTICATION_PATH } from './constants.ts';\n\n/**\n * The \"you are not signed in\" page.\n *\n * ## Provenance\n *\n * `components/layout/Unauthorized.tsx` in **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git**, **Mail-Otter** and **Edge-Sonic** — five copies, byte-identical\n * apart from the doc comment — plus `Unauthorized.tsx` at the components root\n * in **AWS-AccessBridge** and **CalDAV-Bridge**.\n *\n * ## Why `onAuthenticate` is an argument and not a fixed `location.assign`\n *\n * All seven copies hard-coded `globalThis.location.assign(ZERO_TRUST_AUTHENTICATION_PATH)`.\n * That is untestable — jsdom refuses to navigate, so the one branch that\n * matters (what happens when the operator actually clicks the button) had no\n * assertions at all — and it hard-codes a routing assumption into a component\n * that a repo may not share.\n *\n * The default keeps the original behaviour for a repo that wants it, and a\n * caller with a different sign-in route passes its own.\n */\n\ninterface UnauthorizedProps {\n /** The heading. Required: this is the page's only `h1`. */\n title: string;\n /**\n * Why they are being stopped.\n *\n * Optional, and `null`/omitted renders no paragraph rather than an empty one.\n * A blank line under the heading reads as a rendering bug.\n */\n message?: string;\n /** The sign-in button's label. Required. */\n actionLabel: string;\n /**\n * What the button does.\n *\n * Defaults to navigating to {@link ZERO_TRUST_AUTHENTICATION_PATH}, which is\n * what every copy in the family did.\n */\n onAuthenticate?: () => void;\n}\n\nfunction Unauthorized({ title, message, actionLabel, onAuthenticate }: Readonly<UnauthorizedProps>) {\n const authenticate =\n onAuthenticate ??\n ((): void => {\n globalThis.location.assign(ZERO_TRUST_AUTHENTICATION_PATH);\n });\n\n return (\n <div className=\"bg-[var(--color-surface-base)] text-[var(--color-text-primary)] flex items-center justify-center py-16\">\n <div className=\"text-center px-6\">\n <h1 className=\"text-lg font-medium mt-4 mb-1\">{title}</h1>\n {message && <p className=\"text-[var(--color-text-secondary)] text-sm\">{message}</p>}\n <button\n type=\"button\"\n onClick={authenticate}\n className=\"mt-6 inline-flex items-center justify-center rounded-xl bg-[var(--color-accent)] px-5 py-2.5 text-sm font-medium text-[#0d1008] transition-colors hover:bg-[var(--color-accent-dim)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-accent)]\"\n >\n {actionLabel}\n </button>\n </div>\n </div>\n );\n}\n\nexport { Unauthorized };\nexport type { UnauthorizedProps };\n"]}
|