@rexezuge/web 0.0.0-stage → 1.0.1
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/LICENSE +21 -0
- package/dist/Badge.d.ts +42 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +25 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Button.d.ts +69 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +39 -0
- package/dist/Button.js.map +1 -0
- package/dist/Card.d.ts +42 -0
- package/dist/Card.d.ts.map +1 -0
- package/dist/Card.js +42 -0
- package/dist/Card.js.map +1 -0
- package/dist/FocusInput.d.ts +32 -0
- package/dist/FocusInput.d.ts.map +1 -0
- package/dist/FocusInput.js +19 -0
- package/dist/FocusInput.js.map +1 -0
- package/dist/Input.d.ts +52 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +49 -0
- package/dist/Input.js.map +1 -0
- package/dist/LoadingButton.d.ts +46 -0
- package/dist/LoadingButton.d.ts.map +1 -0
- package/dist/LoadingButton.js +30 -0
- package/dist/LoadingButton.js.map +1 -0
- package/dist/Pagination.d.ts +63 -0
- package/dist/Pagination.d.ts.map +1 -0
- package/dist/Pagination.js +75 -0
- package/dist/Pagination.js.map +1 -0
- package/dist/Spinner.d.ts +31 -0
- package/dist/Spinner.d.ts.map +1 -0
- package/dist/Spinner.js +14 -0
- package/dist/Spinner.js.map +1 -0
- package/dist/api.d.ts +132 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +258 -0
- package/dist/api.js.map +1 -0
- package/dist/constants.d.ts +49 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +49 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/theme.d.ts +79 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +134 -0
- package/dist/theme.js.map +1 -0
- package/dist/useCurrentUser.d.ts +67 -0
- package/dist/useCurrentUser.d.ts.map +1 -0
- package/dist/useCurrentUser.js +49 -0
- package/dist/useCurrentUser.js.map +1 -0
- package/dist/useNotice.d.ts +60 -0
- package/dist/useNotice.d.ts.map +1 -0
- package/dist/useNotice.js +34 -0
- package/dist/useNotice.js.map +1 -0
- package/dist/useSpaLanguage.d.ts +81 -0
- package/dist/useSpaLanguage.d.ts.map +1 -0
- package/dist/useSpaLanguage.js +149 -0
- package/dist/useSpaLanguage.js.map +1 -0
- package/dist/utils.d.ts +53 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +346 -0
- package/dist/utils.js.map +1 -0
- package/package.json +51 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rexezuge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/Badge.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A status pill.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* `components/ui/Badge.tsx` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
8
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
9
|
+
* copies that agree on the base classes, the five variants, and the `neutral`
|
|
10
|
+
* default. Edge-Sonic's is the best of them (its props spread onto the DOM
|
|
11
|
+
* element, so a badge can carry `id`/`role`/`data-*`), so it is the shape here.
|
|
12
|
+
*
|
|
13
|
+
* The variants are *tones*, not statuses: every repo additionally carries a
|
|
14
|
+
* stack of domain badges (`ConnectionBadge`, `VisibilityBadge`,
|
|
15
|
+
* `TaskRunStatusBadge`, …) that map its own status vocabulary onto a tone and
|
|
16
|
+
* translate a label with `t()`. Those are product vocabularies with
|
|
17
|
+
* product-specific translation keys, so they stay with their apps — the kit
|
|
18
|
+
* ships the tone layer and `badgeClass()` so a consumer's own
|
|
19
|
+
* `variantFor(status)` maps onto it without re-deriving the classes.
|
|
20
|
+
*
|
|
21
|
+
* Requires the CSS variables `--color-{success,error,warning,info,neutral}-{bg,text}`,
|
|
22
|
+
* which all six consuming apps already define.
|
|
23
|
+
*/
|
|
24
|
+
type BadgeVariant = 'success' | 'error' | 'warning' | 'info' | 'neutral';
|
|
25
|
+
/** Layout and type scale, shared by every variant. */
|
|
26
|
+
declare const badgeBaseClass = "inline-flex shrink-0 items-center rounded-md px-2 py-0.5 text-xs font-medium";
|
|
27
|
+
/** The tone palette. `neutral` is the default: an unknown verdict is not a failure. */
|
|
28
|
+
declare const badgeVariantClass: Record<BadgeVariant, string>;
|
|
29
|
+
interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
30
|
+
/** Tone; defaults to `neutral`. */
|
|
31
|
+
variant?: BadgeVariant;
|
|
32
|
+
}
|
|
33
|
+
declare function Badge({ className, variant, ...rest }: Readonly<BadgeProps>): ReactElement;
|
|
34
|
+
/**
|
|
35
|
+
* The class string for a badge, for callers building the element themselves —
|
|
36
|
+
* a `<button>` that looks like a badge, or a domain badge wrapper that adds
|
|
37
|
+
* `t()`-translated children.
|
|
38
|
+
*/
|
|
39
|
+
declare function badgeClass(variant?: BadgeVariant, className?: string): string;
|
|
40
|
+
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass };
|
|
41
|
+
export type { BadgeProps, BadgeVariant };
|
|
42
|
+
//# sourceMappingURL=Badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../src/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,KAAK,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzE,sDAAsD;AACtD,QAAA,MAAM,cAAc,iFAAiF,CAAC;AAEtG,uFAAuF;AACvF,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAMnD,CAAC;AAEF,UAAU,UAAW,SAAQ,cAAc,CAAC,eAAe,CAAC;IAC1D,mCAAmC;IACnC,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,iBAAS,KAAK,CAAC,EAAE,SAAS,EAAE,OAAmB,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY,CAE9F;AAED;;;;GAIG;AACH,iBAAS,UAAU,CAAC,OAAO,GAAE,YAAwB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC"}
|
package/dist/Badge.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './utils';
|
|
3
|
+
/** Layout and type scale, shared by every variant. */
|
|
4
|
+
const badgeBaseClass = 'inline-flex shrink-0 items-center rounded-md px-2 py-0.5 text-xs font-medium';
|
|
5
|
+
/** The tone palette. `neutral` is the default: an unknown verdict is not a failure. */
|
|
6
|
+
const badgeVariantClass = {
|
|
7
|
+
neutral: 'bg-[var(--color-neutral-bg)] text-[var(--color-neutral-text)]',
|
|
8
|
+
success: 'bg-[var(--color-success-bg)] text-[var(--color-success-text)]',
|
|
9
|
+
warning: 'bg-[var(--color-warning-bg)] text-[var(--color-warning-text)]',
|
|
10
|
+
error: 'bg-[var(--color-error-bg)] text-[var(--color-error-text)]',
|
|
11
|
+
info: 'bg-[var(--color-info-bg)] text-[var(--color-info-text)]',
|
|
12
|
+
};
|
|
13
|
+
function Badge({ className, variant = 'neutral', ...rest }) {
|
|
14
|
+
return _jsx("span", { className: cn(badgeBaseClass, badgeVariantClass[variant], className), ...rest });
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The class string for a badge, for callers building the element themselves —
|
|
18
|
+
* a `<button>` that looks like a badge, or a domain badge wrapper that adds
|
|
19
|
+
* `t()`-translated children.
|
|
20
|
+
*/
|
|
21
|
+
function badgeClass(variant = 'neutral', className) {
|
|
22
|
+
return cn(badgeBaseClass, badgeVariantClass[variant], className);
|
|
23
|
+
}
|
|
24
|
+
export { Badge, badgeBaseClass, badgeClass, badgeVariantClass };
|
|
25
|
+
//# sourceMappingURL=Badge.js.map
|
|
@@ -0,0 +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"}
|
package/dist/Button.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The one button.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* `components/ui/Button.tsx` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
8
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
9
|
+
* copies written from one design, agreeing on the base classes, the four
|
|
10
|
+
* variants (`primary`/`secondary`/`ghost`/`danger`) and the three sizes. The
|
|
11
|
+
* differences that had to be settled:
|
|
12
|
+
*
|
|
13
|
+
* - **Default variant.** CalDAV-Bridge defaults to `primary`; the other five
|
|
14
|
+
* default to `secondary`. The majority wins: a page of solid-coloured
|
|
15
|
+
* buttons is noise, and `primary` should mark the one action that matters.
|
|
16
|
+
* - **`type`.** Durable-DAV and Edge-Sonic default it to `button`; the others
|
|
17
|
+
* leave the HTML default (`submit`) in place, so a `<Button>` inside a
|
|
18
|
+
* `<form>` submits it. The explicit default is kept — it is the documented
|
|
19
|
+
* fix, and a consumer that wants a submit button passes `type="submit"`.
|
|
20
|
+
* - **`ghost` hover.** Four repos hover to `--color-surface-3` with
|
|
21
|
+
* `--color-text-secondary`; Edge-Sonic uses `surface-2`/`text-muted`. The
|
|
22
|
+
* majority wins.
|
|
23
|
+
* - **`danger` hover.** Four repos use `hover:brightness-125`; Edge-Sonic uses
|
|
24
|
+
* `hover:opacity-90`. The majority wins.
|
|
25
|
+
*
|
|
26
|
+
* ## Loading
|
|
27
|
+
*
|
|
28
|
+
* Converged from **AWS-AccessBridge**'s `components/ui/LoadingButton.tsx`, the
|
|
29
|
+
* one place the family tracked busy state itself. Its two behaviours fold
|
|
30
|
+
* cleanly into this component's `loading` prop: the button is `disabled` while
|
|
31
|
+
* loading (so neither a pointer, a keyboard, nor a screen reader can activate
|
|
32
|
+
* it), *and* the click handler bails out, so a synthesized `click()` — which
|
|
33
|
+
* jsdom and some test harnesses dispatch without honouring `disabled` — cannot
|
|
34
|
+
* fire a second submission. The ring is this package's `Spinner`, which
|
|
35
|
+
* inherits the button's text colour.
|
|
36
|
+
*/
|
|
37
|
+
type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
|
|
38
|
+
type ButtonSize = 'sm' | 'md' | 'lg';
|
|
39
|
+
/**
|
|
40
|
+
* Layout and focus affordance. The focus ring is on `focus-visible`, so a
|
|
41
|
+
* pointer press does not paint it and a keyboard press always does.
|
|
42
|
+
*/
|
|
43
|
+
declare const buttonBaseClass = "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)]";
|
|
44
|
+
declare const buttonVariantClass: Record<ButtonVariant, string>;
|
|
45
|
+
declare const buttonSizeClass: Record<ButtonSize, string>;
|
|
46
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
47
|
+
/** Visual weight; defaults to `secondary`. */
|
|
48
|
+
variant?: ButtonVariant;
|
|
49
|
+
/** Control size; defaults to `md`. */
|
|
50
|
+
size?: ButtonSize;
|
|
51
|
+
/**
|
|
52
|
+
* Shows the spinner and blocks activation until it clears. A busy button is
|
|
53
|
+
* a disabled button: the prop alone is enough, no `disabled` bookkeeping at
|
|
54
|
+
* the call site.
|
|
55
|
+
*/
|
|
56
|
+
loading?: boolean;
|
|
57
|
+
}
|
|
58
|
+
declare function Button({ className, variant, size, loading, disabled, children, onClick, type, ...rest }: Readonly<ButtonProps>): ReactElement;
|
|
59
|
+
/**
|
|
60
|
+
* The class string for a button, for callers rendering the element themselves —
|
|
61
|
+
* a link styled as a button, or a toolbar control that is not a `<button>`.
|
|
62
|
+
*/
|
|
63
|
+
declare function buttonClass({ variant, size }?: {
|
|
64
|
+
variant?: ButtonVariant;
|
|
65
|
+
size?: ButtonSize;
|
|
66
|
+
}, className?: string): string;
|
|
67
|
+
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass };
|
|
68
|
+
export type { ButtonProps, ButtonSize, ButtonVariant };
|
|
69
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAc,YAAY,EAAE,MAAM,OAAO,CAAC;AAI5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,KAAK,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAClE,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAErC;;;GAGG;AACH,QAAA,MAAM,eAAe,0PACoO,CAAC;AAE1P,QAAA,MAAM,kBAAkB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAKrD,CAAC;AAEF,QAAA,MAAM,eAAe,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAI/C,CAAC;AAEF,UAAU,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACnE,8CAA8C;IAC9C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,sCAAsC;IACtC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,iBAAS,MAAM,CAAC,EACd,SAAS,EACT,OAAqB,EACrB,IAAW,EACX,OAAe,EACf,QAAgB,EAChB,QAAQ,EACR,OAAO,EACP,IAAe,EACf,GAAG,IAAI,EACR,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,YAAY,CAuBtC;AAED;;;GAGG;AACH,iBAAS,WAAW,CAClB,EAAE,OAAqB,EAAE,IAAW,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,aAAa,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAA;CAAO,EAC3F,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAER;AAED,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC;AACrF,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/Button.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './utils';
|
|
3
|
+
import { Spinner } from './Spinner';
|
|
4
|
+
/**
|
|
5
|
+
* Layout and focus affordance. The focus ring is on `focus-visible`, so a
|
|
6
|
+
* pointer press does not paint it and a keyboard press always does.
|
|
7
|
+
*/
|
|
8
|
+
const buttonBaseClass = '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)]';
|
|
9
|
+
const buttonVariantClass = {
|
|
10
|
+
primary: 'bg-[var(--color-accent)] text-[#0d1008] hover:bg-[var(--color-accent-dim)]',
|
|
11
|
+
secondary: 'bg-[var(--color-surface-3)] text-[var(--color-text-primary)] hover:bg-[var(--color-surface-4)]',
|
|
12
|
+
ghost: 'bg-transparent text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-3)] hover:text-[var(--color-text-primary)]',
|
|
13
|
+
danger: 'bg-[var(--color-error-bg)] text-[var(--color-error-text)] hover:brightness-125',
|
|
14
|
+
};
|
|
15
|
+
const buttonSizeClass = {
|
|
16
|
+
sm: 'px-3 py-1.5 text-xs',
|
|
17
|
+
md: 'px-4 py-2',
|
|
18
|
+
lg: 'px-5 py-2.5 text-base',
|
|
19
|
+
};
|
|
20
|
+
function Button({ className, variant = 'secondary', size = 'md', loading = false, disabled = false, children, onClick, type = 'button', ...rest }) {
|
|
21
|
+
const handleClick = (event) => {
|
|
22
|
+
// Belt and braces: `disabled` already stops a real pointer or key press,
|
|
23
|
+
// and this stops a synthesized event from re-entering an in-flight action.
|
|
24
|
+
if (disabled || loading) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
onClick?.(event);
|
|
28
|
+
};
|
|
29
|
+
return (_jsxs("button", { type: type, className: cn(buttonBaseClass, buttonVariantClass[variant], buttonSizeClass[size], className), disabled: disabled || loading, "aria-busy": loading || undefined, onClick: handleClick, ...rest, children: [loading ? _jsx(Spinner, { size: 16, color: "currentColor", padding: "0" }) : null, children] }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The class string for a button, for callers rendering the element themselves —
|
|
33
|
+
* a link styled as a button, or a toolbar control that is not a `<button>`.
|
|
34
|
+
*/
|
|
35
|
+
function buttonClass({ variant = 'secondary', size = 'md' } = {}, className) {
|
|
36
|
+
return cn(buttonBaseClass, buttonVariantClass[variant], buttonSizeClass[size], className);
|
|
37
|
+
}
|
|
38
|
+
export { Button, buttonBaseClass, buttonClass, buttonSizeClass, buttonVariantClass };
|
|
39
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../src/Button.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyCpC;;;GAGG;AACH,MAAM,eAAe,GACnB,uPAAuP,CAAC;AAE1P,MAAM,kBAAkB,GAAkC;IACxD,OAAO,EAAE,4EAA4E;IACrF,SAAS,EAAE,gGAAgG;IAC3G,KAAK,EAAE,4HAA4H;IACnI,MAAM,EAAE,gFAAgF;CACzF,CAAC;AAEF,MAAM,eAAe,GAA+B;IAClD,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,WAAW;IACf,EAAE,EAAE,uBAAuB;CAC5B,CAAC;AAeF,SAAS,MAAM,CAAC,EACd,SAAS,EACT,OAAO,GAAG,WAAW,EACrB,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,OAAO,EACP,IAAI,GAAG,QAAQ,EACf,GAAG,IAAI,EACe;IACtB,MAAM,WAAW,GAAG,CAAC,KAAoC,EAAQ,EAAE;QACjE,yEAAyE;QACzE,2EAA2E;QAC3E,IAAI,QAAQ,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"}
|
package/dist/Card.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Surface primitives: `Card`, `CardHeader`, `CardTitle`.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* `components/ui/Card.tsx` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
8
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
9
|
+
* copies that are identical apart from Edge-Sonic's two improvements, both of
|
|
10
|
+
* which are adopted here:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Props spread onto the DOM element.** The other five take only
|
|
13
|
+
* `className` and `children`, so a card that needs an `id`, a `role` or a
|
|
14
|
+
* `data-testid` has to be wrapped in a redundant element.
|
|
15
|
+
* 2. **The base classes live in one exported string** rather than being
|
|
16
|
+
* re-spelled by `CardHeader`/`CardTitle`, so a change to the surface lands
|
|
17
|
+
* once.
|
|
18
|
+
*
|
|
19
|
+
* `CardTitle` renders an `<h2>` in every copy. No copy in the family
|
|
20
|
+
* parameterised the heading level, and inventing a `headingLevel` prop here
|
|
21
|
+
* would strand the other six call sites, so the level stays fixed and a caller
|
|
22
|
+
* that needs a different level composes the class string it needs from
|
|
23
|
+
* `cardTitleClass`.
|
|
24
|
+
*/
|
|
25
|
+
/** The card surface. */
|
|
26
|
+
declare const cardClass = "rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] p-5";
|
|
27
|
+
interface CardProps extends HTMLAttributes<HTMLDivElement> {
|
|
28
|
+
}
|
|
29
|
+
declare function Card({ className, ...rest }: Readonly<CardProps>): ReactElement;
|
|
30
|
+
/** The header row: title on the left, actions on the right. */
|
|
31
|
+
declare const cardHeaderClass = "mb-4 flex items-center justify-between gap-3";
|
|
32
|
+
interface CardHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
33
|
+
}
|
|
34
|
+
declare function CardHeader({ className, ...rest }: Readonly<CardHeaderProps>): ReactElement;
|
|
35
|
+
/** The card's title. Renders an `<h2>`; nested headings override the level via `role`. */
|
|
36
|
+
declare const cardTitleClass = "text-lg font-semibold text-[var(--color-text-primary)]";
|
|
37
|
+
interface CardTitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
38
|
+
}
|
|
39
|
+
declare function CardTitle({ className, ...rest }: Readonly<CardTitleProps>): ReactElement;
|
|
40
|
+
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle };
|
|
41
|
+
export type { CardHeaderProps, CardProps, CardTitleProps };
|
|
42
|
+
//# sourceMappingURL=Card.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../src/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAwB;AACxB,QAAA,MAAM,SAAS,mFAAmF,CAAC;AAEnG,UAAU,SAAU,SAAQ,cAAc,CAAC,cAAc,CAAC;CAAG;AAE7D,iBAAS,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,YAAY,CAEvE;AAED,+DAA+D;AAC/D,QAAA,MAAM,eAAe,iDAAiD,CAAC;AAEvE,UAAU,eAAgB,SAAQ,cAAc,CAAC,cAAc,CAAC;CAAG;AAEnE,iBAAS,UAAU,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,YAAY,CAEnF;AAED,0FAA0F;AAC1F,QAAA,MAAM,cAAc,2DAA2D,CAAC;AAEhF,UAAU,cAAe,SAAQ,cAAc,CAAC,kBAAkB,CAAC;CAAG;AAEtE,iBAAS,SAAS,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,YAAY,CAEjF;AAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AACnF,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/Card.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Surface primitives: `Card`, `CardHeader`, `CardTitle`.
|
|
5
|
+
*
|
|
6
|
+
* ## Provenance
|
|
7
|
+
*
|
|
8
|
+
* `components/ui/Card.tsx` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
9
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
10
|
+
* copies that are identical apart from Edge-Sonic's two improvements, both of
|
|
11
|
+
* which are adopted here:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Props spread onto the DOM element.** The other five take only
|
|
14
|
+
* `className` and `children`, so a card that needs an `id`, a `role` or a
|
|
15
|
+
* `data-testid` has to be wrapped in a redundant element.
|
|
16
|
+
* 2. **The base classes live in one exported string** rather than being
|
|
17
|
+
* re-spelled by `CardHeader`/`CardTitle`, so a change to the surface lands
|
|
18
|
+
* once.
|
|
19
|
+
*
|
|
20
|
+
* `CardTitle` renders an `<h2>` in every copy. No copy in the family
|
|
21
|
+
* parameterised the heading level, and inventing a `headingLevel` prop here
|
|
22
|
+
* would strand the other six call sites, so the level stays fixed and a caller
|
|
23
|
+
* that needs a different level composes the class string it needs from
|
|
24
|
+
* `cardTitleClass`.
|
|
25
|
+
*/
|
|
26
|
+
/** The card surface. */
|
|
27
|
+
const cardClass = 'rounded-xl border border-[var(--color-border)] bg-[var(--color-surface-1)] p-5';
|
|
28
|
+
function Card({ className, ...rest }) {
|
|
29
|
+
return _jsx("div", { className: cn(cardClass, className), ...rest });
|
|
30
|
+
}
|
|
31
|
+
/** The header row: title on the left, actions on the right. */
|
|
32
|
+
const cardHeaderClass = 'mb-4 flex items-center justify-between gap-3';
|
|
33
|
+
function CardHeader({ className, ...rest }) {
|
|
34
|
+
return _jsx("div", { className: cn(cardHeaderClass, className), ...rest });
|
|
35
|
+
}
|
|
36
|
+
/** The card's title. Renders an `<h2>`; nested headings override the level via `role`. */
|
|
37
|
+
const cardTitleClass = 'text-lg font-semibold text-[var(--color-text-primary)]';
|
|
38
|
+
function CardTitle({ className, ...rest }) {
|
|
39
|
+
return _jsx("h2", { className: cn(cardTitleClass, className), ...rest });
|
|
40
|
+
}
|
|
41
|
+
export { Card, cardClass, cardHeaderClass, cardTitleClass, CardHeader, CardTitle };
|
|
42
|
+
//# sourceMappingURL=Card.js.map
|
package/dist/Card.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.js","sourceRoot":"","sources":["../src/Card.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wBAAwB;AACxB,MAAM,SAAS,GAAG,gFAAgF,CAAC;AAInG,SAAS,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAuB;IACvD,OAAO,cAAK,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AAChE,CAAC;AAED,+DAA+D;AAC/D,MAAM,eAAe,GAAG,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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type InputHTMLAttributes, type ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A text field that paints its border while it holds focus.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* `components/ui/FocusInput.tsx` in **AWS-AccessBridge** — the only copy in the
|
|
8
|
+
* family, and the only AWS primitive still in active use after the Tailwind
|
|
9
|
+
* repos' `Input` absorbed the focus treatment into its class list
|
|
10
|
+
* (`focus:border-[var(--color-accent)]`). It is kept because the two mechanisms
|
|
11
|
+
* are not equivalent for a consumer without Tailwind: the class version needs
|
|
12
|
+
* the stylesheet, the inline version needs nothing.
|
|
13
|
+
*
|
|
14
|
+
* Two normalizations from the original:
|
|
15
|
+
*
|
|
16
|
+
* - It **renders `Input`**, so the field's base styling (padding, radius,
|
|
17
|
+
* disabled opacity, placeholder colour) comes from the kit instead of a
|
|
18
|
+
* second, drifting copy.
|
|
19
|
+
* - It no longer re-spells `inputStyle`. The original built its own style
|
|
20
|
+
* object and merged the caller's over it; this one passes `style` straight
|
|
21
|
+
* through, which is the same contract with one less place to change.
|
|
22
|
+
*
|
|
23
|
+
* Auto-focus is the standard `autoFocus` attribute — React applies it on mount,
|
|
24
|
+
* and a component-level `focus()` call in an effect would race the caller's own
|
|
25
|
+
* focus management for no gain.
|
|
26
|
+
*/
|
|
27
|
+
interface FocusInputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
28
|
+
}
|
|
29
|
+
declare function FocusInput({ style, onFocus, onBlur, ...rest }: Readonly<FocusInputProps>): ReactElement;
|
|
30
|
+
export { FocusInput };
|
|
31
|
+
export type { FocusInputProps };
|
|
32
|
+
//# sourceMappingURL=FocusInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FocusInput.d.ts","sourceRoot":"","sources":["../src/FocusInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiD,KAAK,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAInH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,UAAU,eAAgB,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;CAAG;AAE1E,iBAAS,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,YAAY,CAehG;AAED,OAAO,EAAE,UAAU,EAAE,CAAC;AACtB,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Input } from './Input';
|
|
4
|
+
import { theme } from './theme';
|
|
5
|
+
function FocusInput({ style, onFocus, onBlur, ...rest }) {
|
|
6
|
+
const [focused, setFocused] = useState(false);
|
|
7
|
+
const focusStyle = { borderColor: focused ? theme.focusBorder : theme.border, ...style };
|
|
8
|
+
const handleFocus = (event) => {
|
|
9
|
+
setFocused(true);
|
|
10
|
+
onFocus?.(event);
|
|
11
|
+
};
|
|
12
|
+
const handleBlur = (event) => {
|
|
13
|
+
setFocused(false);
|
|
14
|
+
onBlur?.(event);
|
|
15
|
+
};
|
|
16
|
+
return _jsx(Input, { ...rest, style: focusStyle, onFocus: handleFocus, onBlur: handleBlur });
|
|
17
|
+
}
|
|
18
|
+
export { FocusInput };
|
|
19
|
+
//# sourceMappingURL=FocusInput.js.map
|
|
@@ -0,0 +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,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,CAAC,KAAmC,EAAQ,EAAE;QAC/D,UAAU,CAAC,KAAK,CAAC,CAAC;QAClB,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,KAAC,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"}
|
package/dist/Input.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, LabelHTMLAttributes, ReactElement, ReactNode, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Form controls: `Input`, `Select`, `Textarea`, `Label`.
|
|
4
|
+
*
|
|
5
|
+
* ## Provenance
|
|
6
|
+
*
|
|
7
|
+
* `components/ui/Input.tsx` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
8
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
9
|
+
* copies that all export the same four controls and agree on the field classes
|
|
10
|
+
* up to two drifting details, both settled the Edge-Sonic way:
|
|
11
|
+
*
|
|
12
|
+
* 1. **One shared class string** (`fieldClass`) instead of four re-spelled
|
|
13
|
+
* copies. CalDAV-Bridge, Durable-DAV-Router, Edge-Git and Mail-Otter omit
|
|
14
|
+
* `w-full` from their `Select`; CalDAV-Bridge's `Select`/`Label` and every
|
|
15
|
+
* `Textarea` re-spell the field classes minus one property. A placeholder
|
|
16
|
+
* colour that matches an input but not its select is a difference nobody
|
|
17
|
+
* notices until a client is looking at both.
|
|
18
|
+
* 2. **`htmlFor` is stated, not spread.** Edge-Sonic's `Label` takes `htmlFor`
|
|
19
|
+
* and `children` explicitly, because a label with no `for` is announced as
|
|
20
|
+
* unassociated text: the click target and the accessible name both depend
|
|
21
|
+
* on it, and neither is visible in the markup that omits it.
|
|
22
|
+
*
|
|
23
|
+
* ## Error state
|
|
24
|
+
*
|
|
25
|
+
* None of the six copies carries an error state — each renders its field-level
|
|
26
|
+
* error beside the input with its own markup (a `<p>` in `--color-error-text`,
|
|
27
|
+
* or the app's notice bar), and none of them wires `aria-invalid`. Rather than
|
|
28
|
+
* invent a sixth shape, the kit leaves the element to do what it already does:
|
|
29
|
+
* `aria-invalid` and `aria-describedby` are standard input attributes and both
|
|
30
|
+
* spread through here, and a consumer whose design reddens the border on error
|
|
31
|
+
* passes the class itself (`className={error ? 'border-[var(--color-error-text)]' : undefined}`).
|
|
32
|
+
*/
|
|
33
|
+
/** The shared look of every text-entry control. */
|
|
34
|
+
declare const fieldClass = "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";
|
|
35
|
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
36
|
+
}
|
|
37
|
+
declare function Input({ className, ...rest }: Readonly<InputProps>): ReactElement;
|
|
38
|
+
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
|
|
39
|
+
}
|
|
40
|
+
declare function Select({ className, children, ...rest }: Readonly<SelectProps>): ReactElement;
|
|
41
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
42
|
+
}
|
|
43
|
+
declare function Textarea({ className, ...rest }: Readonly<TextareaProps>): ReactElement;
|
|
44
|
+
interface LabelProps extends Omit<LabelHTMLAttributes<HTMLLabelElement>, 'htmlFor'> {
|
|
45
|
+
/** The `id` of the control this label names. */
|
|
46
|
+
htmlFor?: string;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
declare function Label({ children, htmlFor, ...rest }: Readonly<LabelProps>): ReactElement;
|
|
50
|
+
export { Input, Label, Select, Textarea, fieldClass };
|
|
51
|
+
export type { InputProps, LabelProps, SelectProps, TextareaProps };
|
|
52
|
+
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,OAAO,CAAC;AAGf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,mDAAmD;AACnD,QAAA,MAAM,UAAU,gSAC+Q,CAAC;AAEhS,UAAU,UAAW,SAAQ,mBAAmB,CAAC,gBAAgB,CAAC;CAAG;AAErE,iBAAS,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY,CAEzE;AAED,UAAU,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;CAAG;AAExE,iBAAS,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,YAAY,CAMrF;AAED,UAAU,aAAc,SAAQ,sBAAsB,CAAC,mBAAmB,CAAC;CAAG;AAE9E,iBAAS,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,YAAY,CAE/E;AAED,UAAU,UAAW,SAAQ,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IACjF,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,iBAAS,KAAK,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY,CAMjF;AAED,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;AACtD,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/Input.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Form controls: `Input`, `Select`, `Textarea`, `Label`.
|
|
5
|
+
*
|
|
6
|
+
* ## Provenance
|
|
7
|
+
*
|
|
8
|
+
* `components/ui/Input.tsx` in **CalDAV-Bridge**, **Durable-DAV**,
|
|
9
|
+
* **Durable-DAV-Router**, **Edge-Git**, **Edge-Sonic** and **Mail-Otter** — six
|
|
10
|
+
* copies that all export the same four controls and agree on the field classes
|
|
11
|
+
* up to two drifting details, both settled the Edge-Sonic way:
|
|
12
|
+
*
|
|
13
|
+
* 1. **One shared class string** (`fieldClass`) instead of four re-spelled
|
|
14
|
+
* copies. CalDAV-Bridge, Durable-DAV-Router, Edge-Git and Mail-Otter omit
|
|
15
|
+
* `w-full` from their `Select`; CalDAV-Bridge's `Select`/`Label` and every
|
|
16
|
+
* `Textarea` re-spell the field classes minus one property. A placeholder
|
|
17
|
+
* colour that matches an input but not its select is a difference nobody
|
|
18
|
+
* notices until a client is looking at both.
|
|
19
|
+
* 2. **`htmlFor` is stated, not spread.** Edge-Sonic's `Label` takes `htmlFor`
|
|
20
|
+
* and `children` explicitly, because a label with no `for` is announced as
|
|
21
|
+
* unassociated text: the click target and the accessible name both depend
|
|
22
|
+
* on it, and neither is visible in the markup that omits it.
|
|
23
|
+
*
|
|
24
|
+
* ## Error state
|
|
25
|
+
*
|
|
26
|
+
* None of the six copies carries an error state — each renders its field-level
|
|
27
|
+
* error beside the input with its own markup (a `<p>` in `--color-error-text`,
|
|
28
|
+
* or the app's notice bar), and none of them wires `aria-invalid`. Rather than
|
|
29
|
+
* invent a sixth shape, the kit leaves the element to do what it already does:
|
|
30
|
+
* `aria-invalid` and `aria-describedby` are standard input attributes and both
|
|
31
|
+
* spread through here, and a consumer whose design reddens the border on error
|
|
32
|
+
* passes the class itself (`className={error ? 'border-[var(--color-error-text)]' : undefined}`).
|
|
33
|
+
*/
|
|
34
|
+
/** The shared look of every text-entry control. */
|
|
35
|
+
const fieldClass = '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';
|
|
36
|
+
function Input({ className, ...rest }) {
|
|
37
|
+
return _jsx("input", { className: cn(fieldClass, className), ...rest });
|
|
38
|
+
}
|
|
39
|
+
function Select({ className, children, ...rest }) {
|
|
40
|
+
return (_jsx("select", { className: cn(fieldClass, className), ...rest, children: children }));
|
|
41
|
+
}
|
|
42
|
+
function Textarea({ className, ...rest }) {
|
|
43
|
+
return _jsx("textarea", { className: cn(fieldClass, 'min-h-20 resize-y', className), ...rest });
|
|
44
|
+
}
|
|
45
|
+
function Label({ children, htmlFor, ...rest }) {
|
|
46
|
+
return (_jsx("label", { htmlFor: htmlFor, className: "mb-1 block text-xs font-medium text-[var(--color-text-muted)]", ...rest, children: children }));
|
|
47
|
+
}
|
|
48
|
+
export { Input, Label, Select, Textarea, fieldClass };
|
|
49
|
+
//# sourceMappingURL=Input.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import { type ButtonSize, type ButtonVariant } from './Button';
|
|
3
|
+
/**
|
|
4
|
+
* A button that owns its own busy state.
|
|
5
|
+
*
|
|
6
|
+
* ## Provenance
|
|
7
|
+
*
|
|
8
|
+
* `components/ui/LoadingButton.tsx` in **AWS-AccessBridge**. `Button` absorbed
|
|
9
|
+
* everything it does — the `loading` prop, the disabled-while-busy semantics,
|
|
10
|
+
* the spinner — so a consumer that drives state itself should reach for
|
|
11
|
+
* `Button`. This wrapper stays for the call sites that hand it an async
|
|
12
|
+
* `onClick` and let it track the in-flight promise, which is the shape every
|
|
13
|
+
* `LoadingButton` in that repo uses.
|
|
14
|
+
*
|
|
15
|
+
* Two normalizations from the original:
|
|
16
|
+
*
|
|
17
|
+
* - **Variant names.** `'blue' | 'green' | 'red'` became the kit's
|
|
18
|
+
* `'primary' | 'secondary' | 'danger' | 'ghost'`; the original's default
|
|
19
|
+
* (`'blue'`, the solid action colour) maps to `primary`, and that default is
|
|
20
|
+
* kept even though `Button` itself defaults to `secondary` — a caller that
|
|
21
|
+
* reaches for this component wants the action to be the loudest thing it can
|
|
22
|
+
* be, and the original's call sites all relied on it.
|
|
23
|
+
* - **The handler is fire-and-forget with `void`.** `onClick` may return a
|
|
24
|
+
* promise; the button holds `loading` until it settles, and the promise is
|
|
25
|
+
* deliberately not awaited inside the handler so an `await`-less call site
|
|
26
|
+
* reads the same as an async one.
|
|
27
|
+
*/
|
|
28
|
+
interface LoadingButtonProps {
|
|
29
|
+
/** Runs on activation; the button is busy until a returned promise settles. */
|
|
30
|
+
onClick: () => Promise<void> | void;
|
|
31
|
+
/** Blocks activation regardless of the busy state. */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** Visual weight; defaults to `primary`. */
|
|
34
|
+
variant?: ButtonVariant;
|
|
35
|
+
/** Control size; defaults to `md`. */
|
|
36
|
+
size?: ButtonSize;
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
/** Defaults to `button`, matching `Button`. */
|
|
39
|
+
type?: 'button' | 'submit' | 'reset';
|
|
40
|
+
/** Extra classes, merged over the button's. */
|
|
41
|
+
className?: string;
|
|
42
|
+
}
|
|
43
|
+
declare function LoadingButton({ onClick, disabled, variant, size, children, type, className, }: Readonly<LoadingButtonProps>): ReactElement;
|
|
44
|
+
export { LoadingButton };
|
|
45
|
+
export type { LoadingButtonProps };
|
|
46
|
+
//# sourceMappingURL=LoadingButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingButton.d.ts","sourceRoot":"","sources":["../src/LoadingButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClG,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,UAAU,kBAAkB;IAC1B,+EAA+E;IAC/E,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACpC,sDAAsD;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,sCAAsC;IACtC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iBAAS,aAAa,CAAC,EACrB,OAAO,EACP,QAAgB,EAChB,OAAmB,EACnB,IAAW,EACX,QAAQ,EACR,IAAe,EACf,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,YAAY,CAiC7C;AAED,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import { Button } from './Button';
|
|
4
|
+
function LoadingButton({ onClick, disabled = false, variant = 'primary', size = 'md', children, type = 'button', className, }) {
|
|
5
|
+
const [loading, setLoading] = useState(false);
|
|
6
|
+
const handleClick = useCallback((event) => {
|
|
7
|
+
if (disabled || loading) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const result = onClick();
|
|
11
|
+
if (result instanceof Promise) {
|
|
12
|
+
setLoading(true);
|
|
13
|
+
// The state flip is scheduled before the await, not after it: a caller
|
|
14
|
+
// reading the tree right after the click must already see the spinner.
|
|
15
|
+
//
|
|
16
|
+
// A rejection clears the busy state and is deliberately *not*
|
|
17
|
+
// re-thrown: the handler is fire-and-forget, so re-throwing would only
|
|
18
|
+
// produce an unhandled rejection (and a failed test run under vitest).
|
|
19
|
+
// The call site owns its error reporting — every AWS-AccessBridge call
|
|
20
|
+
// site does exactly that inside its own `onClick`.
|
|
21
|
+
const settle = () => {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
};
|
|
24
|
+
void result.then(settle, settle);
|
|
25
|
+
}
|
|
26
|
+
}, [disabled, loading, onClick]);
|
|
27
|
+
return (_jsx(Button, { variant: variant, size: size, type: type, className: className, loading: loading, disabled: disabled, onClick: handleClick, children: children }));
|
|
28
|
+
}
|
|
29
|
+
export { LoadingButton };
|
|
30
|
+
//# sourceMappingURL=LoadingButton.js.map
|
|
@@ -0,0 +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,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"}
|