@rexezuge/web 1.5.1 → 1.5.2

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.
Files changed (51) hide show
  1. package/dist/AppPage.js +1 -1
  2. package/dist/AppPage.js.map +2 -2
  3. package/dist/Badge.js +1 -1
  4. package/dist/Badge.js.map +2 -2
  5. package/dist/Button.js +1 -1
  6. package/dist/Button.js.map +2 -2
  7. package/dist/Card.js +1 -1
  8. package/dist/Card.js.map +2 -2
  9. package/dist/ContextBar.js +1 -1
  10. package/dist/ContextBar.js.map +2 -2
  11. package/dist/FocusInput.js +1 -1
  12. package/dist/FocusInput.js.map +2 -2
  13. package/dist/Input.js +1 -1
  14. package/dist/Input.js.map +2 -2
  15. package/dist/LanguageSelector.js +1 -1
  16. package/dist/LanguageSelector.js.map +2 -2
  17. package/dist/LoadingButton.js +1 -1
  18. package/dist/LoadingButton.js.map +2 -2
  19. package/dist/ModalShell.js +1 -1
  20. package/dist/ModalShell.js.map +2 -2
  21. package/dist/NoticeBar.js +1 -1
  22. package/dist/NoticeBar.js.map +2 -2
  23. package/dist/PageHeaderCard.js +1 -1
  24. package/dist/PageHeaderCard.js.map +2 -2
  25. package/dist/PageState.js +1 -1
  26. package/dist/PageState.js.map +2 -2
  27. package/dist/Pagination.js +1 -1
  28. package/dist/Pagination.js.map +2 -2
  29. package/dist/ReadOnlyField.js +1 -1
  30. package/dist/ReadOnlyField.js.map +2 -2
  31. package/dist/RefreshButton.js +1 -1
  32. package/dist/RefreshButton.js.map +2 -2
  33. package/dist/Spinner.js +1 -1
  34. package/dist/Spinner.js.map +2 -2
  35. package/dist/TypeToConfirmModal.js +1 -1
  36. package/dist/TypeToConfirmModal.js.map +2 -2
  37. package/dist/Unauthorized.js +1 -1
  38. package/dist/Unauthorized.js.map +2 -2
  39. package/dist/api.js +1 -1
  40. package/dist/api.js.map +2 -2
  41. package/dist/useCopyToClipboard.js +1 -1
  42. package/dist/useCopyToClipboard.js.map +2 -2
  43. package/dist/useCurrentUser.js +1 -1
  44. package/dist/useCurrentUser.js.map +2 -2
  45. package/dist/useNotice.js +1 -1
  46. package/dist/useNotice.js.map +2 -2
  47. package/dist/useSpaLanguage.js +1 -1
  48. package/dist/useSpaLanguage.js.map +2 -2
  49. package/dist/utils.js +1 -1
  50. package/dist/utils.js.map +2 -2
  51. package/package.json +3 -3
package/dist/AppPage.js CHANGED
@@ -1 +1 @@
1
- import{jsx as m}from"react/jsx-runtime";import{cn as o}from"./utils.js";function r({variant:p="wide",className:x,children:e}){return m("div",{className:o("mx-auto w-full px-6",p==="wide"&&"max-w-5xl py-8 space-y-4",p==="narrow"&&"max-w-2xl py-8 space-y-4",p==="hero"&&"max-w-5xl py-16",x),children:e})}export{r as AppPage};
1
+ var o=Object.defineProperty;var e=(p,x)=>o(p,"name",{value:x,configurable:!0});import{jsx as r}from"react/jsx-runtime";import{cn as a}from"./utils.js";function l({variant:p="wide",className:x,children:m}){return r("div",{className:a("mx-auto w-full px-6",p==="wide"&&"max-w-5xl py-8 space-y-4",p==="narrow"&&"max-w-2xl py-8 space-y-4",p==="hero"&&"max-w-5xl py-16",x),children:m})}e(l,"AppPage");export{l as AppPage};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/AppPage.tsx"],
4
4
  "sourcesContent": ["import type { ReactNode } from 'react';\nimport { cn } from './utils.ts';\n\n/**\n * The one page container.\n *\n * ## Provenance\n *\n * `components/layout/AppPage.tsx` in **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git** and **Edge-Sonic** — four copies, three of them identical.\n *\n * ## The divergence, and which side won\n *\n * Three copies used `max-w-7xl`; Edge-Sonic's used `max-w-5xl` and recorded\n * why: the operator surface is two lists and two forms, and the wider measure\n * only adds line length to prose already at its readable limit. That is the\n * better answer, so it is the one here — with `className` as the documented\n * escape hatch for a repo that genuinely wants the wider measure, because the\n * decision is per-app and a vendored copy would freeze ours.\n *\n * `hero` follows `wide` rather than carrying its own width: a hero that is\n * wider than the page it introduces is a layout bug, not a style.\n */\n\n/**\n`wide` is the default for every view. `narrow` is for centered forms.\n*/\ntype AppPageVariant = 'wide' | 'narrow' | 'hero';\n\ninterface AppPageProps {\n variant?: AppPageVariant;\n /**\n Merged last, so it wins over the variant's own classes.\n */\n className?: string;\n children: ReactNode;\n}\n\nfunction AppPage({ variant = 'wide', className, children }: Readonly<AppPageProps>) {\n return (\n <div\n className={cn(\n 'mx-auto w-full px-6',\n variant === 'wide' && 'max-w-5xl py-8 space-y-4',\n variant === 'narrow' && 'max-w-2xl py-8 space-y-4',\n variant === 'hero' && 'max-w-5xl py-16',\n className,\n )}\n >\n {children}\n </div>\n );\n}\n\nexport { AppPage };\nexport type { AppPageProps, AppPageVariant };\n"],
5
- "mappings": "wCACA,OAAS,MAAAA,MAAU,aAqCnB,SAASC,EAAQ,CAAE,QAAAC,EAAU,OAAQ,UAAAC,EAAW,SAAAC,CAAQ,EAA0B,CAChF,OACEC,EAAA,MAAA,CACE,UAAWL,EACT,sBACAE,IAAY,QAAU,2BACtBA,IAAY,UAAY,2BACxBA,IAAY,QAAU,kBACtBC,CAAS,EACV,SAEAC,CAAQ,CAAA,CAGf",
6
- "names": ["cn", "AppPage", "variant", "className", "children", "_jsx"]
5
+ "mappings": "uHACA,OAAS,MAAAA,MAAU,aAqCnB,SAASC,EAAQ,CAAE,QAAAC,EAAU,OAAQ,UAAAC,EAAW,SAAAC,CAAQ,EAA0B,CAChF,OACEC,EAAA,MAAA,CACE,UAAWL,EACT,sBACAE,IAAY,QAAU,2BACtBA,IAAY,UAAY,2BACxBA,IAAY,QAAU,kBACtBC,CAAS,EACV,SAEAC,CAAQ,CAAA,CAGf,CAdSE,EAAAL,EAAA",
6
+ "names": ["cn", "AppPage", "variant", "className", "children", "_jsx", "__name"]
7
7
  }
package/dist/Badge.js CHANGED
@@ -1 +1 @@
1
- import{jsx as s}from"react/jsx-runtime";import{cn as a}from"./utils.js";const e="inline-flex shrink-0 items-center rounded-md px-2 py-0.5 text-xs font-medium",o={neutral:"bg-[var(--color-neutral-bg)] text-[var(--color-neutral-text)]",success:"bg-[var(--color-success-bg)] text-[var(--color-success-text)]",warning:"bg-[var(--color-warning-bg)] text-[var(--color-warning-text)]",error:"bg-[var(--color-error-bg)] text-[var(--color-error-text)]",info:"bg-[var(--color-info-bg)] text-[var(--color-info-text)]"};function c({className:r,variant:t="neutral",...n}){return s("span",{className:a(e,o[t],r),...n})}function l(r="neutral",t){return a(e,o[r],t)}export{c as Badge,e as badgeBaseClass,l as badgeClass,o as badgeVariantClass};
1
+ var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});import{jsx as l}from"react/jsx-runtime";import{cn as n}from"./utils.js";const o="inline-flex shrink-0 items-center rounded-md px-2 py-0.5 text-xs font-medium",a={neutral:"bg-[var(--color-neutral-bg)] text-[var(--color-neutral-text)]",success:"bg-[var(--color-success-bg)] text-[var(--color-success-text)]",warning:"bg-[var(--color-warning-bg)] text-[var(--color-warning-text)]",error:"bg-[var(--color-error-bg)] text-[var(--color-error-text)]",info:"bg-[var(--color-info-bg)] text-[var(--color-info-text)]"};function g({className:r,variant:t="neutral",...s}){return l("span",{className:n(o,a[t],r),...s})}e(g,"Badge");function x(r="neutral",t){return n(o,a[r],t)}e(x,"badgeClass");export{g as Badge,o as badgeBaseClass,x as badgeClass,a as badgeVariantClass};
package/dist/Badge.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Badge.tsx"],
4
4
  "sourcesContent": ["import type { HTMLAttributes, ReactElement } from 'react';\nimport { cn } from './utils.ts';\n\n/**\n * A status pill.\n *\n * ## Provenance\n *\n * `components/ui/Badge.tsx` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that agree on the base classes, the five variants, and the `neutral`\n * default. Edge-Sonic's is the best of them (its props spread onto the DOM\n * element, so a badge can carry `id`/`role`/`data-*`), so it is the shape here.\n *\n * The variants are *tones*, not statuses: every repo additionally carries a\n * stack of domain badges (`ConnectionBadge`, `VisibilityBadge`,\n * `TaskRunStatusBadge`, …) that map its own status vocabulary onto a tone and\n * translate a label with `t()`. Those are product vocabularies with\n * product-specific translation keys, so they stay with their apps — the kit\n * ships the tone layer and `badgeClass()` so a consumer's own\n * `variantFor(status)` maps onto it without re-deriving the classes.\n *\n * Requires the CSS variables `--color-{success,error,warning,info,neutral}-{bg,text}`,\n * which all six consuming apps already define.\n */\n\ntype BadgeVariant = 'success' | 'error' | 'warning' | 'info' | 'neutral';\n\n/**\nLayout and type scale, shared by every variant.\n*/\nconst badgeBaseClass = 'inline-flex shrink-0 items-center rounded-md px-2 py-0.5 text-xs font-medium';\n\n/**\nThe tone palette. `neutral` is the default: an unknown verdict is not a failure.\n*/\nconst badgeVariantClass: Record<BadgeVariant, string> = {\n neutral: 'bg-[var(--color-neutral-bg)] text-[var(--color-neutral-text)]',\n success: 'bg-[var(--color-success-bg)] text-[var(--color-success-text)]',\n warning: 'bg-[var(--color-warning-bg)] text-[var(--color-warning-text)]',\n error: 'bg-[var(--color-error-bg)] text-[var(--color-error-text)]',\n info: 'bg-[var(--color-info-bg)] text-[var(--color-info-text)]',\n};\n\ninterface BadgeProps extends HTMLAttributes<HTMLSpanElement> {\n /**\n Tone; defaults to `neutral`.\n */\n variant?: BadgeVariant;\n}\n\nfunction Badge({ className, variant = 'neutral', ...rest }: Readonly<BadgeProps>): ReactElement {\n return <span className={cn(badgeBaseClass, badgeVariantClass[variant], className)} {...rest} />;\n}\n\n/**\n * The class string for a badge, for callers building the element themselves —\n * a `<button>` that looks like a badge, or a domain badge wrapper that adds\n * `t()`-translated children.\n */\nfunction badgeClass(variant: BadgeVariant = 'neutral', className?: string): string {\n return cn(badgeBaseClass, badgeVariantClass[variant], className);\n}\n\nexport { Badge, badgeBaseClass, badgeClass, badgeVariantClass };\nexport type { BadgeProps, BadgeVariant };\n"],
5
- "mappings": "wCACA,OAAS,MAAAA,MAAU,aA8BnB,MAAMC,EAAiB,+EAKjBC,EAAkD,CACtD,QAAS,gEACT,QAAS,gEACT,QAAS,gEACT,MAAO,4DACP,KAAM,2DAUR,SAASC,EAAM,CAAE,UAAAC,EAAW,QAAAC,EAAU,UAAW,GAAGC,CAAI,EAAwB,CAC9E,OAAOC,EAAA,OAAA,CAAM,UAAWP,EAAGC,EAAgBC,EAAkBG,CAAO,EAAGD,CAAS,EAAC,GAAME,CAAI,CAAA,CAC7F,CAOA,SAASE,EAAWH,EAAwB,UAAWD,EAAkB,CACvE,OAAOJ,EAAGC,EAAgBC,EAAkBG,CAAO,EAAGD,CAAS,CACjE",
6
- "names": ["cn", "badgeBaseClass", "badgeVariantClass", "Badge", "className", "variant", "rest", "_jsx", "badgeClass"]
5
+ "mappings": "uHACA,OAAS,MAAAA,MAAU,aA8BnB,MAAMC,EAAiB,+EAKjBC,EAAkD,CACtD,QAAS,gEACT,QAAS,gEACT,QAAS,gEACT,MAAO,4DACP,KAAM,2DAUR,SAASC,EAAM,CAAE,UAAAC,EAAW,QAAAC,EAAU,UAAW,GAAGC,CAAI,EAAwB,CAC9E,OAAOC,EAAA,OAAA,CAAM,UAAWP,EAAGC,EAAgBC,EAAkBG,CAAO,EAAGD,CAAS,EAAC,GAAME,CAAI,CAAA,CAC7F,CAFSE,EAAAL,EAAA,SAST,SAASM,EAAWJ,EAAwB,UAAWD,EAAkB,CACvE,OAAOJ,EAAGC,EAAgBC,EAAkBG,CAAO,EAAGD,CAAS,CACjE,CAFSI,EAAAC,EAAA",
6
+ "names": ["cn", "badgeBaseClass", "badgeVariantClass", "Badge", "className", "variant", "rest", "_jsx", "__name", "badgeClass"]
7
7
  }
package/dist/Button.js CHANGED
@@ -1 +1 @@
1
- import{jsx as v,jsxs as m}from"react/jsx-runtime";import{cn as i}from"./utils.js";import{Spinner as f}from"./Spinner.js";const n="inline-flex items-center justify-center gap-2 rounded-lg text-sm font-medium transition-colors duration-150 disabled:opacity-50 disabled:pointer-events-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]",s={primary:"bg-[var(--color-accent)] text-[#0d1008] hover:bg-[var(--color-accent-dim)]",secondary:"bg-[var(--color-surface-3)] text-[var(--color-text-primary)] hover:bg-[var(--color-surface-4)]",ghost:"bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]",danger:"bg-[var(--color-error-bg)] text-[var(--color-error-text)] hover:brightness-125"},a={sm:"px-3 py-1.5 text-xs",md:"px-4 py-2",lg:"px-5 py-2.5 text-base"};function g({className:t,variant:e="secondary",size:o="md",loading:r=!1,disabled:c=!1,children:l,onClick:u,type:b="button",...x}){const d=p=>{c||r||u?.(p)};return m("button",{type:b,className:i(n,s[e],a[o],t),disabled:c||r,"aria-busy":r||void 0,onClick:d,...x,children:[r?v(f,{size:16,color:"currentColor",padding:"0"}):null,l]})}function y({variant:t="secondary",size:e="md"}={},o){return i(n,s[t],a[e],o)}export{g as Button,n as buttonBaseClass,y as buttonClass,a as buttonSizeClass,s as buttonVariantClass};
1
+ var m=Object.defineProperty;var o=(r,t)=>m(r,"name",{value:t,configurable:!0});import{jsx as f,jsxs as g}from"react/jsx-runtime";import{cn as l}from"./utils.js";import{Spinner as y}from"./Spinner.js";const s="inline-flex items-center justify-center gap-2 rounded-lg text-sm font-medium transition-colors duration-150 disabled:opacity-50 disabled:pointer-events-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]",a={primary:"bg-[var(--color-accent)] text-[#0d1008] hover:bg-[var(--color-accent-dim)]",secondary:"bg-[var(--color-surface-3)] text-[var(--color-text-primary)] hover:bg-[var(--color-surface-4)]",ghost:"bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]",danger:"bg-[var(--color-error-bg)] text-[var(--color-error-text)] hover:brightness-125"},c={sm:"px-3 py-1.5 text-xs",md:"px-4 py-2",lg:"px-5 py-2.5 text-base"};function h({className:r,variant:t="secondary",size:n="md",loading:e=!1,disabled:i=!1,children:u,onClick:b,type:x="button",...d}){const p=o(v=>{i||e||b?.(v)},"handleClick");return g("button",{type:x,className:l(s,a[t],c[n],r),disabled:i||e,"aria-busy":e||void 0,onClick:p,...d,children:[e?f(y,{size:16,color:"currentColor",padding:"0"}):null,u]})}o(h,"Button");function C({variant:r="secondary",size:t="md"}={},n){return l(s,a[r],c[t],n)}o(C,"buttonClass");export{h as Button,s as buttonBaseClass,C as buttonClass,c as buttonSizeClass,a as buttonVariantClass};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Button.tsx"],
4
4
  "sourcesContent": ["import type { ButtonHTMLAttributes, MouseEvent, ReactElement } from 'react';\nimport { cn } from './utils.ts';\nimport { Spinner } from './Spinner.tsx';\n\n/**\n * The one button.\n *\n * ## Provenance\n *\n * `components/ui/Button.tsx` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies written from one design, agreeing on the base classes, the four\n * variants (`primary`/`secondary`/`ghost`/`danger`) and the three sizes. The\n * differences that had to be settled:\n *\n * - **Default variant.** CalDAV-Bridge defaults to `primary`; the other five\n * default to `secondary`. The majority wins: a page of solid-coloured\n * buttons is noise, and `primary` should mark the one action that matters.\n * - **`type`.** Durable-DAV and Edge-Sonic default it to `button`; the others\n * leave the HTML default (`submit`) in place, so a `<Button>` inside a\n * `<form>` submits it. The explicit default is kept — it is the documented\n * fix, and a consumer that wants a submit button passes `type=\"submit\"`.\n * - **`ghost` hover.** Four repos hover to `--color-surface-3` with\n * `--color-text-secondary`; Edge-Sonic uses `surface-2`/`text-muted`. The\n * majority wins.\n * - **`danger` hover.** Four repos use `hover:brightness-125`; Edge-Sonic uses\n * `hover:opacity-90`. The majority wins.\n *\n * ## Loading\n *\n * Converged from **AWS-AccessBridge**'s `components/ui/LoadingButton.tsx`, the\n * one place the family tracked busy state itself. Its two behaviours fold\n * cleanly into this component's `loading` prop: the button is `disabled` while\n * loading (so neither a pointer, a keyboard, nor a screen reader can activate\n * it), *and* the click handler bails out, so a synthesized `click()` — which\n * jsdom and some test harnesses dispatch without honouring `disabled` — cannot\n * fire a second submission. The ring is this package's `Spinner`, which\n * inherits the button's text colour.\n */\n\ntype ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';\ntype ButtonSize = 'sm' | 'md' | 'lg';\n\n/**\n * Layout and focus affordance. The focus ring is on `focus-visible`, so a\n * pointer press does not paint it and a keyboard press always does.\n */\nconst buttonBaseClass =\n 'inline-flex items-center justify-center gap-2 rounded-lg text-sm font-medium transition-colors duration-150 disabled:opacity-50 disabled:pointer-events-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]';\n\nconst buttonVariantClass: Record<ButtonVariant, string> = {\n primary: 'bg-[var(--color-accent)] text-[#0d1008] hover:bg-[var(--color-accent-dim)]',\n secondary: 'bg-[var(--color-surface-3)] text-[var(--color-text-primary)] hover:bg-[var(--color-surface-4)]',\n ghost: 'bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]',\n danger: 'bg-[var(--color-error-bg)] text-[var(--color-error-text)] hover:brightness-125',\n};\n\nconst buttonSizeClass: Record<ButtonSize, string> = {\n sm: 'px-3 py-1.5 text-xs',\n md: 'px-4 py-2',\n lg: 'px-5 py-2.5 text-base',\n};\n\ninterface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n Visual weight; defaults to `secondary`.\n */\n variant?: ButtonVariant;\n /**\n Control size; defaults to `md`.\n */\n size?: ButtonSize;\n /**\n * Shows the spinner and blocks activation until it clears. A busy button is\n * a disabled button: the prop alone is enough, no `disabled` bookkeeping at\n * the call site.\n */\n loading?: boolean;\n}\n\nfunction Button({\n className,\n variant = 'secondary',\n size = 'md',\n loading = false,\n disabled = false,\n children,\n onClick,\n type = 'button',\n ...rest\n}: Readonly<ButtonProps>): ReactElement {\n const handleClick = (event: MouseEvent<HTMLButtonElement>): void => {\n // Belt and braces: `disabled` already stops a real pointer or key press,\n // and this stops a synthesized event from re-entering an in-flight action.\n if (disabled || loading) {\n return;\n }\n onClick?.(event);\n };\n\n return (\n <button\n type={type}\n className={cn(buttonBaseClass, buttonVariantClass[variant], buttonSizeClass[size], className)}\n disabled={disabled || loading}\n aria-busy={loading || undefined}\n onClick={handleClick}\n {...rest}\n >\n {loading ? <Spinner size={16} color=\"currentColor\" padding=\"0\" /> : null}\n {children}\n </button>\n );\n}\n\n/**\n * The class string for a button, for callers rendering the element themselves —\n * a link styled as a button, or a toolbar control that is not a `<button>`.\n */\nfunction buttonClass(\n { variant = 'secondary', size = 'md' }: { variant?: ButtonVariant; size?: ButtonSize } = {},\n className?: string,\n): string {\n return cn(buttonBaseClass, buttonVariantClass[variant], buttonSizeClass[size], className);\n}\n\nexport { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass };\nexport type { ButtonProps, ButtonSize, ButtonVariant };\n"],
5
- "mappings": "kDACA,OAAS,MAAAA,MAAU,aACnB,OAAS,WAAAC,MAAe,eA6CxB,MAAMC,EACJ,wPAEIC,EAAoD,CACxD,QAAS,6EACT,UAAW,iGACX,MAAO,6HACP,OAAQ,kFAGJC,EAA8C,CAClD,GAAI,sBACJ,GAAI,YACJ,GAAI,yBAoBN,SAASC,EAAO,CACd,UAAAC,EACA,QAAAC,EAAU,YACV,KAAAC,EAAO,KACP,QAAAC,EAAU,GACV,SAAAC,EAAW,GACX,SAAAC,EACA,QAAAC,EACA,KAAAC,EAAO,SACP,GAAGC,CAAI,EACe,CACtB,MAAMC,EAAeC,GAA8C,CAG7DN,GAAYD,GAGhBG,IAAUI,CAAK,CACjB,EAEA,OACEC,EAAA,SAAA,CACE,KAAMJ,EACN,UAAWb,EAAGE,EAAiBC,EAAmBI,CAAO,EAAGH,EAAgBI,CAAI,EAAGF,CAAS,EAC5F,SAAUI,GAAYD,EAAO,YAClBA,GAAW,OACtB,QAASM,EAAW,GAChBD,EAAI,SAAA,CAEPL,EAAUS,EAACjB,EAAO,CAAC,KAAM,GAAI,MAAM,eAAe,QAAQ,GAAG,CAAA,EAAM,KACnEU,CAAQ,CAAA,CAAA,CAGf,CAMA,SAASQ,EACP,CAAE,QAAAZ,EAAU,YAAa,KAAAC,EAAO,IAAI,EAAqD,CAAA,EACzFF,EAAkB,CAElB,OAAON,EAAGE,EAAiBC,EAAmBI,CAAO,EAAGH,EAAgBI,CAAI,EAAGF,CAAS,CAC1F",
6
- "names": ["cn", "Spinner", "buttonBaseClass", "buttonVariantClass", "buttonSizeClass", "Button", "className", "variant", "size", "loading", "disabled", "children", "onClick", "type", "rest", "handleClick", "event", "_jsxs", "_jsx", "buttonClass"]
5
+ "mappings": "iIACA,OAAS,MAAAA,MAAU,aACnB,OAAS,WAAAC,MAAe,eA6CxB,MAAMC,EACJ,wPAEIC,EAAoD,CACxD,QAAS,6EACT,UAAW,iGACX,MAAO,6HACP,OAAQ,kFAGJC,EAA8C,CAClD,GAAI,sBACJ,GAAI,YACJ,GAAI,yBAoBN,SAASC,EAAO,CACd,UAAAC,EACA,QAAAC,EAAU,YACV,KAAAC,EAAO,KACP,QAAAC,EAAU,GACV,SAAAC,EAAW,GACX,SAAAC,EACA,QAAAC,EACA,KAAAC,EAAO,SACP,GAAGC,CAAI,EACe,CACtB,MAAMC,EAAcC,EAACC,GAA8C,CAG7DP,GAAYD,GAGhBG,IAAUK,CAAK,CACjB,EAPoB,eASpB,OACEC,EAAA,SAAA,CACE,KAAML,EACN,UAAWb,EAAGE,EAAiBC,EAAmBI,CAAO,EAAGH,EAAgBI,CAAI,EAAGF,CAAS,EAC5F,SAAUI,GAAYD,EAAO,YAClBA,GAAW,OACtB,QAASM,EAAW,GAChBD,EAAI,SAAA,CAEPL,EAAUU,EAAClB,EAAO,CAAC,KAAM,GAAI,MAAM,eAAe,QAAQ,GAAG,CAAA,EAAM,KACnEU,CAAQ,CAAA,CAAA,CAGf,CAjCSK,EAAAX,EAAA,UAuCT,SAASe,EACP,CAAE,QAAAb,EAAU,YAAa,KAAAC,EAAO,IAAI,EAAqD,CAAA,EACzFF,EAAkB,CAElB,OAAON,EAAGE,EAAiBC,EAAmBI,CAAO,EAAGH,EAAgBI,CAAI,EAAGF,CAAS,CAC1F,CALSU,EAAAI,EAAA",
6
+ "names": ["cn", "Spinner", "buttonBaseClass", "buttonVariantClass", "buttonSizeClass", "Button", "className", "variant", "size", "loading", "disabled", "children", "onClick", "type", "rest", "handleClick", "__name", "event", "_jsxs", "_jsx", "buttonClass"]
7
7
  }
package/dist/Card.js CHANGED
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{cn as a}from"./utils.js";const o="rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] p-5";function n({className:r,...e}){return t("div",{className:a(o,r),...e})}const s="mb-4 flex items-center justify-between gap-3";function d({className:r,...e}){return t("div",{className:a(s,r),...e})}const c="text-lg font-semibold text-[var(--color-text-primary)]";function l({className:r,...e}){return t("h2",{className:a(c,r),...e})}export{n as Card,d as CardHeader,l as CardTitle,o as cardClass,s as cardHeaderClass,c as cardTitleClass};
1
+ var d=Object.defineProperty;var t=(r,e)=>d(r,"name",{value:e,configurable:!0});import{jsx as a}from"react/jsx-runtime";import{cn as o}from"./utils.js";const s="rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] p-5";function l({className:r,...e}){return a("div",{className:o(s,r),...e})}t(l,"Card");const c="mb-4 flex items-center justify-between gap-3";function i({className:r,...e}){return a("div",{className:o(c,r),...e})}t(i,"CardHeader");const n="text-lg font-semibold text-[var(--color-text-primary)]";function m({className:r,...e}){return a("h2",{className:o(n,r),...e})}t(m,"CardTitle");export{l as Card,i as CardHeader,m as CardTitle,s as cardClass,c as cardHeaderClass,n as cardTitleClass};
package/dist/Card.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Card.tsx"],
4
4
  "sourcesContent": ["import type { HTMLAttributes, ReactElement } from 'react';\nimport { cn } from './utils.ts';\n\n/**\n * Surface primitives: `Card`, `CardHeader`, `CardTitle`.\n *\n * ## Provenance\n *\n * `components/ui/Card.tsx` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that are identical apart from Edge-Sonic's two improvements, both of\n * which are adopted here:\n *\n * 1. **Props spread onto the DOM element.** The other five take only\n * `className` and `children`, so a card that needs an `id`, a `role` or a\n * `data-testid` has to be wrapped in a redundant element.\n * 2. **The base classes live in one exported string** rather than being\n * re-spelled by `CardHeader`/`CardTitle`, so a change to the surface lands\n * once.\n *\n * `CardTitle` renders an `<h2>` in every copy. No copy in the family\n * parameterised the heading level, and inventing a `headingLevel` prop here\n * would strand the other six call sites, so the level stays fixed and a caller\n * that needs a different level composes the class string it needs from\n * `cardTitleClass`.\n */\n\n/**\nThe card surface.\n*/\nconst cardClass = 'rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] p-5';\n\ntype CardProps = HTMLAttributes<HTMLDivElement>;\n\nfunction Card({ className, ...rest }: Readonly<CardProps>): ReactElement {\n return <div className={cn(cardClass, className)} {...rest} />;\n}\n\n/**\nThe header row: title on the left, actions on the right.\n*/\nconst cardHeaderClass = 'mb-4 flex items-center justify-between gap-3';\n\ntype CardHeaderProps = HTMLAttributes<HTMLDivElement>;\n\nfunction CardHeader({ className, ...rest }: Readonly<CardHeaderProps>): ReactElement {\n return <div className={cn(cardHeaderClass, className)} {...rest} />;\n}\n\n/**\nThe card's title. Renders an `<h2>`; nested headings override the level via `role`.\n*/\nconst cardTitleClass = 'text-lg font-semibold text-[var(--color-text-primary)]';\n\ntype CardTitleProps = HTMLAttributes<HTMLHeadingElement>;\n\nfunction CardTitle({ className, ...rest }: Readonly<CardTitleProps>): ReactElement {\n return <h2 className={cn(cardTitleClass, className)} {...rest} />;\n}\n\nexport { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle };\nexport type { CardHeaderProps, CardProps, CardTitleProps };\n"],
