@rexezuge/web 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Badge.js.map +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/Card.js.map +1 -1
- package/dist/FocusInput.js.map +1 -1
- package/dist/Input.js.map +1 -1
- package/dist/LoadingButton.js.map +1 -1
- package/dist/Pagination.js.map +1 -1
- package/dist/Spinner.js.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/theme.js.map +1 -1
- package/dist/useCurrentUser.js.map +1 -1
- package/dist/useNotice.js.map +1 -1
- package/dist/useSpaLanguage.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/dist/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../src/Badge.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AA2B7B,sDAAsD;AACtD,MAAM,cAAc,GAAG,8EAA8E,CAAC;AAEtG,uFAAuF;AACvF,MAAM,iBAAiB,GAAiC;IACtD,OAAO,EAAE,+DAA+D;IACxE,OAAO,EAAE,+DAA+D;IACxE,OAAO,EAAE,+DAA+D;IACxE,KAAK,EAAE,2DAA2D;IAClE,IAAI,EAAE,yDAAyD;CAChE,CAAC;AAOF,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,EAAwB;IAC9E,OAAO,eAAM,SAAS,EAAE,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AAClG,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,UAAwB,SAAS,EAAE,SAAkB;IACvE,OAAO,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../src/Badge.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AA2B7B,sDAAsD;AACtD,MAAM,cAAc,GAAG,8EAA8E,CAAC;AAEtG,uFAAuF;AACvF,MAAM,iBAAiB,GAAiC;IACtD,OAAO,EAAE,+DAA+D;IACxE,OAAO,EAAE,+DAA+D;IACxE,OAAO,EAAE,+DAA+D;IACxE,KAAK,EAAE,2DAA2D;IAClE,IAAI,EAAE,yDAAyD;CAChE,CAAC;AAOF,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,EAAwB;IAC9E,OAAO,eAAM,SAAS,EAAE,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AAClG,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,UAAwB,SAAS,EAAE,SAAkB;IACvE,OAAO,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;AACnE,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { HTMLAttributes, ReactElement } from 'react';\nimport { cn } from './utils';\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/** Layout and type scale, shared by every variant. */\nconst badgeBaseClass = 'inline-flex shrink-0 items-center rounded-md px-2 py-0.5 text-xs font-medium';\n\n/** The tone palette. `neutral` is the default: an unknown verdict is not a failure. */\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 /** Tone; defaults to `neutral`. */\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"]}
|
package/dist/Button.js.map
CHAN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Q,IAAI,OAAO,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,CACL,kBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,EAC7F,QAAQ,EAAE,QAAQ,IAAI,OAAO,eAClB,OAAO,IAAI,SAAS,EAC/B,OAAO,EAAE,WAAW,KAChB,IAAI,aAEP,OAAO,CAAC,CAAC,CAAC,KAAC,OAAO,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAC,cAAc,EAAC,OAAO,EAAC,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EACvE,QAAQ,IACF,CACV,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,EAAE,OAAO,GAAG,WAAW,EAAE,IAAI,GAAG,IAAI,KAAqD,EAAE,EAC3F,SAAkB;IAElB,OAAO,EAAE,CAAC,eAAe,EAAE,kBAAkB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;AAC5F,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC","sourcesContent":["import type { ButtonHTMLAttributes, MouseEvent, ReactElement } from 'react';\nimport { cn } from './utils';\nimport { Spinner } from './Spinner';\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 /** Visual weight; defaults to `secondary`. */\n variant?: ButtonVariant;\n /** Control size; defaults to `md`. */\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"]}
|
package/dist/Card.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../src/Card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,E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8CAA8C,CAAC;AAIvE,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAA6B;IACnE,OAAO,cAAK,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AACtE,CAAC;AAED,0FAA0F;AAC1F,MAAM,cAAc,GAAG,wDAAwD,CAAC;AAIhF,SAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAA4B;IACjE,OAAO,aAAI,SAAS,EAAE,EAAE,CAAC,cAAc,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AACpE,CAAC;AAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import type { HTMLAttributes, ReactElement } from 'react';\nimport { cn } from './utils';\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/** The card surface. */\nconst cardClass = 'rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] p-5';\n\ninterface CardProps extends HTMLAttributes<HTMLDivElement> {}\n\nfunction Card({ className, ...rest }: Readonly<CardProps>): ReactElement {\n return <div className={cn(cardClass, className)} {...rest} />;\n}\n\n/** The header row: title on the left, actions on the right. */\nconst cardHeaderClass = 'mb-4 flex items-center justify-between gap-3';\n\ninterface CardHeaderProps extends HTMLAttributes<HTMLDivElement> {}\n\nfunction CardHeader({ className, ...rest }: Readonly<CardHeaderProps>): ReactElement {\n return <div className={cn(cardHeaderClass, className)} {...rest} />;\n}\n\n/** The card's title. Renders an `<h2>`; nested headings override the level via `role`. */\nconst cardTitleClass = 'text-lg font-semibold text-[var(--color-text-primary)]';\n\ninterface CardTitleProps extends 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"]}
|
package/dist/FocusInput.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FocusInput.js","sourceRoot":"","sources":["../src/FocusInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAoF,MAAM,OAAO,CAAC;AACnH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AA8BhC,SAAS,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAA6B;IAChF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,UAAU,GAAkB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IAExG,MAAM,WAAW,GAAG,CAAC,KAAmC,EAAQ,EAAE;QAChE,UAAU,CAAC,IAAI,CAAC,CAAC;QACjB,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KAAK,OAAK,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAI,CAAC;AAC1F,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { useState, type CSSProperties, type FocusEvent, type InputHTMLAttributes, type ReactElement } from 'react';\nimport { Input } from './Input';\nimport { theme } from './theme';\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\ninterface FocusInputProps extends 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"]}
|
package/dist/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,mDAAmD;AACnD,MAAM,UAAU,GACd,6RAA6R,CAAC;AAIhS,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAwB;IACzD,OAAO,gBAAO,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AACnE,CAAC;AAID,SAAS,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAyB;IACrE,OAAO,CACL,iBAAQ,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,KAAM,IAAI,YACnD,QAAQ,GACF,CACV,CAAC;AACJ,CAAC;AAID,SAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAA2B;IAC/D,OAAO,mBAAU,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AAC3F,CAAC;AAQD,SAAS,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAwB;IACjE,OAAO,CACL,gBAAO,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,+DAA+D,KAAK,IAAI,YACxG,QAAQ,GACH,CACT,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,mDAAmD;AACnD,MAAM,UAAU,GACd,6RAA6R,CAAC;AAIhS,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAwB;IACzD,OAAO,gBAAO,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AACnE,CAAC;AAID,SAAS,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAyB;IACrE,OAAO,CACL,iBAAQ,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,KAAM,IAAI,YACnD,QAAQ,GACF,CACV,CAAC;AACJ,CAAC;AAID,SAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAA2B;IAC/D,OAAO,mBAAU,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,mBAAmB,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AAC3F,CAAC;AAQD,SAAS,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAwB;IACjE,OAAO,CACL,gBAAO,OAAO,EAAE,OAAO,EAAE,SAAS,EAAC,+DAA+D,KAAK,IAAI,YACxG,QAAQ,GACH,CACT,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type {\n InputHTMLAttributes,\n LabelHTMLAttributes,\n ReactElement,\n ReactNode,\n SelectHTMLAttributes,\n TextareaHTMLAttributes,\n} from 'react';\nimport { cn } from './utils';\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/** The shared look of every text-entry control. */\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\ninterface InputProps extends InputHTMLAttributes<HTMLInputElement> {}\n\nfunction Input({ className, ...rest }: Readonly<InputProps>): ReactElement {\n return <input className={cn(fieldClass, className)} {...rest} />;\n}\n\ninterface SelectProps extends 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\ninterface TextareaProps extends 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 /** The `id` of the control this label names. */\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingButton.js","sourceRoot":"","sources":["../src/LoadingButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAsD,MAAM,OAAO,CAAC;AAClG,OAAO,EAAE,MAAM,EAAuC,MAAM,UAAU,CAAC;AA4CvE,SAAS,aAAa,CAAC,EACrB,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,OAAO,GAAG,SAAS,EACnB,IAAI,GAAG,IAAI,EACX,QAAQ,EACR,IAAI,GAAG,QAAQ,EACf,SAAS,GACoB;IAC7B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9C,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,KAAoC,EAAE,EAAE;QACvC,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,OAAO,EAAE,CAAC;QACzB,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC9B,UAAU,CAAC,IAAI,CAAC,CAAC;YACjB,uEAAuE;YACvE,uEAAuE;YACvE,EAAE;YACF,8DAA8D;YAC9D,uEAAuE;YACvE,uEAAuE;YACvE,uEAAuE;YACvE,mDAAmD;YACnD,MAAM,MAAM,GAAG,GAAS,EAAE;gBACxB,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC;YACF,KAAK,MAAM,CAAC,IAAI,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AAE;gBACxB,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC,CAAC;YACF,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,EACD,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAC7B,CAAC;IAEF,OAAO,CACL,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,YAC/H,QAAQ,GACF,CACV,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { useCallback, useState, type MouseEvent, type ReactElement, type ReactNode } from 'react';\nimport { Button, type ButtonSize, type ButtonVariant } from './Button';\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 /** Runs on activation; the button is busy until a returned promise settles. */\n onClick: () => Promise<void> | void;\n /** Blocks activation regardless of the busy state. */\n disabled?: boolean;\n /** Visual weight; defaults to `primary`. */\n variant?: ButtonVariant;\n /** Control size; defaults to `md`. */\n size?: ButtonSize;\n children: ReactNode;\n /** Defaults to `button`, matching `Button`. */\n type?: 'button' | 'submit' | 'reset';\n /** Extra classes, merged over the button's. */\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 (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled || loading) {\n return;\n }\n const result = onClick();\n if (result instanceof Promise) {\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, settle);\n }\n },\n [disabled, loading, onClick],\n );\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"]}
|
package/dist/Pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","sourceRoot":"","sources":["../src/Pagination.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,sGAAsG;AACtG,SAAS,YAAY,CAAC,KAAa,EAAE,QAAgB;IACnD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QA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U,CAQR,CACV,CAAC,GACE,CACP,EACD,KAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,IAAI,EAAC,QAAQ,EAAE,OAAO,IAAI,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,gBAAc,SAAS,YACtH,SAAS,GACH,IACL,CACP,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import type { ReactElement } from 'react';\nimport { Button } from './Button';\nimport { cn } from './utils';\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/** How many pages `total` items occupy. A non-positive page size yields 1, never `Infinity`/`NaN`. */\nfunction pageCountFor(total: number, pageSize: number): number {\n if (!Number.isFinite(total) || !Number.isFinite(pageSize) || pageSize <= 0 || total <= 0) {\n return 1;\n }\n return Math.ceil(total / pageSize);\n}\n\n/** Pins `page` into `[1, pageCount]`, rounding to the first page when it cannot be read. */\nfunction clampPage(page: number, pageCount: number): number {\n const upper = Math.max(1, Math.trunc(Number.isFinite(pageCount) ? pageCount : 1));\n const wanted = Number.isFinite(page) ? Math.trunc(page) : 1;\n return Math.min(upper, Math.max(1, wanted));\n}\n\n/**\n * The 1-based page numbers to show, keeping the current page as close to the\n * middle of the window as the ends allow. The window is clamped against\n * `windowSize` rather than a fixed `pageCount - 2`, so a non-default window\n * cannot emit page numbers past the last page.\n */\nfunction pageWindow(currentPage: number, pageCount: number, windowSize = 5): number[] {\n const count = Math.min(windowSize, pageCount);\n if (count <= 0) {\n return [];\n }\n const start = Math.max(1, Math.min(currentPage - Math.floor(windowSize / 2), pageCount - count + 1));\n return Array.from({ length: count }, (_, index) => start + index);\n}\n\n/** Overridable text, so an i18next app is not stuck with the English defaults. */\ninterface PaginationLabels {\n /** Prev-button accessible name / label. */\n previous?: string;\n /** Next-button accessible name / label. */\n next?: string;\n /** The \"Page X of Y\" summary in `compact` (and as the pager's `aria-label` in `full`). */\n summary?: (page: number, pageCount: number) => string;\n}\n\ninterface PaginationProps {\n /** The page being displayed, 1-based. Clamped into range for rendering. */\n page: number;\n /** Total pages. Omit to derive it from `total` and `pageSize`. */\n pageCount?: number;\n /** Total item count across every page. */\n total?: number;\n /** Items per page. */\n pageSize?: number;\n /** Called with the 1-based page to move to; already clamped into range. */\n onChange: (page: number) => void;\n /** `full` shows page numbers, `compact` shows a summary. */\n variant?: 'full' | 'compact';\n labels?: PaginationLabels;\n}\n\nfunction Pagination({\n page,\n pageCount,\n total,\n pageSize,\n onChange,\n variant = 'full',\n labels = {},\n}: Readonly<PaginationProps>): ReactElement | null {\n const derivedPageCount =\n pageCount ?? (total !== undefined && pageSize !== undefined ? pageCountFor(total, pageSize) : 1);\n const pages = Math.max(1, Math.trunc(Number.isFinite(derivedPageCount) ? derivedPageCount : 1));\n const current = clampPage(page, pages);\n const previousLabel = labels.previous ?? 'Previous';\n const nextLabel = labels.next ?? 'Next';\n const summaryLabel = labels.summary ?? ((page: number, count: number) => `Page ${page} of ${count}`);\n\n // Nothing to page: a single-page list shows no pager rather than a disabled one.\n if (pages <= 1) {\n return null;\n }\n\n const step = (next: number): void => {\n const target = clampPage(next, pages);\n if (target !== current) {\n onChange(target);\n }\n };\n\n const summary = (\n <span className=\"text-xs text-[var(--color-text-muted)] tabular-nums\">{summaryLabel(current, pages)}</span>\n );\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"]}
|
package/dist/Spinner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../src/Spinner.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AA8BhC,SAAS,OAAO,CAAC,EACf,IAAI,GAAG,EAAE,EACT,KAAK,GAAG,KAAK,CAAC,WAAW,EACzB,KAAK,EACL,OAAO,GAAG,QAAQ,EAClB,KAAK,GACkB;IACvB,OAAO,CACL,eAAK,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,aACpD,cACE,SAAS,EAAC,cAAc,iBACZ,MAAM,EAClB,KAAK,EAAE;oBACL,KAAK,E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esContent":["import type { CSSProperties } from 'react';\nimport { theme } from './theme';\n\n/**\n * The loading ring.\n *\n * ## Provenance\n *\n * `components/ui/Spinner.tsx` in **AWS-AccessBridge** — the only named spinner\n * in the family. The other repos inline the same ring into their buttons as a\n * `Loader2` icon from `lucide-react`, which the kit does not depend on, so this\n * component *is* the kit's spinner vocabulary: `Button` and `LoadingButton`\n * render it while busy.\n *\n * The ring is a bordered circle with one transparent edge, animated by\n * Tailwind's `animate-spin` (present in every consuming app's stylesheet).\n */\n\ninterface SpinnerProps {\n /** Diameter in pixels. */\n size?: number;\n /** Border colour; `currentColor` inherits from the surrounding text. */\n color?: string;\n /** Optional caption under the ring. */\n label?: string;\n /** Padding around the whole block, as a CSS shorthand. */\n padding?: string;\n /** Extra styles for the outer wrapper. */\n style?: CSSProperties;\n}\n\nfunction Spinner({\n size = 24,\n color = theme.spinnerBlue,\n label,\n padding = '16px 0',\n style,\n}: 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"]}
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,kBAAkB,CAAC;AAqG1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,CAAC,OAAO,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACrG,KAAK,EAAE,KAAK,EAAK,IAAY,EAAE,IAAc,EAAc,EAAE,CAAC,OAAO,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzG,MAAM,EAAE,KAAK,EAAK,IAAY,EAAE,IAAc,EAAc,EAAE,CAAC,OAAO,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KAC5G,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,CAAC","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/** The `fetch` shape a client is built on: same-origin by default, no token in JavaScript. */\ntype FetchFn = (input: string, init?: RequestInit) => Promise<Response>;\n\n/** A query-string value. `null`/`undefined`/`''` are omitted, as in every copy. */\ntype QueryValue = string | number | boolean | null | undefined;\n\ntype QueryParams = Record<string, QueryValue | readonly QueryValue[]>;\n\ninterface ApiRequestInit {\n method?: string;\n /** Serialized as JSON with a matching `Content-Type`. */\n body?: unknown;\n headers?: HeadersInit;\n signal?: AbortSignal | null;\n}\n\ninterface CreateApiClientOptions {\n /** Prepended to every path; `''` (the default) sends the path as given. */\n baseUrl?: string;\n /** Headers merged into every request; a per-request header wins over these. */\n headers?: HeadersInit;\n /** Passed through to `fetch`; omitted leaves the browser default. */\n credentials?: RequestCredentials;\n /** Truncation limit for a server-provided error message. Defaults to 500. */\n maxErrorMessageLength?: number;\n}\n\ninterface ApiClient {\n /** One request. Throws a `ServiceError`; resolves to the parsed JSON body. */\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/** Default truncation for a server-provided message. */\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 /** What the server said, or `null` when it said nothing usable. */\n message: string | null;\n /** The server's machine-readable code, when it sent one. */\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/** Rejects control characters: that is what separates text from a binary or a document. */\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 const ErrorClass = HTTP_ERROR_CLASSES[response.status];\n if (ErrorClass !== undefined) {\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"]}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;GAEG;AACH,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,8BAA8B,GAAG,QAAQ,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B;;GAEG;AACH,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,8BAA8B,GAAG,QAAQ,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,CAAC","sourcesContent":["/**\n * Timing and path constants the SPA primitives share.\n *\n * ## Provenance\n *\n * `lib/constants.ts` in **CalDAV-Bridge**, **Durable-DAV**, **Durable-DAV-Router**,\n * **Edge-Git**, **Edge-Sonic**, **Mail-Meow**, **Mail-Otter** and\n * **AWS-AccessBridge** — eight copies, of which only three values are shared by\n * most:\n *\n * | Value | Repos |\n * | --------------------------------- | ----- |\n * | `NOTICE_TIMEOUT_MS = 6000` | 7 of 8 (all but AWS-AccessBridge, which has no notice bar) |\n * | `ZERO_TRUST_AUTHENTICATION_PATH` | 7 of 8 (all but CalDAV-Bridge) |\n * | `COPY_FEEDBACK_TIMEOUT_MS = 1500` | 5 of 8 |\n *\n * Everything else stayed in exactly one repo and is therefore *not* here — a\n * constant with a single consumer is that consumer's vocabulary, not the\n * family's. Consumers re-declaring these locally should delete them and import\n * from `@rexezuge/web`:\n *\n * - `SCAN_POLL_INTERVAL_MS` (Edge-Sonic) — a library-scan poll cadence.\n * - `FORM_HIGHLIGHT_TIMEOUT_MS` (Mail-Otter) — form highlight animation.\n * - `OAUTH2_FEATURES` / `OAUTH2_FEATURE_SCOPES` (Mail-Otter) — provider tables.\n * - `DEFAULT_TEAM_ID` (AWS-AccessBridge) — re-exported from its own `shared`.\n */\n\n/**\n * How long a notice stays on screen before it dismisses itself.\n *\n * Six seconds in every repo that has one: long enough to read a sentence, short\n * enough that a stale error is not still on screen after the user has fixed it.\n */\nconst NOTICE_TIMEOUT_MS = 6000;\n\n/**\n * How long a \"Copied\" affordance stays visible after a clipboard write.\n */\nconst COPY_FEEDBACK_TIMEOUT_MS = 1500;\n\n/**\n * The path that is always behind Cloudflare Access.\n *\n * Navigating here starts the Zero Trust login flow for a caller with no valid\n * session; after login, Access redirects back to the URL it interrupted, which\n * is why each app also registers this path — Edge-Sonic answers it with a\n * redirect to `/` so a returning signer-in does not land on a JSON\n * `Exception{NotFound}` from what they were told was the app home.\n */\nconst ZERO_TRUST_AUTHENTICATION_PATH = '/user/';\n\nexport { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH };\n"]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAG/E,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGrG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGjG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,C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AAC;AAG1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,OAAO,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG7B,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC","sourcesContent":["/**\n * `@rexezuge/web` — the SPA layer of the kit.\n *\n * React primitives, the hooks every app's shell needs, and the one API client.\n * Every export is the converged form of a framework that lived as copies inside\n * the nine consumer repos; see the `## Provenance` block at the top of each\n * module for what it replaced and which copy won.\n *\n * ```ts\n * import { Button, Card, createApiClient, useCurrentUser, useNotice, useSpaLanguage } from '@rexezuge/web';\n * ```\n *\n * ## What a consumer must provide\n *\n * - **The CSS variables the class-based components read.** All six Tailwind\n * repos define the same set, so this is usually already present:\n * `--color-accent`, `--color-accent-dim`, `--color-border`,\n * `--color-surface-base`, `--color-surface-1..4`,\n * `--color-text-primary`, `--color-text-secondary`, `--color-text-muted`, and\n * `--color-{success,error,warning,info,neutral}-{bg,text}`.\n * - **`animate-spin`**, for `Spinner` (and therefore `Button`'s busy state).\n * Tailwind ships it; a non-Tailwind app defines the keyframes once.\n * - **A dependency on `@rexezuge/errors`**, which `api.ts` imports for\n * `ServiceError` and the status classes.\n *\n * ## What is deliberately not here\n *\n * Domain badges (`ConnectionBadge`, `TaskRunStatusBadge`, …), the OAuth\n * `?oauth2=` notice seeding, the D1 bookmark header, WebDAV `207` handling, the\n * authed-first public fallback, and every app's `SUPPORTED_LANGUAGES`. Each had\n * exactly one consumer, so each stays with it — see `constants.ts` and the\n * per-module provenance notes for the list.\n */\n\nexport { Badge, badgeBaseClass, badgeClass, badgeVariantClass } from './Badge';\nexport type { BadgeProps, BadgeVariant } from './Badge';\n\nexport { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass } from './Button';\nexport type { ButtonProps, ButtonSize, ButtonVariant } from './Button';\n\nexport { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle } from './Card';\nexport type { CardHeaderProps, CardProps, CardTitleProps } from './Card';\n\nexport { FocusInput } from './FocusInput';\nexport type { FocusInputProps } from './FocusInput';\n\nexport { Input, Label, Select, Textarea, fieldClass } from './Input';\nexport type { InputProps, LabelProps, SelectProps, TextareaProps } from './Input';\n\nexport { LoadingButton } from './LoadingButton';\nexport type { LoadingButtonProps } from './LoadingButton';\n\nexport { Pagination, clampPage, pageCountFor, pageWindow } from './Pagination';\nexport type { PaginationLabels, PaginationProps } from './Pagination';\n\nexport { Spinner } from './Spinner';\nexport type { SpinnerProps } from './Spinner';\n\nexport {\n btnBase,\n btnBlueStyle,\n btnGreenStyle,\n btnSmallStyle,\n buttonColors,\n cardStyle,\n inputStyle,\n paginationBtnStyle,\n tableCardStyle,\n tdStyle,\n theme,\n thStyle,\n} from './theme';\n\nexport { cn } from './utils';\nexport type { ClassDictionary, ClassValue } from './utils';\n\nexport { COPY_FEEDBACK_TIMEOUT_MS, NOTICE_TIMEOUT_MS, ZERO_TRUST_AUTHENTICATION_PATH } from './constants';\n\nexport { useNotice } from './useNotice';\nexport type { Notice, NoticeKind, ShowNotice, UseNoticeOptions, UseNoticeResult } from './useNotice';\n\nexport {\n canonicalizeLanguageTag,\n DEFAULT_FALLBACK_LANGUAGE,\n DEFAULT_LANGUAGE_STORAGE_KEY,\n DEFAULT_SUPPORTED_LANGUAGES,\n resolveLanguageTag,\n useSpaLanguage,\n} from './useSpaLanguage';\nexport type { LanguageTag, UseSpaLanguageOptions, UseSpaLanguageResult } from './useSpaLanguage';\n\nexport { CURRENT_USER_PATH, useCurrentUser } from './useCurrentUser';\nexport type { CurrentUser, UseCurrentUserOptions, UseCurrentUserResult } from './useCurrentUser';\n\nexport { buildQuery, createApiClient, HttpStatusError, MAX_ERROR_MESSAGE_LENGTH } from './api';\nexport type { ApiClient, ApiRequestInit, CreateApiClientOptions, FetchFn, QueryParams, QueryValue } from './api';\n"]}
|
package/dist/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;GAGG;AACH,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,SAAS;IACrB,GAAG,EAAE,SAAS;IACd,QAAQ,EAAE,SAAS;IACnB,WAAW,EAAE,SAAS;IACtB,gDAAgD;IAChD,WAAW,EAAE,SAAS;CACd,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,YAAY,GAAkD;IAClE,IAAI,EAAE,EAA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ACZ,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,OAAO,GACR,CAAC","sourcesContent":["import type { CSSProperties } from 'react';\n\n/**\n * Design tokens for the inline-styled parts of the SPA.\n *\n * ## Provenance\n *\n * Verbatim from `apps/web/src/components/ui/theme.ts` in **AWS-AccessBridge**,\n * which is the only repo of the eight that styled its primitives with inline\n * styles rather than Tailwind classes. It wins by default: nothing else in the\n * family carries a token table, and the six Tailwind repos encode the same\n * decisions as CSS custom properties (`--color-accent`, `--color-surface-1`, …)\n * in their `globals.css` instead of in TypeScript.\n *\n * So this file serves two audiences:\n *\n * - Consumers that render the class-based primitives (`Button`, `Card`, `Input`,\n * `Badge`, `Pagination`) need nothing from here — those components carry\n * Tailwind classes that read the CSS variables their `globals.css` defines.\n * - Consumers with bespoke, non-Tailwind surfaces (AWS-AccessBridge's admin\n * tables and its `LoadingButton` chrome) use these tokens directly.\n *\n * The two are deliberately not unified: collapsing them would either push hex\n * values into the class-based components or force every Tailwind consumer to\n * declare a TypeScript mirror of their theme. Neither repo family does that\n * today, and a token that exists in two places is a token that drifts.\n */\n\n/**\n * The palette. One flat record so a consumer can spread it into a CSS-in-JS\n * theme or read `theme.accent`-style names without a nested lookup.\n */\nconst theme = {\n cardBg: '#1e2433',\n inputBg: '#252d3d',\n border: '#374151',\n blue: '#2563eb',\n blueHover: '#1d4ed8',\n green: '#16a34a',\n greenHover: '#15803d',\n red: '#dc2626',\n redHover: '#b91c1c',\n spinnerBlue: '#60a5fa',\n /** The border colour a focused field paints. */\n focusBorder: '#3b82f6',\n} as const;\n\n/**\n * Background/hover pairs for the solid action colours.\n *\n * Keyed by colour name rather than by the kit's `Button` variants because a\n * plain colour table is what a bespoke button needs; `Button` maps its\n * normalized variants onto its own classes.\n */\nconst buttonColors: Record<string, { bg: string; hover: string }> = {\n blue: { bg: theme.blue, hover: theme.blueHover },\n green: { bg: theme.green, hover: theme.greenHover },\n red: { bg: theme.red, hover: theme.redHover },\n};\n\n/** The standard content card surface. */\nconst cardStyle: CSSProperties = {\n background: theme.cardBg,\n borderRadius: '12px',\n padding: '24px',\n};\n\n/** The standard text field surface. */\nconst inputStyle: CSSProperties = {\n width: '100%',\n padding: '12px',\n background: theme.inputBg,\n borderRadius: '8px',\n border: `1px solid ${theme.border}`,\n color: '#ffffff',\n outline: 'none',\n boxSizing: 'border-box',\n transition: 'border-color 0.15s',\n};\n\n/** A card whose content is a table: the table supplies its own padding. */\nconst tableCardStyle: CSSProperties = {\n background: theme.cardBg,\n borderRadius: '12px',\n overflow: 'hidden',\n};\n\n/** Column header cell. */\nconst thStyle: CSSProperties = {\n textAlign: 'left',\n padding: '12px',\n background: theme.inputBg,\n color: '#9ca3af',\n textTransform: 'uppercase',\n letterSpacing: '0.05em',\n fontSize: '12px',\n fontWeight: 500,\n};\n\n/** Body cell. */\nconst tdStyle: CSSProperties = {\n padding: '12px',\n borderTop: '1px solid rgba(55,65,81,0.3)',\n};\n\n/** A pager control, as used by `Pagination`'s inline-styled consumers. */\nconst paginationBtnStyle: CSSProperties = {\n padding: '6px 12px',\n background: theme.inputBg,\n border: 'none',\n borderRadius: '8px',\n color: 'white',\n cursor: 'pointer',\n transition: 'background 0.15s',\n};\n\n/**\n * Shared geometry for the solid action buttons: `btnBlueStyle`, `btnGreenStyle`\n * and the small variant each spread it and override only what differs, so a\n * change to the radius or weight lands in all of them at once.\n */\nconst btnBase: CSSProperties = {\n padding: '10px 20px',\n borderRadius: '8px',\n color: 'white',\n fontWeight: 500,\n border: 'none',\n cursor: 'pointer',\n transition: 'background 0.15s',\n};\n\nconst btnBlueStyle: CSSProperties = { ...btnBase, background: theme.blue };\nconst btnGreenStyle: CSSProperties = { ...btnBase, background: theme.green };\n\n/** The dense action button used in table rows. */\nconst btnSmallStyle: CSSProperties = {\n padding: '6px 12px',\n borderRadius: '6px',\n color: 'white',\n fontWeight: 500,\n fontSize: '13px',\n border: 'none',\n cursor: 'pointer',\n transition: 'background 0.15s',\n};\n\nexport {\n btnBase,\n btnBlueStyle,\n btnGreenStyle,\n btnSmallStyle,\n buttonColors,\n cardStyle,\n inputStyle,\n paginationBtnStyle,\n tableCardStyle,\n tdStyle,\n theme,\n thStyle,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrentUser.js","sourceRoot":"","sources":["../src/useCurrentUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkEhD,yDAAyD;AACzD,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC,SAAS,cAAc,CACrB,MAAiB,EACjB,EAAE,IAAI,GAAG,iBAAiB,KAAsC,EAAE;IAElE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAC;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAsB,IAAI,CAAC,CAAC;IAC9D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE9C,2EAA2E;IAC3E,oDAAoD;IACpD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,SAAS,CAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAC7B,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACjC,CAAC,EA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E;YACpE,gDAAgD;YAChD,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YACnC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;IAEtB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC1C,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { ServiceError } from '@rexezuge/errors';\nimport type { ApiClient } from './api';\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/** The account shape a caller reads. `preferredLanguage` is what `useSpaLanguage` consumes. */\ninterface CurrentUser {\n preferredLanguage?: string | null;\n}\n\ninterface UseCurrentUserOptions {\n /** The path to GET. Defaults to `/user/me`, the family's profile route. */\n path?: string;\n}\n\ninterface UseCurrentUserResult<TUser> {\n /** The account, or `null` until it loads (and after a failure). */\n user: TUser | null;\n /** `true` while the request is in flight, including the first one. */\n loading: boolean;\n /** The normalized failure, or `null`. A `ServiceError`, always. */\n error: ServiceError | null;\n /** Re-runs the request. */\n reload: () => void;\n}\n\n/** The profile route every repo in the family serves. */\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 setReloadKey((key) => key + 1);\n }, []);\n\n useEffect(() => {\n let cancelled = false;\n setLoading(true);\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"]}
|
package/dist/useNotice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNotice.js","sourceRoot":"","sources":["../src/useNotice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAgEhD,SAAS,SAAS,CAAC,EAAE,cAAc,GAAG,iBAAiB,EAAE,OAAO,GAAG,IAAI,KAAiC,EAAE;IACxG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAgB,OAAO,CAAC,CAAC;IAC7D,MAAM,QAAQ,GAAG,MAAM,CAAuC,IAAI,CAAC,CAAC;IAEpE,MAAM,qBAAqB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7C,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,qBAAqB,EAAE,CAAC;QACxB,SAAS,CAAC,IAAI,CAAC,CAAC;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AAO,KAAK,IAAI,EAAE,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/B,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;IAC1B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,qBAAqB,EAAE,CAAC;QACxB,SAAS,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAE5B,MAAM,UAAU,GAAG,WAAW,CAC5B,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QAChB,yEAAyE;QACzE,wEAAwE;QACxE,mBAAmB;QACnB,qBAAqB,EAAE,CAAC;QACxB,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAC7B,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YACjC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC;YACxB,SAAS,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC,EAAE,cAAc,CAAC,CAAC;IACrB,CAAC,EACD,CAAC,qBAAqB,EAAE,cAAc,CAAC,CACxC,CAAC;IAEF,wEAAwE;IACxE,yDAAyD;IACzD,SAAS,CAAC,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAEhE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;AAC/C,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { NOTICE_TIMEOUT_MS } from './constants';\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/** One transient message. `kind` is the tone, `message` the sentence. */\ninterface Notice {\n kind: NoticeKind;\n message: string;\n}\n\n/** The setter views and hooks are handed. */\ntype ShowNotice = (kind: NoticeKind, message: string) => void;\n\ninterface UseNoticeOptions {\n /** How long a notice stays up. Defaults to `NOTICE_TIMEOUT_MS`. */\n dismissAfterMs?: number;\n /** A notice to start with — the URL-seeded OAuth result, in a consumer. */\n initial?: Notice | null;\n}\n\ninterface UseNoticeResult {\n /** The notice to render, or `null` when there is nothing to say. */\n notice: Notice | null;\n /** Shows a notice, replacing any notice already showing (and its timer). */\n showNotice: ShowNotice;\n /** Hides the notice and cancels its pending dismissal. */\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpaLanguage.js","sourceRoot":"","sources":["../src/useSpaLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,qFAAqF;AACrF,MAAM,2BAA2B,GAA2B,CAAC,IAAI,CAAC,CAAC;AAEnE,2DAA2D;AAC3D,MAAM,yBAAyB,GAAgB,IAAI,CAAC;AAEpD,8DAA8D;AAC9D,MAAM,4BAA4B,GAAG,UAAU,CAAC;AAYhD,kFAAkF;AAClF,SAAS,iBAAiB,CAAC,SAAiC;IAC1D,OAAO,SAAS,CAAC,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AM,CAAC;YACP,8DAA8D;QAChE,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,GAAW,EAAE,EAAE;QACd,MAAM,IAAI,GAAG,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;QAC3E,gBAAgB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACnE,yEAAyE;QACzE,wEAAwE;QACxE,mBAAmB;QACnB,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC,EACD,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,UAAU,CAAC,CACnD,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC;AAClE,CAAC;AAED,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,GACf,CAAC","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/** The tags offered when a caller does not say. English-only is the safe default. */\nconst DEFAULT_SUPPORTED_LANGUAGES: readonly LanguageTag[] = ['en'];\n\n/** The tag used when nothing supported can be resolved. */\nconst DEFAULT_FALLBACK_LANGUAGE: LanguageTag = 'en';\n\n/** The `localStorage` key used when a caller does not say. */\nconst DEFAULT_LANGUAGE_STORAGE_KEY = 'language';\n\n/** One entry of the supported list, pre-canonicalized for comparison. */\ninterface SupportedLanguage {\n /** The tag as the caller spells it — what the hook returns. */\n tag: LanguageTag;\n /** Its canonical form, for matching. */\n key: string;\n /** Its primary subtag (`zh` for `zh-CN`). */\n primary: string;\n}\n\n/** The supported list in canonical form, computed once per render of the hook. */\nfunction describeSupported(supported: readonly LanguageTag[]): SupportedLanguage[] {\n return supported.map((tag) => {\n const key = canonicalizeLanguageTag(tag);\n return { tag, key, primary: key.split('-')[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('-')[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 /** The tags the app ships bundles for. Memoize it: it is a dependency. */\n supported?: readonly LanguageTag[];\n /** The `localStorage` key the choice is persisted under. */\n storageKey?: string;\n /** The tag used when nothing supported resolves. Defaults to `en`. */\n fallbackLanguage?: LanguageTag;\n}\n\ninterface UseSpaLanguageResult {\n /** The tag currently in effect — a member of `supported`. */\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 /** The tags offered, as resolved — render this list in a selector. */\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[]>(\n () => (supportedKey === '' ? [] : supportedKey.split(' ')),\n [supportedKey],\n );\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 effect\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 useEffect(() => {\n if (preferred === undefined || preferred === null || preferred.trim() === '') {\n return;\n }\n const next = resolveLanguageTag(preferred, supportedLanguages, fallbackLanguage);\n setLanguageState((current) => (current === next ? current : next));\n }, [preferred, supportedLanguages, fallbackLanguage]);\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 {\n canonicalizeLanguageTag,\n DEFAULT_FALLBACK_LANGUAGE,\n DEFAULT_LANGUAGE_STORAGE_KEY,\n DEFAULT_SUPPORTED_LANGUAGES,\n resolveLanguageTag,\n useSpaLanguage,\n};\nexport type { LanguageTag, UseSpaLanguageOptions, UseSpaLanguageResult };\n"]}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAUH;;;GAGG;AACH,MAAM,sBAAsB,GAAsB;IAChD,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,OAAO;IACP,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,WAAW;IACX,UAAU;IACV,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;IACP,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,SAAS;IACT,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,GAAG;IACH,GAAG;IACH,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,SAAS;IACT,8DAA8D;IAC9D,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,QAAQ;IACR,uDAAuD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C,GAAG,MAAoB;IACjC,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC,OAAO,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzD,CAAC;AAED,OAAO,EAAE,EAAE,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAUH;;;GAGG;AACH,MAAM,sBAAsB,GAAsB;IAChD,kBAAkB;IAClB,SAAS;IACT,SAAS;IACT,OAAO;IACP,WAAW;IACX,WAAW;IACX,UAAU;IACV,WAAW;IACX,WAAW;IACX,UAAU;IACV,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;IACP,OAAO;IACP,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,SAAS;IACT,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,GAAG;IACH,GAAG;IACH,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,WAAW;IACX,SAAS;IACT,8DAA8D;IAC9D,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,QA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,SAAS,EAAE,CAAC,GAAG,MAAoB;IACjC,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClC,OAAO,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzD,CAAC;AAED,OAAO,EAAE,EAAE,EAAE,CAAC","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/** Everything `cn` accepts, mirroring clsx's `ClassValue`. */\ntype ClassValue = string | number | boolean | null | undefined | ClassDictionary | readonly ClassValue[];\n\n/** `{ 'px-4': isActive }` — a class is present when its value is truthy. */\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/** A length/count-like remainder: `-2`, `1.5`, `[3px]`, `px`, `full`, `none`. */\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/** Pushes the whitespace-separated classes of one string, dropping empties. */\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/** Flattens clsx-style inputs into the classes they contribute, in order. */\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 for (let index = 0; index < className.length; index += 1) {\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 }\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 const singletonGroup = SINGLETON_UTILITIES[base];\n if (singletonGroup !== undefined) {\n return `${variants}|${singletonGroup}`;\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/** Drops an exact duplicate, keeping its last occurrence. */\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/** Drops each class that a later member of its own group has replaced. */\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexezuge/web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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.0.
|
|
29
|
-
"@rexezuge/shared": "1.0.
|
|
28
|
+
"@rexezuge/errors": "1.0.3",
|
|
29
|
+
"@rexezuge/shared": "1.0.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^19.3.0",
|