@rexezuge/web 1.0.9 → 1.2.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/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/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/ModalShell.d.ts +53 -0
- package/dist/ModalShell.d.ts.map +1 -0
- package/dist/ModalShell.js +22 -0
- package/dist/ModalShell.js.map +1 -0
- 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.d.ts +47 -0
- package/dist/PageState.d.ts.map +1 -0
- package/dist/PageState.js +47 -0
- package/dist/PageState.js.map +1 -0
- 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/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 +44 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -1
- 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/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PageState.js","sourceRoot":"","sources":["../src/PageState.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;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';\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"]}
|
|
@@ -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';
|
|
5
|
+
import { cn } from './utils';
|
|
6
|
+
import { useCopyToClipboard } from './useCopyToClipboard';
|
|
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,SAAS,CAAC;AAChC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAiD1D,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';\nimport { cn } from './utils';\nimport { useCopyToClipboard } from './useCopyToClipboard';\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';
|
|
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,UAAU,CAAC;AAoClC,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';\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"]}
|
|
@@ -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';
|
|
5
|
+
import { Input, Label } from './Input';
|
|
6
|
+
import { ModalShell } from './ModalShell';
|
|
7
|
+
import { useCopyToClipboard } from './useCopyToClipboard';
|
|
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
|
+
//# sourceMappingURL=TypeToConfirmModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeToConfirmModal.js","sourceRoot":"","sources":["../src/TypeToConfirmModal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA+C1D,SAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX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Q,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EACjD,WAAW,EAAE,YAAY,EACzB,YAAY,EAAC,KAAK,EAClB,SAAS,SACT,IACE,EACN,eAAK,SAAS,EAAC,YAAY,aACzB,KAAC,MAAM,IACL,OAAO,EAAC,OAAO,EACf,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,KAAC,MAAM,IACL,OAAO,EAAC,QAAQ,EAChB,SAAS,EAAC,QAAQ;4BAClB,kEAAkE;4BAClE,gEAAgE;4BAChE,QAAQ,EAAE,CAAC,OAAO,EAClB,OAAO,EAAE,OAAO,EAChB,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,CAAC","sourcesContent":["import { useState } from 'react';\nimport { AlertTriangle, Check, Copy } from 'lucide-react';\nimport { Button } from './Button';\nimport { Input, Label } from './Input';\nimport { ModalShell } from './ModalShell';\nimport { useCopyToClipboard } from './useCopyToClipboard';\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';
|
|
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,aAAa,CAAC;AA6C7D,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';\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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* module for what it replaced and which copy won.
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
10
|
+
* import { AppPage, Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* ## What a consumer must provide
|
|
@@ -23,6 +23,26 @@
|
|
|
23
23
|
* - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for
|
|
24
24
|
* `ServiceError` and the status classes.
|
|
25
25
|
*
|
|
26
|
+
* ## Glyphs in, strings out
|
|
27
|
+
*
|
|
28
|
+
* Three components (`RefreshButton`, `ReadOnlyField`, `TypeToConfirmModal`) take
|
|
29
|
+
* their icon from `lucide-react`, which is why it is a peer rather than a
|
|
30
|
+
* dependency. Everything *sayable* is a prop: no component here calls
|
|
31
|
+
* `useTranslation`, because the app rendering a dialog knows what it says and a
|
|
32
|
+
* kit that hard-codes English for it has taken over the app's string catalogue.
|
|
33
|
+
*
|
|
34
|
+
* The dividing line is deliberate. `Button` keeps using this package's own
|
|
35
|
+
* `Spinner` rather than lucide's `Loader2` — chrome is cheap to draw, iconography
|
|
36
|
+
* is not, and vendoring a glyph's path data freezes it at whatever version was
|
|
37
|
+
* current when it was copied.
|
|
38
|
+
*
|
|
39
|
+
* ## Migrating the copies
|
|
40
|
+
*
|
|
41
|
+
* `codemods/` rewrites the family's `../components/…` imports onto this package
|
|
42
|
+
* for every component converged here, and names the ones it has not. Those
|
|
43
|
+
* imports are **relative**, so this is a separate transform from the
|
|
44
|
+
* `@scope/pkg` one — see `codemods/src/web-components.ts`.
|
|
45
|
+
*
|
|
26
46
|
* ## What is deliberately not here
|
|
27
47
|
*
|
|
28
48
|
* Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth
|
|
@@ -43,6 +63,29 @@ export { Input, Label, Select, Textarea, fieldClass } from './Input';
|
|
|
43
63
|
export type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input';
|
|
44
64
|
export { LoadingButton } from './LoadingButton';
|
|
45
65
|
export type { LoadingButtonProps } from './LoadingButton';
|
|
66
|
+
export { ModalShell } from './ModalShell';
|
|
67
|
+
export type { ModalShellProps } from './ModalShell';
|
|
68
|
+
export { ConfirmDeleteModal, EmptyState, LoadingSpinner } from './PageState';
|
|
69
|
+
export { AppPage } from './AppPage';
|
|
70
|
+
export type { AppPageProps, AppPageVariant } from './AppPage';
|
|
71
|
+
export { PageHeaderCard } from './PageHeaderCard';
|
|
72
|
+
export type { PageHeaderCardProps } from './PageHeaderCard';
|
|
73
|
+
export { ContextBar } from './ContextBar';
|
|
74
|
+
export type { ContextBarProps } from './ContextBar';
|
|
75
|
+
export { Unauthorized } from './Unauthorized';
|
|
76
|
+
export type { UnauthorizedProps } from './Unauthorized';
|
|
77
|
+
export { NoticeBar } from './NoticeBar';
|
|
78
|
+
export type { NoticeBarProps, NoticeStatusLabels } from './NoticeBar';
|
|
79
|
+
export { LanguageSelector } from './LanguageSelector';
|
|
80
|
+
export type { LanguageSelectorProps } from './LanguageSelector';
|
|
81
|
+
export { RefreshButton } from './RefreshButton';
|
|
82
|
+
export type { RefreshButtonProps } from './RefreshButton';
|
|
83
|
+
export { ReadOnlyField } from './ReadOnlyField';
|
|
84
|
+
export type { ReadOnlyFieldProps } from './ReadOnlyField';
|
|
85
|
+
export { TypeToConfirmModal } from './TypeToConfirmModal';
|
|
86
|
+
export type { TypeToConfirmModalProps } from './TypeToConfirmModal';
|
|
87
|
+
export { useCopyToClipboard } from './useCopyToClipboard';
|
|
88
|
+
export type { UseCopyToClipboardResult } from './useCopyToClipboard';
|
|
46
89
|
export { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination';
|
|
47
90
|
export type { PaginationLabels, PaginationProps } from './Pagination';
|
|
48
91
|
export { Spinner } from './Spinner';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,KAAK,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AO,EACP,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAErG,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EAAE,WAAW,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEjG,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAC/F,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* module for what it replaced and which copy won.
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
10
|
+
* import { AppPage, Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* ## What a consumer must provide
|
|
@@ -23,6 +23,26 @@
|
|
|
23
23
|
* - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for
|
|
24
24
|
* `ServiceError` and the status classes.
|
|
25
25
|
*
|
|
26
|
+
* ## Glyphs in, strings out
|
|
27
|
+
*
|
|
28
|
+
* Three components (`RefreshButton`, `ReadOnlyField`, `TypeToConfirmModal`) take
|
|
29
|
+
* their icon from `lucide-react`, which is why it is a peer rather than a
|
|
30
|
+
* dependency. Everything *sayable* is a prop: no component here calls
|
|
31
|
+
* `useTranslation`, because the app rendering a dialog knows what it says and a
|
|
32
|
+
* kit that hard-codes English for it has taken over the app's string catalogue.
|
|
33
|
+
*
|
|
34
|
+
* The dividing line is deliberate. `Button` keeps using this package's own
|
|
35
|
+
* `Spinner` rather than lucide's `Loader2` — chrome is cheap to draw, iconography
|
|
36
|
+
* is not, and vendoring a glyph's path data freezes it at whatever version was
|
|
37
|
+
* current when it was copied.
|
|
38
|
+
*
|
|
39
|
+
* ## Migrating the copies
|
|
40
|
+
*
|
|
41
|
+
* `codemods/` rewrites the family's `../components/…` imports onto this package
|
|
42
|
+
* for every component converged here, and names the ones it has not. Those
|
|
43
|
+
* imports are **relative**, so this is a separate transform from the
|
|
44
|
+
* `@scope/pkg` one — see `codemods/src/web-components.ts`.
|
|
45
|
+
*
|
|
26
46
|
* ## What is deliberately not here
|
|
27
47
|
*
|
|
28
48
|
* Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth
|
|
@@ -37,6 +57,26 @@ export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle
|
|
|
37
57
|
export { FocusInput } from './FocusInput';
|
|
38
58
|
export { Input, Label, Select, Textarea, fieldClass } from './Input';
|
|
39
59
|
export { LoadingButton } from './LoadingButton';
|
|
60
|
+
// Converged from the `ModalShell` / `ConfirmDeleteModal` / `PageState` copies
|
|
61
|
+
// that Durable-DAV, Durable-DAV-Router, Mail-Otter and Edge-Git each shipped.
|
|
62
|
+
// Deliberately dependency-free — labels are props, not `useTranslation` — so
|
|
63
|
+
// adopting these does not require a translation library or an icon set.
|
|
64
|
+
export { ModalShell } from './ModalShell';
|
|
65
|
+
export { ConfirmDeleteModal, EmptyState, LoadingSpinner } from './PageState';
|
|
66
|
+
// The second convergence round: page layout, the notice banner, the access
|
|
67
|
+
// page, the language picker, and the two clipboard-bearing controls. Same rule
|
|
68
|
+
// on labels — the app owns its string catalogue. Three of these need
|
|
69
|
+
// `lucide-react`, which is why it is a peer and not a dependency.
|
|
70
|
+
export { AppPage } from './AppPage';
|
|
71
|
+
export { PageHeaderCard } from './PageHeaderCard';
|
|
72
|
+
export { ContextBar } from './ContextBar';
|
|
73
|
+
export { Unauthorized } from './Unauthorized';
|
|
74
|
+
export { NoticeBar } from './NoticeBar';
|
|
75
|
+
export { LanguageSelector } from './LanguageSelector';
|
|
76
|
+
export { RefreshButton } from './RefreshButton';
|
|
77
|
+
export { ReadOnlyField } from './ReadOnlyField';
|
|
78
|
+
export { TypeToConfirmModal } from './TypeToConfirmModal';
|
|
79
|
+
export { useCopyToClipboard } from './useCopyToClipboard';
|
|
40
80
|
export { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination';
|
|
41
81
|
export { Spinner } from './Spinner';
|
|
42
82
|
export { btnBase, btnBlueStyle, btnGreenStyle, btnSmallStyle, buttonColors, cardStyle, inputStyle, paginationBtnStyle, tableCardStyle, tdStyle, theme, thStyle, } from './theme';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAA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AE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG7B,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC","sourcesContent":["/**\n * `@rexezuge/web` — the SPA layer of the kit.\n *\n * React primitives, the hooks every app's shell needs, and the one API client.\n * Every export is the converged form of a framework that lived as copies inside\n * the nine consumer repos; see the `## Provenance` block at the top of each\n * module for what it replaced and which copy won.\n *\n * ```ts\n * import { AppPage, Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';\n * ```\n *\n * ## What a consumer must provide\n *\n * - **The CSS variables the class-based components read.** All six Tailwind\n * repos define the same set, so this is usually already present:\n * `--color-accent`, `--color-accent-dim`, `--color-border`,\n * `--color-surface-base`, `--color-surface-1..4`,\n * `--color-text-primary`, `--color-text-secondary`, `--color-text-muted`, and\n * `--color-{success,error,warning,info,neutral}-{bg,text}`.\n * - **`animate-spin`**, for `Spinner` (and therefore `Button`'s busy state).\n * Tailwind ships it; a non-Tailwind app defines the keyframes once.\n * - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for\n * `ServiceError` and the status classes.\n *\n * ## Glyphs in, strings out\n *\n * Three components (`RefreshButton`, `ReadOnlyField`, `TypeToConfirmModal`) take\n * their icon from `lucide-react`, which is why it is a peer rather than a\n * dependency. Everything *sayable* is a prop: no component here calls\n * `useTranslation`, because the app rendering a dialog knows what it says and a\n * kit that hard-codes English for it has taken over the app's string catalogue.\n *\n * The dividing line is deliberate. `Button` keeps using this package's own\n * `Spinner` rather than lucide's `Loader2` — chrome is cheap to draw, iconography\n * is not, and vendoring a glyph's path data freezes it at whatever version was\n * current when it was copied.\n *\n * ## Migrating the copies\n *\n * `codemods/` rewrites the family's `../components/…` imports onto this package\n * for every component converged here, and names the ones it has not. Those\n * imports are **relative**, so this is a separate transform from the\n * `@scope/pkg` one — see `codemods/src/web-components.ts`.\n *\n * ## What is deliberately not here\n *\n * Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth\n * `?oauth2=` notice seeding, the D1 bookmark header, WebDAV `207` handling, the\n * authed-first public fallback, and every app's `SUPPORTED_LANGUAGES`. Each had\n * exactly one consumer, so each stays with it — see `constants.ts` and the\n * per-module provenance notes for the list.\n */\n\nexport { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge';\nexport type { BadgeProps, BadgeVariant } from './Badge';\n\nexport { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button';\nexport type { ButtonProps, ButtonSize, ButtonVariant } from './Button';\n\nexport { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card';\nexport type { CardHeaderProps, CardProps, CardTitleProps } from './Card';\n\nexport { FocusInput } from './FocusInput';\nexport type { FocusInputProps } from './FocusInput';\n\nexport { Input, Label, Select, Textarea, fieldClass } from './Input';\nexport type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input';\n\nexport { LoadingButton } from './LoadingButton';\nexport type { LoadingButtonProps } from './LoadingButton';\n\n// Converged from the `ModalShell` / `ConfirmDeleteModal` / `PageState` copies\n// that Durable-DAV, Durable-DAV-Router, Mail-Otter and Edge-Git each shipped.\n// Deliberately dependency-free — labels are props, not `useTranslation` — so\n// adopting these does not require a translation library or an icon set.\nexport { ModalShell } from './ModalShell';\nexport type { ModalShellProps } from './ModalShell';\nexport { ConfirmDeleteModal, EmptyState, LoadingSpinner } from './PageState';\n\n// The second convergence round: page layout, the notice banner, the access\n// page, the language picker, and the two clipboard-bearing controls. Same rule\n// on labels — the app owns its string catalogue. Three of these need\n// `lucide-react`, which is why it is a peer and not a dependency.\nexport { AppPage } from './AppPage';\nexport type { AppPageProps, AppPageVariant } from './AppPage';\nexport { PageHeaderCard } from './PageHeaderCard';\nexport type { PageHeaderCardProps } from './PageHeaderCard';\nexport { ContextBar } from './ContextBar';\nexport type { ContextBarProps } from './ContextBar';\nexport { Unauthorized } from './Unauthorized';\nexport type { UnauthorizedProps } from './Unauthorized';\nexport { NoticeBar } from './NoticeBar';\nexport type { NoticeBarProps, NoticeStatusLabels } from './NoticeBar';\nexport { LanguageSelector } from './LanguageSelector';\nexport type { LanguageSelectorProps } from './LanguageSelector';\nexport { RefreshButton } from './RefreshButton';\nexport type { RefreshButtonProps } from './RefreshButton';\nexport { ReadOnlyField } from './ReadOnlyField';\nexport type { ReadOnlyFieldProps } from './ReadOnlyField';\nexport { TypeToConfirmModal } from './TypeToConfirmModal';\nexport type { TypeToConfirmModalProps } from './TypeToConfirmModal';\nexport { useCopyToClipboard } from './useCopyToClipboard';\nexport type { UseCopyToClipboardResult } from './useCopyToClipboard';\n\nexport { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination';\nexport type { PaginationLabels, PaginationProps } from './Pagination';\n\nexport { Spinner } from './Spinner';\nexport type { SpinnerProps } from './Spinner';\n\nexport {\n btnBase,\n btnBlueStyle,\n btnGreenStyle,\n btnSmallStyle,\n buttonColors,\n cardStyle,\n inputStyle,\n paginationBtnStyle,\n tableCardStyle,\n tdStyle,\n theme,\n thStyle,\n} from './theme';\n\nexport { cn } from './utils';\nexport type { ClassDictionary, ClassValue } from './utils';\n\nexport { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from './constants';\n\nexport { useNotice } from './useNotice';\nexport type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult } from './useNotice';\n\nexport {\n canonicalizeLanguageTag,\n DEFAULT_FALLBACK_LANGUAGE,\n DEFAULT_LANGUAGE_STORAGE_KEY,\n DEFAULT_SUPPORTED_LANGUAGES,\n resolveLanguageTag,\n useSpaLanguage,\n} from './useSpaLanguage';\nexport type { LanguageTag, UseSpaLanguageOptions, UseSpaLanguageResult } from './useSpaLanguage';\n\nexport { CURRENT_USER_PATH, useCurrentUser } from './useCurrentUser';\nexport type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult } from './useCurrentUser';\n\nexport { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from './api';\nexport type { ApiClient, ApiRequestInit, CreateApiClientOptions, FetchFn, QueryParams, QueryValue } from './api';\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy text to the clipboard, reporting success only when it happened.
|
|
3
|
+
*
|
|
4
|
+
* ## Provenance
|
|
5
|
+
*
|
|
6
|
+
* `hooks/useCopyToClipboard.ts` in **Durable-DAV** — the one copy that had
|
|
7
|
+
* solved the two failures the others carried. The other three handlers were
|
|
8
|
+
* inlined into `ReadOnlyField` (Edge-Git, Mail-Otter, Durable-DAV-Router) and
|
|
9
|
+
* `TypeToConfirmModal`, and were byte-identical to each other.
|
|
10
|
+
*
|
|
11
|
+
* ## The two live bugs this converges away
|
|
12
|
+
*
|
|
13
|
+
* 1. **`navigator.clipboard` is absent in an insecure context.** A plain
|
|
14
|
+
* `navigator.clipboard.writeText` throws *synchronously* there, so the
|
|
15
|
+
* handler dies before setting state. Where it was guarded with
|
|
16
|
+
* `if (clipboard)`, the guard fell through to `setCopied(true)` anyway and
|
|
17
|
+
* showed a checkmark for a copy that never happened.
|
|
18
|
+
* 2. **The write is a promise that rejects on a denied permission.** Awaiting
|
|
19
|
+
* it is not enough; the rejection has to be handled, or it surfaces as an
|
|
20
|
+
* unhandled rejection *and* the checkmark still appears.
|
|
21
|
+
*
|
|
22
|
+
* That second case is why this is a hook rather than a helper. The honest
|
|
23
|
+
* answer — "nothing was copied, so there is nothing to undo" — is expressed by
|
|
24
|
+
* `copied` simply never becoming true, which is state a helper function cannot
|
|
25
|
+
* hold.
|
|
26
|
+
*
|
|
27
|
+
* Every call site in the family is a secret reveal: a bucket credential's
|
|
28
|
+
* copy-once password, a resource name typed to confirm a destructive action.
|
|
29
|
+
* A false success sends the operator away believing they have something they do
|
|
30
|
+
* not.
|
|
31
|
+
*
|
|
32
|
+
* ## Timer handling
|
|
33
|
+
*
|
|
34
|
+
* The reset timer is a ref and is cleared on unmount. Local `setTimeout` handles
|
|
35
|
+
* in the inlined copies leaked both ways: a modal closed inside the feedback
|
|
36
|
+
* window set state on an unmounted component, and repeated clicks each replaced
|
|
37
|
+
* the timer without cancelling the previous one, so an early timer could clear
|
|
38
|
+
* the checkmark while a later copy was still pending.
|
|
39
|
+
*/
|
|
40
|
+
interface UseCopyToClipboardResult {
|
|
41
|
+
/**
|
|
42
|
+
* True only after a write that actually resolved.
|
|
43
|
+
*
|
|
44
|
+
* Never optimistically set: a denied permission or an insecure context leaves
|
|
45
|
+
* this `false`, which is the answer that matters — there is nothing to undo.
|
|
46
|
+
*/
|
|
47
|
+
copied: boolean;
|
|
48
|
+
/** Writes `text`, or does nothing if the clipboard is unavailable. */
|
|
49
|
+
copy: (text: string) => void;
|
|
50
|
+
}
|
|
51
|
+
declare function useCopyToClipboard(): UseCopyToClipboardResult;
|
|
52
|
+
export { useCopyToClipboard };
|
|
53
|
+
export type { UseCopyToClipboardResult };
|
|
54
|
+
//# sourceMappingURL=useCopyToClipboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../src/useCopyToClipboard.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,UAAU,wBAAwB;IAChC;;;;;OAKG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC9B;AAED,iBAAS,kBAAkB,IAAI,wBAAwB,CAuCtD;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { COPY_FEEDBACK_TIMEOUT_MS } from './constants';
|
|
3
|
+
function useCopyToClipboard() {
|
|
4
|
+
const [copied, setCopied] = useState(false);
|
|
5
|
+
const resetTimer = useRef(null);
|
|
6
|
+
useEffect(() => () => {
|
|
7
|
+
if (resetTimer.current !== null)
|
|
8
|
+
clearTimeout(resetTimer.current);
|
|
9
|
+
}, []);
|
|
10
|
+
const copy = useCallback((text) => {
|
|
11
|
+
// Optional chaining rather than an assumption: `navigator.clipboard` is
|
|
12
|
+
// genuinely absent over plain HTTP, and for a self-hosted deployment over
|
|
13
|
+
// plain HTTP that is a normal configuration, not an error to surface.
|
|
14
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
15
|
+
// Nothing was copied, so there is nothing to report and nothing to undo.
|
|
16
|
+
if (!clipboard)
|
|
17
|
+
return;
|
|
18
|
+
void clipboard
|
|
19
|
+
.writeText(text)
|
|
20
|
+
.then(() => {
|
|
21
|
+
setCopied(true);
|
|
22
|
+
// Cancel any pending reset before arming a new one. Replacing the
|
|
23
|
+
// handle without clearing leaves the earlier timer live, and it can
|
|
24
|
+
// clear the checkmark for a copy that is still being reported.
|
|
25
|
+
if (resetTimer.current !== null)
|
|
26
|
+
clearTimeout(resetTimer.current);
|
|
27
|
+
resetTimer.current = setTimeout(() => {
|
|
28
|
+
resetTimer.current = null;
|
|
29
|
+
setCopied(false);
|
|
30
|
+
}, COPY_FEEDBACK_TIMEOUT_MS);
|
|
31
|
+
})
|
|
32
|
+
// Leave `copied` false rather than flashing and clearing it: a rejection
|
|
33
|
+
// means the text is still on screen and unread, so the affordance must
|
|
34
|
+
// not claim otherwise.
|
|
35
|
+
.catch(() => undefined);
|
|
36
|
+
}, []);
|
|
37
|
+
return { copied, copy };
|
|
38
|
+
}
|
|
39
|
+
export { useCopyToClipboard };
|
|
40
|
+
//# sourceMappingURL=useCopyToClipboard.js.map
|