5
- "mappings": "wCACA,OAAS,MAAAA,MAAU,aA6BnB,MAAMC,EAAY,iFAIlB,SAASC,EAAK,CAAE,UAAAC,EAAW,GAAGC,CAAI,EAAuB,CACvD,OAAOC,EAAA,MAAA,CAAK,UAAWL,EAAGC,EAAWE,CAAS,EAAC,GAAMC,CAAI,CAAA,CAC3D,CAKA,MAAME,EAAkB,+CAIxB,SAASC,EAAW,CAAE,UAAAJ,EAAW,GAAGC,CAAI,EAA6B,CACnE,OAAOC,EAAA,MAAA,CAAK,UAAWL,EAAGM,EAAiBH,CAAS,EAAC,GAAMC,CAAI,CAAA,CACjE,CAKA,MAAMI,EAAiB,yDAIvB,SAASC,EAAU,CAAE,UAAAN,EAAW,GAAGC,CAAI,EAA4B,CACjE,OAAOC,EAAA,KAAA,CAAI,UAAWL,EAAGQ,EAAgBL,CAAS,EAAC,GAAMC,CAAI,CAAA,CAC/D",
6
- "names": ["cn", "cardClass", "Card", "className", "rest", "_jsx", "cardHeaderClass", "CardHeader", "cardTitleClass", "CardTitle"]
5
+ "mappings": "uHACA,OAAS,MAAAA,MAAU,aA6BnB,MAAMC,EAAY,iFAIlB,SAASC,EAAK,CAAE,UAAAC,EAAW,GAAGC,CAAI,EAAuB,CACvD,OAAOC,EAAA,MAAA,CAAK,UAAWL,EAAGC,EAAWE,CAAS,EAAC,GAAMC,CAAI,CAAA,CAC3D,CAFSE,EAAAJ,EAAA,QAOT,MAAMK,EAAkB,+CAIxB,SAASC,EAAW,CAAE,UAAAL,EAAW,GAAGC,CAAI,EAA6B,CACnE,OAAOC,EAAA,MAAA,CAAK,UAAWL,EAAGO,EAAiBJ,CAAS,EAAC,GAAMC,CAAI,CAAA,CACjE,CAFSE,EAAAE,EAAA,cAOT,MAAMC,EAAiB,yDAIvB,SAASC,EAAU,CAAE,UAAAP,EAAW,GAAGC,CAAI,EAA4B,CACjE,OAAOC,EAAA,KAAA,CAAI,UAAWL,EAAGS,EAAgBN,CAAS,EAAC,GAAMC,CAAI,CAAA,CAC/D,CAFSE,EAAAI,EAAA",
6
+ "names": ["cn", "cardClass", "Card", "className", "rest", "_jsx", "__name", "cardHeaderClass", "CardHeader", "cardTitleClass", "CardTitle"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as e,jsxs as l}from"react/jsx-runtime";import{cn as o}from"./utils.js";function c({home:a,crumb:s,actions:r,className:t}){return e("div",{className:o("sticky top-0 z-40 border-b border-[var(--color-border)] bg-[var(--color-surface-1)]/95 backdrop-blur",t),children:l("div",{className:"max-w-7xl mx-auto px-6 py-3 flex items-center gap-3 flex-wrap",children:[a,e("span",{"aria-hidden":"true",className:"text-[var(--color-text-muted)] font-normal",children:"/"}),e("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:s}),r&&e("div",{className:"ml-auto flex items-center gap-2 shrink-0",children:r})]})})}export{c as ContextBar};
1
+ var o=Object.defineProperty;var t=(r,a)=>o(r,"name",{value:a,configurable:!0});import{jsx as e,jsxs as c}from"react/jsx-runtime";import{cn as i}from"./utils.js";function m({home:r,crumb:a,actions:s,className:l}){return e("div",{className:i("sticky top-0 z-40 border-b border-[var(--color-border)] bg-[var(--color-surface-1)]/95 backdrop-blur",l),children:c("div",{className:"max-w-7xl mx-auto px-6 py-3 flex items-center gap-3 flex-wrap",children:[r,e("span",{"aria-hidden":"true",className:"text-[var(--color-text-muted)] font-normal",children:"/"}),e("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:a}),s&&e("div",{className:"ml-auto flex items-center gap-2 shrink-0",children:s})]})})}t(m,"ContextBar");export{m as ContextBar};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/ContextBar.tsx"],
4
4
  "sourcesContent": ["import type { ReactNode } from 'react';\nimport { cn } from './utils.ts';\n\n/**\n * The sticky bar every non-root page renders.\n *\n * ## Provenance\n *\n * `components/layout/ContextBar.tsx` in **Durable-DAV**, **Durable-DAV-Router**\n * and **Edge-Git** — three copies differing only in the logo and the\n * `aria-label` on the home link.\n *\n * ## Why `home` is a node and not a `<Link>`\n *\n * All three imports `react-router-dom`, solely to wrap a logo in a `Link` to\n * `/`. That is the whole of their router coupling — and it is why none of them\n * could be lifted into a package the kit's other seven stay clear of, and why\n * a repo on a different router could not use the bar at all.\n *\n * So the caller renders the anchor and passes it in. The bar keeps the part\n * that was genuinely duplicated (the sticky geometry, the breadcrumb slot, the\n * right-aligned actions) and gives up the part that was a routing assumption.\n * The caller also owns the link's accessible name, which is the one thing that\n * genuinely differs between the three copies and could not have been defaulted.\n */\n\ninterface ContextBarProps {\n /**\n * The home link, already rendered by the caller.\n *\n * Required, even though the bar is usable without one: a bar with no way back\n * to the root is the failure this component exists to prevent, so it should\n * not be omittable. Pass an empty node only if a route genuinely has no home.\n */\n home: ReactNode;\n /**\n The current location's name. Usually a `Link` or breadcrumb segment.\n */\n crumb: ReactNode;\n /**\n Right-aligned controls — refresh, settings, a sign-out button.\n */\n actions?: ReactNode;\n /**\n Merged last onto the bar's outer element.\n */\n className?: string;\n}\n\nfunction ContextBar({ home, crumb, actions, className }: Readonly<ContextBarProps>) {\n return (\n <div className={cn('sticky top-0 z-40 border-b border-[var(--color-border)] bg-[var(--color-surface-1)]/95 backdrop-blur', className)}>\n <div className=\"max-w-7xl mx-auto px-6 py-3 flex items-center gap-3 flex-wrap\">\n {home}\n {/* Decorative: the breadcrumb and the home link already separate these\n regions for a screen reader, and a stray \"/\" read aloud between them\n is noise. */}\n <span aria-hidden=\"true\" className=\"text-[var(--color-text-muted)] font-normal\">\n /\n </span>\n <div className=\"flex items-center gap-2 min-w-0 flex-1\">{crumb}</div>\n {actions && <div className=\"ml-auto flex items-center gap-2 shrink-0\">{actions}</div>}\n </div>\n </div>\n );\n}\n\nexport { ContextBar };\nexport type { ContextBarProps };\n"],
5
- "mappings": "kDACA,OAAS,MAAAA,MAAU,aAgDnB,SAASC,EAAW,CAAE,KAAAC,EAAM,MAAAC,EAAO,QAAAC,EAAS,UAAAC,CAAS,EAA6B,CAChF,OACEC,EAAA,MAAA,CAAK,UAAWN,EAAG,uGAAwGK,CAAS,EAAC,SACnIE,EAAA,MAAA,CAAK,UAAU,gEAA+D,SAAA,CAC3EL,EAIDI,EAAA,OAAA,CAAA,cAAkB,OAAO,UAAU,6CAA4C,SAAA,GAAA,CAAA,EAG/EA,EAAA,MAAA,CAAK,UAAU,yCAAwC,SAAEH,CAAK,CAAA,EAC7DC,GAAWE,EAAA,MAAA,CAAK,UAAU,2CAA0C,SAAEF,CAAO,CAAA,CAAO,CAAA,CAAA,CACjF,CAAA,CAGZ",
6
- "names": ["cn", "ContextBar", "home", "crumb", "actions", "className", "_jsx", "_jsxs"]
5
+ "mappings": "iIACA,OAAS,MAAAA,MAAU,aAgDnB,SAASC,EAAW,CAAE,KAAAC,EAAM,MAAAC,EAAO,QAAAC,EAAS,UAAAC,CAAS,EAA6B,CAChF,OACEC,EAAA,MAAA,CAAK,UAAWN,EAAG,uGAAwGK,CAAS,EAAC,SACnIE,EAAA,MAAA,CAAK,UAAU,gEAA+D,SAAA,CAC3EL,EAIDI,EAAA,OAAA,CAAA,cAAkB,OAAO,UAAU,6CAA4C,SAAA,GAAA,CAAA,EAG/EA,EAAA,MAAA,CAAK,UAAU,yCAAwC,SAAEH,CAAK,CAAA,EAC7DC,GAAWE,EAAA,MAAA,CAAK,UAAU,2CAA0C,SAAEF,CAAO,CAAA,CAAO,CAAA,CAAA,CACjF,CAAA,CAGZ,CAhBSI,EAAAP,EAAA",
6
+ "names": ["cn", "ContextBar", "home", "crumb", "actions", "className", "_jsx", "_jsxs", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as f}from"react/jsx-runtime";import{useState as d}from"react";import{Input as m}from"./Input.js";import{theme as e}from"./theme.js";function a({style:s,onFocus:t,onBlur:u,...n}){const[c,r]=d(!1),l={borderColor:c?e.focusBorder:e.border,...s};return f(m,{...n,style:l,onFocus:o=>{r(!0),t?.(o)},onBlur:o=>{r(!1),u?.(o)}})}export{a as FocusInput};
1
+ var d=Object.defineProperty;var o=(r,e)=>d(r,"name",{value:e,configurable:!0});import{jsx as m}from"react/jsx-runtime";import{useState as a}from"react";import{Input as p}from"./Input.js";import{theme as u}from"./theme.js";function h({style:r,onFocus:e,onBlur:n,...c}){const[l,t]=a(!1),f={borderColor:l?u.focusBorder:u.border,...r};return m(p,{...c,style:f,onFocus:o(s=>{t(!0),e?.(s)},"handleFocus"),onBlur:o(s=>{t(!1),n?.(s)},"handleBlur")})}o(h,"FocusInput");export{h as FocusInput};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/FocusInput.tsx"],
4
4
  "sourcesContent": ["import { useState, type CSSProperties, type FocusEvent, type InputHTMLAttributes, type ReactElement } from 'react';\nimport { Input } from './Input.tsx';\nimport { theme } from './theme.ts';\n\n/**\n * A text field that paints its border while it holds focus.\n *\n * ## Provenance\n *\n * `components/ui/FocusInput.tsx` in **AWS-AccessBridge** — the only copy in the\n * family, and the only AWS primitive still in active use after the Tailwind\n * repos' `Input` absorbed the focus treatment into its class list\n * (`focus:border-[var(--color-accent)]`). It is kept because the two mechanisms\n * are not equivalent for a consumer without Tailwind: the class version needs\n * the stylesheet, the inline version needs nothing.\n *\n * Two normalizations from the original:\n *\n * - It **renders `Input`**, so the field's base styling (padding, radius,\n * disabled opacity, placeholder colour) comes from the kit instead of a\n * second, drifting copy.\n * - It no longer re-spells `inputStyle`. The original built its own style\n * object and merged the caller's over it; this one passes `style` straight\n * through, which is the same contract with one less place to change.\n *\n * Auto-focus is the standard `autoFocus` attribute — React applies it on mount,\n * and a component-level `focus()` call in an effect would race the caller's own\n * focus management for no gain.\n */\n\ntype FocusInputProps = InputHTMLAttributes<HTMLInputElement>;\n\nfunction FocusInput({ style, onFocus, onBlur, ...rest }: Readonly<FocusInputProps>): ReactElement {\n const [focused, setFocused] = useState(false);\n const focusStyle: CSSProperties = { borderColor: focused ? theme.focusBorder : theme.border, ...style };\n\n const handleFocus = (event: FocusEvent<HTMLInputElement>): void => {\n setFocused(true);\n onFocus?.(event);\n };\n\n const handleBlur = (event: FocusEvent<HTMLInputElement>): void => {\n setFocused(false);\n onBlur?.(event);\n };\n\n return <Input {...rest} style={focusStyle} onFocus={handleFocus} onBlur={handleBlur} />;\n}\n\nexport { FocusInput };\nexport type { FocusInputProps };\n"],
5
- "mappings": "wCAAA,OAAS,YAAAA,MAAkG,QAC3G,OAAS,SAAAC,MAAa,aACtB,OAAS,SAAAC,MAAa,aA8BtB,SAASC,EAAW,CAAE,MAAAC,EAAO,QAAAC,EAAS,OAAAC,EAAQ,GAAGC,CAAI,EAA6B,CAChF,KAAM,CAACC,EAASC,CAAU,EAAIT,EAAS,EAAK,EACtCU,EAA4B,CAAE,YAAaF,EAAUN,EAAM,YAAcA,EAAM,OAAQ,GAAGE,CAAK,EAYrG,OAAOO,EAACV,EAAK,CAAA,GAAKM,EAAM,MAAOG,EAAY,QAVtBE,GAA6C,CAChEH,EAAW,EAAI,EACfJ,IAAUO,CAAK,CACjB,EAOiE,OAL7CA,GAA6C,CAC/DH,EAAW,EAAK,EAChBH,IAASM,CAAK,CAChB,CAEmF,CAAA,CACrF",
6
- "names": ["useState", "Input", "theme", "FocusInput", "style", "onFocus", "onBlur", "rest", "focused", "setFocused", "focusStyle", "_jsx", "event"]
5
+ "mappings": "uHAAA,OAAS,YAAAA,MAAkG,QAC3G,OAAS,SAAAC,MAAa,aACtB,OAAS,SAAAC,MAAa,aA8BtB,SAASC,EAAW,CAAE,MAAAC,EAAO,QAAAC,EAAS,OAAAC,EAAQ,GAAGC,CAAI,EAA6B,CAChF,KAAM,CAACC,EAASC,CAAU,EAAIT,EAAS,EAAK,EACtCU,EAA4B,CAAE,YAAaF,EAAUN,EAAM,YAAcA,EAAM,OAAQ,GAAGE,CAAK,EAYrG,OAAOO,EAACV,EAAK,CAAA,GAAKM,EAAM,MAAOG,EAAY,QAVvBE,EAACC,GAA6C,CAChEJ,EAAW,EAAI,EACfJ,IAAUQ,CAAK,CACjB,EAHoB,eAU6C,OAL9CD,EAACC,GAA6C,CAC/DJ,EAAW,EAAK,EAChBH,IAASO,CAAK,CAChB,EAHmB,aAKgE,CAAA,CACrF,CAfSD,EAAAT,EAAA",
6
+ "names": ["useState", "Input", "theme", "FocusInput", "style", "onFocus", "onBlur", "rest", "focused", "setFocused", "focusStyle", "_jsx", "__name", "event"]
7
7
  }
package/dist/Input.js CHANGED
@@ -1 +1 @@
1
- import{jsx as t}from"react/jsx-runtime";import{cn as c}from"./utils.js";const o="w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-base)] px-3 py-2 text-sm text-[var(--color-text-primary)] placeholder:text-[var(--color-text-muted)] transition-colors duration-150 focus:border-[var(--color-accent)] focus:outline-none disabled:opacity-60";function l({className:e,...r}){return t("input",{className:c(o,e),...r})}function n({className:e,children:r,...a}){return t("select",{className:c(o,e),...a,children:r})}function s({className:e,...r}){return t("textarea",{className:c(o,"min-h-20 resize-y",e),...r})}function i({children:e,htmlFor:r,...a}){return t("label",{htmlFor:r,className:"mb-1 block text-xs font-medium text-[var(--color-text-muted)]",...a,children:e})}export{l as Input,i as Label,n as Select,s as Textarea,o as fieldClass};
1
+ var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});import{jsx as o}from"react/jsx-runtime";import{cn as l}from"./utils.js";const a="w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-base)] px-3 py-2 text-sm text-[var(--color-text-primary)] placeholder:text-[var(--color-text-muted)] transition-colors duration-150 focus:border-[var(--color-accent)] focus:outline-none disabled:opacity-60";function s({className:e,...r}){return o("input",{className:l(a,e),...r})}t(s,"Input");function i({className:e,children:r,...c}){return o("select",{className:l(a,e),...c,children:r})}t(i,"Select");function u({className:e,...r}){return o("textarea",{className:l(a,"min-h-20 resize-y",e),...r})}t(u,"Textarea");function m({children:e,htmlFor:r,...c}){return o("label",{htmlFor:r,className:"mb-1 block text-xs font-medium text-[var(--color-text-muted)]",...c,children:e})}t(m,"Label");export{s as Input,m as Label,i as Select,u as Textarea,a as fieldClass};
package/dist/Input.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Input.tsx"],
4
4
  "sourcesContent": ["import type {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n ReactElement,\n ReactNode,\n SelectHTMLAttributes,\n TextareaHTMLAttributes,\n} from 'react';\nimport { cn } from './utils.ts';\n\n/**\n * Form controls: `Input`, `Select`, `Textarea`, `Label`.\n *\n * ## Provenance\n *\n * `components/ui/Input.tsx` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that all export the same four controls and agree on the field classes\n * up to two drifting details, both settled the Edge-Sonic way:\n *\n * 1. **One shared class string** (`fieldClass`) instead of four re-spelled\n * copies. CalDAV-Bridge, Durable-DAV-Router, Edge-Git and Mail-Otter omit\n * `w-full` from their `Select`; CalDAV-Bridge's `Select`/`Label` and every\n * `Textarea` re-spell the field classes minus one property. A placeholder\n * colour that matches an input but not its select is a difference nobody\n * notices until a client is looking at both.\n * 2. **`htmlFor` is stated, not spread.** Edge-Sonic's `Label` takes `htmlFor`\n * and `children` explicitly, because a label with no `for` is announced as\n * unassociated text: the click target and the accessible name both depend\n * on it, and neither is visible in the markup that omits it.\n *\n * ## Error state\n *\n * None of the six copies carries an error state — each renders its field-level\n * error beside the input with its own markup (a `<p>` in `--color-error-text`,\n * or the app's notice bar), and none of them wires `aria-invalid`. Rather than\n * invent a sixth shape, the kit leaves the element to do what it already does:\n * `aria-invalid` and `aria-describedby` are standard input attributes and both\n * spread through here, and a consumer whose design reddens the border on error\n * passes the class itself (`className={error ? 'border-[var(--color-error-text)]' : undefined}`).\n */\n\n/**\nThe shared look of every text-entry control.\n*/\nconst fieldClass =\n 'w-full rounded-lg border border-[var(--color-border)] bg-[var(--color-surface-base)] px-3 py-2 text-sm text-[var(--color-text-primary)] placeholder:text-[var(--color-text-muted)] transition-colors duration-150 focus:border-[var(--color-accent)] focus:outline-none disabled:opacity-60';\n\ntype InputProps = InputHTMLAttributes<HTMLInputElement>;\n\nfunction Input({ className, ...rest }: Readonly<InputProps>): ReactElement {\n return <input className={cn(fieldClass, className)} {...rest} />;\n}\n\ntype SelectProps = SelectHTMLAttributes<HTMLSelectElement>;\n\nfunction Select({ className, children, ...rest }: Readonly<SelectProps>): ReactElement {\n return (\n <select className={cn(fieldClass, className)} {...rest}>\n {children}\n </select>\n );\n}\n\ntype TextareaProps = TextareaHTMLAttributes<HTMLTextAreaElement>;\n\nfunction Textarea({ className, ...rest }: Readonly<TextareaProps>): ReactElement {\n return <textarea className={cn(fieldClass, 'min-h-20 resize-y', className)} {...rest} />;\n}\n\ninterface LabelProps extends Omit<LabelHTMLAttributes<HTMLLabelElement>, 'htmlFor'> {\n /**\n The `id` of the control this label names.\n */\n htmlFor?: string;\n children: ReactNode;\n}\n\nfunction Label({ children, htmlFor, ...rest }: Readonly<LabelProps>): ReactElement {\n return (\n <label htmlFor={htmlFor} className=\"mb-1 block text-xs font-medium text-[var(--color-text-muted)]\" {...rest}>\n {children}\n </label>\n );\n}\n\nexport { Input, Label, Select, Textarea, fieldClass };\nexport type { InputProps, LabelProps, SelectProps, TextareaProps };\n"],
5
- "mappings": "wCAQA,OAAS,MAAAA,MAAU,aAqCnB,MAAMC,EACJ,8RAIF,SAASC,EAAM,CAAE,UAAAC,EAAW,GAAGC,CAAI,EAAwB,CACzD,OAAOC,EAAA,QAAA,CAAO,UAAWL,EAAGC,EAAYE,CAAS,EAAC,GAAMC,CAAI,CAAA,CAC9D,CAIA,SAASE,EAAO,CAAE,UAAAH,EAAW,SAAAI,EAAU,GAAGH,CAAI,EAAyB,CACrE,OACEC,EAAA,SAAA,CAAQ,UAAWL,EAAGC,EAAYE,CAAS,EAAC,GAAMC,EAAI,SACnDG,CAAQ,CAAA,CAGf,CAIA,SAASC,EAAS,CAAE,UAAAL,EAAW,GAAGC,CAAI,EAA2B,CAC/D,OAAOC,EAAA,WAAA,CAAU,UAAWL,EAAGC,EAAY,oBAAqBE,CAAS,EAAC,GAAMC,CAAI,CAAA,CACtF,CAUA,SAASK,EAAM,CAAE,SAAAF,EAAU,QAAAG,EAAS,GAAGN,CAAI,EAAwB,CACjE,OACEC,EAAA,QAAA,CAAO,QAASK,EAAS,UAAU,gEAA+D,GAAKN,EAAI,SACxGG,CAAQ,CAAA,CAGf",
6
- "names": ["cn", "fieldClass", "Input", "className", "rest", "_jsx", "Select", "children", "Textarea", "Label", "htmlFor"]
5
+ "mappings": "uHAQA,OAAS,MAAAA,MAAU,aAqCnB,MAAMC,EACJ,8RAIF,SAASC,EAAM,CAAE,UAAAC,EAAW,GAAGC,CAAI,EAAwB,CACzD,OAAOC,EAAA,QAAA,CAAO,UAAWL,EAAGC,EAAYE,CAAS,EAAC,GAAMC,CAAI,CAAA,CAC9D,CAFSE,EAAAJ,EAAA,SAMT,SAASK,EAAO,CAAE,UAAAJ,EAAW,SAAAK,EAAU,GAAGJ,CAAI,EAAyB,CACrE,OACEC,EAAA,SAAA,CAAQ,UAAWL,EAAGC,EAAYE,CAAS,EAAC,GAAMC,EAAI,SACnDI,CAAQ,CAAA,CAGf,CANSF,EAAAC,EAAA,UAUT,SAASE,EAAS,CAAE,UAAAN,EAAW,GAAGC,CAAI,EAA2B,CAC/D,OAAOC,EAAA,WAAA,CAAU,UAAWL,EAAGC,EAAY,oBAAqBE,CAAS,EAAC,GAAMC,CAAI,CAAA,CACtF,CAFSE,EAAAG,EAAA,YAYT,SAASC,EAAM,CAAE,SAAAF,EAAU,QAAAG,EAAS,GAAGP,CAAI,EAAwB,CACjE,OACEC,EAAA,QAAA,CAAO,QAASM,EAAS,UAAU,gEAA+D,GAAKP,EAAI,SACxGI,CAAQ,CAAA,CAGf,CANSF,EAAAI,EAAA",
6
+ "names": ["cn", "fieldClass", "Input", "className", "rest", "_jsx", "__name", "Select", "children", "Textarea", "Label", "htmlFor"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as r}from"react/jsx-runtime";import{LocaleUtil as n,SUPPORTED_LOCALES as m}from"@rexezuge/shared";import{Select as i}from"./Input.js";function p({value:a,onChange:o,label:l,unknownLabel:t,supported:u=m,disabled:c}){if(a===null)return r(i,{"aria-label":l,value:"",disabled:!0,onChange:()=>{},children:r("option",{value:"",children:t})});const d=n.normalize(a);return r(i,{"aria-label":l,value:d,disabled:c,onChange:e=>o(e.target.value),children:u.map(e=>r("option",{value:e,children:n.displayName(e)},e))})}export{p as LanguageSelector};
1
+ var p=Object.defineProperty;var a=(r,n)=>p(r,"name",{value:n,configurable:!0});import{jsx as l}from"react/jsx-runtime";import{LocaleUtil as o,SUPPORTED_LOCALES as s}from"@rexezuge/shared";import{Select as t}from"./Input.js";function h({value:r,onChange:n,label:i,unknownLabel:u,supported:c=s,disabled:d}){if(r===null)return l(t,{"aria-label":i,value:"",disabled:!0,onChange:a(()=>{},"onChange"),children:l("option",{value:"",children:u})});const m=o.normalize(r);return l(t,{"aria-label":i,value:m,disabled:d,onChange:a(e=>n(e.target.value),"onChange"),children:c.map(e=>l("option",{value:e,children:o.displayName(e)},e))})}a(h,"LanguageSelector");export{h as LanguageSelector};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/LanguageSelector.tsx"],
4
4
  "sourcesContent": ["import { LocaleUtil, SUPPORTED_LOCALES } from '@rexezuge/shared';\nimport { Select } from './Input.tsx';\n\n/**\n * The language picker.\n *\n * ## Provenance\n *\n * `components/shared/LanguageSelector.tsx` in **AWS-AccessBridge**,\n * **CalDAV-Bridge**, **ChordDHT-Tracker**, **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git**, **Mail-Meow** and **Mail-Otter** — six real copies plus two\n * smaller ones, in two shapes.\n *\n * ## What converges away\n *\n * **The 12-locale table.** Every copy declared its own `LANGUAGE_LABELS` /\n * `NATIVE_NAMES` map — the same twelve entries, `en` through `ko`, re-typed in\n * each repo. `@rexezuge/shared`'s `LocaleUtil` already holds that table and its\n * `displayName`, converged from AWS-AccessBridge, Mail-Meow and Mail-Otter. So\n * this component now has no table of its own, and the two would have had to\n * agree by hand otherwise.\n *\n * **The `'unknown'` sentinel.** Mail-Otter spelled \"the browser asked for a\n * language this app does not have\" as the string `'unknown'`, which then had to\n * be compared against at every call site and could not be distinguished from a\n * locale literally spelled `unknown`. It is `null` here — absent, per the kit's\n * `AGENTS.md` — and the disabled branch renders from that.\n *\n * **The `i18n.resolvedLanguage ?? i18n.language` fallback.** The copies read\n * i18next's own state to decide what is selected. In the kit that resolution\n * belongs to `useSpaLanguage`, which already does it; this component takes the\n * resolved tag and normalizes defensively, so a caller passing a raw browser\n * tag (`en-US`) still lands on a real option.\n */\n\ninterface LanguageSelectorProps {\n /**\n * The current tag, or `null` when the app could not resolve one.\n *\n * `null` renders a disabled control reading {@link LanguageSelectorProps.unknownLabel}.\n */\n value: string | null;\n onChange: (languageTag: string) => void;\n /**\n The control's accessible name. Required — a bare `<select>` has none.\n */\n label: string;\n /**\n Shown instead of the language list when `value` is `null`.\n */\n unknownLabel: string;\n /**\n * The offered tags.\n *\n * Defaults to the family's twelve. A caller narrows this; it cannot widen it,\n * because an option with no display name in the shared table renders as its\n * raw tag.\n */\n supported?: readonly string[];\n disabled?: boolean;\n}\n\nfunction LanguageSelector({\n value,\n onChange,\n label,\n unknownLabel,\n supported = SUPPORTED_LOCALES,\n disabled,\n}: Readonly<LanguageSelectorProps>) {\n if (value === null) {\n return (\n <Select aria-label={label} value=\"\" disabled onChange={() => {}}>\n <option value=\"\">{unknownLabel}</option>\n </Select>\n );\n }\n\n const current = LocaleUtil.normalize(value);\n\n return (\n <Select aria-label={label} value={current} disabled={disabled} onChange={(event) => onChange(event.target.value)}>\n {supported.map((tag) => (\n <option key={tag} value={tag}>\n {/* `displayName` normalizes first, so a supported-but-unspelled tag\n still resolves against the shared table rather than rendering raw. */}\n {LocaleUtil.displayName(tag)}\n </option>\n ))}\n </Select>\n );\n}\n\nexport { LanguageSelector };\nexport type { LanguageSelectorProps };\n"],
5
- "mappings": "wCAAA,OAAS,cAAAA,EAAY,qBAAAC,MAAyB,mBAC9C,OAAS,UAAAC,MAAc,aA6DvB,SAASC,EAAiB,CACxB,MAAAC,EACA,SAAAC,EACA,MAAAC,EACA,aAAAC,EACA,UAAAC,EAAYP,EACZ,SAAAQ,CAAQ,EACwB,CAChC,GAAIL,IAAU,KACZ,OACEM,EAACR,EAAM,CAAA,aAAaI,EAAO,MAAM,GAAG,SAAQ,GAAC,SAAU,IAAK,CAAE,EAAC,SAC7DI,EAAA,SAAA,CAAQ,MAAM,GAAE,SAAEH,CAAY,CAAA,CAAU,CAAA,EAK9C,MAAMI,EAAUX,EAAW,UAAUI,CAAK,EAE1C,OACEM,EAACR,EAAM,CAAA,aAAaI,EAAO,MAAOK,EAAS,SAAUF,EAAU,SAAWG,GAAUP,EAASO,EAAM,OAAO,KAAK,EAAC,SAC7GJ,EAAU,IAAKK,GACdH,EAAA,SAAA,CAAkB,MAAOG,EAAG,SAGzBb,EAAW,YAAYa,CAAG,CAAC,EAHjBA,CAAG,CAKjB,CAAC,CAAA,CAGR",
6
- "names": ["LocaleUtil", "SUPPORTED_LOCALES", "Select", "LanguageSelector", "value", "onChange", "label", "unknownLabel", "supported", "disabled", "_jsx", "current", "event", "tag"]
5
+ "mappings": "uHAAA,OAAS,cAAAA,EAAY,qBAAAC,MAAyB,mBAC9C,OAAS,UAAAC,MAAc,aA6DvB,SAASC,EAAiB,CACxB,MAAAC,EACA,SAAAC,EACA,MAAAC,EACA,aAAAC,EACA,UAAAC,EAAYP,EACZ,SAAAQ,CAAQ,EACwB,CAChC,GAAIL,IAAU,KACZ,OACEM,EAACR,EAAM,CAAA,aAAaI,EAAO,MAAM,GAAG,SAAQ,GAAC,SAAUK,EAAA,IAAK,CAAE,EAAP,YAAQ,SAC7DD,EAAA,SAAA,CAAQ,MAAM,GAAE,SAAEH,CAAY,CAAA,CAAU,CAAA,EAK9C,MAAMK,EAAUZ,EAAW,UAAUI,CAAK,EAE1C,OACEM,EAACR,EAAM,CAAA,aAAaI,EAAO,MAAOM,EAAS,SAAUH,EAAU,SAAUE,EAACE,GAAUR,EAASQ,EAAM,OAAO,KAAK,EAAtC,YAAuC,SAC7GL,EAAU,IAAKM,GACdJ,EAAA,SAAA,CAAkB,MAAOI,EAAG,SAGzBd,EAAW,YAAYc,CAAG,CAAC,EAHjBA,CAAG,CAKjB,CAAC,CAAA,CAGR,CA7BSH,EAAAR,EAAA",
6
+ "names": ["LocaleUtil", "SUPPORTED_LOCALES", "Select", "LanguageSelector", "value", "onChange", "label", "unknownLabel", "supported", "disabled", "_jsx", "__name", "current", "event", "tag"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as m}from"react/jsx-runtime";import{useCallback as d,useState as p}from"react";import{Button as g}from"./Button.js";function h({onClick:n,disabled:t=!1,variant:a="primary",size:i="md",children:c,type:l="button",className:u}){const[e,o]=p(!1),f=d(()=>{if(t||e)return;const r=n();if(!(r instanceof Promise))return;o(!0);const s=()=>{o(!1)};r.then(s).catch(s)},[t,e,n]);return m(g,{variant:a,size:i,type:l,className:u,loading:e,disabled:t,onClick:f,children:c})}export{h as LoadingButton};
1
+ var d=Object.defineProperty;var o=(e,t)=>d(e,"name",{value:t,configurable:!0});import{jsx as p}from"react/jsx-runtime";import{useCallback as g,useState as h}from"react";import{Button as x}from"./Button.js";function j({onClick:e,disabled:t=!1,variant:i="primary",size:c="md",children:l,type:u="button",className:f}){const[n,r]=h(!1),m=g(()=>{if(t||n)return;const s=e();if(!(s instanceof Promise))return;r(!0);const a=o(()=>{r(!1)},"settle");s.then(a).catch(a)},[t,n,e]);return p(x,{variant:i,size:c,type:u,className:f,loading:n,disabled:t,onClick:m,children:l})}o(j,"LoadingButton");export{j as LoadingButton};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/LoadingButton.tsx"],
4
4
  "sourcesContent": ["import { useCallback, useState, type ReactElement, type ReactNode } from 'react';\nimport { Button, type ButtonSize, type ButtonVariant } from './Button.tsx';\n\n/**\n * A button that owns its own busy state.\n *\n * ## Provenance\n *\n * `components/ui/LoadingButton.tsx` in **AWS-AccessBridge**. `Button` absorbed\n * everything it does — the `loading` prop, the disabled-while-busy semantics,\n * the spinner — so a consumer that drives state itself should reach for\n * `Button`. This wrapper stays for the call sites that hand it an async\n * `onClick` and let it track the in-flight promise, which is the shape every\n * `LoadingButton` in that repo uses.\n *\n * Two normalizations from the original:\n *\n * - **Variant names.** `'blue' | 'green' | 'red'` became the kit's\n * `'primary' | 'secondary' | 'danger' | 'ghost'`; the original's default\n * (`'blue'`, the solid action colour) maps to `primary`, and that default is\n * kept even though `Button` itself defaults to `secondary` — a caller that\n * reaches for this component wants the action to be the loudest thing it can\n * be, and the original's call sites all relied on it.\n * - **The handler is fire-and-forget with `void`.** `onClick` may return a\n * promise; the button holds `loading` until it settles, and the promise is\n * deliberately not awaited inside the handler so an `await`-less call site\n * reads the same as an async one.\n */\n\ninterface LoadingButtonProps {\n /**\n Runs on activation; the button is busy until a returned promise settles.\n */\n onClick: () => Promise<void> | void;\n /**\n Blocks activation regardless of the busy state.\n */\n disabled?: boolean;\n /**\n Visual weight; defaults to `primary`.\n */\n variant?: ButtonVariant;\n /**\n Control size; defaults to `md`.\n */\n size?: ButtonSize;\n children: ReactNode;\n /**\n Defaults to `button`, matching `Button`.\n */\n type?: 'button' | 'submit' | 'reset';\n /**\n Extra classes, merged over the button's.\n */\n className?: string;\n}\n\nfunction LoadingButton({\n onClick,\n disabled = false,\n variant = 'primary',\n size = 'md',\n children,\n type = 'button',\n className,\n}: Readonly<LoadingButtonProps>): ReactElement {\n const [loading, setLoading] = useState(false);\n\n const handleClick = useCallback(() => {\n if (disabled || loading) {\n return;\n }\n const result = onClick();\n if (!(result instanceof Promise)) {\n return;\n }\n setLoading(true);\n // The state flip is scheduled before the await, not after it: a caller\n // reading the tree right after the click must already see the spinner.\n //\n // A rejection clears the busy state and is deliberately *not*\n // re-thrown: the handler is fire-and-forget, so re-throwing would only\n // produce an unhandled rejection (and a failed test run under vitest).\n // The call site owns its error reporting — every AWS-AccessBridge call\n // site does exactly that inside its own `onClick`.\n const settle = (): void => {\n setLoading(false);\n };\n void result.then(settle).catch(settle);\n }, [disabled, loading, onClick]);\n\n return (\n <Button variant={variant} size={size} type={type} className={className} loading={loading} disabled={disabled} onClick={handleClick}>\n {children}\n </Button>\n );\n}\n\nexport { LoadingButton };\nexport type { LoadingButtonProps };\n"],
5
- "mappings": "wCAAA,OAAS,eAAAA,EAAa,YAAAC,MAAmD,QACzE,OAAS,UAAAC,MAAmD,cAwD5D,SAASC,EAAc,CACrB,QAAAC,EACA,SAAAC,EAAW,GACX,QAAAC,EAAU,UACV,KAAAC,EAAO,KACP,SAAAC,EACA,KAAAC,EAAO,SACP,UAAAC,CAAS,EACoB,CAC7B,KAAM,CAACC,EAASC,CAAU,EAAIX,EAAS,EAAK,EAEtCY,EAAcb,EAAY,IAAK,CACnC,GAAIK,GAAYM,EACd,OAEF,MAAMG,EAASV,EAAO,EACtB,GAAI,EAAEU,aAAkB,SACtB,OAEFF,EAAW,EAAI,EASf,MAAMG,EAAS,IAAW,CACxBH,EAAW,EAAK,CAClB,EACKE,EAAO,KAAKC,CAAM,EAAE,MAAMA,CAAM,CACvC,EAAG,CAACV,EAAUM,EAASP,CAAO,CAAC,EAE/B,OACEY,EAACd,EAAM,CAAC,QAASI,EAAS,KAAMC,EAAM,KAAME,EAAM,UAAWC,EAAW,QAASC,EAAS,SAAUN,EAAU,QAASQ,EAAW,SAC/HL,CAAQ,CAAA,CAGf",
6
- "names": ["useCallback", "useState", "Button", "LoadingButton", "onClick", "disabled", "variant", "size", "children", "type", "className", "loading", "setLoading", "handleClick", "result", "settle", "_jsx"]
5
+ "mappings": "uHAAA,OAAS,eAAAA,EAAa,YAAAC,MAAmD,QACzE,OAAS,UAAAC,MAAmD,cAwD5D,SAASC,EAAc,CACrB,QAAAC,EACA,SAAAC,EAAW,GACX,QAAAC,EAAU,UACV,KAAAC,EAAO,KACP,SAAAC,EACA,KAAAC,EAAO,SACP,UAAAC,CAAS,EACoB,CAC7B,KAAM,CAACC,EAASC,CAAU,EAAIX,EAAS,EAAK,EAEtCY,EAAcb,EAAY,IAAK,CACnC,GAAIK,GAAYM,EACd,OAEF,MAAMG,EAASV,EAAO,EACtB,GAAI,EAAEU,aAAkB,SACtB,OAEFF,EAAW,EAAI,EASf,MAAMG,EAASC,EAAA,IAAW,CACxBJ,EAAW,EAAK,CAClB,EAFe,UAGVE,EAAO,KAAKC,CAAM,EAAE,MAAMA,CAAM,CACvC,EAAG,CAACV,EAAUM,EAASP,CAAO,CAAC,EAE/B,OACEa,EAACf,EAAM,CAAC,QAASI,EAAS,KAAMC,EAAM,KAAME,EAAM,UAAWC,EAAW,QAASC,EAAS,SAAUN,EAAU,QAASQ,EAAW,SAC/HL,CAAQ,CAAA,CAGf,CAvCSQ,EAAAb,EAAA",
6
+ "names": ["useCallback", "useState", "Button", "LoadingButton", "onClick", "disabled", "variant", "size", "children", "type", "className", "loading", "setLoading", "handleClick", "result", "settle", "__name", "_jsx"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as i,jsxs as o}from"react/jsx-runtime";import{useEffect as c}from"react";function m({onClose:e,children:n,widthClass:d="w-80",ariaLabel:l,closeLabel:t="Close",closeOnEscape:a=!0}){return c(()=>{if(!a)return;const r=s=>{s.key==="Escape"&&e()};return addEventListener("keydown",r),()=>removeEventListener("keydown",r)},[a,e]),o("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:e,role:"presentation",children:[i("div",{className:"fixed inset-0 bg-black/60 animate-backdrop-in","aria-hidden":"true"}),o("div",{className:`relative bg-[var(--color-surface-1)] border border-[var(--color-border-muted)] rounded-2xl shadow-2xl animate-fade-in ${d}`,onClick:r=>{r.stopPropagation()},role:"dialog","aria-modal":"true","aria-label":l,children:[i("button",{type:"button",onClick:e,"aria-label":t,className:"absolute top-3 right-3 text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors",children:t}),n]})]})}export{m as ModalShell};
1
+ var m=Object.defineProperty;var t=(e,a)=>m(e,"name",{value:a,configurable:!0});import{jsx as n,jsxs as d}from"react/jsx-runtime";import{useEffect as u}from"react";function x({onClose:e,children:a,widthClass:l="w-80",ariaLabel:s,closeLabel:i="Close",closeOnEscape:o=!0}){return u(()=>{if(!o)return;const r=t(c=>{c.key==="Escape"&&e()},"onKeyDown");return addEventListener("keydown",r),()=>removeEventListener("keydown",r)},[o,e]),d("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:e,role:"presentation",children:[n("div",{className:"fixed inset-0 bg-black/60 animate-backdrop-in","aria-hidden":"true"}),d("div",{className:`relative bg-[var(--color-surface-1)] border border-[var(--color-border-muted)] rounded-2xl shadow-2xl animate-fade-in ${l}`,onClick:t(r=>{r.stopPropagation()},"onClick"),role:"dialog","aria-modal":"true","aria-label":s,children:[n("button",{type:"button",onClick:e,"aria-label":i,className:"absolute top-3 right-3 text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors",children:i}),a]})]})}t(x,"ModalShell");export{x as ModalShell};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/ModalShell.tsx"],
4
4
  "sourcesContent": ["import { useEffect, type ReactNode } from 'react';\n\n/**\n * The modal frame every confirm dialog in the family sits inside.\n *\n * Converged from `components/modals/ModalShell.tsx` in Durable-DAV,\n * Durable-DAV-Router, Mail-Otter and Edge-Git, where the copies were\n * byte-identical apart from an import-order difference.\n *\n * ## Two decisions the copies made by accident, now made deliberately\n *\n * **It renders in a portal.** A dialog nested in a scrolling container is\n * clipped by it, and one nested inside a `position: fixed` ancestor is\n * positioned by that ancestor rather than the viewport. The portal is what makes\n * \"centre of the screen\" mean the same thing everywhere.\n *\n * **It closes on the backdrop but not on the panel.** The backdrop click closes;\n * a click inside the panel stops propagating so that selecting text in a\n * confirmation message does not dismiss the dialog the operator is reading. The\n * stop is on the panel, not the backdrop, so a click on the panel never closes\n * it and a click outside always does.\n *\n * ## Labels are props, not translations\n *\n * The copies called `useTranslation` for the close button and the default width.\n * A shared primitive that reaches into a translation library forces every\n * consumer to have one installed *and* configured, for a string it already has\n * — the caller rendering the dialog is the one that knows what it says. So\n * `closeLabel` and `ariaLabel` are ordinary props with no default, and a repo\n * passes `t('common.close')` when it wants them translated.\n */\n\n/**\nEscape closes, and the initial focus lands on the dialog.\n*/\ninterface ModalShellProps {\n onClose: () => void;\n children: ReactNode;\n /**\n Width utility class. Kept as a class so a repo themes it without forking.\n */\n widthClass?: string;\n /**\n Announced to assistive tech; there is no visible title in the frame itself.\n */\n ariaLabel: string;\n /**\n * Accessible name for the corner close button.\n *\n * Kept distinct from any cancel action in the body: a dialog whose close\n * button and cancel button share a name is announced as two identical\n * buttons, and the operator has to guess which one they are on.\n */\n closeLabel?: string;\n /**\n Close on Escape. Defaults to true.\n */\n closeOnEscape?: boolean;\n}\n\nfunction ModalShell({ onClose, children, widthClass = 'w-80', ariaLabel, closeLabel = 'Close', closeOnEscape = true }: ModalShellProps) {\n useEffect(() => {\n if (!closeOnEscape) return;\n const onKeyDown = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') onClose();\n };\n addEventListener('keydown', onKeyDown);\n // Removed on unmount: a dialog that closed by leaving a listener behind\n // would close its replacement too, on the next Escape anywhere.\n return (): void => removeEventListener('keydown', onKeyDown);\n }, [closeOnEscape, onClose]);\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\" onClick={onClose} role=\"presentation\">\n <div className=\"fixed inset-0 bg-black/60 animate-backdrop-in\" aria-hidden=\"true\" />\n <div\n className={`relative bg-[var(--color-surface-1)] border border-[var(--color-border-muted)] rounded-2xl shadow-2xl animate-fade-in ${widthClass}`}\n onClick={(event) => {\n // The one place a click inside the panel must not reach the backdrop.\n event.stopPropagation();\n }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n >\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={closeLabel}\n className=\"absolute top-3 right-3 text-[var(--color-text-muted)] hover:text-[var(--color-text-primary)] transition-colors\"\n >\n {closeLabel}\n </button>\n {children}\n </div>\n </div>\n );\n}\n\nexport { ModalShell };\nexport type { ModalShellProps };\n"],
5
- "mappings": "kDAAA,OAAS,aAAAA,MAAiC,QA4D1C,SAASC,EAAW,CAAE,QAAAC,EAAS,SAAAC,EAAU,WAAAC,EAAa,OAAQ,UAAAC,EAAW,WAAAC,EAAa,QAAS,cAAAC,EAAgB,EAAI,EAAmB,CACpI,OAAAP,EAAU,IAAK,CACb,GAAI,CAACO,EAAe,OACpB,MAAMC,EAAaC,GAA8B,CAC3CA,EAAM,MAAQ,UAAUP,EAAO,CACrC,EACA,wBAAiB,UAAWM,CAAS,EAG9B,IAAY,oBAAoB,UAAWA,CAAS,CAC7D,EAAG,CAACD,EAAeL,CAAO,CAAC,EAGzBQ,EAAA,MAAA,CAAK,UAAU,sDAAsD,QAASR,EAAS,KAAK,eAAc,SAAA,CACxGS,EAAA,MAAA,CAAK,UAAU,gDAA+C,cAAa,MAAM,CAAA,EACjFD,EAAA,MAAA,CACE,UAAW,yHAAyHN,CAAU,GAC9I,QAAUK,GAAS,CAEjBA,EAAM,gBAAe,CACvB,EACA,KAAK,SAAQ,aACF,OAAM,aACLJ,EAAS,SAAA,CAErBM,EAAA,SAAA,CACE,KAAK,SACL,QAAST,EAAO,aACJI,EACZ,UAAU,iHAAgH,SAEzHA,CAAU,CAAA,EAEZH,CAAQ,CAAA,CAAA,CACL,CAAA,CAAA,CAGZ",
6
- "names": ["useEffect", "ModalShell", "onClose", "children", "widthClass", "ariaLabel", "closeLabel", "closeOnEscape", "onKeyDown", "event", "_jsxs", "_jsx"]
5
+ "mappings": "iIAAA,OAAS,aAAAA,MAAiC,QA4D1C,SAASC,EAAW,CAAE,QAAAC,EAAS,SAAAC,EAAU,WAAAC,EAAa,OAAQ,UAAAC,EAAW,WAAAC,EAAa,QAAS,cAAAC,EAAgB,EAAI,EAAmB,CACpI,OAAAP,EAAU,IAAK,CACb,GAAI,CAACO,EAAe,OACpB,MAAMC,EAAYC,EAACC,GAA8B,CAC3CA,EAAM,MAAQ,UAAUR,EAAO,CACrC,EAFkB,aAGlB,wBAAiB,UAAWM,CAAS,EAG9B,IAAY,oBAAoB,UAAWA,CAAS,CAC7D,EAAG,CAACD,EAAeL,CAAO,CAAC,EAGzBS,EAAA,MAAA,CAAK,UAAU,sDAAsD,QAAST,EAAS,KAAK,eAAc,SAAA,CACxGU,EAAA,MAAA,CAAK,UAAU,gDAA+C,cAAa,MAAM,CAAA,EACjFD,EAAA,MAAA,CACE,UAAW,yHAAyHP,CAAU,GAC9I,QAASK,EAACC,GAAS,CAEjBA,EAAM,gBAAe,CACvB,EAHS,WAIT,KAAK,SAAQ,aACF,OAAM,aACLL,EAAS,SAAA,CAErBO,EAAA,SAAA,CACE,KAAK,SACL,QAASV,EAAO,aACJI,EACZ,UAAU,iHAAgH,SAEzHA,CAAU,CAAA,EAEZH,CAAQ,CAAA,CAAA,CACL,CAAA,CAAA,CAGZ,CArCSM,EAAAR,EAAA",
6
+ "names": ["useEffect", "ModalShell", "onClose", "children", "widthClass", "ariaLabel", "closeLabel", "closeOnEscape", "onKeyDown", "__name", "event", "_jsxs", "_jsx"]
7
7
  }
package/dist/NoticeBar.js CHANGED
@@ -1 +1 @@
1
- import{jsxs as s,jsx as l}from"react/jsx-runtime";function o({notice:r,statusLabels:a}){if(r===null)return null;const e=r.kind==="error";return s("div",{role:e?"alert":"status",className:"fixed top-20 left-1/2 -translate-x-1/2 z-50 animate-slide-down px-5 py-3 rounded-xl shadow-xl bg-[var(--color-surface-2)] border border-[var(--color-border-muted)] max-w-[calc(100vw-2rem)]",children:[s("span",{className:"sr-only",children:[a[r.kind],": "]}),l("span",{className:e?"text-[var(--color-error-text)]":"text-[var(--color-success-text)]",children:r.message})]})}export{o as NoticeBar};
1
+ var o=Object.defineProperty;var a=(r,e)=>o(r,"name",{value:e,configurable:!0});import{jsxs as l,jsx as t}from"react/jsx-runtime";function d({notice:r,statusLabels:e}){if(r===null)return null;const s=r.kind==="error";return l("div",{role:s?"alert":"status",className:"fixed top-20 left-1/2 -translate-x-1/2 z-50 animate-slide-down px-5 py-3 rounded-xl shadow-xl bg-[var(--color-surface-2)] border border-[var(--color-border-muted)] max-w-[calc(100vw-2rem)]",children:[l("span",{className:"sr-only",children:[e[r.kind],": "]}),t("span",{className:s?"text-[var(--color-error-text)]":"text-[var(--color-success-text)]",children:r.message})]})}a(d,"NoticeBar");export{d as NoticeBar};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/NoticeBar.tsx"],
4
4
  "sourcesContent": ["import type { Notice, NoticeKind } from './useNotice.ts';\n\n/**\n * The transient status banner.\n *\n * ## Provenance\n *\n * `components/layout/NoticeBar.tsx` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** —\n * six copies in three distinct shapes.\n *\n * ## This renders the kit's own `Notice`\n *\n * Every copy took `{ type: 'success' | 'error'; text: string }`, while\n * `@rexezuge/web`'s `useNotice` — converged from the same six repos, and\n * already shipping — returns `{ kind, message }`. The copies were therefore\n * each doing a field-by-field shuffle at their call site to feed a component\n * the hook had already produced.\n *\n * Taking the kit's own type makes the pair compose directly. Consumers rename\n * two fields at their call sites; in exchange the banner and the hook can never\n * drift apart, because there is only one shape.\n *\n * ## Durable-DAV's fix is the one that shipped\n *\n * All six used `role=\"status\"`, which implies `aria-live=\"polite\"`. A failed\n * credential revoke was therefore announced at the same priority as a\n * background update, and a screen-reader user might never hear it. Durable-DAV's\n * copy splits it: errors assert, successes stay polite. That is the base here.\n *\n * Mail-Otter's copy dropped the screen-reader-only status prefix entirely,\n * which loses the kind for a user who cannot see the colour.\n */\n\n/**\nThe two accessible names, keyed by the kind they announce.\n*/\ntype NoticeStatusLabels = Record<NoticeKind, string>;\n\ninterface NoticeBarProps {\n /**\n The notice to show, or `null` for nothing — which is what `useNotice` hands back when idle.\n */\n notice: Notice | null;\n /**\n * The screen-reader prefix for each kind, e.g. `{ success: 'Success', error: 'Error' }`.\n *\n * Required, and keyed rather than a single string, because the label depends\n * on the kind: one label would either mislabel half the notices or need a\n * conditional at every call site — which is where the copies diverged.\n */\n statusLabels: NoticeStatusLabels;\n}\n\nfunction NoticeBar({ notice, statusLabels }: Readonly<NoticeBarProps>) {\n if (notice === null) return null;\n\n const isError = notice.kind === 'error';\n\n return (\n <div\n // Errors assert; successes stay polite. See the file header for why this\n // is not one role for both.\n role={isError ? 'alert' : 'status'}\n className=\"fixed top-20 left-1/2 -translate-x-1/2 z-50 animate-slide-down px-5 py-3 rounded-xl shadow-xl bg-[var(--color-surface-2)] border border-[var(--color-border-muted)] max-w-[calc(100vw-2rem)]\"\n >\n <span className=\"sr-only\">{statusLabels[notice.kind]}: </span>\n <span className={isError ? 'text-[var(--color-error-text)]' : 'text-[var(--color-success-text)]'}>{notice.message}</span>\n </div>\n );\n}\n\nexport { NoticeBar };\nexport type { NoticeBarProps, NoticeStatusLabels };\n"],
5
- "mappings": "kDAsDA,SAASA,EAAU,CAAE,OAAAC,EAAQ,aAAAC,CAAY,EAA4B,CACnE,GAAID,IAAW,KAAM,OAAO,KAE5B,MAAME,EAAUF,EAAO,OAAS,QAEhC,OACEG,EAAA,MAAA,CAGE,KAAMD,EAAU,QAAU,SAC1B,UAAU,+LAA8L,SAAA,CAExMC,EAAA,OAAA,CAAM,UAAU,UAAS,SAAA,CAAEF,EAAaD,EAAO,IAAI,EAAC,IAAA,CAAA,CAAA,EACpDI,EAAA,OAAA,CAAM,UAAWF,EAAU,iCAAmC,mCAAkC,SAAGF,EAAO,OAAO,CAAA,CAAQ,CAAA,CAAA,CAG/H",
6
- "names": ["NoticeBar", "notice", "statusLabels", "isError", "_jsxs", "_jsx"]
5
+ "mappings": "iIAsDA,SAASA,EAAU,CAAE,OAAAC,EAAQ,aAAAC,CAAY,EAA4B,CACnE,GAAID,IAAW,KAAM,OAAO,KAE5B,MAAME,EAAUF,EAAO,OAAS,QAEhC,OACEG,EAAA,MAAA,CAGE,KAAMD,EAAU,QAAU,SAC1B,UAAU,+LAA8L,SAAA,CAExMC,EAAA,OAAA,CAAM,UAAU,UAAS,SAAA,CAAEF,EAAaD,EAAO,IAAI,EAAC,IAAA,CAAA,CAAA,EACpDI,EAAA,OAAA,CAAM,UAAWF,EAAU,iCAAmC,mCAAkC,SAAGF,EAAO,OAAO,CAAA,CAAQ,CAAA,CAAA,CAG/H,CAhBSK,EAAAN,EAAA",
6
+ "names": ["NoticeBar", "notice", "statusLabels", "isError", "_jsxs", "_jsx", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{Card as c}from"./Card.js";function i({icon:t,title:a,description:l,actions:s}){return r(c,{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4 py-4",children:[r("div",{className:"flex items-center gap-3 min-w-0",children:[t&&e("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-surface-3)] shrink-0",children:t}),r("div",{className:"min-w-0",children:[e("h1",{className:"text-xl font-semibold text-[var(--color-text-primary)] truncate",children:a}),l&&e("div",{className:"text-sm text-[var(--color-text-muted)] truncate",children:l})]})]}),s&&e("div",{className:"flex flex-wrap items-center gap-3 shrink-0",children:s})]})}export{i as PageHeaderCard};
1
+ var i=Object.defineProperty;var c=(e,t)=>i(e,"name",{value:t,configurable:!0});import{jsx as r,jsxs as l}from"react/jsx-runtime";import{Card as m}from"./Card.js";function n({icon:e,title:t,description:s,actions:a}){return l(m,{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-4 py-4",children:[l("div",{className:"flex items-center gap-3 min-w-0",children:[e&&r("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-surface-3)] shrink-0",children:e}),l("div",{className:"min-w-0",children:[r("h1",{className:"text-xl font-semibold text-[var(--color-text-primary)] truncate",children:t}),s&&r("div",{className:"text-sm text-[var(--color-text-muted)] truncate",children:s})]})]}),a&&r("div",{className:"flex flex-wrap items-center gap-3 shrink-0",children:a})]})}c(n,"PageHeaderCard");export{n as PageHeaderCard};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/PageHeaderCard.tsx"],
4
4
  "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 /**\n Leading avatar. Omitted renders no avatar slot at all, not an empty one.\n */\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 /**\n Right-aligned. Omitted renders no actions slot.\n */\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"],
5
- "mappings": "kDACA,OAAS,QAAAA,MAAY,YA2CrB,SAASC,EAAe,CAAE,KAAAC,EAAM,MAAAC,EAAO,YAAAC,EAAa,QAAAC,CAAO,EAAiC,CAC1F,OACEC,EAACN,EAAI,CAAC,UAAU,uEAAsE,SAAA,CACpFM,EAAA,MAAA,CAAK,UAAU,kCAAiC,SAAA,CAC7CJ,GAAQK,EAAA,MAAA,CAAK,UAAU,+FAA8F,SAAEL,CAAI,CAAA,EAC5HI,EAAA,MAAA,CAAK,UAAU,UAAS,SAAA,CACtBC,EAAA,KAAA,CAAI,UAAU,kEAAiE,SAAEJ,CAAK,CAAA,EACrFC,GAAeG,EAAA,MAAA,CAAK,UAAU,kDAAiD,SAAEH,CAAW,CAAA,CAAO,CAAA,CAAA,CAChG,CAAA,CAAA,EAEPC,GAAWE,EAAA,MAAA,CAAK,UAAU,6CAA4C,SAAEF,CAAO,CAAA,CAAO,CAAA,CAAA,CAG7F",
6
- "names": ["Card", "PageHeaderCard", "icon", "title", "description", "actions", "_jsxs", "_jsx"]
5
+ "mappings": "iIACA,OAAS,QAAAA,MAAY,YA2CrB,SAASC,EAAe,CAAE,KAAAC,EAAM,MAAAC,EAAO,YAAAC,EAAa,QAAAC,CAAO,EAAiC,CAC1F,OACEC,EAACN,EAAI,CAAC,UAAU,uEAAsE,SAAA,CACpFM,EAAA,MAAA,CAAK,UAAU,kCAAiC,SAAA,CAC7CJ,GAAQK,EAAA,MAAA,CAAK,UAAU,+FAA8F,SAAEL,CAAI,CAAA,EAC5HI,EAAA,MAAA,CAAK,UAAU,UAAS,SAAA,CACtBC,EAAA,KAAA,CAAI,UAAU,kEAAiE,SAAEJ,CAAK,CAAA,EACrFC,GAAeG,EAAA,MAAA,CAAK,UAAU,kDAAiD,SAAEH,CAAW,CAAA,CAAO,CAAA,CAAA,CAChG,CAAA,CAAA,EAEPC,GAAWE,EAAA,MAAA,CAAK,UAAU,6CAA4C,SAAEF,CAAO,CAAA,CAAO,CAAA,CAAA,CAG7F,CAbSG,EAAAP,EAAA",
6
+ "names": ["Card", "PageHeaderCard", "icon", "title", "description", "actions", "_jsxs", "_jsx", "__name"]
7
7
  }
package/dist/PageState.js CHANGED
@@ -1 +1 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{ModalShell as c}from"./ModalShell.js";function d({label:t="Loading\u2026"}){return e("div",{className:"min-h-64 flex items-center justify-center",role:"status","aria-label":t,children:e("div",{className:"h-10 w-10 rounded-full border-2 border-[var(--color-accent)] border-t-transparent animate-spin"})})}function m({icon:t,message:r}){return n("div",{className:"text-center text-[var(--color-text-muted)] py-10 text-sm",children:[t&&e("div",{className:"mb-3 flex justify-center",children:t}),r]})}function x({message:t,confirmLabel:r,cancelLabel:l,ariaLabel:o,onConfirm:i,onCancel:s}){return e(c,{onClose:s,widthClass:"w-80",ariaLabel:o,children:n("div",{className:"p-6",children:[e("p",{className:"text-sm text-[var(--color-text-secondary)] text-center mb-6",children:t}),n("div",{className:"flex gap-3",children:[e("button",{type:"button",className:"flex-1",onClick:a=>{a.stopPropagation(),s()},children:l}),e("button",{type:"button",className:"flex-1",onClick:a=>{a.stopPropagation(),i()},children:r})]})]})})}export{x as ConfirmDeleteModal,m as EmptyState,d as LoadingSpinner};
1
+ var d=Object.defineProperty;var r=(e,a)=>d(e,"name",{value:a,configurable:!0});import{jsx as t,jsxs as s}from"react/jsx-runtime";import{ModalShell as m}from"./ModalShell.js";function x({label:e="Loading\u2026"}){return t("div",{className:"min-h-64 flex items-center justify-center",role:"status","aria-label":e,children:t("div",{className:"h-10 w-10 rounded-full border-2 border-[var(--color-accent)] border-t-transparent animate-spin"})})}r(x,"LoadingSpinner");function p({icon:e,message:a}){return s("div",{className:"text-center text-[var(--color-text-muted)] py-10 text-sm",children:[e&&t("div",{className:"mb-3 flex justify-center",children:e}),a]})}r(p,"EmptyState");function u({message:e,confirmLabel:a,cancelLabel:o,ariaLabel:i,onConfirm:c,onCancel:l}){return t(m,{onClose:l,widthClass:"w-80",ariaLabel:i,children:s("div",{className:"p-6",children:[t("p",{className:"text-sm text-[var(--color-text-secondary)] text-center mb-6",children:e}),s("div",{className:"flex gap-3",children:[t("button",{type:"button",className:"flex-1",onClick:r(n=>{n.stopPropagation(),l()},"onClick"),children:o}),t("button",{type:"button",className:"flex-1",onClick:r(n=>{n.stopPropagation(),c()},"onClick"),children:a})]})]})})}r(u,"ConfirmDeleteModal");export{u as ConfirmDeleteModal,p as EmptyState,x as LoadingSpinner};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/PageState.tsx"],
4
4
  "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/**\nThe shared spinner. `label` is announced, so it should say what is loading.\n*/\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/**\nThe shared centered empty message, with an optional icon above it.\n*/\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 /**\n The full question, naming what will be deleted.\n */\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"],
5
- "mappings": "kDACA,OAAS,cAAAA,MAAkB,kBAiB3B,SAASC,EAAe,CAAE,MAAAC,EAAQ,eAAU,EAAsB,CAChE,OACEC,EAAA,MAAA,CAAK,UAAU,4CAA4C,KAAK,SAAQ,aAAaD,EAAK,SACxFC,EAAA,MAAA,CAAK,UAAU,gGAAgG,CAAA,CAAG,CAAA,CAGxH,CAKA,SAASC,EAAW,CAAE,KAAAC,EAAM,QAAAC,CAAO,EAA4C,CAC7E,OACEC,EAAA,MAAA,CAAK,UAAU,2DAA0D,SAAA,CACtEF,GAAQF,EAAA,MAAA,CAAK,UAAU,2BAA0B,SAAEE,CAAI,CAAA,EACvDC,CAAO,CAAA,CAAA,CAGd,CAiBA,SAASE,EAAmB,CAC1B,QAAAF,EACA,aAAAG,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,SAAAC,CAAQ,EAWT,CACC,OACEV,EAACH,EAAU,CAAC,QAASa,EAAU,WAAW,OAAO,UAAWF,EAAS,SACnEJ,EAAA,MAAA,CAAK,UAAU,MAAK,SAAA,CAClBJ,EAAA,IAAA,CAAG,UAAU,8DAA6D,SAAEG,CAAO,CAAA,EACnFC,EAAA,MAAA,CAAK,UAAU,aAAY,SAAA,CACzBJ,EAAA,SAAA,CACE,KAAK,SACL,UAAU,SACV,QAAUW,GAAS,CACjBA,EAAM,gBAAe,EACrBD,EAAQ,CACV,EAAC,SAEAH,CAAW,CAAA,EAEdP,EAAA,SAAA,CACE,KAAK,SACL,UAAU,SACV,QAAUW,GAAS,CACjBA,EAAM,gBAAe,EACrBF,EAAS,CACX,EAAC,SAEAH,CAAY,CAAA,CACN,CAAA,CAAA,CACL,CAAA,CAAA,CACF,CAAA,CAGZ",
6
- "names": ["ModalShell", "LoadingSpinner", "label", "_jsx", "EmptyState", "icon", "message", "_jsxs", "ConfirmDeleteModal", "confirmLabel", "cancelLabel", "ariaLabel", "onConfirm", "onCancel", "event"]
5
+ "mappings": "iIACA,OAAS,cAAAA,MAAkB,kBAiB3B,SAASC,EAAe,CAAE,MAAAC,EAAQ,eAAU,EAAsB,CAChE,OACEC,EAAA,MAAA,CAAK,UAAU,4CAA4C,KAAK,SAAQ,aAAaD,EAAK,SACxFC,EAAA,MAAA,CAAK,UAAU,gGAAgG,CAAA,CAAG,CAAA,CAGxH,CANSC,EAAAH,EAAA,kBAWT,SAASI,EAAW,CAAE,KAAAC,EAAM,QAAAC,CAAO,EAA4C,CAC7E,OACEC,EAAA,MAAA,CAAK,UAAU,2DAA0D,SAAA,CACtEF,GAAQH,EAAA,MAAA,CAAK,UAAU,2BAA0B,SAAEG,CAAI,CAAA,EACvDC,CAAO,CAAA,CAAA,CAGd,CAPSH,EAAAC,EAAA,cAwBT,SAASI,EAAmB,CAC1B,QAAAF,EACA,aAAAG,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,SAAAC,CAAQ,EAWT,CACC,OACEX,EAACH,EAAU,CAAC,QAASc,EAAU,WAAW,OAAO,UAAWF,EAAS,SACnEJ,EAAA,MAAA,CAAK,UAAU,MAAK,SAAA,CAClBL,EAAA,IAAA,CAAG,UAAU,8DAA6D,SAAEI,CAAO,CAAA,EACnFC,EAAA,MAAA,CAAK,UAAU,aAAY,SAAA,CACzBL,EAAA,SAAA,CACE,KAAK,SACL,UAAU,SACV,QAASC,EAACW,GAAS,CACjBA,EAAM,gBAAe,EACrBD,EAAQ,CACV,EAHS,WAGR,SAEAH,CAAW,CAAA,EAEdR,EAAA,SAAA,CACE,KAAK,SACL,UAAU,SACV,QAASC,EAACW,GAAS,CACjBA,EAAM,gBAAe,EACrBF,EAAS,CACX,EAHS,WAGR,SAEAH,CAAY,CAAA,CACN,CAAA,CAAA,CACL,CAAA,CAAA,CACF,CAAA,CAGZ,CA/CSN,EAAAK,EAAA",
6
+ "names": ["ModalShell", "LoadingSpinner", "label", "_jsx", "__name", "EmptyState", "icon", "message", "_jsxs", "ConfirmDeleteModal", "confirmLabel", "cancelLabel", "ariaLabel", "onConfirm", "onCancel", "event"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as o,jsxs as N}from"react/jsx-runtime";import{Button as d}from"./Button.js";import{cn as P}from"./utils.js";function b(t,n){return!Number.isFinite(t)||!Number.isFinite(n)||n<=0||t<=0?1:Math.ceil(t/n)}function f(t,n){const i=Math.max(1,Math.trunc(Number.isFinite(n)?n:1)),a=Number.isFinite(t)?Math.trunc(t):1;return Math.min(i,Math.max(1,a))}function y(t,n,i=5){const a=Math.min(i,n);if(a<=0)return[];const u=Math.max(1,Math.min(t-Math.floor(i/2),n-a+1));return Array.from({length:a},(x,c)=>u+c)}function j({page:t,pageCount:n,total:i,pageSize:a,onChange:u,variant:x="full",labels:c={}}){const h=n??(i!==void 0&&a!==void 0?b(i,a):1),s=Math.max(1,Math.trunc(Number.isFinite(h)?h:1)),r=f(t,s);if(s<=1)return null;const M=c.previous??"Previous",v=c.next??"Next",p=c.summary??((e,m)=>`Page ${e} of ${m}`),l=e=>{const m=f(e,s);m!==r&&u(m)},F=o("span",{className:"text-xs text-[var(--color-text-muted)] tabular-nums",children:p(r,s)});return N("nav",{className:"flex flex-wrap items-center gap-2","aria-label":p(r,s),children:[o(d,{variant:"secondary",size:"sm",disabled:r<=1,onClick:()=>l(r-1),"aria-label":M,children:M}),x==="compact"?F:o("div",{className:"flex items-center gap-1",children:y(r,s).map(e=>o(d,{variant:"secondary",size:"sm",className:P(e===r&&"bg-[var(--color-accent)] text-[#0d1008]"),"aria-current":e===r?"page":void 0,onClick:()=>l(e),children:e},e))}),o(d,{variant:"secondary",size:"sm",disabled:r>=s,onClick:()=>l(r+1),"aria-label":v,children:v})]})}export{j as Pagination,f as clampPage,b as pageCountFor,y as pageWindow};
1
+ var P=Object.defineProperty;var a=(t,n)=>P(t,"name",{value:n,configurable:!0});import{jsx as m,jsxs as j}from"react/jsx-runtime";import{Button as f}from"./Button.js";import{cn as g}from"./utils.js";function y(t,n){return!Number.isFinite(t)||!Number.isFinite(n)||n<=0||t<=0?1:Math.ceil(t/n)}a(y,"pageCountFor");function x(t,n){const s=Math.max(1,Math.trunc(Number.isFinite(n)?n:1)),i=Number.isFinite(t)?Math.trunc(t):1;return Math.min(s,Math.max(1,i))}a(x,"clampPage");function F(t,n,s=5){const i=Math.min(s,n);if(i<=0)return[];const l=Math.max(1,Math.min(t-Math.floor(s/2),n-i+1));return Array.from({length:i},(h,o)=>l+o)}a(F,"pageWindow");function k({page:t,pageCount:n,total:s,pageSize:i,onChange:l,variant:h="full",labels:o={}}){const M=n??(s!==void 0&&i!==void 0?y(s,i):1),c=Math.max(1,Math.trunc(Number.isFinite(M)?M:1)),r=x(t,c);if(c<=1)return null;const v=o.previous??"Previous",p=o.next??"Next",b=o.summary??((e,u)=>`Page ${e} of ${u}`),d=a(e=>{const u=x(e,c);u!==r&&l(u)},"step"),N=m("span",{className:"text-xs text-[var(--color-text-muted)] tabular-nums",children:b(r,c)});return j("nav",{className:"flex flex-wrap items-center gap-2","aria-label":b(r,c),children:[m(f,{variant:"secondary",size:"sm",disabled:r<=1,onClick:a(()=>d(r-1),"onClick"),"aria-label":v,children:v}),h==="compact"?N:m("div",{className:"flex items-center gap-1",children:F(r,c).map(e=>m(f,{variant:"secondary",size:"sm",className:g(e===r&&"bg-[var(--color-accent)] text-[#0d1008]"),"aria-current":e===r?"page":void 0,onClick:a(()=>d(e),"onClick"),children:e},e))}),m(f,{variant:"secondary",size:"sm",disabled:r>=c,onClick:a(()=>d(r+1),"onClick"),"aria-label":p,children:p})]})}a(k,"Pagination");export{k as Pagination,x as clampPage,y as pageCountFor,F as pageWindow};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Pagination.tsx"],
4
4
  "sourcesContent": ["import type { ReactElement } from 'react';\nimport { Button } from './Button.tsx';\nimport { cn } from './utils.ts';\n\n/**\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/**\nHow many pages `total` items occupy. A non-positive page size yields 1, never `Infinity`/`NaN`.\n*/\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/**\nPins `page` into `[1, pageCount]`, rounding to the first page when it cannot be read.\n*/\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/**\nOverridable text, so an i18next app is not stuck with the English defaults.\n*/\ninterface PaginationLabels {\n /**\n Prev-button accessible name / label.\n */\n previous?: string;\n /**\n Next-button accessible name / label.\n */\n next?: string;\n /**\n The \"Page X of Y\" summary in `compact` (and as the pager's `aria-label` in `full`).\n */\n summary?: (page: number, pageCount: number) => string;\n}\n\ninterface PaginationProps {\n /**\n The page being displayed, 1-based. Clamped into range for rendering.\n */\n page: number;\n /**\n Total pages. Omit to derive it from `total` and `pageSize`.\n */\n pageCount?: number;\n /**\n Total item count across every page.\n */\n total?: number;\n /**\n Items per page.\n */\n pageSize?: number;\n /**\n Called with the 1-based page to move to; already clamped into range.\n */\n onChange: (page: number) => void;\n /**\n `full` shows page numbers, `compact` shows a summary.\n */\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\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 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 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"],
5
- "mappings": "kDACA,OAAS,UAAAA,MAAc,cACvB,OAAS,MAAAC,MAAU,aA6BnB,SAASC,EAAaC,EAAeC,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AkB,QAAQP,CAAI,OAAOO,CAAK,IAE3Fc,EAAQC,GAAsB,CAClC,MAAMC,EAASxB,EAAUuB,EAAMN,CAAK,EAChCO,IAAWN,GACbL,EAASW,CAAM,CAEnB,EAEMC,EAAUC,EAAA,OAAA,CAAM,UAAU,sDAAqD,SAAEL,EAAaH,EAASD,CAAK,CAAC,CAAA,EAEnH,OACEU,EAAA,MAAA,CAAK,UAAU,oCAAmC,aAAaN,EAAaH,EAASD,CAAK,EAAC,SAAA,CACzFS,EAAC/B,EAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,SAAUuB,GAAW,EAAG,QAAS,IAAMI,EAAKJ,EAAU,CAAC,EAAC,aAAcC,EAAa,SACtHA,CAAa,CAAA,EAEfL,IAAY,UACXW,EAEAC,EAAA,MAAA,CAAK,UAAU,0BAAyB,SACrCrB,EAAWa,EAASD,CAAK,EAAE,IAAKW,GAC/BF,EAAC/B,EAAM,CAEL,QAAQ,YACR,KAAK,KACL,UAAWC,EAAGgC,IAAeV,GAAW,yCAAyC,EAAC,eACpEU,IAAeV,EAAU,OAAS,OAChD,QAAS,IAAMI,EAAKM,CAAU,EAAC,SAE9BA,CAAU,EAPNA,CAAU,CASlB,CAAC,CAAA,EAGNF,EAAC/B,EAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,SAAUuB,GAAWD,EAAO,QAAS,IAAMK,EAAKJ,EAAU,CAAC,EAAC,aAAcE,EAAS,SACtHA,CAAS,CAAA,CACH,CAAA,CAAA,CAGf",
6
- "names": ["Button", "cn", "pageCountFor", "total", "pageSize", "clampPage", "page", "pageCount", "upper", "wanted", "pageWindow", "currentPage", "windowSize", "count", "start", "_", "index", "Pagination", "onChange", "variant", "labels", "derivedPageCount", "pages", "current", "previousLabel", "nextLabel", "summaryLabel", "step", "next", "target", "summary", "_jsx", "_jsxs", "pageNumber"]
5
+ "mappings": "iIACA,OAAS,UAAAA,MAAc,cACvB,OAAS,MAAAC,MAAU,aA6BnB,SAASC,EAAaC,EAA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EAAYL,EAAO,MAAQ,OAC3BM,EAAeN,EAAO,UAAY,CAACd,EAAcO,IAAkB,QAAQP,CAAI,OAAOO,CAAK,IAE3Fc,EAAOvB,EAACwB,GAAsB,CAClC,MAAMC,EAASxB,EAAUuB,EAAMN,CAAK,EAChCO,IAAWN,GACbL,EAASW,CAAM,CAEnB,EALa,QAOPC,EAAUC,EAAA,OAAA,CAAM,UAAU,sDAAqD,SAAEL,EAAaH,EAASD,CAAK,CAAC,CAAA,EAEnH,OACEU,EAAA,MAAA,CAAK,UAAU,oCAAmC,aAAaN,EAAaH,EAASD,CAAK,EAAC,SAAA,CACzFS,EAAChC,EAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,SAAUwB,GAAW,EAAG,QAASnB,EAAA,IAAMuB,EAAKJ,EAAU,CAAC,EAAtB,WAAuB,aAAcC,EAAa,SACtHA,CAAa,CAAA,EAEfL,IAAY,UACXW,EAEAC,EAAA,MAAA,CAAK,UAAU,0BAAyB,SACrCrB,EAAWa,EAASD,CAAK,EAAE,IAAKW,GAC/BF,EAAChC,EAAM,CAEL,QAAQ,YACR,KAAK,KACL,UAAWC,EAAGiC,IAAeV,GAAW,yCAAyC,EAAC,eACpEU,IAAeV,EAAU,OAAS,OAChD,QAASnB,EAAA,IAAMuB,EAAKM,CAAU,EAArB,WAAsB,SAE9BA,CAAU,EAPNA,CAAU,CASlB,CAAC,CAAA,EAGNF,EAAChC,EAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,SAAUwB,GAAWD,EAAO,QAASlB,EAAA,IAAMuB,EAAKJ,EAAU,CAAC,EAAtB,WAAuB,aAAcE,EAAS,SACtHA,CAAS,CAAA,CACH,CAAA,CAAA,CAGf,CA3DSrB,EAAAa,EAAA",
6
+ "names": ["Button", "cn", "pageCountFor", "total", "pageSize", "__name", "clampPage", "page", "pageCount", "upper", "wanted", "pageWindow", "currentPage", "windowSize", "count", "start", "_", "index", "Pagination", "onChange", "variant", "labels", "derivedPageCount", "pages", "current", "previousLabel", "nextLabel", "summaryLabel", "step", "next", "target", "summary", "_jsx", "_jsxs", "pageNumber"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as r,jsxs as l}from"react/jsx-runtime";import{useId as n}from"react";import{Check as m,Copy as u}from"lucide-react";import{Label as p}from"./Input.js";import{cn as b}from"./utils.js";import{useCopyToClipboard as x}from"./useCopyToClipboard.js";function f({label:s,value:e,showCopy:o=!1,copyLabel:a,className:d}){const{copied:c,copy:i}=x(),t=n();return l("div",{children:[r(p,{className:"mb-1.5",htmlFor:t,children:s}),l("div",{className:"flex",children:[r("input",{id:t,readOnly:!0,value:e,className:b("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",o?"rounded-l-lg border-r-0":"rounded-lg",d)}),o&&r("button",{type:"button",onClick:()=>i(e),title:a,"aria-label":a,"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:c?r(m,{className:"h-3.5 w-3.5 text-[var(--color-success-text)]","aria-hidden":"true"}):r(u,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}export{f as ReadOnlyField};
1
+ var m=Object.defineProperty;var a=(o,e)=>m(o,"name",{value:e,configurable:!0});import{jsx as r,jsxs as d}from"react/jsx-runtime";import{useId as u}from"react";import{Check as p,Copy as b}from"lucide-react";import{Label as x}from"./Input.js";import{cn as f}from"./utils.js";import{useCopyToClipboard as v}from"./useCopyToClipboard.js";function h({label:o,value:e,showCopy:t=!1,copyLabel:l,className:c}){const{copied:i,copy:n}=v(),s=u();return d("div",{children:[r(x,{className:"mb-1.5",htmlFor:s,children:o}),d("div",{className:"flex",children:[r("input",{id:s,readOnly:!0,value:e,className:f("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",t?"rounded-l-lg border-r-0":"rounded-lg",c)}),t&&r("button",{type:"button",onClick:a(()=>n(e),"onClick"),title:l,"aria-label":l,"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:i?r(p,{className:"h-3.5 w-3.5 text-[var(--color-success-text)]","aria-hidden":"true"}):r(b,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]})]})}a(h,"ReadOnlyField");export{h as ReadOnlyField};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/ReadOnlyField.tsx"],
4
4
  "sourcesContent": ["import { useId } 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 /**\n The field's label.\n */\n label: string;\n /**\n The value, shown verbatim and selectable.\n */\n value: string;\n /**\n Show the copy button. Defaults to false.\n */\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 /**\n Merged last onto the value's `<input>`.\n */\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"],
5
- "mappings": "kDAAA,OAAS,SAAAA,MAAa,QACtB,OAAS,SAAAC,EAAO,QAAAC,MAAY,eAC5B,OAAS,SAAAC,MAAa,aACtB,OAAS,MAAAC,MAAU,aACnB,OAAS,sBAAAC,MAA0B,0BAyDnC,SAASC,EAAc,CAAE,MAAAC,EAAO,MAAAC,EAAO,SAAAC,EAAW,GAAO,UAAAC,EAAW,UAAAC,CAAS,EAAgC,CAC3G,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAI,EAAKR,EAAkB,EAKrCS,EAAUd,EAAK,EAErB,OACEe,EAAA,MAAA,CAAA,SAAA,CACEC,EAACb,EAAK,CAAC,UAAU,SAAS,QAASW,EAAO,SACvCP,CAAK,CAAA,EAERQ,EAAA,MAAA,CAAK,UAAU,OAAM,SAAA,CACnBC,EAAA,QAAA,CACE,GAAIF,EACJ,SAAQ,GACR,MAAON,EACP,UAAWJ,EACT,yIACAK,EAAW,0BAA4B,aACvCE,CAAS,CACV,CAAA,EAEFF,GACCO,EAAA,SAAA,CACE,KAAK,SACL,QAAS,IAAMH,EAAKL,CAAK,EACzB,MAAOE,EAAS,aACJA,EAAS,YAIX,SACV,UAAU,6LAA4L,SAErME,EACCI,EAACf,EAAK,CAAC,UAAU,+CAA8C,cAAa,MAAM,CAAA,EAElFe,EAACd,EAAI,CAAC,UAAU,cAAa,cAAa,MAAM,CAAA,CACjD,CAAA,CAEJ,CAAA,CAAA,CACG,CAAA,CAAA,CAGZ",
6
- "names": ["useId", "Check", "Copy", "Label", "cn", "useCopyToClipboard", "ReadOnlyField", "label", "value", "showCopy", "copyLabel", "className", "copied", "copy", "inputId", "_jsxs", "_jsx"]
5
+ "mappings": "iIAAA,OAAS,SAAAA,MAAa,QACtB,OAAS,SAAAC,EAAO,QAAAC,MAAY,eAC5B,OAAS,SAAAC,MAAa,aACtB,OAAS,MAAAC,MAAU,aACnB,OAAS,sBAAAC,MAA0B,0BAyDnC,SAASC,EAAc,CAAE,MAAAC,EAAO,MAAAC,EAAO,SAAAC,EAAW,GAAO,UAAAC,EAAW,UAAAC,CAAS,EAAgC,CAC3G,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAI,EAAKR,EAAkB,EAKrCS,EAAUd,EAAK,EAErB,OACEe,EAAA,MAAA,CAAA,SAAA,CACEC,EAACb,EAAK,CAAC,UAAU,SAAS,QAASW,EAAO,SACvCP,CAAK,CAAA,EAERQ,EAAA,MAAA,CAAK,UAAU,OAAM,SAAA,CACnBC,EAAA,QAAA,CACE,GAAIF,EACJ,SAAQ,GACR,MAAON,EACP,UAAWJ,EACT,yIACAK,EAAW,0BAA4B,aACvCE,CAAS,CACV,CAAA,EAEFF,GACCO,EAAA,SAAA,CACE,KAAK,SACL,QAASC,EAAA,IAAMJ,EAAKL,CAAK,EAAhB,WACT,MAAOE,EAAS,aACJA,EAAS,YAIX,SACV,UAAU,6LAA4L,SAErME,EACCI,EAACf,EAAK,CAAC,UAAU,+CAA8C,cAAa,MAAM,CAAA,EAElFe,EAACd,EAAI,CAAC,UAAU,cAAa,cAAa,MAAM,CAAA,CACjD,CAAA,CAEJ,CAAA,CAAA,CACG,CAAA,CAAA,CAGZ,CA9CSe,EAAAX,EAAA",
6
+ "names": ["useId", "Check", "Copy", "Label", "cn", "useCopyToClipboard", "ReadOnlyField", "label", "value", "showCopy", "copyLabel", "className", "copied", "copy", "inputId", "_jsxs", "_jsx", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as a,jsxs as t}from"react/jsx-runtime";import{RefreshCw as i}from"lucide-react";import{Button as n}from"./Button.js";function m({onRefresh:s,loading:r,label:e,className:o}){return t(n,{variant:"secondary",size:"sm",onClick:s,loading:r,className:o,children:[a(i,{className:"h-3.5 w-3.5","aria-hidden":"true"}),e]})}export{m as RefreshButton};
1
+ var t=Object.defineProperty;var e=(s,r)=>t(s,"name",{value:r,configurable:!0});import{jsx as i,jsxs as n}from"react/jsx-runtime";import{RefreshCw as m}from"lucide-react";import{Button as c}from"./Button.js";function f({onRefresh:s,loading:r,label:o,className:a}){return n(c,{variant:"secondary",size:"sm",onClick:s,loading:r,className:a,children:[i(m,{className:"h-3.5 w-3.5","aria-hidden":"true"}),o]})}e(f,"RefreshButton");export{f as RefreshButton};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/RefreshButton.tsx"],
4
4
  "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 /**\n Shows the spinner and blocks activation until the caller's work clears.\n */\n loading?: boolean;\n /**\n The button's text.\n */\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"],
5
- "mappings": "kDAAA,OAAS,aAAAA,MAAiB,eAC1B,OAAS,UAAAC,MAAc,cAwCvB,SAASC,EAAc,CAAE,UAAAC,EAAW,QAAAC,EAAS,MAAAC,EAAO,UAAAC,CAAS,EAAgC,CAC3F,OACEC,EAACN,EAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,QAASE,EAAW,QAASC,EAAS,UAAWE,EAAS,SAAA,CAC9FE,EAACR,EAAS,CAAC,UAAU,cAAa,cAAa,MAAM,CAAA,EACpDK,CAAK,CAAA,CAAA,CAGZ",
6
- "names": ["RefreshCw", "Button", "RefreshButton", "onRefresh", "loading", "label", "className", "_jsxs", "_jsx"]
5
+ "mappings": "iIAAA,OAAS,aAAAA,MAAiB,eAC1B,OAAS,UAAAC,MAAc,cAwCvB,SAASC,EAAc,CAAE,UAAAC,EAAW,QAAAC,EAAS,MAAAC,EAAO,UAAAC,CAAS,EAAgC,CAC3F,OACEC,EAACN,EAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,QAASE,EAAW,QAASC,EAAS,UAAWE,EAAS,SAAA,CAC9FE,EAACR,EAAS,CAAC,UAAU,cAAa,cAAa,MAAM,CAAA,EACpDK,CAAK,CAAA,CAAA,CAGZ,CAPSI,EAAAP,EAAA",
6
+ "names": ["RefreshCw", "Button", "RefreshButton", "onRefresh", "loading", "label", "className", "_jsxs", "_jsx", "__name"]
7
7
  }
package/dist/Spinner.js CHANGED
@@ -1 +1 @@
1
- import{jsx as i,jsxs as s}from"react/jsx-runtime";import{theme as a}from"./theme.js";function p({size:r=24,color:n=a.spinnerBlue,label:e,padding:t="16px 0",style:o}){return s("div",{style:{textAlign:"center",padding:t,...o},children:[i("div",{className:"animate-spin","aria-hidden":"true",style:{width:`${r}px`,height:`${r}px`,borderRadius:"50%",border:`2px solid ${n}`,borderTopColor:"transparent",margin:"0 auto"}}),e?i("p",{style:{color:"#9ca3af",marginTop:"12px"},children:e}):null]})}export{p as Spinner};
1
+ var a=Object.defineProperty;var n=(r,e)=>a(r,"name",{value:e,configurable:!0});import{jsx as t,jsxs as p}from"react/jsx-runtime";import{theme as d}from"./theme.js";function l({size:r=24,color:e=d.spinnerBlue,label:i,padding:o="16px 0",style:s}){return p("div",{style:{textAlign:"center",padding:o,...s},children:[t("div",{className:"animate-spin","aria-hidden":"true",style:{width:`${r}px`,height:`${r}px`,borderRadius:"50%",border:`2px solid ${e}`,borderTopColor:"transparent",margin:"0 auto"}}),i?t("p",{style:{color:"#9ca3af",marginTop:"12px"},children:i}):null]})}n(l,"Spinner");export{l as Spinner};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Spinner.tsx"],
4
4
  "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 /**\n Diameter in pixels.\n */\n size?: number;\n /**\n Border colour; `currentColor` inherits from the surrounding text.\n */\n color?: string;\n /**\n Optional caption under the ring.\n */\n label?: string;\n /**\n Padding around the whole block, as a CSS shorthand.\n */\n padding?: string;\n /**\n Extra styles for the outer wrapper.\n */\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"],
5
- "mappings": "kDACA,OAAS,SAAAA,MAAa,aAwCtB,SAASC,EAAQ,CAAE,KAAAC,EAAO,GAAI,MAAAC,EAAQH,EAAM,YAAa,MAAAI,EAAO,QAAAC,EAAU,SAAU,MAAAC,CAAK,EAA0B,CACjH,OACEC,EAAA,MAAA,CAAK,MAAO,CAAE,UAAW,SAAU,QAAAF,EAAS,GAAGC,CAAK,EAAE,SAAA,CACpDE,EAAA,MAAA,CACE,UAAU,eAAc,cACZ,OACZ,MAAO,CACL,MAAO,GAAGN,CAAI,KACd,OAAQ,GAAGA,CAAI,KACf,aAAc,MACd,OAAQ,aAAaC,CAAK,GAC1B,eAAgB,cAChB,OAAQ,SACT,CAAA,EAEFC,EAAQI,EAAA,IAAA,CAAG,MAAO,CAAE,MAAO,UAAW,UAAW,MAAM,EAAE,SAAGJ,CAAK,CAAA,EAAQ,IAAI,CAAA,CAAA,CAGpF",
6
- "names": ["theme", "Spinner", "size", "color", "label", "padding", "style", "_jsxs", "_jsx"]
5
+ "mappings": "iIACA,OAAS,SAAAA,MAAa,aAwCtB,SAASC,EAAQ,CAAE,KAAAC,EAAO,GAAI,MAAAC,EAAQH,EAAM,YAAa,MAAAI,EAAO,QAAAC,EAAU,SAAU,MAAAC,CAAK,EAA0B,CACjH,OACEC,EAAA,MAAA,CAAK,MAAO,CAAE,UAAW,SAAU,QAAAF,EAAS,GAAGC,CAAK,EAAE,SAAA,CACpDE,EAAA,MAAA,CACE,UAAU,eAAc,cACZ,OACZ,MAAO,CACL,MAAO,GAAGN,CAAI,KACd,OAAQ,GAAGA,CAAI,KACf,aAAc,MACd,OAAQ,aAAaC,CAAK,GAC1B,eAAgB,cAChB,OAAQ,SACT,CAAA,EAEFC,EAAQI,EAAA,IAAA,CAAG,MAAO,CAAE,MAAO,UAAW,UAAW,MAAM,EAAE,SAAGJ,CAAK,CAAA,EAAQ,IAAI,CAAA,CAAA,CAGpF,CAlBSK,EAAAR,EAAA",
6
+ "names": ["theme", "Spinner", "size", "color", "label", "padding", "style", "_jsxs", "_jsx", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as r,jsxs as a}from"react/jsx-runtime";import{useState as g}from"react";import{AlertTriangle as y,Check as C,Copy as N}from"lucide-react";import{Button as i}from"./Button.js";import{Input as w,Label as j}from"./Input.js";import{ModalShell as k}from"./ModalShell.js";import{useCopyToClipboard as T}from"./useCopyToClipboard.js";function F({title:t,description:n,expectedName:o,confirmLabel:d,cancelLabel:m,copyLabel:l,promptLabel:u,onConfirm:p,onCancel:s,loading:h=!1}){const[c,x]=g(""),{copied:f,copy:b}=T(),v=c.trim()===o;return r(k,{onClose:s,widthClass:"w-full max-w-md mx-4",ariaLabel:t,children:a("div",{className:"p-6",children:[r("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-error-bg)] mb-4 mx-auto",children:r(y,{className:"h-5 w-5 text-[var(--color-error-text)]","aria-hidden":"true"})}),r("h2",{className:"text-base font-semibold text-[var(--color-text-primary)] text-center mb-2",children:t}),r("p",{className:"text-sm text-[var(--color-text-secondary)] text-center mb-4",children:n}),a("div",{className:"flex items-center justify-center gap-2 mb-4",children:[r("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:o}),r("button",{type:"button",onClick:()=>b(o),title:l,"aria-label":l,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:f?r(C,{className:"h-3.5 w-3.5 text-[var(--color-success-text)]","aria-hidden":"true"}):r(N,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),a("div",{className:"space-y-1.5 mb-6",children:[r(j,{htmlFor:"danger-confirm-input",children:u}),r(w,{id:"danger-confirm-input",value:c,onChange:e=>x(e.target.value),placeholder:o,autoComplete:"off",autoFocus:!0})]}),a("div",{className:"flex gap-3",children:[r(i,{variant:"ghost",className:"flex-1",onClick:e=>{e.stopPropagation(),s()},children:m}),r(i,{variant:"danger",className:"flex-1",disabled:!v,loading:h,onClick:e=>{e.stopPropagation(),p()},children:d})]})]})})}export{F as TypeToConfirmModal};
1
+ var y=Object.defineProperty;var e=(a,s)=>y(a,"name",{value:s,configurable:!0});import{jsx as r,jsxs as l}from"react/jsx-runtime";import{useState as C}from"react";import{AlertTriangle as N,Check as w,Copy as j}from"lucide-react";import{Button as d}from"./Button.js";import{Input as k,Label as T}from"./Input.js";import{ModalShell as F}from"./ModalShell.js";import{useCopyToClipboard as I}from"./useCopyToClipboard.js";function M({title:a,description:s,expectedName:t,confirmLabel:m,cancelLabel:u,copyLabel:c,promptLabel:p,onConfirm:h,onCancel:i,loading:x=!1}){const[n,f]=C(""),{copied:b,copy:v}=I(),g=n.trim()===t;return r(F,{onClose:i,widthClass:"w-full max-w-md mx-4",ariaLabel:a,children:l("div",{className:"p-6",children:[r("div",{className:"flex items-center justify-center w-10 h-10 rounded-full bg-[var(--color-error-bg)] mb-4 mx-auto",children:r(N,{className:"h-5 w-5 text-[var(--color-error-text)]","aria-hidden":"true"})}),r("h2",{className:"text-base font-semibold text-[var(--color-text-primary)] text-center mb-2",children:a}),r("p",{className:"text-sm text-[var(--color-text-secondary)] text-center mb-4",children:s}),l("div",{className:"flex items-center justify-center gap-2 mb-4",children:[r("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:t}),r("button",{type:"button",onClick:e(()=>v(t),"onClick"),title:c,"aria-label":c,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:b?r(w,{className:"h-3.5 w-3.5 text-[var(--color-success-text)]","aria-hidden":"true"}):r(j,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),l("div",{className:"space-y-1.5 mb-6",children:[r(T,{htmlFor:"danger-confirm-input",children:p}),r(k,{id:"danger-confirm-input",value:n,onChange:e(o=>f(o.target.value),"onChange"),placeholder:t,autoComplete:"off",autoFocus:!0})]}),l("div",{className:"flex gap-3",children:[r(d,{variant:"ghost",className:"flex-1",onClick:e(o=>{o.stopPropagation(),i()},"onClick"),children:u}),r(d,{variant:"danger",className:"flex-1",disabled:!g,loading:x,onClick:e(o=>{o.stopPropagation(),h()},"onClick"),children:m})]})]})})}e(M,"TypeToConfirmModal");export{M as TypeToConfirmModal};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/TypeToConfirmModal.tsx"],
4
4
  "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 /**\n The dialog's heading, and its accessible name.\n */\n title: string;\n /**\n The line under the heading, explaining what happens on confirm.\n */\n description: string;\n /**\n The string the operator must type. Shown, and offered as a copy.\n */\n expectedName: string;\n confirmLabel: string;\n cancelLabel: string;\n /**\n The copy button's accessible name and tooltip.\n */\n copyLabel: string;\n /**\n The prompt over the input. Name the thing: `Type \"prod\" to confirm`.\n */\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"],
5
- "mappings": "kDAAA,OAAS,YAAAA,MAAgB,QACzB,OAAS,iBAAAC,EAAe,SAAAC,EAAO,QAAAC,MAAY,eAC3C,OAAS,UAAAC,MAAc,cACvB,OAAS,SAAAC,EAAO,SAAAC,MAAa,aAC7B,OAAS,cAAAC,MAAkB,kBAC3B,OAAS,sBAAAC,MAA0B,0BAyDnC,SAASC,EAAmB,CAC1B,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,aAAAC,EACA,YAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,SAAAC,EACA,QAAAC,EAAU,EAAK,EACmB,CAClC,KAAM,CAACC,EAAOC,CAAQ,EAAIrB,EAAS,EAAE,EAC/B,CAAE,OAAAsB,EAAQ,KAAAC,CAAI,EAAKf,EAAkB,EAErCgB,EAAUJ,EAAM,KAAI,IAAOR,EAEjC,OAIEa,EAAClB,EAAU,CAAC,QAASW,EAAU,WAAW,uBAAuB,UAAWR,EAAK,SAC/EgB,EAAA,MAAA,CAAK,UAAU,MAAK,SAAA,CAClBD,EAAA,MAAA,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useState", "AlertTriangle", "Check", "Copy", "Button", "Input", "Label", "ModalShell", "useCopyToClipboard", "TypeToConfirmModal", "title", "description", "expectedName", "confirmLabel", "cancelLabel", "copyLabel", "promptLabel", "onConfirm", "onCancel", "loading", "input", "setInput", "copied", "copy", "matched", "_jsx", "_jsxs", "event"]
5
+ "mappings": "iIAAA,OAAS,YAAAA,MAAgB,QACzB,OAAS,iBAAAC,EAAe,SAAAC,EAAO,QAAAC,MAAY,eAC3C,OAAS,UAAAC,MAAc,cACvB,OAAS,SAAAC,EAAO,SAAAC,MAAa,aAC7B,OAAS,cAAAC,MAAkB,kBAC3B,OAAS,sBAAAC,MAA0B,0BAyDnC,SAASC,EAAmB,CAC1B,MAAAC,EACA,YAAAC,EACA,aAAAC,EACA,aAAAC,EACA,YAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,SAAAC,EACA,QAAAC,EAAU,EAAK,EACmB,CAClC,KAAM,CAACC,EAAOC,CAAQ,EAAIrB,EAAS,EAAE,EAC/B,CAAE,OAAAsB,EAAQ,KAAAC,CAAI,EAAKf,EAAkB,EAErCgB,EAAUJ,EAAM,KAAI,IAAOR,EAEjC,OAIEa,EAAClB,EAAU,CAAC,QAASW,EAAU,WAAW,uBAAuB,UAAWR,EAAK,SAC/EgB,EAAA,MAAA,CAAK,UAAU,MAAK,SAAA,CAClBD,EAAA,MAAA,CAAK,UAAU,kGAAiG,SAC9GA,EAACxB,EAAa,CAAC,UAAU,yCAAwC,cAAa,MAAM,CAAA,CAAG,CAAA,EAEzFwB,EAAA,KAAA,CAAI,UAAU,4EAA2E,SAAEf,CAAK,CAAA,EAChGe,EAAA,IAAA,CAAG,UAAU,8DAA6D,SAAEd,CAAW,CAAA,EACvFe,EAAA,MAAA,CAAK,UAAU,8CAA6C,SAAA,CAC1DD,EAAA,OAAA,CAAM,UAAU,2JAA0J,SACvKb,CAAY,CAAA,EAEfa,EAAA,SAAA,CACE,KAAK,SACL,QAASE,EAAA,IAAMJ,EAAKX,CAAY,EAAvB,WACT,MAAOG,EAAS,aACJA,EACZ,UAAU,6LAA4L,SAErMO,EACCG,EAACvB,EAAK,CAAC,UAAU,+CAA8C,cAAa,MAAM,CAAA,EAElFuB,EAACtB,EAAI,CAAC,UAAU,cAAa,cAAa,MAAM,CAAA,CACjD,CAAA,CACM,CAAA,CAAA,EAEXuB,EAAA,MAAA,CAAK,UAAU,mBAAkB,SAAA,CAC/BD,EAACnB,EAAK,CAAC,QAAQ,uBAAsB,SAAEU,CAAW,CAAA,EAClDS,EAACpB,EAAK,CACJ,GAAG,uBACH,MAAOe,EACP,SAAUO,EAACC,GAAUP,EAASO,EAAM,OAAO,KAAK,EAAtC,YACV,YAAahB,EACb,aAAa,MACb,UAAS,EAAA,CAAA,CACT,CAAA,CAAA,EAEJc,EAAA,MAAA,CAAK,UAAU,aAAY,SAAA,CACzBD,EAACrB,EAAM,CACL,QAAQ,QACR,UAAU,SACV,QAASuB,EAACC,GAAS,CACjBA,EAAM,gBAAe,EACrBV,EAAQ,CACV,EAHS,WAGR,SAEAJ,CAAW,CAAA,EAEdW,EAACrB,EAAM,CACL,QAAQ,SACR,UAAU,SAGV,SAAU,CAACoB,EACX,QAASL,EACT,QAASQ,EAACC,GAAS,CACjBA,EAAM,gBAAe,EACrBX,EAAS,CACX,EAHS,WAGR,SAEAJ,CAAY,CAAA,CACN,CAAA,CAAA,CACL,CAAA,CAAA,CACF,CAAA,CAGZ,CAtFSc,EAAAlB,EAAA",
6
+ "names": ["useState", "AlertTriangle", "Check", "Copy", "Button", "Input", "Label", "ModalShell", "useCopyToClipboard", "TypeToConfirmModal", "title", "description", "expectedName", "confirmLabel", "cancelLabel", "copyLabel", "promptLabel", "onConfirm", "onCancel", "loading", "input", "setInput", "copied", "copy", "matched", "_jsx", "_jsxs", "__name", "event"]
7
7
  }
@@ -1 +1 @@
1
- import{jsx as e,jsxs as r}from"react/jsx-runtime";import{ZERO_TRUST_AUTHENTICATION_PATH as n}from"./constants.js";function l({title:o,message:t,actionLabel:c,onAuthenticate:i}){const s=i??(()=>{location.assign(n)});return e("div",{className:"bg-[var(--color-surface-base)] text-[var(--color-text-primary)] flex items-center justify-center py-16",children:r("div",{className:"text-center px-6",children:[e("h1",{className:"text-lg font-medium mt-4 mb-1",children:o}),t&&e("p",{className:"text-[var(--color-text-secondary)] text-sm",children:t}),e("button",{type:"button",onClick:s,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:c})]})})}export{l as Unauthorized};
1
+ var n=Object.defineProperty;var c=(o,e)=>n(o,"name",{value:e,configurable:!0});import{jsx as t,jsxs as l}from"react/jsx-runtime";import{ZERO_TRUST_AUTHENTICATION_PATH as a}from"./constants.js";function m({title:o,message:e,actionLabel:i,onAuthenticate:s}){const r=s??(()=>{location.assign(a)});return t("div",{className:"bg-[var(--color-surface-base)] text-[var(--color-text-primary)] flex items-center justify-center py-16",children:l("div",{className:"text-center px-6",children:[t("h1",{className:"text-lg font-medium mt-4 mb-1",children:o}),e&&t("p",{className:"text-[var(--color-text-secondary)] text-sm",children:e}),t("button",{type:"button",onClick:r,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:i})]})})}c(m,"Unauthorized");export{m as Unauthorized};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/Unauthorized.tsx"],
4
4
  "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 /**\n The heading. Required: this is the page's only `h1`.\n */\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 /**\n The sign-in button's label. Required.\n */\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 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"],
5
- "mappings": "kDAAA,OAAS,kCAAAA,MAAsC,iBAiD/C,SAASC,EAAa,CAAE,MAAAC,EAAO,QAAAC,EAAS,YAAAC,EAAa,eAAAC,CAAc,EAA+B,CAChG,MAAMC,EACJD,IACC,IAAW,CACV,SAAS,OAAOL,CAA8B,CAChD,GAEF,OACEO,EAAA,MAAA,CAAK,UAAU,yGAAwG,SACrHC,EAAA,MAAA,CAAK,UAAU,mBAAkB,SAAA,CAC/BD,EAAA,KAAA,CAAI,UAAU,gCAA+B,SAAEL,CAAK,CAAA,EACnDC,GAAWI,EAAA,IAAA,CAAG,UAAU,6CAA4C,SAAEJ,CAAO,CAAA,EAC9EI,EAAA,SAAA,CACE,KAAK,SACL,QAASD,EACT,UAAU,gTAA+S,SAExTF,CAAW,CAAA,CACL,CAAA,CAAA,CACL,CAAA,CAGZ",
6
- "names": ["ZERO_TRUST_AUTHENTICATION_PATH", "Unauthorized", "title", "message", "actionLabel", "onAuthenticate", "authenticate", "_jsx", "_jsxs"]
5
+ "mappings": "iIAAA,OAAS,kCAAAA,MAAsC,iBAiD/C,SAASC,EAAa,CAAE,MAAAC,EAAO,QAAAC,EAAS,YAAAC,EAAa,eAAAC,CAAc,EAA+B,CAChG,MAAMC,EACJD,IACC,IAAW,CACV,SAAS,OAAOL,CAA8B,CAChD,GAEF,OACEO,EAAA,MAAA,CAAK,UAAU,yGAAwG,SACrHC,EAAA,MAAA,CAAK,UAAU,mBAAkB,SAAA,CAC/BD,EAAA,KAAA,CAAI,UAAU,gCAA+B,SAAEL,CAAK,CAAA,EACnDC,GAAWI,EAAA,IAAA,CAAG,UAAU,6CAA4C,SAAEJ,CAAO,CAAA,EAC9EI,EAAA,SAAA,CACE,KAAK,SACL,QAASD,EACT,UAAU,gTAA+S,SAExTF,CAAW,CAAA,CACL,CAAA,CAAA,CACL,CAAA,CAGZ,CAtBSK,EAAAR,EAAA",
6
+ "names": ["ZERO_TRUST_AUTHENTICATION_PATH", "Unauthorized", "title", "message", "actionLabel", "onAuthenticate", "authenticate", "_jsx", "_jsxs", "__name"]
7
7
  }
package/dist/api.js CHANGED
@@ -1 +1 @@
1
- import{BadGatewayError as $,BadRequestError as A,ConflictError as C,ForbiddenError as O,InternalServerError as H,MethodNotAllowedError as P,NotFoundError as M,NotImplementedError as N,PayloadTooLargeError as U,PreconditionFailedError as x,RateLimitedError as j,ServiceError as m,ServiceUnavailableError as L,UnauthorizedError as _,UnsupportedMediaTypeError as F}from"@rexezuge/errors";const S=500,T={400:A,401:_,403:O,404:M,405:P,409:C,412:x,413:U,415:F,429:j,500:H,501:N,502:$,503:L};class g extends m{constructor(n,u,r){super(n,r??`HttpStatus${n}`,u)}}function i(e){return typeof e=="string"&&e.trim()!==""?e:null}function h(e,n){return e.length>n?`${e.slice(0,n)}\u2026`:e}const J=/[\u0000-\u001F\u007F]/;function q(e,n){return e.length===0||e.length>n||e.includes("<")?!1:!J.test(e)}function B(e,n,u){if(typeof e=="string"){const t=e.trim();return{message:t===""?null:h(t,u),type:null}}if(typeof e!="object"||e===null)return{message:null,type:null};const r=e,s=typeof r.error=="object"&&r.error!==null?r.error:null,c=i(r.Exception?.Type)??(typeof r.error=="string"?i(r.error):null)??i(s?.code)??i(r.code)??null,f=i(r.Exception?.Message)??i(r.message)??(typeof r.error=="string"?i(r.error):null)??i(s?.message)??null;return f!==null?{message:h(f,u),type:c}:c!==null?{message:`${c} (HTTP ${n})`,type:c}:{message:null,type:null}}function G(e,n,u){const r=e.trim();if(r==="")return{message:null,type:null};try{return B(JSON.parse(r),n,u)}catch{return{message:q(r,u)?h(r,u):null,type:null}}}function v(e,n){const u=new Headers(e);if(n===void 0)return u;for(const[r,s]of new Headers(n))u.set(r,s);return u}function I(e){return Array.isArray(e)}function b(e){const n=new URLSearchParams;for(const[r,s]of Object.entries(e))if(!(s==null||s==="")){if(I(s)){for(const c of s)c!=null&&c!==""&&n.append(r,String(c));continue}n.set(r,String(s))}const u=n.toString();return u===""?"":`?${u}`}function Q(e,n={}){const u=n.baseUrl??"",r=n.maxErrorMessageLength??S;async function s(t,o={}){const a=(o.method??"GET").toUpperCase(),l=`${u}${t}`,p=o.body!==void 0,d=v(n.headers,o.headers);d.has("Accept")||d.set("Accept","application/json"),p&&!d.has("Content-Type")&&d.set("Content-Type","application/json");const y={method:a,headers:d};n.credentials!==void 0&&(y.credentials=n.credentials),p&&(y.body=JSON.stringify(o.body)),o.signal!==void 0&&o.signal!==null&&(y.signal=o.signal);const w=`${a} ${l}`;let E;try{E=await e(l,y)}catch(R){throw m.from(R)}if(!E.ok)throw await c(E);return f(E,w)}async function c(t){let o="";try{o=await t.text()}catch{}const a=G(o,t.status,r);if(Object.hasOwn(T,t.status)){const l=T[t.status];return new l(a.message??void 0)}return new g(t.status,a.message??`Request failed with status ${t.status}.`,a.type)}async function f(t,o){if(t.status===204)return;let a;try{a=await t.text()}catch(l){throw m.from(l)}if(a.trim()!=="")try{return JSON.parse(a)}catch{throw new g(t.status,`Malformed response body: ${o}`,null)}}return{request:s,get:async(t,o)=>s(`${t}${o===void 0?"":b(o)}`),post:async(t,o)=>s(t,{method:"POST",body:o}),put:async(t,o)=>s(t,{method:"PUT",body:o}),patch:async(t,o)=>s(t,{method:"PATCH",body:o}),delete:async(t,o)=>s(t,{method:"DELETE",body:o})}}export{g as HttpStatusError,S as MAX_ERROR_MESSAGE_LENGTH,b as buildQuery,Q as createApiClient};
1
+ var A=Object.defineProperty;var s=(e,r)=>A(e,"name",{value:r,configurable:!0});import{BadGatewayError as C,BadRequestError as O,ConflictError as H,ForbiddenError as P,InternalServerError as M,MethodNotAllowedError as N,NotFoundError as U,NotImplementedError as x,PayloadTooLargeError as j,PreconditionFailedError as L,RateLimitedError as _,ServiceError as g,ServiceUnavailableError as F,UnauthorizedError as J,UnsupportedMediaTypeError as q}from"@rexezuge/errors";const T=500,b={400:O,401:J,403:P,404:U,405:N,409:H,412:L,413:j,415:q,429:_,500:M,501:x,502:C,503:F};class h extends g{static{s(this,"HttpStatusError")}constructor(r,c,t){super(r,t??`HttpStatus${r}`,c)}}function l(e){return typeof e=="string"&&e.trim()!==""?e:null}s(l,"readString");function p(e,r){return e.length>r?`${e.slice(0,r)}\u2026`:e}s(p,"truncate");const B=/[\u0000-\u001F\u007F]/;function G(e,r){return e.length===0||e.length>r||e.includes("<")?!1:!B.test(e)}s(G,"isProbablyProse");function v(e,r,c){if(typeof e=="string"){const n=e.trim();return{message:n===""?null:p(n,c),type:null}}if(typeof e!="object"||e===null)return{message:null,type:null};const t=e,u=typeof t.error=="object"&&t.error!==null?t.error:null,a=l(t.Exception?.Type)??(typeof t.error=="string"?l(t.error):null)??l(u?.code)??l(t.code)??null,y=l(t.Exception?.Message)??l(t.message)??(typeof t.error=="string"?l(t.error):null)??l(u?.message)??null;return y!==null?{message:p(y,c),type:a}:a!==null?{message:`${a} (HTTP ${r})`,type:a}:{message:null,type:null}}s(v,"decodeJsonError");function I(e,r,c){const t=e.trim();if(t==="")return{message:null,type:null};try{return v(JSON.parse(t),r,c)}catch{return{message:G(t,c)?p(t,c):null,type:null}}}s(I,"decodeErrorBody");function Q(e,r){const c=new Headers(e);if(r===void 0)return c;for(const[t,u]of new Headers(r))c.set(t,u);return c}s(Q,"mergeHeaders");function k(e){return Array.isArray(e)}s(k,"isQueryList");function w(e){const r=new URLSearchParams;for(const[t,u]of Object.entries(e))if(!(u==null||u==="")){if(k(u)){for(const a of u)a!=null&&a!==""&&r.append(t,String(a));continue}r.set(t,String(u))}const c=r.toString();return c===""?"":`?${c}`}s(w,"buildQuery");function z(e,r={}){const c=r.baseUrl??"",t=r.maxErrorMessageLength??T;async function u(n,o={}){const i=(o.method??"GET").toUpperCase(),d=`${c}${n}`,S=o.body!==void 0,f=Q(r.headers,o.headers);f.has("Accept")||f.set("Accept","application/json"),S&&!f.has("Content-Type")&&f.set("Content-Type","application/json");const E={method:i,headers:f};r.credentials!==void 0&&(E.credentials=r.credentials),S&&(E.body=JSON.stringify(o.body)),o.signal!==void 0&&o.signal!==null&&(E.signal=o.signal);const R=`${i} ${d}`;let m;try{m=await e(d,E)}catch($){throw g.from($)}if(!m.ok)throw await a(m);return y(m,R)}s(u,"request");async function a(n){let o="";try{o=await n.text()}catch{}const i=I(o,n.status,t);if(Object.hasOwn(b,n.status)){const d=b[n.status];return new d(i.message??void 0)}return new h(n.status,i.message??`Request failed with status ${n.status}.`,i.type)}s(a,"toServiceError");async function y(n,o){if(n.status===204)return;let i;try{i=await n.text()}catch(d){throw g.from(d)}if(i.trim()!=="")try{return JSON.parse(i)}catch{throw new h(n.status,`Malformed response body: ${o}`,null)}}return s(y,"readJson"),{request:u,get:s(async(n,o)=>u(`${n}${o===void 0?"":w(o)}`),"get"),post:s(async(n,o)=>u(n,{method:"POST",body:o}),"post"),put:s(async(n,o)=>u(n,{method:"PUT",body:o}),"put"),patch:s(async(n,o)=>u(n,{method:"PATCH",body:o}),"patch"),delete:s(async(n,o)=>u(n,{method:"DELETE",body:o}),"delete")}}s(z,"createApiClient");export{h as HttpStatusError,T as MAX_ERROR_MESSAGE_LENGTH,w as buildQuery,z as createApiClient};
package/dist/api.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/api.ts"],
4
4
  "sourcesContent": ["import {\n BadGatewayError,\n BadRequestError,\n ConflictError,\n ForbiddenError,\n InternalServerError,\n MethodNotAllowedError,\n NotFoundError,\n NotImplementedError,\n PayloadTooLargeError,\n PreconditionFailedError,\n RateLimitedError,\n ServiceError,\n ServiceUnavailableError,\n UnauthorizedError,\n UnsupportedMediaTypeError,\n} from '@rexezuge/errors';\n\n/**\n * The SPA's request path.\n *\n * ## Provenance\n *\n * `lib/api.ts` in **CalDAV-Bridge**, **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git**, **Edge-Sonic**, **Mail-Otter** and **AWS-AccessBridge** — seven\n * copies that all drift on the same three decisions, settled here as follows.\n *\n * **1. Error model.** Six of the seven define a private `BackendError`\n * (`{ message, errorType, status }`) and hand-roll the status→branch mapping at\n * every call site; AWS defines `ApiError` (`{ status, message }`) plus an\n * `ApiResult{ok,status,data,error}` shape that its own guide records as\n * abandoned — every admin tab bypassed it, which is how nine of its seventeen\n * functions ended up with no caller. The kit replaces both with the family\n * taxonomy: every rejection is a `ServiceError`, so `error.status`,\n * `error.type`, `error.retryable` and `instanceof ServiceError` are available\n * without a per-repo error class, and `ServiceError.from` covers the\n * transport-level failures the private classes swallowed.\n *\n * **2. Error body decoding.** Converged from the three variants that exist:\n *\n * - The **AWS envelope** `{ Exception: { Type, Message } }`, read first in all\n * copies.\n * - The **legacy** `{ error, message }` shape, where Durable-DAV also reads a\n * string `error` as the *type* — otherwise a legacy body produced a correct\n * message and a `null` type, which sent it through the generic fallback and\n * lost the specific wording.\n * - **Edge-Sonic's prose test** for a non-JSON body: an Access login page or a\n * proxy's HTML error page is not a message an operator can act on, so markup\n * is reported as absent rather than quoted into a notice bar. Short,\n * single-line, tag-free text *is* surfaced, truncated.\n * - **Truncation** at 500 characters, from every copy that has one: an\n * unbounded error string from a proxy page is a rendering hazard.\n * - **`text()` then `JSON.parse`, never `json()` with a `text()` fallback** —\n * Edge-Sonic's comment records why the old shape cannot work: `json()`\n * consumes the body stream before it fails to parse, so the second read\n * returned `''` and the \"not JSON\" branch was unreachable.\n *\n * **3. Empty bodies.** Durable-DAV's fix is the one kept: a `204`, and an empty\n * body from an edge error page, resolve to `undefined` rather than throwing a\n * `SyntaxError` — which used to report a generic failure for an operation that\n * had actually succeeded (credential revoke). AWS-AccessBridge resolved the same\n * case to `{}`; `undefined` is the honest answer for \"there is no body\".\n *\n * ## What is deliberately not here\n *\n * - **The D1 session bookmark** (`x-d1-bookmark`, CalDAV-Bridge and\n * Mail-Otter). It is module state threading a D1 replica pin through every\n * `/user/*` request; the kit has no D1 client, so the header policy stays\n * with the repos that own the binding.\n * - **`apiAuthedFirst`** (Edge-Git) — a public-fallback policy with\n * fail-closed 401/403/404 handling, specific to that app's two-surface API.\n * - **WebDAV `readDav`** (Durable-DAV, Durable-DAV-Router) — it accepts `207\n * Multi-Status` as success, which is a WebDAV rule, not an HTTP rule. A\n * consumer needing XML calls `client.request` and reads `response.text()`\n * itself.\n * - **The `/user` base path.** Edge-Sonic bakes it in; the others pass full\n * paths. `baseUrl` is an option here, defaulting to empty, so the caller\n * decides.\n */\n\n/**\nThe `fetch` shape a client is built on: same-origin by default, no token in JavaScript.\n*/\ntype FetchFn = (input: string, init?: RequestInit) => Promise<Response>;\n\n/**\nA query-string value. `null`/`undefined`/`''` are omitted, as in every copy.\n*/\ntype QueryValue = string | number | boolean | null | undefined;\n\ntype QueryParams = Record<string, QueryValue | readonly QueryValue[]>;\n\ninterface ApiRequestInit {\n method?: string;\n /**\n Serialized as JSON with a matching `Content-Type`.\n */\n body?: unknown;\n headers?: HeadersInit;\n signal?: AbortSignal | null;\n}\n\ninterface CreateApiClientOptions {\n /**\n Prepended to every path; `''` (the default) sends the path as given.\n */\n baseUrl?: string;\n /**\n Headers merged into every request; a per-request header wins over these.\n */\n headers?: HeadersInit;\n /**\n Passed through to `fetch`; omitted leaves the browser default.\n */\n credentials?: RequestCredentials;\n /**\n Truncation limit for a server-provided error message. Defaults to 500.\n */\n maxErrorMessageLength?: number;\n}\n\ninterface ApiClient {\n /**\n One request. Throws a `ServiceError`; resolves to the parsed JSON body.\n */\n request<T>(path: string, init?: ApiRequestInit): Promise<T>;\n get<T>(path: string, params?: QueryParams): Promise<T>;\n post<T>(path: string, body?: unknown): Promise<T>;\n put<T>(path: string, body?: unknown): Promise<T>;\n patch<T>(path: string, body?: unknown): Promise<T>;\n delete<T>(path: string, body?: unknown): Promise<T>;\n}\n\n/**\nDefault truncation for a server-provided message.\n*/\nconst MAX_ERROR_MESSAGE_LENGTH = 500;\n\n/**\n * Statuses the family taxonomy has a class for, mapped to it.\n *\n * The map is keyed by status rather than by the server's `Exception.Type`\n * because the status is the fact that survives a rolling deploy: a body from an\n * older Worker build still carries today's status, while a `Type` may be\n * spelled either way.\n */\nconst HTTP_ERROR_CLASSES: Readonly<Record<number, new (message?: string) => ServiceError>> = {\n 400: BadRequestError,\n 401: UnauthorizedError,\n 403: ForbiddenError,\n 404: NotFoundError,\n 405: MethodNotAllowedError,\n 409: ConflictError,\n 412: PreconditionFailedError,\n 413: PayloadTooLargeError,\n 415: UnsupportedMediaTypeError,\n 429: RateLimitedError,\n 500: InternalServerError,\n 501: NotImplementedError,\n 502: BadGatewayError,\n 503: ServiceUnavailableError,\n};\n\n/**\n * A failure whose only fact is its HTTP status: a status the catalog has no\n * class for (451, 418, a proxy's own 5xx), or a 2xx body that is not JSON.\n *\n * It exists so the thrown value is *always* a `ServiceError` — a caller\n * branching on `instanceof ServiceError` does not have to know which statuses\n * the catalog happens to cover.\n */\nclass HttpStatusError extends ServiceError {\n constructor(status: number, message: string, type: string | null) {\n super(status, type ?? `HttpStatus${status}`, message);\n }\n}\n\ninterface DecodedErrorBody {\n /**\n What the server said, or `null` when it said nothing usable.\n */\n message: string | null;\n /**\n The server's machine-readable code, when it sent one.\n */\n type: string | null;\n}\n\nfunction readString(value: unknown): string | null {\n return typeof value === 'string' && value.trim() !== '' ? value : null;\n}\n\nfunction truncate(value: string, maxLength: number): string {\n return value.length > maxLength ? `${value.slice(0, maxLength)}…` : value;\n}\n\n/**\nRejects control characters: that is what separates text from a binary or a document.\n*/\n// eslint-disable-next-line no-control-regex -- rejecting control characters IS the test\nconst CONTROL_CHARACTER = /[\\u0000-\\u001F\\u007F]/;\n\n/**\n * Whether a non-JSON error body is text worth showing rather than markup or a\n * blob. Deliberately conservative: the cost of wrongly refusing is the generic\n * status sentence, and the cost of wrongly accepting is an HTML page in a\n * notice bar.\n */\nfunction isProbablyProse(raw: string, maxLength: number): boolean {\n if (raw.length === 0 || raw.length > maxLength || raw.includes('<')) {\n return false;\n }\n return !CONTROL_CHARACTER.test(raw);\n}\n\nfunction decodeJsonError(payload: unknown, status: number, maxLength: number): DecodedErrorBody {\n if (typeof payload === 'string') {\n const message = payload.trim();\n return { message: message === '' ? null : truncate(message, maxLength), type: null };\n }\n if (typeof payload !== 'object' || payload === null) {\n return { message: null, type: null };\n }\n // Three dialects, newest first: the AWS envelope, the unified `{error:\n // {code,message}}` object, and the legacy flat `{error, message}`.\n const envelope = payload as {\n Exception?: { Type?: unknown; Message?: unknown };\n error?: unknown;\n message?: unknown;\n code?: unknown;\n };\n const nestedError =\n typeof envelope.error === 'object' && envelope.error !== null ? (envelope.error as { message?: unknown; code?: unknown }) : null;\n const type =\n readString(envelope.Exception?.Type) ??\n (typeof envelope.error === 'string' ? readString(envelope.error) : null) ??\n readString(nestedError?.code) ??\n readString(envelope.code) ??\n null;\n const message =\n readString(envelope.Exception?.Message) ??\n readString(envelope.message) ??\n (typeof envelope.error === 'string' ? readString(envelope.error) : null) ??\n readString(nestedError?.message) ??\n null;\n if (message !== null) {\n return { message: truncate(message, maxLength), type };\n }\n if (type !== null) {\n // The server named the failure but gave no sentence for it.\n return { message: `${type} (HTTP ${status})`, type };\n }\n return { message: null, type: null };\n}\n\nfunction decodeErrorBody(text: string, status: number, maxLength: number): DecodedErrorBody {\n const trimmed = text.trim();\n if (trimmed === '') {\n return { message: null, type: null };\n }\n try {\n return decodeJsonError(JSON.parse(trimmed) as unknown, status, maxLength);\n } catch {\n return { message: isProbablyProse(trimmed, maxLength) ? truncate(trimmed, maxLength) : null, type: null };\n }\n}\n\nfunction mergeHeaders(base: HeadersInit | undefined, overrides?: HeadersInit): Headers {\n const headers = new Headers(base);\n if (overrides === undefined) {\n return headers;\n }\n for (const [name, value] of new Headers(overrides)) {\n headers.set(name, value);\n }\n return headers;\n}\n\nfunction isQueryList(value: QueryValue | readonly QueryValue[]): value is readonly QueryValue[] {\n return Array.isArray(value);\n}\n\n/**\n * Builds a query string, with the leading `?` and without it when empty.\n *\n * `null`, `undefined` and `''` are dropped rather than sent as empty\n * parameters, and an array value repeats the key — both as in the copies this\n * replaces.\n */\nfunction buildQuery(params: QueryParams): string {\n const search = new URLSearchParams();\n for (const [name, value] of Object.entries(params)) {\n if (value === undefined || value === null || value === '') {\n continue;\n }\n if (isQueryList(value)) {\n for (const entry of value) {\n if (entry !== undefined && entry !== null && entry !== '') {\n search.append(name, String(entry));\n }\n }\n continue;\n }\n search.set(name, String(value));\n }\n const encoded = search.toString();\n return encoded === '' ? '' : `?${encoded}`;\n}\n\n/**\n * Builds a client over a `fetch` implementation.\n *\n * ```ts\n * const api = createApiClient(fetch, { baseUrl: '/user' });\n * const me = await api.get<CurrentUser>('/me');\n * ```\n *\n * The `fetchFn` parameter is what makes this testable without a network and\n * swappable for an instrumented wrapper; in a browser it is the global `fetch`.\n * Memoize the client (a module constant, or `useMemo`) — `useCurrentUser`\n * deliberately does not re-fetch when a new client instance appears, but a new\n * instance per render still churns.\n */\nfunction createApiClient(fetchFn: FetchFn, options: CreateApiClientOptions = {}): ApiClient {\n const baseUrl = options.baseUrl ?? '';\n const maxErrorMessageLength = options.maxErrorMessageLength ?? MAX_ERROR_MESSAGE_LENGTH;\n\n async function request<T>(path: string, init: ApiRequestInit = {}): Promise<T> {\n const method = (init.method ?? 'GET').toUpperCase();\n const url = `${baseUrl}${path}`;\n const hasBody = init.body !== undefined;\n const headers = mergeHeaders(options.headers, init.headers);\n // Same-origin only, and no token in JavaScript: the Cloudflare Access\n // session cookie rides along under the default credentials, and there is no\n // place for a token to leak to. Both defaults yield to an explicit header\n // — a consumer that wants XML passes its own `Accept`.\n if (!headers.has('Accept')) {\n headers.set('Accept', 'application/json');\n }\n if (hasBody && !headers.has('Content-Type')) {\n headers.set('Content-Type', 'application/json');\n }\n const requestInit: RequestInit = { method, headers };\n if (options.credentials !== undefined) {\n requestInit.credentials = options.credentials;\n }\n if (hasBody) {\n requestInit.body = JSON.stringify(init.body);\n }\n if (init.signal !== undefined && init.signal !== null) {\n requestInit.signal = init.signal;\n }\n\n const context = `${method} ${url}`;\n let response: Response;\n try {\n response = await fetchFn(url, requestInit);\n } catch (cause) {\n // The transport never answered — offline, DNS, CORS, an aborted signal.\n // There is no status to report, so the failure normalizes through\n // `ServiceError.from` like any other unknown throw. A caller that cancels\n // its own request therefore sees a 500-shaped error too; the taxonomy has\n // no \"aborted\" class, and swallowing it here would hide real transport\n // failures. A caller that cancels should not surface the rejection.\n throw ServiceError.from(cause);\n }\n if (!response.ok) {\n throw await toServiceError(response);\n }\n return readJson<T>(response, context);\n }\n\n async function toServiceError(response: Response): Promise<ServiceError> {\n let text = '';\n try {\n text = await response.text();\n } catch {\n // The body could not be read at all — a reset after the headers. The\n // status is still the one true thing about the request, and the catalog\n // default message says more than anything this could invent.\n }\n const decoded = decodeErrorBody(text, response.status, maxErrorMessageLength);\n if (Object.hasOwn(HTTP_ERROR_CLASSES, response.status)) {\n const ErrorClass = HTTP_ERROR_CLASSES[response.status];\n // A `null` message leaves the catalog's default in place, which is a\n // better sentence than anything the client could invent.\n return new ErrorClass(decoded.message ?? undefined);\n }\n return new HttpStatusError(response.status, decoded.message ?? `Request failed with status ${response.status}.`, decoded.type);\n }\n\n async function readJson<T>(response: Response, context: string): Promise<T> {\n if (response.status === 204) {\n return undefined as T;\n }\n let text: string;\n try {\n text = await response.text();\n } catch (cause) {\n throw ServiceError.from(cause);\n }\n if (text.trim() === '') {\n return undefined as T;\n }\n try {\n return JSON.parse(text) as T;\n } catch {\n // A 2xx body that is not JSON is an HTML error page from a proxy. It must\n // surface as a ServiceError, not a SyntaxError, so the caller's error\n // handling has one shape to recognize.\n throw new HttpStatusError(response.status, `Malformed response body: ${context}`, null);\n }\n }\n\n return {\n request,\n get: async <T>(path: string, params?: QueryParams): Promise<T> =>\n request<T>(`${path}${params === undefined ? '' : buildQuery(params)}`),\n post: async <T>(path: string, body?: unknown): Promise<T> => request<T>(path, { method: 'POST', body }),\n put: async <T>(path: string, body?: unknown): Promise<T> => request<T>(path, { method: 'PUT', body }),\n patch: async <T>(path: string, body?: unknown): Promise<T> => request<T>(path, { method: 'PATCH', body }),\n delete: async <T>(path: string, body?: unknown): Promise<T> => request<T>(path, { method: 'DELETE', body }),\n };\n}\n\nexport { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH };\nexport type { ApiClient, ApiRequestInit, CreateApiClientOptions, FetchFn, QueryParams, QueryValue };\n"],
5
- "mappings": "AAAA,OACE,mBAAAA,EACA,mBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,uBAAAC,EACA,yBAAAC,EACA,iBAAAC,EACA,uBAAAC,EACA,wBAAAC,EACA,2BAAAC,EACA,oBAAAC,EACA,gBAAAC,EACA,2BAAAC,EACA,qBAAAC,EACA,6BAAAC,MACK,mBAwHP,MAAMC,EAA2B,IAU3BC,EAAuF,CAC3F,IAAKf,EACL,IAAKY,EACL,IAAKV,EACL,IAAKG,EACL,IAAKD,EACL,IAAKH,EACL,IAAKO,EACL,IAAKD,EACL,IAAKM,EACL,IAAKJ,EACL,IAAKN,EACL,IAAKG,EACL,IAAKP,EACL,IAAKY,GAWP,MAAMK,UAAwBN,CAAY,CACxC,YAAYO,EAAgBC,EAAiBC,EAAmB,CAC9D,MAAMF,EAAQE,GAAQ,aAAaF,CAAM,GAAIC,CAAO,CACtD,EAcF,SAASE,EAAWC,EAAc,CAChC,OAAO,OAAOA,GAAU,UAAYA,EAAM,KAAI,IAAO,GAAKA,EAAQ,IACpE,CAEA,SAASC,EAASD,EAAeE,EAAiB,CAChD,OAAOF,EAAM,OAASE,EAAY,GAAGF,EAAM,MAAM,EAAGE,CAAS,CAAC,SAAMF,CACtE,CAMA,MAAMG,EAAoB,wBAQ1B,SAASC,EAAgBC,EAAaH,EAAiB,CACrD,OAAIG,EAAI,SAAW,GAAKA,EAAI,OAASH,GAAaG,EAAI,SAAS,GAAG,EACzD,GAEF,CAACF,EAAkB,KAAKE,CAAG,CACpC,CAEA,SAASC,EAAgBC,EAAkBX,EAAgBM,EAAiB,CAC1E,GAAI,OAAOK,GAAY,SAAU,CAC/B,MAA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AKD,EAAWC,CAAM,CAAC,EAAE,EACvE,KAAM,MAAUU,EAAca,IAA+Bd,EAAWC,EAAM,CAAE,OAAQ,OAAQ,KAAAa,CAAI,CAAE,EACtG,IAAK,MAAUb,EAAca,IAA+Bd,EAAWC,EAAM,CAAE,OAAQ,MAAO,KAAAa,CAAI,CAAE,EACpG,MAAO,MAAUb,EAAca,IAA+Bd,EAAWC,EAAM,CAAE,OAAQ,QAAS,KAAAa,CAAI,CAAE,EACxG,OAAQ,MAAUb,EAAca,IAA+Bd,EAAWC,EAAM,CAAE,OAAQ,SAAU,KAAAa,CAAI,CAAE,EAE9G",
6
- "names": ["BadGatewayError", "BadRequestError", "ConflictError", "ForbiddenError", "InternalServerError", "MethodNotAllowedError", "NotFoundError", "NotImplementedError", "PayloadTooLargeError", "PreconditionFailedError", "RateLimitedError", "ServiceError", "ServiceUnavailableError", "UnauthorizedError", "UnsupportedMediaTypeError", "MAX_ERROR_MESSAGE_LENGTH", "HTTP_ERROR_CLASSES", "HttpStatusError", "status", "message", "type", "readString", "value", "truncate", "maxLength", "CONTROL_CHARACTER", "isProbablyProse", "raw", "decodeJsonError", "payload", "envelope", "nestedError", "decodeErrorBody", "text", "trimmed", "mergeHeaders", "base", "overrides", "headers", "name", "isQueryList", "buildQuery", "params", "search", "entry", "encoded", "createApiClient", "fetchFn", "options", "baseUrl", "maxErrorMessageLength", "request", "path", "init", "method", "url", "hasBody", "requestInit", "context", "response", "cause", "toServiceError", "readJson", "decoded", "ErrorClass", "body"]
5
+ "mappings": "+EAAA,OACE,mBAAAA,EACA,mBAAAC,EACA,iBAAAC,EACA,kBAAAC,EACA,uBAAAC,EACA,yBAAAC,EACA,iBAAAC,EACA,uBAAAC,EACA,wBAAAC,EACA,2BAAAC,EACA,oBAAAC,EACA,gBAAAC,EACA,2BAAAC,EACA,qBAAAC,EACA,6BAAAC,MACK,mBAwHP,MAAMC,EAA2B,IAU3BC,EAAuF,CAC3F,IAAKf,EACL,IAAKY,EACL,IAAK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AQ,MAAO,KAAAa,CAAI,CAAE,EAA/F,OACL,MAAOhD,EAAA,MAAUmC,EAAca,IAA+Bd,EAAWC,EAAM,CAAE,OAAQ,QAAS,KAAAa,CAAI,CAAE,EAAjG,SACP,OAAQhD,EAAA,MAAUmC,EAAca,IAA+Bd,EAAWC,EAAM,CAAE,OAAQ,SAAU,KAAAa,CAAI,CAAE,EAAlG,UAEZ,CApGShD,EAAA6B,EAAA",
6
+ "names": ["BadGatewayError", "BadRequestError", "ConflictError", "ForbiddenError", "InternalServerError", "MethodNotAllowedError", "NotFoundError", "NotImplementedError", "PayloadTooLargeError", "PreconditionFailedError", "RateLimitedError", "ServiceError", "ServiceUnavailableError", "UnauthorizedError", "UnsupportedMediaTypeError", "MAX_ERROR_MESSAGE_LENGTH", "HTTP_ERROR_CLASSES", "HttpStatusError", "__name", "status", "message", "type", "readString", "value", "truncate", "maxLength", "CONTROL_CHARACTER", "isProbablyProse", "raw", "decodeJsonError", "payload", "envelope", "nestedError", "decodeErrorBody", "text", "trimmed", "mergeHeaders", "base", "overrides", "headers", "name", "isQueryList", "buildQuery", "params", "search", "entry", "encoded", "createApiClient", "fetchFn", "options", "baseUrl", "maxErrorMessageLength", "request", "path", "init", "method", "url", "hasBody", "requestInit", "context", "response", "cause", "toServiceError", "readJson", "decoded", "ErrorClass", "body"]
7
7
  }
@@ -1 +1 @@
1
- import{useCallback as n,useEffect as i,useRef as l,useState as s}from"react";import{COPY_FEEDBACK_TIMEOUT_MS as a}from"./constants.js";function f(){const[o,r]=s(!1),e=l(null);i(()=>()=>{e.current!==null&&clearTimeout(e.current)},[]);const u=n(c=>{const t=globalThis.navigator?.clipboard;t&&t.writeText(c).then(()=>{r(!0),e.current!==null&&clearTimeout(e.current),e.current=setTimeout(()=>{e.current=null,r(!1)},a)}).catch(()=>{})},[]);return{copied:o,copy:u}}export{f as useCopyToClipboard};
1
+ var i=Object.defineProperty;var u=(t,r)=>i(t,"name",{value:r,configurable:!0});import{useCallback as l,useEffect as s,useRef as a,useState as f}from"react";import{COPY_FEEDBACK_TIMEOUT_MS as p}from"./constants.js";function T(){const[t,r]=f(!1),e=a(null);s(()=>()=>{e.current!==null&&clearTimeout(e.current)},[]);const c=l(n=>{const o=globalThis.navigator?.clipboard;o&&o.writeText(n).then(()=>{r(!0),e.current!==null&&clearTimeout(e.current),e.current=setTimeout(()=>{e.current=null,r(!1)},p)}).catch(()=>{})},[]);return{copied:t,copy:c}}u(T,"useCopyToClipboard");export{T as useCopyToClipboard};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/useCopyToClipboard.ts"],
4
4
  "sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { COPY_FEEDBACK_TIMEOUT_MS } from './constants.ts';\n\n/**\n * Copy text to the clipboard, reporting success only when it happened.\n *\n * ## Provenance\n *\n * `hooks/useCopyToClipboard.ts` in **Durable-DAV** — the one copy that had\n * solved the two failures the others carried. The other three handlers were\n * inlined into `ReadOnlyField` (Edge-Git, Mail-Otter, Durable-DAV-Router) and\n * `TypeToConfirmModal`, and were byte-identical to each other.\n *\n * ## The two live bugs this converges away\n *\n * 1. **`navigator.clipboard` is absent in an insecure context.** A plain\n * `navigator.clipboard.writeText` throws *synchronously* there, so the\n * handler dies before setting state. Where it was guarded with\n * `if (clipboard)`, the guard fell through to `setCopied(true)` anyway and\n * showed a checkmark for a copy that never happened.\n * 2. **The write is a promise that rejects on a denied permission.** Awaiting\n * it is not enough; the rejection has to be handled, or it surfaces as an\n * unhandled rejection *and* the checkmark still appears.\n *\n * That second case is why this is a hook rather than a helper. The honest\n * answer — \"nothing was copied, so there is nothing to undo\" — is expressed by\n * `copied` simply never becoming true, which is state a helper function cannot\n * hold.\n *\n * Every call site in the family is a secret reveal: a bucket credential's\n * copy-once password, a resource name typed to confirm a destructive action.\n * A false success sends the operator away believing they have something they do\n * not.\n *\n * ## Timer handling\n *\n * The reset timer is a ref and is cleared on unmount. Local `setTimeout` handles\n * in the inlined copies leaked both ways: a modal closed inside the feedback\n * window set state on an unmounted component, and repeated clicks each replaced\n * the timer without cancelling the previous one, so an early timer could clear\n * the checkmark while a later copy was still pending.\n */\n\ninterface UseCopyToClipboardResult {\n /**\n * True only after a write that actually resolved.\n *\n * Never optimistically set: a denied permission or an insecure context leaves\n * this `false`, which is the answer that matters — there is nothing to undo.\n */\n copied: boolean;\n /**\n Writes `text`, or does nothing if the clipboard is unavailable.\n */\n copy: (text: string) => void;\n}\n\nfunction useCopyToClipboard(): UseCopyToClipboardResult {\n const [copied, setCopied] = useState(false);\n const resetTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(\n () => () => {\n if (resetTimer.current !== null) clearTimeout(resetTimer.current);\n },\n [],\n );\n\n const copy = useCallback((text: string): void => {\n // Optional chaining rather than an assumption: `navigator.clipboard` is\n // genuinely absent over plain HTTP, and for a self-hosted deployment over\n // plain HTTP that is a normal configuration, not an error to surface.\n const clipboard = globalThis.navigator?.clipboard as Clipboard | undefined;\n // Nothing was copied, so there is nothing to report and nothing to undo.\n if (!clipboard) return;\n\n void clipboard\n .writeText(text)\n .then(() => {\n setCopied(true);\n // Cancel any pending reset before arming a new one. Replacing the\n // handle without clearing leaves the earlier timer live, and it can\n // clear the checkmark for a copy that is still being reported.\n if (resetTimer.current !== null) clearTimeout(resetTimer.current);\n resetTimer.current = setTimeout(() => {\n resetTimer.current = null;\n setCopied(false);\n }, COPY_FEEDBACK_TIMEOUT_MS);\n })\n // Leave `copied` false rather than flashing and clearing it: a rejection\n // means the text is still on screen and unread, so the affordance must\n // not claim otherwise.\n .catch(() => {});\n }, []);\n\n return { copied, copy };\n}\n\nexport { useCopyToClipboard };\nexport type { UseCopyToClipboardResult };\n"],
5
- "mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QACzD,OAAS,4BAAAC,MAAgC,iBAwDzC,SAASC,GAAkB,CACzB,KAAM,CAACC,EAAQC,CAAS,EAAIJ,EAAS,EAAK,EACpCK,EAAaN,EAA6C,IAAI,EAEpED,EACE,IAAM,IAAK,CACLO,EAAW,UAAY,MAAM,aAAaA,EAAW,OAAO,CAClE,EACA,CAAA,CAAE,EAGJ,MAAMC,EAAOT,EAAaU,GAAsB,CAI9C,MAAMC,EAAY,WAAW,WAAW,UAEnCA,GAEAA,EACF,UAAUD,CAAI,EACd,KAAK,IAAK,CACTH,EAAU,EAAI,EAIVC,EAAW,UAAY,MAAM,aAAaA,EAAW,OAAO,EAChEA,EAAW,QAAU,WAAW,IAAK,CACnCA,EAAW,QAAU,KACrBD,EAAU,EAAK,CACjB,EAAGH,CAAwB,CAC7B,CAAC,EAIA,MAAM,IAAK,CAAE,CAAC,CACnB,EAAG,CAAA,CAAE,EAEL,MAAO,CAAE,OAAAE,EAAQ,KAAAG,CAAI,CACvB",
6
- "names": ["useCallback", "useEffect", "useRef", "useState", "COPY_FEEDBACK_TIMEOUT_MS", "useCopyToClipboard", "copied", "setCopied", "resetTimer", "copy", "text", "clipboard"]
5
+ "mappings": "+EAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QACzD,OAAS,4BAAAC,MAAgC,iBAwDzC,SAASC,GAAkB,CACzB,KAAM,CAACC,EAAQC,CAAS,EAAIJ,EAAS,EAAK,EACpCK,EAAaN,EAA6C,IAAI,EAEpED,EACE,IAAM,IAAK,CACLO,EAAW,UAAY,MAAM,aAAaA,EAAW,OAAO,CAClE,EACA,CAAA,CAAE,EAGJ,MAAMC,EAAOT,EAAaU,GAAsB,CAI9C,MAAMC,EAAY,WAAW,WAAW,UAEnCA,GAEAA,EACF,UAAUD,CAAI,EACd,KAAK,IAAK,CACTH,EAAU,EAAI,EAIVC,EAAW,UAAY,MAAM,aAAaA,EAAW,OAAO,EAChEA,EAAW,QAAU,WAAW,IAAK,CACnCA,EAAW,QAAU,KACrBD,EAAU,EAAK,CACjB,EAAGH,CAAwB,CAC7B,CAAC,EAIA,MAAM,IAAK,CAAE,CAAC,CACnB,EAAG,CAAA,CAAE,EAEL,MAAO,CAAE,OAAAE,EAAQ,KAAAG,CAAI,CACvB,CAvCSG,EAAAP,EAAA",
6
+ "names": ["useCallback", "useEffect", "useRef", "useState", "COPY_FEEDBACK_TIMEOUT_MS", "useCopyToClipboard", "copied", "setCopied", "resetTimer", "copy", "text", "clipboard", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{useCallback as g,useEffect as c,useRef as C,useState as r}from"react";import{ServiceError as S}from"@rexezuge/errors";const f="/user/me";function p(t,{path:o=f}={}){const[a,i]=r(null),[d,s]=r(!0),[m,u]=r(null),[R,E]=r(0),l=C(t);c(()=>{l.current=t},[t]);const U=g(()=>{s(!0),E(e=>e+1)},[]);return c(()=>{let e=!1;return l.current.get(o).then(n=>{e||(i(n),u(null),s(!1))}).catch(n=>{e||(u(S.from(n)),s(!1))}),()=>{e=!0}},[o,R]),{user:a,loading:d,error:m,reload:U}}export{f as CURRENT_USER_PATH,p as useCurrentUser};
1
+ var C=Object.defineProperty;var c=(e,t)=>C(e,"name",{value:t,configurable:!0});import{useCallback as S,useEffect as f,useRef as p,useState as s}from"react";import{ServiceError as y}from"@rexezuge/errors";const a="/user/me";function K(e,{path:t=a}={}){const[i,d]=s(null),[m,n]=s(!0),[R,u]=s(null),[E,U]=s(0),l=p(e);f(()=>{l.current=e},[e]);const g=S(()=>{n(!0),U(r=>r+1)},[]);return f(()=>{let r=!1;return l.current.get(t).then(o=>{r||(d(o),u(null),n(!1))}).catch(o=>{r||(u(y.from(o)),n(!1))}),()=>{r=!0}},[t,E]),{user:i,loading:m,error:R,reload:g}}c(K,"useCurrentUser");export{a as CURRENT_USER_PATH,K as useCurrentUser};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/useCurrentUser.ts"],
4
4
  "sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { ServiceError } from '@rexezuge/errors';\nimport type { ApiClient } from './api.ts';\n\n/**\n * The signed-in account, fetched once on mount.\n *\n * ## Provenance\n *\n * `hooks/useCurrentUser.ts` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that differ on the three questions this hook exists to answer:\n *\n * 1. **Who fetches.** CalDAV-Bridge, Edge-Git, Edge-Sonic and Mail-Otter call a\n * module-level `loadCurrentUser()` from `services/userService`; Durable-DAV\n * and Durable-DAV-Router call the same helper but keep the client injectable.\n * The kit normalizes to the injectable form: the hook takes the client, so\n * nothing about the request path is baked in and a test hands it a stub.\n * 2. **What a failure means.** Durable-DAV-Router records the bug in a comment:\n * `authorized` was set to `false` for *any* failure, so a 500 or a dropped\n * connection rendered \"Sign In With Cloudflare Access\" to a caller who was\n * signed in — and the only way back was a hard reload. Its fix is a separate\n * `error` flag meaning \"we could not find out\", rendered as a retry. That is\n * the shape here: `error` carries the failure, `user` stays `null`, and the\n * caller decides what a retry looks like. A 401 is not special-cased — a 401\n * *is* an error, and a shell that renders a sign-in prompt from it should do\n * so because the app says so.\n * 3. **Effect dependencies.** Durable-DAV documents the other half of the bug:\n * the effect listed `onError` (its only dependency), `SpaApp` passed an\n * inline arrow, so the effect re-ran on every render and issued an\n * unbounded stream of `GET /user/me` from first paint. The kit takes the\n * same cure: the client is read through a ref, and the effect is keyed on\n * `reloadKey` alone. A caller can pass a fresh client every render and the\n * request count is unchanged.\n *\n * ## Normalization\n *\n * `useCurrentUser(client)` returns `{ user, loading, error, reload }`. The\n * `authorized` tri-state (`null`/`true`/`false`) is gone: `loading` already\n * distinguishes \"in flight\" from \"answered\", and `error` distinguishes\n * \"answered badly\" from \"not signed in\" — a caller that wants `authorized`\n * derives it as `loading ? null : user !== null`. `setUser` is gone too; a\n * change to the account is a refresh (`reload()`), which is what the sources\n * do at every call site anyway.\n */\n\n/**\nThe account shape a caller reads. `preferredLanguage` is what `useSpaLanguage` consumes.\n*/\ninterface CurrentUser {\n preferredLanguage?: string | null;\n}\n\ninterface UseCurrentUserOptions {\n /**\n The path to GET. Defaults to `/user/me`, the family's profile route.\n */\n path?: string;\n}\n\ninterface UseCurrentUserResult<TUser> {\n /**\n The account, or `null` until it loads (and after a failure).\n */\n user: TUser | null;\n /**\n `true` while the request is in flight, including the first one.\n */\n loading: boolean;\n /**\n The normalized failure, or `null`. A `ServiceError`, always.\n */\n error: ServiceError | null;\n /**\n Re-runs the request.\n */\n reload: () => void;\n}\n\n/**\nThe profile route every repo in the family serves.\n*/\nconst CURRENT_USER_PATH = '/user/me';\n\nfunction useCurrentUser<TUser = CurrentUser>(\n client: ApiClient,\n { path = CURRENT_USER_PATH }: Readonly<UseCurrentUserOptions> = {},\n): UseCurrentUserResult<TUser> {\n const [user, setUser] = useState<TUser | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<ServiceError | null>(null);\n const [reloadKey, setReloadKey] = useState(0);\n\n // Read through a ref so a caller's fresh client instance cannot re-run the\n // effect; refreshing is explicit, through `reload`.\n const clientRef = useRef(client);\n useEffect(() => {\n clientRef.current = client;\n }, [client]);\n\n const reload = useCallback(() => {\n // Set here, in the event, rather than in the effect below: the effect\n // adopting it would be a set-state-in-effect, and the initial `useState`\n // already covers the first load.\n setLoading(true);\n setReloadKey((key) => key + 1);\n }, []);\n\n useEffect(() => {\n let cancelled = false;\n clientRef.current\n .get<TUser>(path)\n .then((me) => {\n if (cancelled) {\n return;\n }\n setUser(me);\n setError(null);\n setLoading(false);\n })\n .catch((cause: unknown) => {\n if (cancelled) {\n return;\n }\n // Normalized here as well as in the client: a client that is not this\n // package's (`createApiClient`) may throw anything, and a hook that\n // promises a `ServiceError` should deliver one.\n setError(ServiceError.from(cause));\n setLoading(false);\n });\n return () => {\n cancelled = true;\n };\n }, [path, reloadKey]);\n\n return { user, loading, error, reload };\n}\n\nexport { CURRENT_USER_PATH, useCurrentUser };\nexport type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult };\n"],
5
- "mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QACzD,OAAS,gBAAAC,MAAoB,mBAiF7B,MAAMC,EAAoB,WAE1B,SAASC,EACPC,EACA,CAAE,KAAAC,EAAOH,CAAiB,EAAsC,CAAA,EAAE,CAElE,KAAM,CAACI,EAAMC,CAAO,EAAIP,EAAuB,IAAI,EAC7C,CAACQ,EAASC,CAAU,EAAIT,EAAS,EAAI,EACrC,CAACU,EAAOC,CAAQ,EAAIX,EAA8B,IAAI,EACtD,CAACY,EAAWC,CAAY,EAAIb,EAAS,CAAC,EAItCc,EAAYf,EAAOK,CAAM,EAC/BN,EAAU,IAAK,CACbgB,EAAU,QAAUV,CACtB,EAAG,CAACA,CAAM,CAAC,EAEX,MAAMW,EAASlB,EAAY,IAAK,CAI9BY,EAAW,EAAI,EACfI,EAAcG,GAAQA,EAAM,CAAC,CAC/B,EAAG,CAAA,CAAE,EAEL,OAAAlB,EAAU,IAAK,CACb,IAAImB,EAAY,GAChB,OAAAH,EAAU,QACP,IAAWT,CAAI,EACf,KAAMa,GAAM,CACPD,IAGJV,EAAQW,CAAE,EACVP,EAAS,IAAI,EACbF,EAAW,EAAK,EAClB,CAAC,EACA,MAAOU,GAAkB,CACpBF,IAMJN,EAASV,EAAa,KAAKkB,CAAK,CAAC,EACjCV,EAAW,EAAK,EAClB,CAAC,EACI,IAAK,CACVQ,EAAY,EACd,CACF,EAAG,CAACZ,EAAMO,CAAS,CAAC,EAEb,CAAE,KAAAN,EAAM,QAAAE,EAAS,MAAAE,EAAO,OAAAK,CAAM,CACvC",
6
- "names": ["useCallback", "useEffect", "useRef", "useState", "ServiceError", "CURRENT_USER_PATH", "useCurrentUser", "client", "path", "user", "setUser", "loading", "setLoading", "error", "setError", "reloadKey", "setReloadKey", "clientRef", "reload", "key", "cancelled", "me", "cause"]
5
+ "mappings": "+EAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QACzD,OAAS,gBAAAC,MAAoB,mBAiF7B,MAAMC,EAAoB,WAE1B,SAASC,EACPC,EACA,CAAE,KAAAC,EAAOH,CAAiB,EAAsC,CAAA,EAAE,CAElE,KAAM,CAACI,EAAMC,CAAO,EAAIP,EAAuB,IAAI,EAC7C,CAACQ,EAASC,CAAU,EAAIT,EAAS,EAAI,EACrC,CAACU,EAAOC,CAAQ,EAAIX,EAA8B,IAAI,EACtD,CAACY,EAAWC,CAAY,EAAIb,EAAS,CAAC,EAItCc,EAAYf,EAAOK,CAAM,EAC/BN,EAAU,IAAK,CACbgB,EAAU,QAAUV,CACtB,EAAG,CAACA,CAAM,CAAC,EAEX,MAAMW,EAASlB,EAAY,IAAK,CAI9BY,EAAW,EAAI,EACfI,EAAcG,GAAQA,EAAM,CAAC,CAC/B,EAAG,CAAA,CAAE,EAEL,OAAAlB,EAAU,IAAK,CACb,IAAImB,EAAY,GAChB,OAAAH,EAAU,QACP,IAAWT,CAAI,EACf,KAAMa,GAAM,CACPD,IAGJV,EAAQW,CAAE,EACVP,EAAS,IAAI,EACbF,EAAW,EAAK,EAClB,CAAC,EACA,MAAOU,GAAkB,CACpBF,IAMJN,EAASV,EAAa,KAAKkB,CAAK,CAAC,EACjCV,EAAW,EAAK,EAClB,CAAC,EACI,IAAK,CACVQ,EAAY,EACd,CACF,EAAG,CAACZ,EAAMO,CAAS,CAAC,EAEb,CAAE,KAAAN,EAAM,QAAAE,EAAS,MAAAE,EAAO,OAAAK,CAAM,CACvC,CApDSK,EAAAjB,EAAA",
6
+ "names": ["useCallback", "useEffect", "useRef", "useState", "ServiceError", "CURRENT_USER_PATH", "useCurrentUser", "client", "path", "user", "setUser", "loading", "setLoading", "error", "setError", "reloadKey", "setReloadKey", "clientRef", "reload", "key", "cancelled", "me", "cause", "__name"]
7
7
  }
package/dist/useNotice.js CHANGED
@@ -1 +1 @@
1
- import{useCallback as u,useEffect as f,useRef as a,useState as N}from"react";import{NOTICE_TIMEOUT_MS as T}from"./constants.js";function p({dismissAfterMs:r=T,initial:c=null}={}){const[l,n]=N(c),t=a(null),e=u(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),o=u(()=>{e(),n(null)},[e]),i=u((s,m)=>{e(),n({kind:s,message:m}),t.current=setTimeout(()=>{t.current=null,n(null)},r)},[e,r]);return f(()=>e,[e]),{notice:l,showNotice:i,dismissNotice:o}}export{p as useNotice};
1
+ var a=Object.defineProperty;var l=(n,u)=>a(n,"name",{value:u,configurable:!0});import{useCallback as c,useEffect as N,useRef as T,useState as p}from"react";import{NOTICE_TIMEOUT_MS as E}from"./constants.js";function C({dismissAfterMs:n=E,initial:u=null}={}){const[o,r]=p(u),t=T(null),e=c(()=>{t.current!==null&&(clearTimeout(t.current),t.current=null)},[]),i=c(()=>{e(),r(null)},[e]),s=c((m,f)=>{e(),r({kind:m,message:f}),t.current=setTimeout(()=>{t.current=null,r(null)},n)},[e,n]);return N(()=>e,[e]),{notice:o,showNotice:s,dismissNotice:i}}l(C,"useNotice");export{C as useNotice};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/useNotice.ts"],
4
4
  "sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { NOTICE_TIMEOUT_MS } from './constants.ts';\n\n/**\n * A transient status message.\n *\n * ## Provenance\n *\n * `hooks/useNotice.ts` in **CalDAV-Bridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies of one hook, with AWS-AccessBridge's `useToast` as the seventh in\n * everything but name. Each contributes one thing:\n *\n * - **Durable-DAV** — the unmount cleanup. Its comment records the bug: the\n * timer was only ever cleared in favour of the *next* notice, so unmounting\n * with a notice showing left it live to call `setState` on a gone component.\n * - **Edge-Sonic** — `clearNotice`, a dismissal that is not just \"replace it\",\n * and the exported `ShowNotice` type so feature tabs stop re-spelling the\n * setter's signature.\n * - **CalDAV-Bridge / Mail-Otter** — seeding the first notice from the URL's\n * `?oauth2=` result. That is *left local*: the parameter names are\n * product-specific, and a hook that reads a query string is a hook a test\n * has to fake a location for. A consumer seeds its own notice by passing\n * `initial` — see `UseNoticeOptions`.\n * - **All six** — a ref-held timer, so a new notice replaces the old one's\n * dismissal instead of being cut short by it (\"the error banner vanished\n * before I read it\").\n *\n * ## Normalization\n *\n * The type is `{ kind, message }`. Every copy used `{ type, text }`, and the\n * field names collided with the DOM's `type` on unrelated elements often enough\n * that `kind`/`message` read better at the call sites that build one by hand\n * (`describeProbe` in Edge-Sonic returns a notice-shaped value). The imperative\n * API is `showNotice(kind, message)` — positional, as every copy had it, so a\n * call site reads as the event it reports — plus `dismissNotice()`.\n */\n\ntype NoticeKind = 'success' | 'error';\n\n/**\nOne transient message. `kind` is the tone, `message` the sentence.\n*/\ninterface Notice {\n kind: NoticeKind;\n message: string;\n}\n\n/**\nThe setter views and hooks are handed.\n*/\ntype ShowNotice = (kind: NoticeKind, message: string) => void;\n\ninterface UseNoticeOptions {\n /**\n How long a notice stays up. Defaults to `NOTICE_TIMEOUT_MS`.\n */\n dismissAfterMs?: number;\n /**\n A notice to start with — the URL-seeded OAuth result, in a consumer.\n */\n initial?: Notice | null;\n}\n\ninterface UseNoticeResult {\n /**\n The notice to render, or `null` when there is nothing to say.\n */\n notice: Notice | null;\n /**\n Shows a notice, replacing any notice already showing (and its timer).\n */\n showNotice: ShowNotice;\n /**\n Hides the notice and cancels its pending dismissal.\n */\n dismissNotice: () => void;\n}\n\nfunction useNotice({ dismissAfterMs = NOTICE_TIMEOUT_MS, initial = null }: Readonly<UseNoticeOptions> = {}): UseNoticeResult {\n const [notice, setNotice] = useState<Notice | null>(initial);\n const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearPendingDismissal = useCallback(() => {\n if (timerRef.current === null) {\n return;\n }\n clearTimeout(timerRef.current);\n timerRef.current = null;\n }, []);\n\n const dismissNotice = useCallback(() => {\n clearPendingDismissal();\n setNotice(null);\n }, [clearPendingDismissal]);\n\n const showNotice = useCallback<ShowNotice>(\n (kind, message) => {\n // Replace the pending dismissal rather than stacking a second timer: two\n // live timers mean the first notice's timeout fires while the second is\n // still on screen.\n clearPendingDismissal();\n setNotice({ kind, message });\n timerRef.current = setTimeout(() => {\n timerRef.current = null;\n setNotice(null);\n }, dismissAfterMs);\n },\n [clearPendingDismissal, dismissAfterMs],\n );\n\n // Unmounting cancels the dismissal. Without this the timer outlives the\n // component and calls `setState` on a tree that is gone.\n useEffect(() => clearPendingDismissal, [clearPendingDismissal]);\n\n return { notice, showNotice, dismissNotice };\n}\n\nexport { useNotice };\nexport type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult };\n"],
5
- "mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QACzD,OAAS,qBAAAC,MAAyB,iBA8ElC,SAASC,EAAU,CAAE,eAAAC,EAAiBF,EAAmB,QAAAG,EAAU,IAAI,EAAiC,CAAA,EAAE,CACxG,KAAM,CAACC,EAAQC,CAAS,EAAIN,EAAwBI,CAAO,EACrDG,EAAWR,EAA6C,IAAI,EAE5DS,EAAwBX,EAAY,IAAK,CACzCU,EAAS,UAAY,OAGzB,aAAaA,EAAS,OAAO,EAC7BA,EAAS,QAAU,KACrB,EAAG,CAAA,CAAE,EAECE,EAAgBZ,EAAY,IAAK,CACrCW,EAAqB,EACrBF,EAAU,IAAI,CAChB,EAAG,CAACE,CAAqB,CAAC,EAEpBE,EAAab,EACjB,CAACc,EAAMC,IAAW,CAIhBJ,EAAqB,EACrBF,EAAU,CAAE,KAAAK,EAAM,QAAAC,CAAO,CAAE,EAC3BL,EAAS,QAAU,WAAW,IAAK,CACjCA,EAAS,QAAU,KACnBD,EAAU,IAAI,CAChB,EAAGH,CAAc,CACnB,EACA,CAACK,EAAuBL,CAAc,CAAC,EAKzC,OAAAL,EAAU,IAAMU,EAAuB,CAACA,CAAqB,CAAC,EAEvD,CAAE,OAAAH,EAAQ,WAAAK,EAAY,cAAAD,CAAa,CAC5C",
6
- "names": ["useCallback", "useEffect", "useRef", "useState", "NOTICE_TIMEOUT_MS", "useNotice", "dismissAfterMs", "initial", "notice", "setNotice", "timerRef", "clearPendingDismissal", "dismissNotice", "showNotice", "kind", "message"]
5
+ "mappings": "+EAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QACzD,OAAS,qBAAAC,MAAyB,iBA8ElC,SAASC,EAAU,CAAE,eAAAC,EAAiBF,EAAmB,QAAAG,EAAU,IAAI,EAAiC,CAAA,EAAE,CACxG,KAAM,CAACC,EAAQC,CAAS,EAAIN,EAAwBI,CAAO,EACrDG,EAAWR,EAA6C,IAAI,EAE5DS,EAAwBX,EAAY,IAAK,CACzCU,EAAS,UAAY,OAGzB,aAAaA,EAAS,OAAO,EAC7BA,EAAS,QAAU,KACrB,EAAG,CAAA,CAAE,EAECE,EAAgBZ,EAAY,IAAK,CACrCW,EAAqB,EACrBF,EAAU,IAAI,CAChB,EAAG,CAACE,CAAqB,CAAC,EAEpBE,EAAab,EACjB,CAACc,EAAMC,IAAW,CAIhBJ,EAAqB,EACrBF,EAAU,CAAE,KAAAK,EAAM,QAAAC,CAAO,CAAE,EAC3BL,EAAS,QAAU,WAAW,IAAK,CACjCA,EAAS,QAAU,KACnBD,EAAU,IAAI,CAChB,EAAGH,CAAc,CACnB,EACA,CAACK,EAAuBL,CAAc,CAAC,EAKzC,OAAAL,EAAU,IAAMU,EAAuB,CAACA,CAAqB,CAAC,EAEvD,CAAE,OAAAH,EAAQ,WAAAK,EAAY,cAAAD,CAAa,CAC5C,CArCSI,EAAAX,EAAA",
6
+ "names": ["useCallback", "useEffect", "useRef", "useState", "NOTICE_TIMEOUT_MS", "useNotice", "dismissAfterMs", "initial", "notice", "setNotice", "timerRef", "clearPendingDismissal", "dismissNotice", "showNotice", "kind", "message", "__name"]
7
7
  }
@@ -1 +1 @@
1
- import{useCallback as T,useEffect as d,useMemo as h,useState as m}from"react";import{canonicalizeLanguageTag as p}from"@rexezuge/shared";const L=["en"],f="en",A="language";function G(t){return t.map(a=>{const n=p(a);return{tag:a,key:n,primary:n.split("-",1)[0]??n}})}function c(t,a,n){if(typeof t!="string"||t.trim()==="")return n;const u=p(t),r=u.split("-",1)[0]??u;let e=null;for(const o of G(a)){if(o.key===u)return o.tag;e===null&&o.primary===r&&(e=o.tag)}return e??n}function U(t){try{return globalThis.localStorage?.getItem(t)??null}catch{return null}}function _(t,a){try{globalThis.localStorage?.setItem(t,a)}catch{}}function x(){try{return globalThis.navigator?.language??null}catch{return null}}function P({preferred:t,supported:a=L,storageKey:n=A,fallbackLanguage:u=f}={}){const r=a.join(" "),e=h(()=>r===""?[]:r.split(" "),[r]),[o,g]=m(()=>c(t??U(n)??x(),e,u)),[y,E]=m(t);if(t!==y&&(E(t),t!=null&&t.trim()!=="")){const i=c(t,e,u);i!==o&&g(i)}d(()=>{try{document.documentElement.lang=o}catch{}},[o]);const S=T(i=>{const s=c(i,e,u);g(l=>l===s?l:s),_(n,s)},[e,u,n]);return{language:o,setLanguage:S,supported:e}}import{canonicalizeLanguageTag as z}from"@rexezuge/shared";export{f as DEFAULT_FALLBACK_LANGUAGE,A as DEFAULT_LANGUAGE_STORAGE_KEY,L as DEFAULT_SUPPORTED_LANGUAGES,z as canonicalizeLanguageTag,c as resolveLanguageTag,P as useSpaLanguage};
1
+ var d=Object.defineProperty;var r=(t,n)=>d(t,"name",{value:n,configurable:!0});import{useCallback as h,useEffect as G,useMemo as U,useState as p}from"react";import{canonicalizeLanguageTag as L}from"@rexezuge/shared";const f=["en"],A="en",y="language";function _(t){return t.map(n=>{const e=L(n);return{tag:n,key:e,primary:e.split("-",1)[0]??e}})}r(_,"describeSupported");function s(t,n,e){if(typeof t!="string"||t.trim()==="")return e;const u=L(t),i=u.split("-",1)[0]??u;let o=null;for(const a of _(n)){if(a.key===u)return a.tag;o===null&&a.primary===i&&(o=a.tag)}return o??e}r(s,"resolveLanguageTag");function x(t){try{return globalThis.localStorage?.getItem(t)??null}catch{return null}}r(x,"readStoredLanguage");function P(t,n){try{globalThis.localStorage?.setItem(t,n)}catch{}}r(P,"writeStoredLanguage");function D(){try{return globalThis.navigator?.language??null}catch{return null}}r(D,"readNavigatorLanguage");function F({preferred:t,supported:n=f,storageKey:e=y,fallbackLanguage:u=A}={}){const i=n.join(" "),o=U(()=>i===""?[]:i.split(" "),[i]),[a,l]=p(()=>s(t??x(e)??D(),o,u)),[E,S]=p(t);if(t!==E&&(S(t),t!=null&&t.trim()!=="")){const c=s(t,o,u);c!==a&&l(c)}G(()=>{try{document.documentElement.lang=a}catch{}},[a]);const T=h(c=>{const g=s(c,o,u);l(m=>m===g?m:g),P(e,g)},[o,u,e]);return{language:a,setLanguage:T,supported:o}}r(F,"useSpaLanguage");import{canonicalizeLanguageTag as M}from"@rexezuge/shared";export{A as DEFAULT_FALLBACK_LANGUAGE,y as DEFAULT_LANGUAGE_STORAGE_KEY,f as DEFAULT_SUPPORTED_LANGUAGES,M as canonicalizeLanguageTag,s as resolveLanguageTag,F as useSpaLanguage};
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/useSpaLanguage.ts"],
4
4
  "sourcesContent": ["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport { canonicalizeLanguageTag } from '@rexezuge/shared';\nimport type { LanguageTag } from '@rexezuge/shared';\n\n/**\n * The language the SPA is rendering, and the setter that changes it.\n *\n * ## Provenance\n *\n * `hooks/useSpaLanguage.ts` in **AWS-AccessBridge**, **Durable-DAV**,\n * **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six\n * copies that agree on the detection precedence and disagree on everything\n * else, because each one also owned its app's i18next wiring:\n *\n * - **Detection precedence.** All six: backend `preferredLanguage` when present\n * > `localStorage` > `navigator.language` > `en`, with the *first present\n * source* winning rather than the first *supported* one — AWS's\n * `lib/language.ts` spells out why: an unsupported backend value falls to\n * `en` rather than to the next source, because the backend value is the\n * user's own choice and silently replacing it with whatever the browser\n * reports would flip the UI the moment the profile loaded.\n * - **`<html lang>` sync**, in all six, guarded because a non-browser\n * environment has no `document`.\n * - **Bundle loading, `languageChanged` bridging, and the backend write** —\n * Mail-Otter/AWS `await updatePreferredLanguage(...)`, the others\n * localStorage-only. These are *left to the app*: the kit hook keeps\n * i18next out so it can be exercised without an i18n instance, and a caller\n * that wants the authoritative save calls its own API from its `setLanguage`\n * wrapper.\n * - **`languageStatus`/`languagePending`** — left out for the same reason: both\n * exist to describe *bundle* loading, which the app now owns.\n *\n * ## Normalization\n *\n * The hook returns `{ language, setLanguage }`. `setLanguage` is synchronous and\n * total: it resolves the tag, persists it, and syncs `<html lang>`; the caller\n * awaits its own bundle load before or after calling it. `supported` comes back\n * too, so a `LanguageSelector` does not need a second import to render the list.\n */\n\n/**\nThe tags offered when a caller does not say. English-only is the safe default.\n*/\nconst DEFAULT_SUPPORTED_LANGUAGES: readonly LanguageTag[] = ['en'];\n\n/**\nThe tag used when nothing supported can be resolved.\n*/\nconst DEFAULT_FALLBACK_LANGUAGE: LanguageTag = 'en';\n\n/**\nThe `localStorage` key used when a caller does not say.\n*/\nconst DEFAULT_LANGUAGE_STORAGE_KEY = 'language';\n\n/**\nOne entry of the supported list, pre-canonicalized for comparison.\n*/\ninterface SupportedLanguage {\n /**\n The tag as the caller spells it — what the hook returns.\n */\n tag: LanguageTag;\n /**\n Its canonical form, for matching.\n */\n key: string;\n /**\n Its primary subtag (`zh` for `zh-CN`).\n */\n primary: string;\n}\n\n/**\nThe supported list in canonical form, computed once per render of the hook.\n*/\nfunction describeSupported(supported: readonly LanguageTag[]): SupportedLanguage[] {\n return supported.map((tag) => {\n const key = canonicalizeLanguageTag(tag);\n return { tag, key, primary: key.split('-', 1)[0] ?? key };\n });\n}\n\n/**\n * Resolves a tag against the supported list: an exact match wins, then the\n * primary subtag (`de-DE` resolves to a supported `de`), then the fallback.\n *\n * The prefix step is why a browser reporting `en-US` does not defeat an\n * English-only app, and why a browser reporting `zh-TW` does not land on\n * `zh-CN` when both are supported.\n */\nfunction resolveLanguageTag(value: string | null | undefined, supported: readonly LanguageTag[], fallback: LanguageTag): LanguageTag {\n if (typeof value !== 'string' || value.trim() === '') {\n return fallback;\n }\n // The shared canonicalizer maps a degenerate tag to `en`, so the empty check\n // above has to happen first — otherwise an empty stored value would silently\n // resolve to `en` instead of the caller's fallback.\n const key = canonicalizeLanguageTag(value);\n const primary = key.split('-', 1)[0] ?? key;\n let prefixMatch: LanguageTag | null = null;\n for (const entry of describeSupported(supported)) {\n if (entry.key === key) {\n return entry.tag;\n }\n if (prefixMatch === null && entry.primary === primary) {\n prefixMatch = entry.tag;\n }\n }\n return prefixMatch ?? fallback;\n}\n\nfunction readStoredLanguage(storageKey: string): string | null {\n try {\n return globalThis.localStorage?.getItem(storageKey) ?? null;\n } catch {\n // Private-mode Safari and a blocked-storage context both throw. Detection\n // carries on without the stored value; the language still works.\n return null;\n }\n}\n\nfunction writeStoredLanguage(storageKey: string, language: LanguageTag): void {\n try {\n globalThis.localStorage?.setItem(storageKey, language);\n } catch {\n // Non-fatal: the selection still applies to this session, it just does not\n // survive a reload.\n }\n}\n\nfunction readNavigatorLanguage(): string | null {\n try {\n return globalThis.navigator?.language ?? null;\n } catch {\n return null;\n }\n}\n\ninterface UseSpaLanguageOptions {\n /**\n * The backend-authoritative preference (a user's `preferredLanguage`), or\n * `null`/`undefined` while the profile is not known. Adopted when it changes.\n */\n preferred?: string | null;\n /**\n The tags the app ships bundles for. Memoize it: it is a dependency.\n */\n supported?: readonly LanguageTag[];\n /**\n The `localStorage` key the choice is persisted under.\n */\n storageKey?: string;\n /**\n The tag used when nothing supported resolves. Defaults to `en`.\n */\n fallbackLanguage?: LanguageTag;\n}\n\ninterface UseSpaLanguageResult {\n /**\n The tag currently in effect — a member of `supported`.\n */\n language: LanguageTag;\n /**\n * Switches the language: resolves the tag, persists it, and syncs\n * `<html lang>`. An unsupported tag resolves to the fallback rather than\n * being ignored, so a mistake is visible instead of silent.\n */\n setLanguage: (tag: string) => void;\n /**\n The tags offered, as resolved — render this list in a selector.\n */\n supported: readonly LanguageTag[];\n}\n\nfunction useSpaLanguage({\n preferred,\n supported = DEFAULT_SUPPORTED_LANGUAGES,\n storageKey = DEFAULT_LANGUAGE_STORAGE_KEY,\n fallbackLanguage = DEFAULT_FALLBACK_LANGUAGE,\n}: Readonly<UseSpaLanguageOptions> = {}): UseSpaLanguageResult {\n // Serialized so an inline `supported` array literal does not change identity\n // on every render and re-run the effects below. Tags never contain spaces.\n const supportedKey = supported.join(' ');\n const supportedLanguages = useMemo<readonly LanguageTag[]>(() => (supportedKey === '' ? [] : supportedKey.split(' ')), [supportedKey]);\n\n const [language, setLanguageState] = useState<LanguageTag>(() =>\n // Precedence: backend > stored > navigator > fallback. The backend value is\n // undefined on a first paint and arrives later, which is what the adoption\n // below is for.\n resolveLanguageTag(preferred ?? readStoredLanguage(storageKey) ?? readNavigatorLanguage(), supportedLanguages, fallbackLanguage),\n );\n\n // Adopt the backend preference once it is known. `preferred` is the\n // authoritative source, so it overrides a value detection picked earlier —\n // which is also what makes a returning user land on the language they chose\n // on another device.\n //\n // Adjusted during render, not in an effect: the guarded `prevPreferred`\n // comparison is React's documented derive-from-props pattern, and it adopts\n // in the render the value arrives in rather than one render later.\n const [prevPreferred, setPrevPreferred] = useState<string | null | undefined>(preferred);\n if (preferred !== prevPreferred) {\n setPrevPreferred(preferred);\n if (preferred !== undefined && preferred !== null && preferred.trim() !== '') {\n const next = resolveLanguageTag(preferred, supportedLanguages, fallbackLanguage);\n if (next !== language) {\n setLanguageState(next);\n }\n }\n }\n\n // `<html lang>` drives hyphenation, font choice and screen-reader\n // pronunciation, so it has to follow the tag even when the change came from\n // detection rather than from `setLanguage`.\n useEffect(() => {\n try {\n document.documentElement.lang = language;\n } catch {\n // No DOM: server rendering, or a worker-ish test environment.\n }\n }, [language]);\n\n const setLanguage = useCallback(\n (tag: string) => {\n const next = resolveLanguageTag(tag, supportedLanguages, fallbackLanguage);\n setLanguageState((current) => (current === next ? current : next));\n // Persisted only on an explicit choice. Writing on mount would turn \"the\n // browser happened to report `de`\" into a stored preference, which is a\n // different claim.\n writeStoredLanguage(storageKey, next);\n },\n [supportedLanguages, fallbackLanguage, storageKey],\n );\n\n return { language, setLanguage, supported: supportedLanguages };\n}\n\nexport { DEFAULT_FALLBACK_LANGUAGE, DEFAULT_LANGUAGE_STORAGE_KEY, DEFAULT_SUPPORTED_LANGUAGES, resolveLanguageTag, useSpaLanguage };\nexport type { UseSpaLanguageOptions, UseSpaLanguageResult };\n\nexport { canonicalizeLanguageTag, type LanguageTag } from '@rexezuge/shared';\n"],
5
- "mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC1D,OAAS,2BAAAC,MAA+B,mBA0CxC,MAAMC,EAAsD,CAAC,IAAI,EAK3DC,EAAyC,KAKzCC,EAA+B,WAuBrC,SAASC,EAAkBC,EAAiC,CAC1D,OAAOA,EAAU,IAAKC,GAAO,CAC3B,MAAMC,EAAMP,EAAwBM,CAAG,EACvC,MAAO,CAAE,IAAAA,EAAK,IAAAC,EAAK,QAASA,EAAI,MAAM,IAAK,CAAC,EAAE,CAAC,GAAKA,CAAG,CACzD,CAAC,CACH,CAUA,SAASC,EAAmBC,EAAkCJ,EAAmCK,EAAqB,CACpH,GAAI,OAAOD,GAAU,UAAYA,EAAM,KAAI,IAAO,GAChD,OAAOC,EAKT,MAAMH,EAAMP,EAAwBS,CAAK,EACnCE,EAAUJ,EAAI,MAAM,IAAK,CAAC,EAAE,CAAC,GAAKA,EACxC,IAAIK,EAAkC,KACtC,UAAWC,KAAST,EAAkBC,CAAS,EAAG,CAChD,GAAIQ,EAAM,MAAQN,EAChB,OAAOM,EAAM,IAEXD,IAAgB,MAAQC,EAAM,UAAYF,IAC5CC,EAAcC,EAAM,IAExB,CACA,OAAOD,GAAeF,CACxB,CAEA,SAASI,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AAoBF,EAAkBN,CAAU,CAAC,EAGpD,MAAO,CAAE,SAAAE,EAAU,YAAAW,EAAa,UAAWL,CAAkB,CAC/D,CAKA,OAAS,2BAAAvB,MAAiD",
6
- "names": ["useCallback", "useEffect", "useMemo", "useState", "canonicalizeLanguageTag", "DEFAULT_SUPPORTED_LANGUAGES", "DEFAULT_FALLBACK_LANGUAGE", "DEFAULT_LANGUAGE_STORAGE_KEY", "describeSupported", "supported", "tag", "key", "resolveLanguageTag", "value", "fallback", "primary", "prefixMatch", "entry", "readStoredLanguage", "storageKey", "writeStoredLanguage", "language", "readNavigatorLanguage", "useSpaLanguage", "preferred", "fallbackLanguage", "supportedKey", "supportedLanguages", "setLanguageState", "prevPreferred", "setPrevPreferred", "next", "setLanguage", "current"]
5
+ "mappings": "+EAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC1D,OAAS,2BAAAC,MAA+B,mBA0CxC,MAAMC,EAAsD,CAAC,IAAI,EAK3DC,EAAyC,KAKzCC,EAA+B,WAuBrC,SAASC,EAAkBC,EAAiC,CAC1D,OAAOA,EAAU,IAAKC,GAAO,CAC3B,MAAMC,EAAMP,EAAwBM,CAAG,EACvC,MAAO,CAAE,IAAAA,EAAK,IAAAC,EAAK,QAASA,EAAI,MAAM,IAAK,CAAC,EAAE,CAAC,GAAKA,CAAG,CACzD,CAAC,CACH,CALSC,EAAAJ,EAAA,qBAeT,SAASK,EAAmBC,EAAkCL,EAAmCM,EAAqB,CACpH,GAAI,OAAOD,GAAU,UAAYA,EAAM,KAAI,IAAO,GAChD,OAAOC,EAKT,MAAMJ,EAAMP,EAAwBU,CAAK,EACnCE,EAAUL,EAAI,MAAM,IAAK,CAAC,EAAE,CAAC,GAAKA,EACxC,IAAIM,EAAkC,KACtC,UAAWC,KAASV,EAAkBC,CAAS,EAAG,CAChD,GAAIS,EAAM,MAAQP,EAChB,OAAOO,EAAM,IAEXD,IAAgB,MAAQC,EAAM,UAAY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ACd,MAAMsB,EAAOnB,EAAmBH,EAAKkB,EAAoBF,CAAgB,EACzEG,EAAkBK,GAAaA,IAAYF,EAAOE,EAAUF,CAAK,EAIjEX,EAAoBD,EAAYY,CAAI,CACtC,EACA,CAACJ,EAAoBF,EAAkBN,CAAU,CAAC,EAGpD,MAAO,CAAE,SAAAE,EAAU,YAAAW,EAAa,UAAWL,CAAkB,CAC/D,CA7DShB,EAAAY,EAAA,kBAkET,OAAS,2BAAApB,MAAiD",
6
+ "names": ["useCallback", "useEffect", "useMemo", "useState", "canonicalizeLanguageTag", "DEFAULT_SUPPORTED_LANGUAGES", "DEFAULT_FALLBACK_LANGUAGE", "DEFAULT_LANGUAGE_STORAGE_KEY", "describeSupported", "supported", "tag", "key", "__name", "resolveLanguageTag", "value", "fallback", "primary", "prefixMatch", "entry", "readStoredLanguage", "storageKey", "writeStoredLanguage", "language", "readNavigatorLanguage", "useSpaLanguage", "preferred", "fallbackLanguage", "supportedKey", "supportedLanguages", "setLanguageState", "prevPreferred", "setPrevPreferred", "next", "setLanguage", "current"]
7
7
  }
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- const a=["inset-x","inset-y","inset","scroll-mx","scroll-my","scroll-m","scroll-px","scroll-py","scroll-p","start","end","top","right","bottom","left","space-x","space-y","gap-x","gap-y","gap","px","py","pt","pr","pb","pl","ps","pe","p","mx","my","mt","mr","mb","ml","ms","me","m","min-w","min-h","max-w","max-h","size","w","h","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl","rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded","border-x","border-y","border-t","border-r","border-b","border-l","border-s","border-e","border","ring-offset","ring","divide-x","divide-y","outline-offset","translate-x","translate-y","scale","rotate","col-span","row-span","grid-cols","grid-rows","basis","grow","shrink","order","z","opacity","leading","tracking","duration","delay"],o={static:"position",fixed:"position",absolute:"position",relative:"position",sticky:"position",block:"display",inline:"display","inline-block":"display",flex:"display","inline-flex":"display",grid:"display","inline-grid":"display",table:"display",hidden:"display",contents:"display","flow-root":"display","list-item":"display","flex-row":"flex-direction","flex-col":"flex-direction","flex-row-reverse":"flex-direction","flex-col-reverse":"flex-direction","flex-wrap":"flex-wrap","flex-wrap-reverse":"flex-wrap","flex-nowrap":"flex-wrap","justify-normal":"justify-content","justify-start":"justify-content","justify-end":"justify-content","justify-center":"justify-content","justify-between":"justify-content","justify-around":"justify-content","justify-evenly":"justify-content","justify-stretch":"justify-content","items-start":"align-items","items-end":"align-items","items-center":"align-items","items-baseline":"align-items","items-stretch":"align-items","self-auto":"align-self","self-start":"align-self","self-end":"align-self","self-center":"align-self","self-stretch":"align-self","text-left":"text-align","text-center":"text-align","text-right":"text-align","text-justify":"text-align","text-start":"text-align","text-end":"text-align","font-thin":"font-weight","font-extralight":"font-weight","font-light":"font-weight","font-normal":"font-weight","font-medium":"font-weight","font-semibold":"font-weight","font-bold":"font-weight","font-extrabold":"font-weight","font-black":"font-weight",visible:"visibility",invisible:"visibility",collapse:"visibility"},d=/^-?(?:\d+(?:\.\d*)?|\[[^\]]*\]|px|full|none|auto|screen|min|max|fit)$/;function u(i){return Array.isArray(i)}function l(i,e){for(const t of e.split(/\s+/))t!==""&&i.push(t)}function f(i,e){for(const t of i)if(!(t==null||t===!1||t==="")){if(typeof t=="string"){l(e,t);continue}if(typeof t=="number"){e.push(String(t));continue}if(u(t)){f(t,e);continue}for(const[n,s]of Object.entries(t))s&&l(e,n)}}function c(i){let e=0,t=-1,n=0;for(;n<i.length;){const s=i[n];s==="["||s==="("?e+=1:s==="]"||s===")"?e-=1:s===":"&&e===0&&(t=n),n+=1}return t===-1?{variants:"",base:i}:{variants:i.slice(0,t),base:i.slice(t+1)}}function p(i){const{variants:e,base:t}=c(i);if(Object.hasOwn(o,t))return`${e}|${o[t]}`;for(const n of a){if(t===n)return`${e}|${n}`;if(!t.startsWith(`${n}-`))continue;const s=t.slice(n.length+1);return d.test(s)?`${e}|${n}`:null}return null}function g(i){const e=new Map;return i.forEach((t,n)=>{e.set(t,n)}),i.filter((t,n)=>e.get(t)===n)}function y(i){const e=[],t=new Map;for(const n of i){const s=p(n);if(s!==null){const r=t.get(s);r!==void 0&&(e[r]=""),t.set(s,e.length)}e.push(n)}return e.filter(n=>n!=="")}function x(...i){const e=[];return f(i,e),y(g(e)).join(" ")}export{x as cn};
1
+ var d=Object.defineProperty;var r=(n,e)=>d(n,"name",{value:e,configurable:!0});const u=["inset-x","inset-y","inset","scroll-mx","scroll-my","scroll-m","scroll-px","scroll-py","scroll-p","start","end","top","right","bottom","left","space-x","space-y","gap-x","gap-y","gap","px","py","pt","pr","pb","pl","ps","pe","p","mx","my","mt","mr","mb","ml","ms","me","m","min-w","min-h","max-w","max-h","size","w","h","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl","rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded","border-x","border-y","border-t","border-r","border-b","border-l","border-s","border-e","border","ring-offset","ring","divide-x","divide-y","outline-offset","translate-x","translate-y","scale","rotate","col-span","row-span","grid-cols","grid-rows","basis","grow","shrink","order","z","opacity","leading","tracking","duration","delay"],l={static:"position",fixed:"position",absolute:"position",relative:"position",sticky:"position",block:"display",inline:"display","inline-block":"display",flex:"display","inline-flex":"display",grid:"display","inline-grid":"display",table:"display",hidden:"display",contents:"display","flow-root":"display","list-item":"display","flex-row":"flex-direction","flex-col":"flex-direction","flex-row-reverse":"flex-direction","flex-col-reverse":"flex-direction","flex-wrap":"flex-wrap","flex-wrap-reverse":"flex-wrap","flex-nowrap":"flex-wrap","justify-normal":"justify-content","justify-start":"justify-content","justify-end":"justify-content","justify-center":"justify-content","justify-between":"justify-content","justify-around":"justify-content","justify-evenly":"justify-content","justify-stretch":"justify-content","items-start":"align-items","items-end":"align-items","items-center":"align-items","items-baseline":"align-items","items-stretch":"align-items","self-auto":"align-self","self-start":"align-self","self-end":"align-self","self-center":"align-self","self-stretch":"align-self","text-left":"text-align","text-center":"text-align","text-right":"text-align","text-justify":"text-align","text-start":"text-align","text-end":"text-align","font-thin":"font-weight","font-extralight":"font-weight","font-light":"font-weight","font-normal":"font-weight","font-medium":"font-weight","font-semibold":"font-weight","font-bold":"font-weight","font-extrabold":"font-weight","font-black":"font-weight",visible:"visibility",invisible:"visibility",collapse:"visibility"},c=/^-?(?:\d+(?:\.\d*)?|\[[^\]]*\]|px|full|none|auto|screen|min|max|fit)$/;function p(n){return Array.isArray(n)}r(p,"isClassList");function f(n,e){for(const t of e.split(/\s+/))t!==""&&n.push(t)}r(f,"pushClasses");function a(n,e){for(const t of n)if(!(t==null||t===!1||t==="")){if(typeof t=="string"){f(e,t);continue}if(typeof t=="number"){e.push(String(t));continue}if(p(t)){a(t,e);continue}for(const[i,s]of Object.entries(t))s&&f(e,i)}}r(a,"flattenClasses");function g(n){let e=0,t=-1,i=0;for(;i<n.length;){const s=n[i];s==="["||s==="("?e+=1:s==="]"||s===")"?e-=1:s===":"&&e===0&&(t=i),i+=1}return t===-1?{variants:"",base:n}:{variants:n.slice(0,t),base:n.slice(t+1)}}r(g,"splitVariants");function y(n){const{variants:e,base:t}=g(n);if(Object.hasOwn(l,t))return`${e}|${l[t]}`;for(const i of u){if(t===i)return`${e}|${i}`;if(!t.startsWith(`${i}-`))continue;const s=t.slice(i.length+1);return c.test(s)?`${e}|${i}`:null}return null}r(y,"groupKeyFor");function x(n){const e=new Map;return n.forEach((t,i)=>{e.set(t,i)}),n.filter((t,i)=>e.get(t)===i)}r(x,"dedupeClasses");function b(n){const e=[],t=new Map;for(const i of n){const s=y(i);if(s!==null){const o=t.get(s);o!==void 0&&(e[o]=""),t.set(s,e.length)}e.push(i)}return e.filter(i=>i!=="")}r(b,"mergeGroups");function m(...n){const e=[];return a(n,e),b(x(e)).join(" ")}r(m,"cn");export{m as cn};
package/dist/utils.js.map CHANGED
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/utils.ts"],
4
4
  "sourcesContent": ["/**\n * Class-name composition.\n *\n * ## Provenance\n *\n * `lib/utils.ts` in **CalDAV-Bridge**, **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six byte-identical copies of\n *\n * ```ts\n * export function cn(...inputs: ClassValue[]) {\n * return twMerge(clsx(inputs));\n * }\n * ```\n *\n * The kit cannot import `clsx` or `tailwind-merge` (this package declares no\n * dependency on either, and the consumers' own copies stay theirs), so the same\n * contract is implemented here in-dependency-free form:\n *\n * - **clsx semantics** — strings, numbers, arrays and `{ [class]: active }`\n * dictionaries are flattened, and falsy entries are dropped.\n * - **tailwind-merge semantics, for a documented subset** — when a later class\n * belongs to the same utility family as an earlier one, the earlier one is\n * dropped, so `<Button className=\"px-6\">` really does override the base\n * `px-4` instead of shipping both and letting stylesheet order decide.\n *\n * The merged families are the ones whose value is a length or a count —\n * spacing, sizing, border width, radius, transitions — plus the single-word\n * utilities (position, display, flex direction, justification, alignment, text\n * alignment, font weight). Families whose suffix is *not* a value\n * (`text-red-500`, `bg-[var(--color-accent)]`, `border-white`) are left in\n * source order on purpose: telling `text-sm` from `text-red-500` takes\n * tailwind-merge's full class table, and guessing wrong would silently drop a\n * colour. A consumer that needs the complete table can wrap this one:\n * `const cn = (...values: ClassValue[]) => twMerge(kitCn(...values))`.\n */\n\n/**\nEverything `cn` accepts, mirroring clsx's `ClassValue`.\n*/\ntype ClassValue = string | number | boolean | null | undefined | ClassDictionary | readonly ClassValue[];\n\n/**\n`{ 'px-4': isActive }` — a class is present when its value is truthy.\n*/\ninterface ClassDictionary {\n [className: string]: boolean | null | undefined;\n}\n\n/**\n * Utility prefixes whose remainder is a length/count, merged longest-first so\n * `px-` is matched before `p-`.\n */\nconst VALUE_UTILITY_PREFIXES: readonly string[] = [\n // Inset / spacing\n 'inset-x',\n 'inset-y',\n 'inset',\n 'scroll-mx',\n 'scroll-my',\n 'scroll-m',\n 'scroll-px',\n 'scroll-py',\n 'scroll-p',\n 'start',\n 'end',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'space-x',\n 'space-y',\n 'gap-x',\n 'gap-y',\n 'gap',\n 'px',\n 'py',\n 'pt',\n 'pr',\n 'pb',\n 'pl',\n 'ps',\n 'pe',\n 'p',\n 'mx',\n 'my',\n 'mt',\n 'mr',\n 'mb',\n 'ml',\n 'ms',\n 'me',\n 'm',\n // Sizing\n 'min-w',\n 'min-h',\n 'max-w',\n 'max-h',\n 'size',\n 'w',\n 'h',\n // Radius\n 'rounded-ss',\n 'rounded-se',\n 'rounded-ee',\n 'rounded-es',\n 'rounded-tl',\n 'rounded-tr',\n 'rounded-br',\n 'rounded-bl',\n 'rounded-s',\n 'rounded-e',\n 'rounded-t',\n 'rounded-r',\n 'rounded-b',\n 'rounded-l',\n 'rounded',\n // Border width (a border *colour* never has a numeric suffix)\n 'border-x',\n 'border-y',\n 'border-t',\n 'border-r',\n 'border-b',\n 'border-l',\n 'border-s',\n 'border-e',\n 'border',\n // Ring / outline width, divide, translate/scale/rotate\n 'ring-offset',\n 'ring',\n 'divide-x',\n 'divide-y',\n 'outline-offset',\n 'translate-x',\n 'translate-y',\n 'scale',\n 'rotate',\n // Grid\n 'col-span',\n 'row-span',\n 'grid-cols',\n 'grid-rows',\n // Flex box\n 'basis',\n 'grow',\n 'shrink',\n 'order',\n 'z',\n 'opacity',\n 'leading',\n 'tracking',\n 'duration',\n 'delay',\n];\n\n/**\n * Single-word utilities that have no value, grouped by the property they set.\n * Only words that are unambiguously that property are listed — `font-medium`\n * (weight) is here, `font-mono` (family) is not.\n */\nconst SINGLETON_UTILITIES: Record<string, string> = {\n // Position\n static: 'position',\n fixed: 'position',\n absolute: 'position',\n relative: 'position',\n sticky: 'position',\n // Display\n block: 'display',\n inline: 'display',\n 'inline-block': 'display',\n flex: 'display',\n 'inline-flex': 'display',\n grid: 'display',\n 'inline-grid': 'display',\n table: 'display',\n hidden: 'display',\n contents: 'display',\n 'flow-root': 'display',\n 'list-item': 'display',\n // Flex direction / wrapping\n 'flex-row': 'flex-direction',\n 'flex-col': 'flex-direction',\n 'flex-row-reverse': 'flex-direction',\n 'flex-col-reverse': 'flex-direction',\n 'flex-wrap': 'flex-wrap',\n 'flex-wrap-reverse': 'flex-wrap',\n 'flex-nowrap': 'flex-wrap',\n // Justification / alignment\n 'justify-normal': 'justify-content',\n 'justify-start': 'justify-content',\n 'justify-end': 'justify-content',\n 'justify-center': 'justify-content',\n 'justify-between': 'justify-content',\n 'justify-around': 'justify-content',\n 'justify-evenly': 'justify-content',\n 'justify-stretch': 'justify-content',\n 'items-start': 'align-items',\n 'items-end': 'align-items',\n 'items-center': 'align-items',\n 'items-baseline': 'align-items',\n 'items-stretch': 'align-items',\n 'self-auto': 'align-self',\n 'self-start': 'align-self',\n 'self-end': 'align-self',\n 'self-center': 'align-self',\n 'self-stretch': 'align-self',\n // Text alignment\n 'text-left': 'text-align',\n 'text-center': 'text-align',\n 'text-right': 'text-align',\n 'text-justify': 'text-align',\n 'text-start': 'text-align',\n 'text-end': 'text-align',\n // Font weight (families are deliberately absent — see the comment above)\n 'font-thin': 'font-weight',\n 'font-extralight': 'font-weight',\n 'font-light': 'font-weight',\n 'font-normal': 'font-weight',\n 'font-medium': 'font-weight',\n 'font-semibold': 'font-weight',\n 'font-bold': 'font-weight',\n 'font-extrabold': 'font-weight',\n 'font-black': 'font-weight',\n // Visibility\n visible: 'visibility',\n invisible: 'visibility',\n collapse: 'visibility',\n};\n\n/**\nA length/count-like remainder: `-2`, `1.5`, `[3px]`, `px`, `full`, `none`.\n*/\nconst VALUE_SUFFIX = /^-?(?:\\d+(?:\\.\\d*)?|\\[[^\\]]*\\]|px|full|none|auto|screen|min|max|fit)$/;\n\nfunction isClassList(value: ClassValue): value is readonly ClassValue[] {\n return Array.isArray(value);\n}\n\n/**\nPushes the whitespace-separated classes of one string, dropping empties.\n*/\nfunction pushClasses(into: string[], value: string): void {\n for (const className of value.split(/\\s+/)) {\n if (className !== '') {\n into.push(className);\n }\n }\n}\n\n/**\nFlattens clsx-style inputs into the classes they contribute, in order.\n*/\nfunction flattenClasses(values: readonly ClassValue[], into: string[]): void {\n for (const value of values) {\n if (value === null || value === undefined || value === false || value === '') {\n continue;\n }\n if (typeof value === 'string') {\n pushClasses(into, value);\n continue;\n }\n if (typeof value === 'number') {\n into.push(String(value));\n continue;\n }\n if (isClassList(value)) {\n flattenClasses(value, into);\n continue;\n }\n for (const [className, active] of Object.entries(value)) {\n if (active) {\n // A dictionary key may itself carry several classes.\n pushClasses(into, className);\n }\n }\n }\n}\n\n/**\n * Splits `hover:focus:px-2` into its variants and base, ignoring the colons\n * that appear inside an arbitrary value such as `bg-[url(https://…)]`.\n */\nfunction splitVariants(className: string): { variants: string; base: string } {\n let depth = 0;\n let lastSeparator = -1;\n let index = 0;\n while (index < className.length) {\n const character = className[index];\n if (character === '[' || character === '(') {\n depth += 1;\n } else if (character === ']' || character === ')') {\n depth -= 1;\n } else if (character === ':' && depth === 0) {\n lastSeparator = index;\n }\n index += 1;\n }\n if (lastSeparator === -1) {\n return { variants: '', base: className };\n }\n return { variants: className.slice(0, lastSeparator), base: className.slice(lastSeparator + 1) };\n}\n\n/**\n * The merge group a class belongs to, or `null` when it must be left alone.\n *\n * Two classes merge only when their group is equal, and the group carries the\n * variant prefix — `sm:px-2` never overrides a bare `px-4`.\n */\nfunction groupKeyFor(className: string): string | null {\n const { variants, base } = splitVariants(className);\n if (Object.hasOwn(SINGLETON_UTILITIES, base)) {\n return `${variants}|${SINGLETON_UTILITIES[base]}`;\n }\n for (const prefix of VALUE_UTILITY_PREFIXES) {\n if (base === prefix) {\n return `${variants}|${prefix}`;\n }\n if (!base.startsWith(`${prefix}-`)) {\n continue;\n }\n // `important` and a trailing `!` are not values; neither is an unknown word,\n // which is how `text-sm`/`border-white` escape the numeric families.\n const suffix = base.slice(prefix.length + 1);\n if (!VALUE_SUFFIX.test(suffix)) {\n return null;\n }\n return `${variants}|${prefix}`;\n }\n return null;\n}\n\n/**\nDrops an exact duplicate, keeping its last occurrence.\n*/\nfunction dedupeClasses(classes: readonly string[]): string[] {\n const lastIndex = new Map<string, number>();\n classes.forEach((className, index) => {\n lastIndex.set(className, index);\n });\n return classes.filter((className, index) => lastIndex.get(className) === index);\n}\n\n/**\nDrops each class that a later member of its own group has replaced.\n*/\nfunction mergeGroups(classes: readonly string[]): string[] {\n const merged: string[] = [];\n const positionByGroup = new Map<string, number>();\n for (const className of classes) {\n const group = groupKeyFor(className);\n if (group !== null) {\n const previous = positionByGroup.get(group);\n if (previous !== undefined) {\n merged[previous] = '';\n }\n positionByGroup.set(group, merged.length);\n }\n merged.push(className);\n }\n return merged.filter((className) => className !== '');\n}\n\n/**\n * Joins class names, dropping falsy entries, exact duplicates, and superseded\n * utilities.\n *\n * ```ts\n * cn('px-4', undefined, ['py-2', { 'font-bold': isActive }], 'px-6'); // 'py-2 px-6'\n * ```\n */\nfunction cn(...inputs: ClassValue[]): string {\n const flattened: string[] = [];\n flattenClasses(inputs, flattened);\n return mergeGroups(dedupeClasses(flattened)).join(' ');\n}\n\nexport { cn };\nexport type { ClassDictionary, ClassValue };\n"],
5
- "mappings": "AAoDA,MAAMA,EAA4C,CAEhD,UACA,UACA,QACA,YACA,YACA,WACA,YACA,YACA,WACA,QACA,MACA,MACA,QACA,SACA,OACA,UACA,UACA,QACA,QACA,MACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,IAEA,QACA,QACA,QACA,QACA,OACA,IACA,IAEA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,YACA,YACA,YACA,YACA,YACA,YACA,UAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,SAEA,cACA,OACA,WACA,WACA,iBACA,cACA,cACA,QACA,SAEA,WACA,WACA,YACA,YAEA,QACA,OACA,SACA,QACA,IACA,UACA,UACA,WACA,WACA,SAQIC,EAA8C,CAElD,OAAQ,WACR,MAAO,WACP,SA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AAS,IAAMO,CAAK,CAChF,CAKA,SAASU,EAAYF,EAA0B,CAC7C,MAAMG,EAAmB,CAAA,EACnBC,EAAkB,IAAI,IAC5B,UAAWnB,KAAae,EAAS,CAC/B,MAAMK,EAAQX,EAAYT,CAAS,EACnC,GAAIoB,IAAU,KAAM,CAClB,MAAMC,EAAWF,EAAgB,IAAIC,CAAK,EACtCC,IAAa,SACfH,EAAOG,CAAQ,EAAI,IAErBF,EAAgB,IAAIC,EAAOF,EAAO,MAAM,CAC1C,CACAA,EAAO,KAAKlB,CAAS,CACvB,CACA,OAAOkB,EAAO,OAAQlB,GAAcA,IAAc,EAAE,CACtD,CAUA,SAASsB,KAAMC,EAAoB,CACjC,MAAMC,EAAsB,CAAA,EAC5B,OAAAvB,EAAesB,EAAQC,CAAS,EACzBP,EAAYH,EAAcU,CAAS,CAAC,EAAE,KAAK,GAAG,CACvD",
6
- "names": ["VALUE_UTILITY_PREFIXES", "SINGLETON_UTILITIES", "VALUE_SUFFIX", "isClassList", "value", "pushClasses", "into", "className", "flattenClasses", "values", "active", "splitVariants", "depth", "lastSeparator", "index", "character", "groupKeyFor", "variants", "base", "prefix", "suffix", "dedupeClasses", "classes", "lastIndex", "mergeGroups", "merged", "positionByGroup", "group", "previous", "cn", "inputs", "flattened"]
5
+ "mappings": "+EAoDA,MAAMA,EAA4C,CAEhD,UACA,UACA,QACA,YACA,YACA,WACA,YACA,YACA,WACA,QACA,MACA,MACA,QACA,SACA,OACA,UACA,UACA,QACA,QACA,MACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,IAEA,QACA,QACA,QACA,QACA,OACA,IACA,IAEA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,YACA,YACA,YACA,YACA,YACA,YACA,UAEA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,SAEA,cACA,OACA,WACA,WACA,iBACA,cACA,cACA,QACA,SAEA,WACA,WACA,Y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A,eA0BT,SAASK,EAAcC,EAA0B,CAC/C,MAAMC,EAAY,IAAI,IACtB,OAAAD,EAAQ,QAAQ,CAACf,EAAWO,IAAS,CACnCS,EAAU,IAAIhB,EAAWO,CAAK,CAChC,CAAC,EACMQ,EAAQ,OAAO,CAACf,EAAWO,IAAUS,EAAU,IAAIhB,CAAS,IAAMO,CAAK,CAChF,CANSV,EAAAiB,EAAA,iBAWT,SAASG,EAAYF,EAA0B,CAC7C,MAAMG,EAAmB,CAAA,EACnBC,EAAkB,IAAI,IAC5B,UAAWnB,KAAae,EAAS,CAC/B,MAAMK,EAAQX,EAAYT,CAAS,EACnC,GAAIoB,IAAU,KAAM,CAClB,MAAMC,EAAWF,EAAgB,IAAIC,CAAK,EACtCC,IAAa,SACfH,EAAOG,CAAQ,EAAI,IAErBF,EAAgB,IAAIC,EAAOF,EAAO,MAAM,CAC1C,CACAA,EAAO,KAAKlB,CAAS,CACvB,CACA,OAAOkB,EAAO,OAAQlB,GAAcA,IAAc,EAAE,CACtD,CAfSH,EAAAoB,EAAA,eAyBT,SAASK,KAAMC,EAAoB,CACjC,MAAMC,EAAsB,CAAA,EAC5B,OAAAvB,EAAesB,EAAQC,CAAS,EACzBP,EAAYH,EAAcU,CAAS,CAAC,EAAE,KAAK,GAAG,CACvD,CAJS3B,EAAAyB,EAAA",
6
+ "names": ["VALUE_UTILITY_PREFIXES", "SINGLETON_UTILITIES", "VALUE_SUFFIX", "isClassList", "value", "__name", "pushClasses", "into", "className", "flattenClasses", "values", "active", "splitVariants", "depth", "lastSeparator", "index", "character", "groupKeyFor", "variants", "base", "prefix", "suffix", "dedupeClasses", "classes", "lastIndex", "mergeGroups", "merged", "positionByGroup", "group", "previous", "cn", "inputs", "flattened"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rexezuge/web",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,8 +25,8 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@rexezuge/errors": "1.5.1",
29
- "@rexezuge/shared": "1.5.1"
28
+ "@rexezuge/errors": "1.5.2",
29
+ "@rexezuge/shared": "1.5.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "lucide-react": "^1.49.0",