@ttt-productions/ui-core 0.11.19 → 0.11.21
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/react/components/consequence-dialog.d.ts +8 -9
- package/dist/react/components/consequence-dialog.d.ts.map +1 -1
- package/dist/react/components/consequence-dialog.js +8 -13
- package/dist/react/components/consequence-dialog.js.map +1 -1
- package/dist/react/components/date-time-picker.d.ts +43 -0
- package/dist/react/components/date-time-picker.d.ts.map +1 -0
- package/dist/react/components/date-time-picker.js +188 -0
- package/dist/react/components/date-time-picker.js.map +1 -0
- package/dist/react/components/format-control.d.ts +25 -0
- package/dist/react/components/format-control.d.ts.map +1 -0
- package/dist/react/components/format-control.js +23 -0
- package/dist/react/components/format-control.js.map +1 -0
- package/dist/react/components/input.d.ts +38 -1
- package/dist/react/components/input.d.ts.map +1 -1
- package/dist/react/components/input.js +5 -2
- package/dist/react/components/input.js.map +1 -1
- package/dist/react/components/search-dropdown.d.ts +19 -6
- package/dist/react/components/search-dropdown.d.ts.map +1 -1
- package/dist/react/components/search-dropdown.js +74 -37
- package/dist/react/components/search-dropdown.js.map +1 -1
- package/dist/react/components/textarea.d.ts +11 -1
- package/dist/react/components/textarea.d.ts.map +1 -1
- package/dist/react/components/textarea.js +3 -2
- package/dist/react/components/textarea.js.map +1 -1
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -0
- package/dist/react/index.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import { type DeclaredInputFormat } from '@ttt-productions/input-format-core';
|
|
1
2
|
/**
|
|
2
|
-
* The inline
|
|
3
|
-
* the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* The inline reason field. The caller OWNS the reason value/onChange (draft state lives at the call
|
|
4
|
+
* site) and the field's declaration — this component declares no business numbers and no copy.
|
|
5
|
+
* Confirm stays disabled until the value passes the declaration's check; `min: 0` makes the reason
|
|
6
|
+
* optional.
|
|
6
7
|
*/
|
|
7
8
|
export interface ConsequenceDialogReason {
|
|
8
|
-
|
|
9
|
-
minLength?: number;
|
|
10
|
-
maxLength?: number;
|
|
9
|
+
inputFormat: DeclaredInputFormat;
|
|
11
10
|
placeholder?: string;
|
|
12
11
|
label?: React.ReactNode;
|
|
13
12
|
value: string;
|
|
@@ -36,7 +35,7 @@ export interface ConsequenceDialogProps {
|
|
|
36
35
|
delayedEffect?: React.ReactNode;
|
|
37
36
|
/** SLOT 3 — whether/how this can be undone or superseded. */
|
|
38
37
|
reversibility?: React.ReactNode;
|
|
39
|
-
/** Inline
|
|
38
|
+
/** Inline reason field. Optional. */
|
|
40
39
|
reason?: ConsequenceDialogReason;
|
|
41
40
|
/** Exact-phrase typed-confirmation gate. Optional. */
|
|
42
41
|
typedConfirmation?: ConsequenceDialogTypedConfirmation;
|
|
@@ -55,7 +54,7 @@ export interface ConsequenceDialogProps {
|
|
|
55
54
|
}
|
|
56
55
|
/**
|
|
57
56
|
* A reusable confirm-before-a-consequential-action dialog. Three optional, consistently-styled
|
|
58
|
-
* consequence slots (immediate / afterward / reversibility), an optional inline
|
|
57
|
+
* consequence slots (immediate / afterward / reversibility), an optional inline reason field,
|
|
59
58
|
* and an optional exact-phrase typed-confirmation gate. Composes the ui-core AlertDialog primitives
|
|
60
59
|
* (Radix) — it never re-implements them. Supports BOTH a `trigger` (uncontrolled) and `open` /
|
|
61
60
|
* `onOpenChange` (controlled).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consequence-dialog.d.ts","sourceRoot":"","sources":["../../../src/react/components/consequence-dialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"consequence-dialog.d.ts","sourceRoot":"","sources":["../../../src/react/components/consequence-dialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAuC,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAGnH;;;;;GAKG;AACH,MAAM,WAAW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AChC,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,eAAe,EACf,aAAa,EACb,aAAa,EACb,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,WAAsB,EACtB,WAAmB,EACnB,SAAS,GACV,EAAE,sBAAsB,+BAgJxB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useId, useState } from 'react';
|
|
3
|
+
import { useCallback, useId, useMemo, useState } from 'react';
|
|
4
4
|
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, } from './alert-dialog.js';
|
|
5
5
|
import { Button } from './button.js';
|
|
6
6
|
import { Textarea } from './textarea.js';
|
|
7
7
|
import { Input } from './input.js';
|
|
8
8
|
import { Label } from './label.js';
|
|
9
|
+
import { checkInputFormat, defineInputFormat } from '@ttt-productions/input-format-core';
|
|
9
10
|
import { Zap, Clock, RotateCcw } from 'lucide-react';
|
|
10
11
|
const SLOT_ICON_CLASS = 'icon-xs mt-0.5 shrink-0 text-muted-foreground';
|
|
11
12
|
/**
|
|
@@ -18,7 +19,7 @@ function ConsequenceRow({ icon: Icon, label, children, }) {
|
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* A reusable confirm-before-a-consequential-action dialog. Three optional, consistently-styled
|
|
21
|
-
* consequence slots (immediate / afterward / reversibility), an optional inline
|
|
22
|
+
* consequence slots (immediate / afterward / reversibility), an optional inline reason field,
|
|
22
23
|
* and an optional exact-phrase typed-confirmation gate. Composes the ui-core AlertDialog primitives
|
|
23
24
|
* (Radix) — it never re-implements them. Supports BOTH a `trigger` (uncontrolled) and `open` /
|
|
24
25
|
* `onOpenChange` (controlled).
|
|
@@ -65,20 +66,14 @@ export function ConsequenceDialog({ trigger, open, onOpenChange, title, immediat
|
|
|
65
66
|
setPending(false);
|
|
66
67
|
}
|
|
67
68
|
}, [pending, onConfirm, setOpenState]);
|
|
68
|
-
const
|
|
69
|
-
const reasonProvided = reasonTrimmedLength > 0;
|
|
70
|
-
const reasonOk = !reason
|
|
71
|
-
? true
|
|
72
|
-
: reason.required && !reasonProvided
|
|
73
|
-
? false
|
|
74
|
-
: !reasonProvided
|
|
75
|
-
? true // optional + empty is fine
|
|
76
|
-
: (reason.minLength === undefined || reasonTrimmedLength >= reason.minLength) &&
|
|
77
|
-
(reason.maxLength === undefined || reason.value.length <= reason.maxLength);
|
|
69
|
+
const reasonOk = !reason || checkInputFormat(reason.value, reason.inputFormat).ok;
|
|
78
70
|
const typedOk = !typedConfirmation ? true : typedValue === typedConfirmation.phrase;
|
|
71
|
+
// The phrase is one line, and nothing longer than it can ever match it.
|
|
72
|
+
const phrase = typedConfirmation?.phrase ?? '';
|
|
73
|
+
const typedFormat = useMemo(() => (phrase.length > 0 ? defineInputFormat({ format: 'singleLine', min: 1, max: phrase.length }) : null), [phrase]);
|
|
79
74
|
return (_jsxs(AlertDialog, { open: actualOpen, onOpenChange: handleOpenChange, children: [trigger ? _jsx(AlertDialogTrigger, { asChild: true, children: trigger }) : null, _jsxs(AlertDialogContent, { onEscapeKeyDown: (e) => {
|
|
80
75
|
if (pending)
|
|
81
76
|
e.preventDefault();
|
|
82
|
-
}, children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: title }), _jsx(AlertDialogDescription, { asChild: true, children: _jsxs("div", { className: "stack-3 text-left", children: [immediateEffect ? (_jsx(ConsequenceRow, { icon: Zap, label: "Immediately", children: immediateEffect })) : null, delayedEffect ? (_jsx(ConsequenceRow, { icon: Clock, label: "Afterward", children: delayedEffect })) : null, reversibility ? (_jsx(ConsequenceRow, { icon: RotateCcw, label: "Reversibility", children: reversibility })) : null] }) })] }), reason ? (_jsxs("div", { className: "stack-2", children: [_jsx(Label, { htmlFor: reasonId, children: reason.label ?? 'Reason' }), _jsx(Textarea, { id: reasonId, value: reason.value, onChange: (e) => reason.onChange(e.target.value), placeholder: reason.placeholder,
|
|
77
|
+
}, children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: title }), _jsx(AlertDialogDescription, { asChild: true, children: _jsxs("div", { className: "stack-3 text-left", children: [immediateEffect ? (_jsx(ConsequenceRow, { icon: Zap, label: "Immediately", children: immediateEffect })) : null, delayedEffect ? (_jsx(ConsequenceRow, { icon: Clock, label: "Afterward", children: delayedEffect })) : null, reversibility ? (_jsx(ConsequenceRow, { icon: RotateCcw, label: "Reversibility", children: reversibility })) : null] }) })] }), reason ? (_jsxs("div", { className: "stack-2", children: [_jsx(Label, { htmlFor: reasonId, children: reason.label ?? 'Reason' }), _jsx(Textarea, { id: reasonId, value: reason.value, onChange: (e) => reason.onChange(e.target.value), placeholder: reason.placeholder, inputFormat: reason.inputFormat, rows: reason.rows ?? 3, disabled: pending })] })) : null, typedConfirmation && typedFormat ? (_jsxs("div", { className: "stack-2", children: [_jsx(Label, { htmlFor: typedId, children: typedConfirmation.label ?? (_jsxs(_Fragment, { children: ["Type ", _jsx("span", { className: "font-mono", children: typedConfirmation.phrase }), " to confirm"] })) }), _jsx(Input, { id: typedId, value: typedValue, onChange: (e) => setTypedValue(e.target.value), placeholder: typedConfirmation.phrase, inputFormat: typedFormat, disabled: pending, autoComplete: "off" })] })) : null, _jsxs(AlertDialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: () => handleOpenChange(false), disabled: pending, children: cancelLabel }), _jsx(Button, { variant: destructive ? 'destructive' : 'default', onClick: handleConfirm, disabled: !reasonOk || !typedOk, pending: pending, children: confirmLabel })] })] })] }));
|
|
83
78
|
}
|
|
84
79
|
//# sourceMappingURL=consequence-dialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consequence-dialog.js","sourceRoot":"","sources":["../../../src/react/components/consequence-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,E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,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC9C,WAAW,EAAE,iBAAiB,CAAC,MAAM,EACrC,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAC,KAAK,GAClB,IACE,CACP,CAAC,CAAC,CAAC,IAAI,EAER,MAAC,iBAAiB,eAChB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACtC,QAAQ,EAAE,OAAO,YAEhB,WAAW,GACL,EACT,KAAC,MAAM,IACL,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAChD,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,CAAC,QAAQ,IAAI,CAAC,OAAO,EAC/B,OAAO,EAAE,OAAO,YAEf,YAAY,GACN,IACS,IACD,IACT,CACf,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useCallback, useId, useState } from 'react';\nimport {\n AlertDialog,\n AlertDialogTrigger,\n AlertDialogContent,\n AlertDialogHeader,\n AlertDialogFooter,\n AlertDialogTitle,\n AlertDialogDescription,\n} from './alert-dialog.js';\nimport { Button } from './button.js';\nimport { Textarea } from './textarea.js';\nimport { Input } from './input.js';\nimport { Label } from './label.js';\nimport { Zap, Clock, RotateCcw } from 'lucide-react';\n\n/**\n * The inline required-reason config. The caller OWNS the reason value/onChange (draft state lives at\n * the call site). Any `minLength`/`maxLength` the caller supplies MUST come from a caller-owned\n * constant — this component declares no business numbers and no copy; it only derives the gate + the\n * Textarea `maxLength` from the values it is handed.\n */\nexport interface ConsequenceDialogReason {\n required?: boolean;\n minLength?: number;\n maxLength?: number;\n placeholder?: string;\n label?: React.ReactNode;\n value: string;\n onChange: (value: string) => void;\n rows?: number;\n}\n\n/**\n * The exact-match typed-confirmation gate. `phrase` is business copy owned by the CALLER; the\n * component only compares the typed value against it.\n */\nexport interface ConsequenceDialogTypedConfirmation {\n phrase: string;\n label?: React.ReactNode;\n}\n\nexport interface ConsequenceDialogProps {\n /** Uncontrolled open model: the element that opens the dialog (rendered `asChild`). */\n trigger?: React.ReactNode;\n /** Controlled open model. Provide with `onOpenChange`. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /** Heading — a string or node so callers can interpolate amounts / names. */\n title: React.ReactNode;\n\n /** SLOT 1 — what happens right now (e.g. \"initiates a Stripe refund of $X now\"). */\n immediateEffect?: React.ReactNode;\n /** SLOT 2 — what settles later, out of band (webhook / worker / async confirmation). */\n delayedEffect?: React.ReactNode;\n /** SLOT 3 — whether/how this can be undone or superseded. */\n reversibility?: React.ReactNode;\n\n /** Inline required-reason field. Optional. */\n reason?: ConsequenceDialogReason;\n /** Exact-phrase typed-confirmation gate. Optional. */\n typedConfirmation?: ConsequenceDialogTypedConfirmation;\n\n confirmLabel: React.ReactNode;\n cancelLabel?: React.ReactNode;\n /** `true` styles the confirm button with `bg-destructive`. */\n destructive?: boolean;\n\n /**\n * Runs on confirm. May be async — while it is pending the dialog STAYS OPEN, both buttons disable,\n * and the confirm button shows its pending spinner. Closes on resolve. If it rejects the dialog\n * stays open so the caller's own surface (error toast, TOTP step-up) can show and the operator can\n * retry or cancel. This component takes no Sentry/monitoring dependency — every error path\n * belongs to the caller's `onConfirm`.\n */\n onConfirm: () => void | Promise<void>;\n}\n\nconst SLOT_ICON_CLASS = 'icon-xs mt-0.5 shrink-0 text-muted-foreground';\n\n/**\n * One consequence slot: the icon beside a block column whose label sits on its own line above\n * the slot text. Every element is a block: the `stack-*` spacing is a vertical margin, which an\n * inline element ignores.\n */\nfunction ConsequenceRow({\n icon: Icon,\n label,\n children,\n}: {\n icon: typeof Zap;\n label: string;\n children: React.ReactNode;\n}) {\n return (\n <div className=\"flex items-start gap-2\">\n <Icon className={SLOT_ICON_CLASS} aria-hidden=\"true\" />\n <div className=\"stack-1 min-w-0\">\n <div className=\"text-caption font-medium uppercase tracking-wide text-muted-foreground\">\n {label}\n </div>\n <div className=\"text-small text-foreground\">{children}</div>\n </div>\n </div>\n );\n}\n\n/**\n * A reusable confirm-before-a-consequential-action dialog. Three optional, consistently-styled\n * consequence slots (immediate / afterward / reversibility), an optional inline required-reason field,\n * and an optional exact-phrase typed-confirmation gate. Composes the ui-core AlertDialog primitives\n * (Radix) — it never re-implements them. Supports BOTH a `trigger` (uncontrolled) and `open` /\n * `onOpenChange` (controlled).\n *\n * Pending model: the confirm button is a plain `Button` (NOT `AlertDialogAction`), so Radix does not\n * auto-close on click; open state is managed here so the dialog stays open with a visible spinner\n * until `onConfirm` resolves.\n */\nexport function ConsequenceDialog({\n trigger,\n open,\n onOpenChange,\n title,\n immediateEffect,\n delayedEffect,\n reversibility,\n reason,\n typedConfirmation,\n confirmLabel,\n cancelLabel = 'Cancel',\n destructive = false,\n onConfirm,\n}: ConsequenceDialogProps) {\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = useState(false);\n const [typedValue, setTypedValue] = useState('');\n const [pending, setPending] = useState(false);\n\n const actualOpen = isControlled ? open : internalOpen;\n\n const reasonId = useId();\n const typedId = useId();\n\n const setOpenState = useCallback(\n (next: boolean) => {\n if (isControlled) onOpenChange?.(next);\n else setInternalOpen(next);\n },\n [isControlled, onOpenChange],\n );\n\n // Never allow an open-state change (Escape, cancel, controlled parent) to fight the pending action.\n const handleOpenChange = useCallback(\n (next: boolean) => {\n if (pending) return;\n setTypedValue(''); // reset the typed gate on every open/close\n setOpenState(next);\n },\n [pending, setOpenState],\n );\n\n const handleConfirm = useCallback(async () => {\n if (pending) return;\n setPending(true);\n try {\n await onConfirm();\n setTypedValue('');\n setOpenState(false);\n } catch {\n // Keep the dialog open — the caller's onConfirm surfaced the error (toast / step-up). The\n // operator can retry or cancel. Never rethrow, never monitor here.\n } finally {\n setPending(false);\n }\n }, [pending, onConfirm, setOpenState]);\n\n const reasonTrimmedLength = reason ? reason.value.trim().length : 0;\n const reasonProvided = reasonTrimmedLength > 0;\n const reasonOk = !reason\n ? true\n : reason.required && !reasonProvided\n ? false\n : !reasonProvided\n ? true // optional + empty is fine\n : (reason.minLength === undefined || reasonTrimmedLength >= reason.minLength) &&\n (reason.maxLength === undefined || reason.value.length <= reason.maxLength);\n\n const typedOk = !typedConfirmation ? true : typedValue === typedConfirmation.phrase;\n\n return (\n <AlertDialog open={actualOpen} onOpenChange={handleOpenChange}>\n {trigger ? <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger> : null}\n <AlertDialogContent\n onEscapeKeyDown={(e) => {\n if (pending) e.preventDefault();\n }}\n >\n <AlertDialogHeader>\n <AlertDialogTitle>{title}</AlertDialogTitle>\n {/* A div, not the primitive's default <p>: the rows are blocks, which a <p> cannot hold.\n Left-aligned at every width — the header centres its text on narrow screens, and a\n wrapped consequence line reads as a list, not a caption. */}\n <AlertDialogDescription asChild>\n <div className=\"stack-3 text-left\">\n {immediateEffect ? (\n <ConsequenceRow icon={Zap} label=\"Immediately\">\n {immediateEffect}\n </ConsequenceRow>\n ) : null}\n {delayedEffect ? (\n <ConsequenceRow icon={Clock} label=\"Afterward\">\n {delayedEffect}\n </ConsequenceRow>\n ) : null}\n {reversibility ? (\n <ConsequenceRow icon={RotateCcw} label=\"Reversibility\">\n {reversibility}\n </ConsequenceRow>\n ) : null}\n </div>\n </AlertDialogDescription>\n </AlertDialogHeader>\n\n {reason ? (\n <div className=\"stack-2\">\n <Label htmlFor={reasonId}>{reason.label ?? 'Reason'}</Label>\n <Textarea\n id={reasonId}\n value={reason.value}\n onChange={(e) => reason.onChange(e.target.value)}\n placeholder={reason.placeholder}\n maxLength={reason.maxLength}\n rows={reason.rows ?? 3}\n disabled={pending}\n />\n </div>\n ) : null}\n\n {typedConfirmation ? (\n <div className=\"stack-2\">\n <Label htmlFor={typedId}>\n {typedConfirmation.label ?? (\n <>\n Type <span className=\"font-mono\">{typedConfirmation.phrase}</span> to confirm\n </>\n )}\n </Label>\n <Input\n id={typedId}\n value={typedValue}\n onChange={(e) => setTypedValue(e.target.value)}\n placeholder={typedConfirmation.phrase}\n disabled={pending}\n autoComplete=\"off\"\n />\n </div>\n ) : null}\n\n <AlertDialogFooter>\n <Button\n variant=\"outline\"\n onClick={() => handleOpenChange(false)}\n disabled={pending}\n >\n {cancelLabel}\n </Button>\n <Button\n variant={destructive ? 'destructive' : 'default'}\n onClick={handleConfirm}\n disabled={!reasonOk || !typedOk}\n pending={pending}\n >\n {confirmLabel}\n </Button>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"consequence-dialog.js","sourceRoot":"","sources":["../../../src/react/components/consequence-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9D,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAA4B,MAAM,oCAAoC,CAAC;AACnH,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA+DrD,MAAM,eAAe,GAAG,+CAA+C,CAAC;AAExE;;;;GAIG;AACH,SAAS,cAAc,CAAC,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EACL,QAAQ,GAKT;IACC,OAAO,CACL,eAAK,SAAS,EAAC,wBAAwB,aACrC,KAAC,IAAI,IAAC,SAAS,EAAE,e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CAAC,WAAW,EAC/B,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,EACtB,QAAQ,EAAE,OAAO,GACjB,IACE,CACP,CAAC,CAAC,CAAC,IAAI,EAEP,iBAAiB,IAAI,WAAW,CAAC,CAAC,CAAC,CAClC,eAAK,SAAS,EAAC,SAAS,aACtB,KAAC,KAAK,IAAC,OAAO,EAAE,OAAO,YACpB,iBAAiB,CAAC,KAAK,IAAI,CAC1B,uCACO,eAAM,SAAS,EAAC,WAAW,YAAE,iBAAiB,CAAC,MAAM,GAAQ,mBACjE,CACJ,GACK,EACR,KAAC,KAAK,IACJ,EAAE,EAAE,OAAO,EACX,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC9C,WAAW,EAAE,iBAAiB,CAAC,MAAM,EACrC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,OAAO,EACjB,YAAY,EAAC,KAAK,GAClB,IACE,CACP,CAAC,CAAC,CAAC,IAAI,EAER,MAAC,iBAAiB,eAChB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACtC,QAAQ,EAAE,OAAO,YAEhB,WAAW,GACL,EACT,KAAC,MAAM,IACL,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,EAChD,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,CAAC,QAAQ,IAAI,CAAC,OAAO,EAC/B,OAAO,EAAE,OAAO,YAEf,YAAY,GACN,IACS,IACD,IACT,CACf,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useCallback, useId, useMemo, useState } from 'react';\nimport {\n AlertDialog,\n AlertDialogTrigger,\n AlertDialogContent,\n AlertDialogHeader,\n AlertDialogFooter,\n AlertDialogTitle,\n AlertDialogDescription,\n} from './alert-dialog.js';\nimport { Button } from './button.js';\nimport { Textarea } from './textarea.js';\nimport { Input } from './input.js';\nimport { Label } from './label.js';\nimport { checkInputFormat, defineInputFormat, type DeclaredInputFormat } from '@ttt-productions/input-format-core';\nimport { Zap, Clock, RotateCcw } from 'lucide-react';\n\n/**\n * The inline reason field. The caller OWNS the reason value/onChange (draft state lives at the call\n * site) and the field's declaration — this component declares no business numbers and no copy.\n * Confirm stays disabled until the value passes the declaration's check; `min: 0` makes the reason\n * optional.\n */\nexport interface ConsequenceDialogReason {\n inputFormat: DeclaredInputFormat;\n placeholder?: string;\n label?: React.ReactNode;\n value: string;\n onChange: (value: string) => void;\n rows?: number;\n}\n\n/**\n * The exact-match typed-confirmation gate. `phrase` is business copy owned by the CALLER; the\n * component only compares the typed value against it.\n */\nexport interface ConsequenceDialogTypedConfirmation {\n phrase: string;\n label?: React.ReactNode;\n}\n\nexport interface ConsequenceDialogProps {\n /** Uncontrolled open model: the element that opens the dialog (rendered `asChild`). */\n trigger?: React.ReactNode;\n /** Controlled open model. Provide with `onOpenChange`. */\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n\n /** Heading — a string or node so callers can interpolate amounts / names. */\n title: React.ReactNode;\n\n /** SLOT 1 — what happens right now (e.g. \"initiates a Stripe refund of $X now\"). */\n immediateEffect?: React.ReactNode;\n /** SLOT 2 — what settles later, out of band (webhook / worker / async confirmation). */\n delayedEffect?: React.ReactNode;\n /** SLOT 3 — whether/how this can be undone or superseded. */\n reversibility?: React.ReactNode;\n\n /** Inline reason field. Optional. */\n reason?: ConsequenceDialogReason;\n /** Exact-phrase typed-confirmation gate. Optional. */\n typedConfirmation?: ConsequenceDialogTypedConfirmation;\n\n confirmLabel: React.ReactNode;\n cancelLabel?: React.ReactNode;\n /** `true` styles the confirm button with `bg-destructive`. */\n destructive?: boolean;\n\n /**\n * Runs on confirm. May be async — while it is pending the dialog STAYS OPEN, both buttons disable,\n * and the confirm button shows its pending spinner. Closes on resolve. If it rejects the dialog\n * stays open so the caller's own surface (error toast, TOTP step-up) can show and the operator can\n * retry or cancel. This component takes no Sentry/monitoring dependency — every error path\n * belongs to the caller's `onConfirm`.\n */\n onConfirm: () => void | Promise<void>;\n}\n\nconst SLOT_ICON_CLASS = 'icon-xs mt-0.5 shrink-0 text-muted-foreground';\n\n/**\n * One consequence slot: the icon beside a block column whose label sits on its own line above\n * the slot text. Every element is a block: the `stack-*` spacing is a vertical margin, which an\n * inline element ignores.\n */\nfunction ConsequenceRow({\n icon: Icon,\n label,\n children,\n}: {\n icon: typeof Zap;\n label: string;\n children: React.ReactNode;\n}) {\n return (\n <div className=\"flex items-start gap-2\">\n <Icon className={SLOT_ICON_CLASS} aria-hidden=\"true\" />\n <div className=\"stack-1 min-w-0\">\n <div className=\"text-caption font-medium uppercase tracking-wide text-muted-foreground\">\n {label}\n </div>\n <div className=\"text-small text-foreground\">{children}</div>\n </div>\n </div>\n );\n}\n\n/**\n * A reusable confirm-before-a-consequential-action dialog. Three optional, consistently-styled\n * consequence slots (immediate / afterward / reversibility), an optional inline reason field,\n * and an optional exact-phrase typed-confirmation gate. Composes the ui-core AlertDialog primitives\n * (Radix) — it never re-implements them. Supports BOTH a `trigger` (uncontrolled) and `open` /\n * `onOpenChange` (controlled).\n *\n * Pending model: the confirm button is a plain `Button` (NOT `AlertDialogAction`), so Radix does not\n * auto-close on click; open state is managed here so the dialog stays open with a visible spinner\n * until `onConfirm` resolves.\n */\nexport function ConsequenceDialog({\n trigger,\n open,\n onOpenChange,\n title,\n immediateEffect,\n delayedEffect,\n reversibility,\n reason,\n typedConfirmation,\n confirmLabel,\n cancelLabel = 'Cancel',\n destructive = false,\n onConfirm,\n}: ConsequenceDialogProps) {\n const isControlled = open !== undefined;\n const [internalOpen, setInternalOpen] = useState(false);\n const [typedValue, setTypedValue] = useState('');\n const [pending, setPending] = useState(false);\n\n const actualOpen = isControlled ? open : internalOpen;\n\n const reasonId = useId();\n const typedId = useId();\n\n const setOpenState = useCallback(\n (next: boolean) => {\n if (isControlled) onOpenChange?.(next);\n else setInternalOpen(next);\n },\n [isControlled, onOpenChange],\n );\n\n // Never allow an open-state change (Escape, cancel, controlled parent) to fight the pending action.\n const handleOpenChange = useCallback(\n (next: boolean) => {\n if (pending) return;\n setTypedValue(''); // reset the typed gate on every open/close\n setOpenState(next);\n },\n [pending, setOpenState],\n );\n\n const handleConfirm = useCallback(async () => {\n if (pending) return;\n setPending(true);\n try {\n await onConfirm();\n setTypedValue('');\n setOpenState(false);\n } catch {\n // Keep the dialog open — the caller's onConfirm surfaced the error (toast / step-up). The\n // operator can retry or cancel. Never rethrow, never monitor here.\n } finally {\n setPending(false);\n }\n }, [pending, onConfirm, setOpenState]);\n\n const reasonOk = !reason || checkInputFormat(reason.value, reason.inputFormat).ok;\n\n const typedOk = !typedConfirmation ? true : typedValue === typedConfirmation.phrase;\n // The phrase is one line, and nothing longer than it can ever match it.\n const phrase = typedConfirmation?.phrase ?? '';\n const typedFormat = useMemo(\n () => (phrase.length > 0 ? defineInputFormat({ format: 'singleLine', min: 1, max: phrase.length }) : null),\n [phrase],\n );\n\n return (\n <AlertDialog open={actualOpen} onOpenChange={handleOpenChange}>\n {trigger ? <AlertDialogTrigger asChild>{trigger}</AlertDialogTrigger> : null}\n <AlertDialogContent\n onEscapeKeyDown={(e) => {\n if (pending) e.preventDefault();\n }}\n >\n <AlertDialogHeader>\n <AlertDialogTitle>{title}</AlertDialogTitle>\n {/* A div, not the primitive's default <p>: the rows are blocks, which a <p> cannot hold.\n Left-aligned at every width — the header centres its text on narrow screens, and a\n wrapped consequence line reads as a list, not a caption. */}\n <AlertDialogDescription asChild>\n <div className=\"stack-3 text-left\">\n {immediateEffect ? (\n <ConsequenceRow icon={Zap} label=\"Immediately\">\n {immediateEffect}\n </ConsequenceRow>\n ) : null}\n {delayedEffect ? (\n <ConsequenceRow icon={Clock} label=\"Afterward\">\n {delayedEffect}\n </ConsequenceRow>\n ) : null}\n {reversibility ? (\n <ConsequenceRow icon={RotateCcw} label=\"Reversibility\">\n {reversibility}\n </ConsequenceRow>\n ) : null}\n </div>\n </AlertDialogDescription>\n </AlertDialogHeader>\n\n {reason ? (\n <div className=\"stack-2\">\n <Label htmlFor={reasonId}>{reason.label ?? 'Reason'}</Label>\n <Textarea\n id={reasonId}\n value={reason.value}\n onChange={(e) => reason.onChange(e.target.value)}\n placeholder={reason.placeholder}\n inputFormat={reason.inputFormat}\n rows={reason.rows ?? 3}\n disabled={pending}\n />\n </div>\n ) : null}\n\n {typedConfirmation && typedFormat ? (\n <div className=\"stack-2\">\n <Label htmlFor={typedId}>\n {typedConfirmation.label ?? (\n <>\n Type <span className=\"font-mono\">{typedConfirmation.phrase}</span> to confirm\n </>\n )}\n </Label>\n <Input\n id={typedId}\n value={typedValue}\n onChange={(e) => setTypedValue(e.target.value)}\n placeholder={typedConfirmation.phrase}\n inputFormat={typedFormat}\n disabled={pending}\n autoComplete=\"off\"\n />\n </div>\n ) : null}\n\n <AlertDialogFooter>\n <Button\n variant=\"outline\"\n onClick={() => handleOpenChange(false)}\n disabled={pending}\n >\n {cancelLabel}\n </Button>\n <Button\n variant={destructive ? 'destructive' : 'default'}\n onClick={handleConfirm}\n disabled={!reasonOk || !typedOk}\n pending={pending}\n >\n {confirmLabel}\n </Button>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n );\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface DateTimePickerTime {
|
|
3
|
+
/** 0–23 */
|
|
4
|
+
hours: number;
|
|
5
|
+
/** 0–59 */
|
|
6
|
+
minutes: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DateTimePickerProps {
|
|
9
|
+
/** The chosen instant (local time). */
|
|
10
|
+
value?: Date;
|
|
11
|
+
/** Called with the new instant — always inside `min`/`max`, seconds and milliseconds zero. */
|
|
12
|
+
onChange?: (value: Date) => void;
|
|
13
|
+
/** The earliest selectable instant. Earlier days and times are unavailable. */
|
|
14
|
+
min?: Date;
|
|
15
|
+
/** The latest selectable instant. Later days and times are unavailable. */
|
|
16
|
+
max?: Date;
|
|
17
|
+
/** Minutes offered are multiples of this (default 1). */
|
|
18
|
+
minuteStep?: number;
|
|
19
|
+
/** Time of day a picked day takes when there is no `value` yet (default 23:59 — end of day). */
|
|
20
|
+
defaultTime?: DateTimePickerTime;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Generic date-and-time picker: `DatePicker` for the day, then hour / minute / AM-PM
|
|
25
|
+
* columns of buttons for the time of day — never a native time input, so it looks and
|
|
26
|
+
* behaves the same everywhere and honours `min` / `max` to the minute.
|
|
27
|
+
*
|
|
28
|
+
* Every offered day, hour, minute, and period is one the value may take: a day with
|
|
29
|
+
* no allowed instant is disabled in the calendar, and an hour, minute, or period
|
|
30
|
+
* that would land outside `min` / `max` on the chosen day is disabled. Picking a day
|
|
31
|
+
* keeps the chosen time of day (or `defaultTime` when there is no value) and moves it
|
|
32
|
+
* to the nearest allowed time on that day; picking an hour or period whose current
|
|
33
|
+
* minute is unavailable takes the nearest allowed minute.
|
|
34
|
+
*
|
|
35
|
+
* Keyboard: each time column is one tab stop with roving focus (ArrowUp / ArrowDown,
|
|
36
|
+
* Home / End); Enter or Space picks.
|
|
37
|
+
*/
|
|
38
|
+
declare function DateTimePicker({ value, onChange, min, max, minuteStep, defaultTime, className, }: DateTimePickerProps): React.JSX.Element;
|
|
39
|
+
declare namespace DateTimePicker {
|
|
40
|
+
var displayName: string;
|
|
41
|
+
}
|
|
42
|
+
export { DateTimePicker };
|
|
43
|
+
//# sourceMappingURL=date-time-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-time-picker.d.ts","sourceRoot":"","sources":["../../../src/react/components/date-time-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,MAAM,WAAW,kBAAkB;IACjC,WAAW;IACX,KAAK,EAAE,MAAM,CAAA;IACb,WAAW;IACX,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,8FAA8F;IAC9F,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAA;IAChC,+EAA+E;IAC/E,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,2EAA2E;IAC3E,GAAG,CAAC,EAAE,IAAI,CAAA;IACV,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gGAAgG;IAChG,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAeD;;;;;;;;;;;;;;GAcG;AACH,iBAAS,cAAc,CAAC,EACtB,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,EACH,UAAc,EACd,WAAwC,EACxC,SAAS,GACV,EAAE,mBAAmB,qBAmJrB;kBA3JQ,cAAc;;;AAuPvB,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { DatePicker } from "./date-picker.js";
|
|
5
|
+
import { cn } from "../../lib/utils.js";
|
|
6
|
+
const MINUTES_PER_DAY = 24 * 60;
|
|
7
|
+
const HOURS_12 = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
|
8
|
+
const PERIODS = ["AM", "PM"];
|
|
9
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
10
|
+
const at = (day, minuteOfDay) => new Date(day.getFullYear(), day.getMonth(), day.getDate(), Math.floor(minuteOfDay / 60), minuteOfDay % 60, 0, 0);
|
|
11
|
+
const minuteOfDayOf = (date) => date.getHours() * 60 + date.getMinutes();
|
|
12
|
+
const to24 = (hour12, period) => (hour12 % 12) + (period === "PM" ? 12 : 0);
|
|
13
|
+
const periodOf = (hours) => (hours >= 12 ? "PM" : "AM");
|
|
14
|
+
const hour12Of = (hours) => (hours % 12 === 0 ? 12 : hours % 12);
|
|
15
|
+
/**
|
|
16
|
+
* Generic date-and-time picker: `DatePicker` for the day, then hour / minute / AM-PM
|
|
17
|
+
* columns of buttons for the time of day — never a native time input, so it looks and
|
|
18
|
+
* behaves the same everywhere and honours `min` / `max` to the minute.
|
|
19
|
+
*
|
|
20
|
+
* Every offered day, hour, minute, and period is one the value may take: a day with
|
|
21
|
+
* no allowed instant is disabled in the calendar, and an hour, minute, or period
|
|
22
|
+
* that would land outside `min` / `max` on the chosen day is disabled. Picking a day
|
|
23
|
+
* keeps the chosen time of day (or `defaultTime` when there is no value) and moves it
|
|
24
|
+
* to the nearest allowed time on that day; picking an hour or period whose current
|
|
25
|
+
* minute is unavailable takes the nearest allowed minute.
|
|
26
|
+
*
|
|
27
|
+
* Keyboard: each time column is one tab stop with roving focus (ArrowUp / ArrowDown,
|
|
28
|
+
* Home / End); Enter or Space picks.
|
|
29
|
+
*/
|
|
30
|
+
function DateTimePicker({ value, onChange, min, max, minuteStep = 1, defaultTime = { hours: 23, minutes: 59 }, className, }) {
|
|
31
|
+
const step = Math.max(1, Math.min(60, Math.floor(minuteStep)));
|
|
32
|
+
const minuteOptions = React.useMemo(() => Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step).filter((m) => m < 60), [step]);
|
|
33
|
+
const isAllowed = React.useCallback((instant) => (!min || instant >= min) && (!max || instant <= max), [min, max]);
|
|
34
|
+
const offeredMinutes = React.useMemo(() => new Set(minuteOptions), [minuteOptions]);
|
|
35
|
+
const isOffered = React.useCallback((minuteOfDay) => offeredMinutes.has(minuteOfDay % 60), [offeredMinutes]);
|
|
36
|
+
/** Allowed minutes-of-day on `day`, ascending. */
|
|
37
|
+
const allowedMinutesOn = React.useCallback((day) => {
|
|
38
|
+
const out = [];
|
|
39
|
+
for (let m = 0; m < MINUTES_PER_DAY; m++) {
|
|
40
|
+
if (isOffered(m) && isAllowed(at(day, m)))
|
|
41
|
+
out.push(m);
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}, [isAllowed, isOffered]);
|
|
45
|
+
const nearestAllowed = (day, wanted) => {
|
|
46
|
+
const allowed = allowedMinutesOn(day);
|
|
47
|
+
if (allowed.length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
let best = allowed[0];
|
|
50
|
+
for (const m of allowed)
|
|
51
|
+
if (Math.abs(m - wanted) < Math.abs(best - wanted))
|
|
52
|
+
best = m;
|
|
53
|
+
return best;
|
|
54
|
+
};
|
|
55
|
+
const commit = (day, wanted) => {
|
|
56
|
+
const m = nearestAllowed(day, wanted);
|
|
57
|
+
if (m === null)
|
|
58
|
+
return;
|
|
59
|
+
onChange?.(at(day, m));
|
|
60
|
+
};
|
|
61
|
+
// A day strictly between the bounds' own days is decided by its first and last offered
|
|
62
|
+
// minute; only the bounds' days need the minute-by-minute check.
|
|
63
|
+
const firstOfferedMinute = minuteOptions[0];
|
|
64
|
+
const lastOfferedMinute = 23 * 60 + minuteOptions[minuteOptions.length - 1];
|
|
65
|
+
const isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
66
|
+
const isDayDisabled = (day) => {
|
|
67
|
+
if ((min && isSameDay(day, min)) || (max && isSameDay(day, max))) {
|
|
68
|
+
return allowedMinutesOn(day).length === 0;
|
|
69
|
+
}
|
|
70
|
+
if (min && at(day, lastOfferedMinute) < min)
|
|
71
|
+
return true;
|
|
72
|
+
if (max && at(day, firstOfferedMinute) > max)
|
|
73
|
+
return true;
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
const handleDayPick = (day) => {
|
|
77
|
+
if (!day)
|
|
78
|
+
return;
|
|
79
|
+
const wanted = value ? minuteOfDayOf(value) : defaultTime.hours * 60 + defaultTime.minutes;
|
|
80
|
+
commit(day, wanted);
|
|
81
|
+
};
|
|
82
|
+
const current = value ? minuteOfDayOf(value) : null;
|
|
83
|
+
const currentHours = current === null ? null : Math.floor(current / 60);
|
|
84
|
+
const currentMinutes = current === null ? null : current % 60;
|
|
85
|
+
const currentPeriod = currentHours === null ? null : periodOf(currentHours);
|
|
86
|
+
const allowedSet = React.useMemo(() => new Set(value ? allowedMinutesOn(value) : []), [value, allowedMinutesOn]);
|
|
87
|
+
const hourEnabled = (hours) => minuteOptions.some((m) => allowedSet.has(hours * 60 + m));
|
|
88
|
+
const minuteEnabled = (minutes) => currentHours !== null && allowedSet.has(currentHours * 60 + minutes);
|
|
89
|
+
const periodEnabled = (period) => {
|
|
90
|
+
const base = period === "PM" ? 12 : 0;
|
|
91
|
+
for (let h = base; h < base + 12; h++)
|
|
92
|
+
if (hourEnabled(h))
|
|
93
|
+
return true;
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
const pickHour = (hour12) => {
|
|
97
|
+
if (!value || currentPeriod === null || currentMinutes === null)
|
|
98
|
+
return;
|
|
99
|
+
const hours = to24(hour12, currentPeriod);
|
|
100
|
+
const firstInHour = minuteOptions.find((m) => allowedSet.has(hours * 60 + m));
|
|
101
|
+
if (firstInHour === undefined)
|
|
102
|
+
return;
|
|
103
|
+
const minutes = allowedSet.has(hours * 60 + currentMinutes) ? currentMinutes : firstInHour;
|
|
104
|
+
commit(value, hours * 60 + minutes);
|
|
105
|
+
};
|
|
106
|
+
const pickMinute = (minutes) => {
|
|
107
|
+
if (!value || currentHours === null)
|
|
108
|
+
return;
|
|
109
|
+
commit(value, currentHours * 60 + minutes);
|
|
110
|
+
};
|
|
111
|
+
const pickPeriod = (period) => {
|
|
112
|
+
if (!value || currentHours === null || currentMinutes === null)
|
|
113
|
+
return;
|
|
114
|
+
const hours = to24(hour12Of(currentHours), period);
|
|
115
|
+
commit(value, hours * 60 + currentMinutes);
|
|
116
|
+
};
|
|
117
|
+
const timeDisabled = !value;
|
|
118
|
+
return (_jsxs("div", { className: cn("flex flex-col gap-3 sm:flex-row sm:items-start", className), children: [_jsx(DatePicker, { selected: value, onSelect: handleDayPick, disabled: isDayDisabled }), _jsxs("div", { className: "flex gap-2 p-4 bg-card rounded-lg", role: "group", "aria-label": "Time", "aria-disabled": timeDisabled || undefined, children: [_jsx(TimeColumn, { label: "Hour", options: HOURS_12.map((h) => ({
|
|
119
|
+
key: h,
|
|
120
|
+
text: String(h),
|
|
121
|
+
ariaLabel: `${h} o'clock`,
|
|
122
|
+
selected: currentHours !== null && hour12Of(currentHours) === h,
|
|
123
|
+
disabled: timeDisabled || currentPeriod === null || !hourEnabled(to24(h, currentPeriod)),
|
|
124
|
+
onPick: () => pickHour(h),
|
|
125
|
+
})) }), _jsx(TimeColumn, { label: "Minute", options: minuteOptions.map((m) => ({
|
|
126
|
+
key: m,
|
|
127
|
+
text: pad2(m),
|
|
128
|
+
ariaLabel: `${pad2(m)} minutes`,
|
|
129
|
+
selected: currentMinutes === m,
|
|
130
|
+
disabled: timeDisabled || !minuteEnabled(m),
|
|
131
|
+
onPick: () => pickMinute(m),
|
|
132
|
+
})) }), _jsx(TimeColumn, { label: "AM or PM", options: PERIODS.map((p) => ({
|
|
133
|
+
key: p,
|
|
134
|
+
text: p,
|
|
135
|
+
ariaLabel: p,
|
|
136
|
+
selected: currentPeriod === p,
|
|
137
|
+
disabled: timeDisabled || !periodEnabled(p),
|
|
138
|
+
onPick: () => pickPeriod(p),
|
|
139
|
+
})) })] })] }));
|
|
140
|
+
}
|
|
141
|
+
DateTimePicker.displayName = "DateTimePicker";
|
|
142
|
+
function TimeColumn({ label, options }) {
|
|
143
|
+
const listRef = React.useRef(null);
|
|
144
|
+
const selectedIndex = options.findIndex((o) => o.selected && !o.disabled);
|
|
145
|
+
const firstEnabled = options.findIndex((o) => !o.disabled);
|
|
146
|
+
const [focusIndex, setFocusIndex] = React.useState(null);
|
|
147
|
+
const rovingIndex = focusIndex !== null && options[focusIndex] && !options[focusIndex].disabled
|
|
148
|
+
? focusIndex
|
|
149
|
+
: selectedIndex >= 0
|
|
150
|
+
? selectedIndex
|
|
151
|
+
: firstEnabled;
|
|
152
|
+
// Keep the chosen option in view inside the fixed-height column.
|
|
153
|
+
React.useLayoutEffect(() => {
|
|
154
|
+
if (selectedIndex < 0)
|
|
155
|
+
return;
|
|
156
|
+
const el = listRef.current?.querySelector(`[data-index="${selectedIndex}"]`);
|
|
157
|
+
el?.scrollIntoView?.({ block: "nearest" });
|
|
158
|
+
}, [selectedIndex]);
|
|
159
|
+
const focusAt = (index) => {
|
|
160
|
+
setFocusIndex(index);
|
|
161
|
+
listRef.current?.querySelector(`[data-index="${index}"]`)?.focus();
|
|
162
|
+
};
|
|
163
|
+
const handleKeyDown = (e) => {
|
|
164
|
+
const enabled = options.map((o, i) => (o.disabled ? -1 : i)).filter((i) => i >= 0);
|
|
165
|
+
if (enabled.length === 0 || rovingIndex < 0)
|
|
166
|
+
return;
|
|
167
|
+
const pos = enabled.indexOf(rovingIndex);
|
|
168
|
+
let next;
|
|
169
|
+
if (e.key === "ArrowDown")
|
|
170
|
+
next = enabled[Math.min(enabled.length - 1, pos + 1)];
|
|
171
|
+
else if (e.key === "ArrowUp")
|
|
172
|
+
next = enabled[Math.max(0, pos - 1)];
|
|
173
|
+
else if (e.key === "Home")
|
|
174
|
+
next = enabled[0];
|
|
175
|
+
else if (e.key === "End")
|
|
176
|
+
next = enabled[enabled.length - 1];
|
|
177
|
+
if (next === undefined)
|
|
178
|
+
return;
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
focusAt(next);
|
|
181
|
+
};
|
|
182
|
+
return (_jsxs("div", { className: "flex flex-col items-center gap-1", children: [_jsx("div", { className: "text-xs font-semibold text-muted-foreground", "aria-hidden": "true", children: label }), _jsx("div", { ref: listRef, role: "group", "aria-label": label, onKeyDown: handleKeyDown, className: "flex h-64 w-14 flex-col gap-1 overflow-y-auto", children: options.map((o, i) => (_jsx("button", { type: "button", "data-index": i, tabIndex: i === rovingIndex ? 0 : -1, disabled: o.disabled, "aria-pressed": o.selected, "aria-label": o.ariaLabel, onClick: () => {
|
|
183
|
+
setFocusIndex(i);
|
|
184
|
+
o.onPick();
|
|
185
|
+
}, className: cn("h-9 shrink-0 rounded-lg text-sm font-semibold flex items-center justify-center", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", !o.disabled && !o.selected && "text-foreground hover:bg-primary/10", o.selected && "bg-primary text-primary-foreground font-bold", o.disabled && "opacity-30 cursor-not-allowed"), children: o.text }, o.key))) })] }));
|
|
186
|
+
}
|
|
187
|
+
export { DateTimePicker };
|
|
188
|
+
//# sourceMappingURL=date-time-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-time-picker.js","sourceRoot":"","sources":["../../../src/react/components/date-time-picker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AAyBvC,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAA;AAC/B,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACxD,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAA;AAGrC,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;AACtD,MAAM,EAAE,GAAG,CAAC,GAAS,EAAE,WAAmB,EAAE,EA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AAkC,aAC/C,cAAK,SAAS,EAAC,6CAA6C,iBAAa,MAAM,YAC5E,KAAK,GACF,EACN,cACE,GAAG,EAAE,OAAO,EACZ,IAAI,EAAC,OAAO,gBACA,KAAK,EACjB,SAAS,EAAE,aAAa,EACxB,SAAS,EAAC,+CAA+C,YAExD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACrB,iBAEE,IAAI,EAAC,QAAQ,gBACD,CAAC,EACb,QAAQ,EAAE,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACpC,QAAQ,EAAE,CAAC,CAAC,QAAQ,kBACN,CAAC,CAAC,QAAQ,gBACZ,CAAC,CAAC,SAAS,EACvB,OAAO,EAAE,GAAG,EAAE;wBACZ,aAAa,CAAC,CAAC,CAAC,CAAA;wBAChB,CAAC,CAAC,MAAM,EAAE,CAAA;oBACZ,CAAC,EACD,SAAS,EAAE,EAAE,CACX,gFAAgF,EAChF,0IAA0I,EAC1I,CAAC,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,QAAQ,IAAI,qCAAqC,EACnE,CAAC,CAAC,QAAQ,IAAI,8CAA8C,EAC5D,CAAC,CAAC,QAAQ,IAAI,+BAA+B,CAC9C,YAEA,CAAC,CAAC,IAAI,IAnBF,CAAC,CAAC,GAAG,CAoBH,CACV,CAAC,GACE,IACF,CACP,CAAA;AACH,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAA","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { DatePicker } from \"./date-picker.js\"\nimport { cn } from \"../../lib/utils.js\"\n\nexport interface DateTimePickerTime {\n /** 0–23 */\n hours: number\n /** 0–59 */\n minutes: number\n}\n\nexport interface DateTimePickerProps {\n /** The chosen instant (local time). */\n value?: Date\n /** Called with the new instant — always inside `min`/`max`, seconds and milliseconds zero. */\n onChange?: (value: Date) => void\n /** The earliest selectable instant. Earlier days and times are unavailable. */\n min?: Date\n /** The latest selectable instant. Later days and times are unavailable. */\n max?: Date\n /** Minutes offered are multiples of this (default 1). */\n minuteStep?: number\n /** Time of day a picked day takes when there is no `value` yet (default 23:59 — end of day). */\n defaultTime?: DateTimePickerTime\n className?: string\n}\n\nconst MINUTES_PER_DAY = 24 * 60\nconst HOURS_12 = [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\nconst PERIODS = [\"AM\", \"PM\"] as const\ntype Period = (typeof PERIODS)[number]\n\nconst pad2 = (n: number) => String(n).padStart(2, \"0\")\nconst at = (day: Date, minuteOfDay: number) =>\n new Date(day.getFullYear(), day.getMonth(), day.getDate(), Math.floor(minuteOfDay / 60), minuteOfDay % 60, 0, 0)\nconst minuteOfDayOf = (date: Date) => date.getHours() * 60 + date.getMinutes()\nconst to24 = (hour12: number, period: Period) => (hour12 % 12) + (period === \"PM\" ? 12 : 0)\nconst periodOf = (hours: number): Period => (hours >= 12 ? \"PM\" : \"AM\")\nconst hour12Of = (hours: number) => (hours % 12 === 0 ? 12 : hours % 12)\n\n/**\n * Generic date-and-time picker: `DatePicker` for the day, then hour / minute / AM-PM\n * columns of buttons for the time of day — never a native time input, so it looks and\n * behaves the same everywhere and honours `min` / `max` to the minute.\n *\n * Every offered day, hour, minute, and period is one the value may take: a day with\n * no allowed instant is disabled in the calendar, and an hour, minute, or period\n * that would land outside `min` / `max` on the chosen day is disabled. Picking a day\n * keeps the chosen time of day (or `defaultTime` when there is no value) and moves it\n * to the nearest allowed time on that day; picking an hour or period whose current\n * minute is unavailable takes the nearest allowed minute.\n *\n * Keyboard: each time column is one tab stop with roving focus (ArrowUp / ArrowDown,\n * Home / End); Enter or Space picks.\n */\nfunction DateTimePicker({\n value,\n onChange,\n min,\n max,\n minuteStep = 1,\n defaultTime = { hours: 23, minutes: 59 },\n className,\n}: DateTimePickerProps) {\n const step = Math.max(1, Math.min(60, Math.floor(minuteStep)))\n const minuteOptions = React.useMemo(\n () => Array.from({ length: Math.ceil(60 / step) }, (_, i) => i * step).filter((m) => m < 60),\n [step],\n )\n\n const isAllowed = React.useCallback(\n (instant: Date) => (!min || instant >= min) && (!max || instant <= max),\n [min, max],\n )\n const offeredMinutes = React.useMemo(() => new Set(minuteOptions), [minuteOptions])\n const isOffered = React.useCallback(\n (minuteOfDay: number) => offeredMinutes.has(minuteOfDay % 60),\n [offeredMinutes],\n )\n\n /** Allowed minutes-of-day on `day`, ascending. */\n const allowedMinutesOn = React.useCallback(\n (day: Date) => {\n const out: number[] = []\n for (let m = 0; m < MINUTES_PER_DAY; m++) {\n if (isOffered(m) && isAllowed(at(day, m))) out.push(m)\n }\n return out\n },\n [isAllowed, isOffered],\n )\n\n const nearestAllowed = (day: Date, wanted: number): number | null => {\n const allowed = allowedMinutesOn(day)\n if (allowed.length === 0) return null\n let best = allowed[0]\n for (const m of allowed) if (Math.abs(m - wanted) < Math.abs(best - wanted)) best = m\n return best\n }\n\n const commit = (day: Date, wanted: number) => {\n const m = nearestAllowed(day, wanted)\n if (m === null) return\n onChange?.(at(day, m))\n }\n\n // A day strictly between the bounds' own days is decided by its first and last offered\n // minute; only the bounds' days need the minute-by-minute check.\n const firstOfferedMinute = minuteOptions[0]\n const lastOfferedMinute = 23 * 60 + minuteOptions[minuteOptions.length - 1]\n const isSameDay = (a: Date, b: Date) =>\n a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate()\n const isDayDisabled = (day: Date) => {\n if ((min && isSameDay(day, min)) || (max && isSameDay(day, max))) {\n return allowedMinutesOn(day).length === 0\n }\n if (min && at(day, lastOfferedMinute) < min) return true\n if (max && at(day, firstOfferedMinute) > max) return true\n return false\n }\n\n const handleDayPick = (day: Date | undefined) => {\n if (!day) return\n const wanted = value ? minuteOfDayOf(value) : defaultTime.hours * 60 + defaultTime.minutes\n commit(day, wanted)\n }\n\n const current = value ? minuteOfDayOf(value) : null\n const currentHours = current === null ? null : Math.floor(current / 60)\n const currentMinutes = current === null ? null : current % 60\n const currentPeriod = currentHours === null ? null : periodOf(currentHours)\n\n const allowedSet = React.useMemo(\n () => new Set(value ? allowedMinutesOn(value) : []),\n [value, allowedMinutesOn],\n )\n const hourEnabled = (hours: number) => minuteOptions.some((m) => allowedSet.has(hours * 60 + m))\n const minuteEnabled = (minutes: number) =>\n currentHours !== null && allowedSet.has(currentHours * 60 + minutes)\n const periodEnabled = (period: Period) => {\n const base = period === \"PM\" ? 12 : 0\n for (let h = base; h < base + 12; h++) if (hourEnabled(h)) return true\n return false\n }\n\n const pickHour = (hour12: number) => {\n if (!value || currentPeriod === null || currentMinutes === null) return\n const hours = to24(hour12, currentPeriod)\n const firstInHour = minuteOptions.find((m) => allowedSet.has(hours * 60 + m))\n if (firstInHour === undefined) return\n const minutes = allowedSet.has(hours * 60 + currentMinutes) ? currentMinutes : firstInHour\n commit(value, hours * 60 + minutes)\n }\n const pickMinute = (minutes: number) => {\n if (!value || currentHours === null) return\n commit(value, currentHours * 60 + minutes)\n }\n const pickPeriod = (period: Period) => {\n if (!value || currentHours === null || currentMinutes === null) return\n const hours = to24(hour12Of(currentHours), period)\n commit(value, hours * 60 + currentMinutes)\n }\n\n const timeDisabled = !value\n\n return (\n <div className={cn(\"flex flex-col gap-3 sm:flex-row sm:items-start\", className)}>\n <DatePicker selected={value} onSelect={handleDayPick} disabled={isDayDisabled} />\n <div\n className=\"flex gap-2 p-4 bg-card rounded-lg\"\n role=\"group\"\n aria-label=\"Time\"\n aria-disabled={timeDisabled || undefined}\n >\n <TimeColumn\n label=\"Hour\"\n options={HOURS_12.map((h) => ({\n key: h,\n text: String(h),\n ariaLabel: `${h} o'clock`,\n selected: currentHours !== null && hour12Of(currentHours) === h,\n disabled: timeDisabled || currentPeriod === null || !hourEnabled(to24(h, currentPeriod)),\n onPick: () => pickHour(h),\n }))}\n />\n <TimeColumn\n label=\"Minute\"\n options={minuteOptions.map((m) => ({\n key: m,\n text: pad2(m),\n ariaLabel: `${pad2(m)} minutes`,\n selected: currentMinutes === m,\n disabled: timeDisabled || !minuteEnabled(m),\n onPick: () => pickMinute(m),\n }))}\n />\n <TimeColumn\n label=\"AM or PM\"\n options={PERIODS.map((p) => ({\n key: p,\n text: p,\n ariaLabel: p,\n selected: currentPeriod === p,\n disabled: timeDisabled || !periodEnabled(p),\n onPick: () => pickPeriod(p),\n }))}\n />\n </div>\n </div>\n )\n}\n\nDateTimePicker.displayName = \"DateTimePicker\"\n\ninterface TimeOption {\n key: string | number\n text: string\n ariaLabel: string\n selected: boolean\n disabled: boolean\n onPick: () => void\n}\n\nfunction TimeColumn({ label, options }: { label: string; options: TimeOption[] }) {\n const listRef = React.useRef<HTMLDivElement | null>(null)\n const selectedIndex = options.findIndex((o) => o.selected && !o.disabled)\n const firstEnabled = options.findIndex((o) => !o.disabled)\n const [focusIndex, setFocusIndex] = React.useState<number | null>(null)\n const rovingIndex =\n focusIndex !== null && options[focusIndex] && !options[focusIndex].disabled\n ? focusIndex\n : selectedIndex >= 0\n ? selectedIndex\n : firstEnabled\n\n // Keep the chosen option in view inside the fixed-height column.\n React.useLayoutEffect(() => {\n if (selectedIndex < 0) return\n const el = listRef.current?.querySelector<HTMLButtonElement>(`[data-index=\"${selectedIndex}\"]`)\n el?.scrollIntoView?.({ block: \"nearest\" })\n }, [selectedIndex])\n\n const focusAt = (index: number) => {\n setFocusIndex(index)\n listRef.current?.querySelector<HTMLButtonElement>(`[data-index=\"${index}\"]`)?.focus()\n }\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n const enabled = options.map((o, i) => (o.disabled ? -1 : i)).filter((i) => i >= 0)\n if (enabled.length === 0 || rovingIndex < 0) return\n const pos = enabled.indexOf(rovingIndex)\n let next: number | undefined\n if (e.key === \"ArrowDown\") next = enabled[Math.min(enabled.length - 1, pos + 1)]\n else if (e.key === \"ArrowUp\") next = enabled[Math.max(0, pos - 1)]\n else if (e.key === \"Home\") next = enabled[0]\n else if (e.key === \"End\") next = enabled[enabled.length - 1]\n if (next === undefined) return\n e.preventDefault()\n focusAt(next)\n }\n\n return (\n <div className=\"flex flex-col items-center gap-1\">\n <div className=\"text-xs font-semibold text-muted-foreground\" aria-hidden=\"true\">\n {label}\n </div>\n <div\n ref={listRef}\n role=\"group\"\n aria-label={label}\n onKeyDown={handleKeyDown}\n className=\"flex h-64 w-14 flex-col gap-1 overflow-y-auto\"\n >\n {options.map((o, i) => (\n <button\n key={o.key}\n type=\"button\"\n data-index={i}\n tabIndex={i === rovingIndex ? 0 : -1}\n disabled={o.disabled}\n aria-pressed={o.selected}\n aria-label={o.ariaLabel}\n onClick={() => {\n setFocusIndex(i)\n o.onPick()\n }}\n className={cn(\n \"h-9 shrink-0 rounded-lg text-sm font-semibold flex items-center justify-center\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n !o.disabled && !o.selected && \"text-foreground hover:bg-primary/10\",\n o.selected && \"bg-primary text-primary-foreground font-bold\",\n o.disabled && \"opacity-30 cursor-not-allowed\",\n )}\n >\n {o.text}\n </button>\n ))}\n </div>\n </div>\n )\n}\n\nexport { DateTimePicker }\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type InputFormatSpec } from "@ttt-productions/input-format-core";
|
|
2
|
+
interface CallerAttributes {
|
|
3
|
+
value?: unknown;
|
|
4
|
+
"aria-required"?: boolean | "true" | "false";
|
|
5
|
+
"aria-invalid"?: boolean | "true" | "false" | "grammar" | "spelling";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* What a free-text control derives from its field declaration: the native length cap, and the
|
|
9
|
+
* required/invalid state assistive technology announces. A caller's own `aria-required` or
|
|
10
|
+
* `aria-invalid` wins — a form field passes the state its whole schema decided.
|
|
11
|
+
*
|
|
12
|
+
* The native cap counts the text as typed while the check counts it trimmed. Every value the
|
|
13
|
+
* field keeps can still be typed, and surrounding whitespace is dropped by the check anyway.
|
|
14
|
+
*
|
|
15
|
+
* Only a controlled value is judged, and a text that is merely too short is not marked invalid
|
|
16
|
+
* while it is being typed: an empty or half-typed required field is not yet an error, so "too
|
|
17
|
+
* short" is left to the form's submit-time validation.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatControlAttributes(spec: InputFormatSpec, props: CallerAttributes): {
|
|
20
|
+
maxLength: number;
|
|
21
|
+
"aria-required": boolean | "true" | "false" | undefined;
|
|
22
|
+
"aria-invalid": boolean | "true" | "false" | "grammar" | "spelling" | undefined;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=format-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-control.d.ts","sourceRoot":"","sources":["../../../src/react/components/format-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAE3F,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,eAAe,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;IAC5C,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAA;CACrE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,gBAAgB;;;;EAQrF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { checkInputFormat } from "@ttt-productions/input-format-core";
|
|
2
|
+
/**
|
|
3
|
+
* What a free-text control derives from its field declaration: the native length cap, and the
|
|
4
|
+
* required/invalid state assistive technology announces. A caller's own `aria-required` or
|
|
5
|
+
* `aria-invalid` wins — a form field passes the state its whole schema decided.
|
|
6
|
+
*
|
|
7
|
+
* The native cap counts the text as typed while the check counts it trimmed. Every value the
|
|
8
|
+
* field keeps can still be typed, and surrounding whitespace is dropped by the check anyway.
|
|
9
|
+
*
|
|
10
|
+
* Only a controlled value is judged, and a text that is merely too short is not marked invalid
|
|
11
|
+
* while it is being typed: an empty or half-typed required field is not yet an error, so "too
|
|
12
|
+
* short" is left to the form's submit-time validation.
|
|
13
|
+
*/
|
|
14
|
+
export function formatControlAttributes(spec, props) {
|
|
15
|
+
const result = typeof props.value === "string" ? checkInputFormat(props.value, spec) : null;
|
|
16
|
+
const malformed = result !== null && !result.ok && result.issue !== "tooShort";
|
|
17
|
+
return {
|
|
18
|
+
maxLength: spec.max,
|
|
19
|
+
"aria-required": props["aria-required"] ?? (spec.min > 0 ? true : undefined),
|
|
20
|
+
"aria-invalid": props["aria-invalid"] ?? (malformed ? true : undefined),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=format-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-control.js","sourceRoot":"","sources":["../../../src/react/components/format-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,oCAAoC,CAAA;AAQ3F;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAqB,EAAE,KAAuB;IACpF,MAAM,MAAM,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3F,MAAM,SAAS,GAAG,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,KAAK,UAAU,CAAA;IAC9E,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,GAAG;QACnB,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;KACxE,CAAA;AACH,CAAC","sourcesContent":["import { checkInputFormat, type InputFormatSpec } from \"@ttt-productions/input-format-core\"\n\ninterface CallerAttributes {\n value?: unknown\n \"aria-required\"?: boolean | \"true\" | \"false\"\n \"aria-invalid\"?: boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\"\n}\n\n/**\n * What a free-text control derives from its field declaration: the native length cap, and the\n * required/invalid state assistive technology announces. A caller's own `aria-required` or\n * `aria-invalid` wins — a form field passes the state its whole schema decided.\n *\n * The native cap counts the text as typed while the check counts it trimmed. Every value the\n * field keeps can still be typed, and surrounding whitespace is dropped by the check anyway.\n *\n * Only a controlled value is judged, and a text that is merely too short is not marked invalid\n * while it is being typed: an empty or half-typed required field is not yet an error, so \"too\n * short\" is left to the form's submit-time validation.\n */\nexport function formatControlAttributes(spec: InputFormatSpec, props: CallerAttributes) {\n const result = typeof props.value === \"string\" ? checkInputFormat(props.value, spec) : null\n const malformed = result !== null && !result.ok && result.issue !== \"tooShort\"\n return {\n maxLength: spec.max,\n \"aria-required\": props[\"aria-required\"] ?? (spec.min > 0 ? true : undefined),\n \"aria-invalid\": props[\"aria-invalid\"] ?? (malformed ? true : undefined),\n }\n}\n"]}
|
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import type { DeclaredInputFormat } from "@ttt-productions/input-format-core";
|
|
3
|
+
/**
|
|
4
|
+
* The input types whose value the browser itself formats or picks — not free text — so they take no
|
|
5
|
+
* input format. A free-text input (`type` omitted or `"text"`) takes one.
|
|
6
|
+
*/
|
|
7
|
+
export type BuiltInFormatInputType = "password" | "email" | "number" | "tel" | "url" | "search" | "file" | "color" | "date" | "datetime-local" | "month" | "week" | "time" | "range" | "checkbox" | "radio" | "hidden" | "button" | "submit" | "reset" | "image";
|
|
8
|
+
type NativeInputProps = React.ComponentPropsWithoutRef<"input">;
|
|
9
|
+
/**
|
|
10
|
+
* A free-text input: its declaration is required, and its bounds and its required state come only
|
|
11
|
+
* from that declaration (ENG-005), so `maxLength`, `minLength`, `pattern`, and `required` are not
|
|
12
|
+
* props.
|
|
13
|
+
*/
|
|
14
|
+
export type FreeTextInputProps = Omit<NativeInputProps, "type" | "maxLength" | "minLength" | "pattern" | "required"> & {
|
|
15
|
+
type?: "text";
|
|
16
|
+
inputFormat: DeclaredInputFormat;
|
|
17
|
+
textEntry?: never;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* What a text box that is not free text holds: digits typed as text (a date-of-birth part, a share
|
|
21
|
+
* count, a one-time code) or an identifier (an account, document, or case id). Neither takes an
|
|
22
|
+
* input format; each keeps its own native `maxLength`, `pattern`, and `inputMode`, and its value is
|
|
23
|
+
* checked by its own rule (a whole-input number parse, the one-segment id rule).
|
|
24
|
+
*/
|
|
25
|
+
export type NonFreeTextEntry = "numeric" | "identifier";
|
|
26
|
+
/** A text box that is not free text: no input format. */
|
|
27
|
+
export type NonFreeTextInputProps = Omit<NativeInputProps, "type"> & {
|
|
28
|
+
type?: "text";
|
|
29
|
+
textEntry: NonFreeTextEntry;
|
|
30
|
+
inputFormat?: never;
|
|
31
|
+
};
|
|
32
|
+
/** An input whose value the browser formats: no input format. */
|
|
33
|
+
export type BuiltInFormatInputProps = Omit<NativeInputProps, "type"> & {
|
|
34
|
+
type: BuiltInFormatInputType;
|
|
35
|
+
inputFormat?: never;
|
|
36
|
+
textEntry?: never;
|
|
37
|
+
};
|
|
38
|
+
export type InputProps = FreeTextInputProps | NonFreeTextInputProps | BuiltInFormatInputProps;
|
|
39
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
3
40
|
export { Input };
|
|
4
41
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA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B,WAAW,CAAC,EAAE,KAAK,CAAA;IACnB,SAAS,CAAC,EAAE,KAAK,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,uBAAuB,CAAA;AAE7F,QAAA,MAAM,KAAK,qFAgBV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../../lib/utils.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { formatControlAttributes } from "./format-control.js";
|
|
6
|
+
const Input = React.forwardRef(
|
|
7
|
+
// `textEntry` only selects the prop shape; it never reaches the DOM.
|
|
8
|
+
({ className, type, inputFormat, textEntry: _textEntry, ...props }, ref) => {
|
|
9
|
+
return (_jsx("input", { type: type, className: cn("flex h-10 w-full rounded-md border-2 border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ref: ref, ...props, ...(inputFormat ? formatControlAttributes(inputFormat, props) : {}) }));
|
|
7
10
|
});
|
|
8
11
|
Input.displayName = "Input";
|
|
9
12
|
export { Input };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/react/components/input.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAqE7D,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU;AAC5B,qEAAqE;AACrE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACzE,OAAO,CACL,gBACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,EAAE,CACX,oYAAoY,EACpY,SAAS,CACV,EACD,GAAG,EAAE,GAAG,KACJ,KAAK,KACL,CAAC,WAAW,CAAC,CAAC,CAAC,uBAAuB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GACpE,CACH,CAAA;AACH,CAAC,CACF,CAAA;AACD,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA;AAE3B,OAAO,EAAE,KAAK,EAAE,CAAA","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport type { DeclaredInputFormat } from \"@ttt-productions/input-format-core\"\nimport { cn } from \"../../lib/utils.js\"\nimport { formatControlAttributes } from \"./format-control.js\"\n\n/**\n * The input types whose value the browser itself formats or picks — not free text — so they take no\n * input format. A free-text input (`type` omitted or `\"text\"`) takes one.\n */\nexport type BuiltInFormatInputType =\n | \"password\"\n | \"email\"\n | \"number\"\n | \"tel\"\n | \"url\"\n | \"search\"\n | \"file\"\n | \"color\"\n | \"date\"\n | \"datetime-local\"\n | \"month\"\n | \"week\"\n | \"time\"\n | \"range\"\n | \"checkbox\"\n | \"radio\"\n | \"hidden\"\n | \"button\"\n | \"submit\"\n | \"reset\"\n | \"image\"\n\ntype NativeInputProps = React.ComponentPropsWithoutRef<\"input\">\n\n/**\n * A free-text input: its declaration is required, and its bounds and its required state come only\n * from that declaration (ENG-005), so `maxLength`, `minLength`, `pattern`, and `required` are not\n * props.\n */\nexport type FreeTextInputProps = Omit<\n NativeInputProps,\n \"type\" | \"maxLength\" | \"minLength\" | \"pattern\" | \"required\"\n> & {\n type?: \"text\"\n inputFormat: DeclaredInputFormat\n textEntry?: never\n}\n\n/**\n * What a text box that is not free text holds: digits typed as text (a date-of-birth part, a share\n * count, a one-time code) or an identifier (an account, document, or case id). Neither takes an\n * input format; each keeps its own native `maxLength`, `pattern`, and `inputMode`, and its value is\n * checked by its own rule (a whole-input number parse, the one-segment id rule).\n */\nexport type NonFreeTextEntry = \"numeric\" | \"identifier\"\n\n/** A text box that is not free text: no input format. */\nexport type NonFreeTextInputProps = Omit<NativeInputProps, \"type\"> & {\n type?: \"text\"\n textEntry: NonFreeTextEntry\n inputFormat?: never\n}\n\n/** An input whose value the browser formats: no input format. */\nexport type BuiltInFormatInputProps = Omit<NativeInputProps, \"type\"> & {\n type: BuiltInFormatInputType\n inputFormat?: never\n textEntry?: never\n}\n\nexport type InputProps = FreeTextInputProps | NonFreeTextInputProps | BuiltInFormatInputProps\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n // `textEntry` only selects the prop shape; it never reaches the DOM.\n ({ className, type, inputFormat, textEntry: _textEntry, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-10 w-full rounded-md border-2 border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n {...(inputFormat ? formatControlAttributes(inputFormat, props) : {})}\n />\n )\n }\n)\nInput.displayName = \"Input\"\n\nexport { Input }\n"]}
|
|
@@ -7,8 +7,13 @@ export interface SearchDropdownProps<T> {
|
|
|
7
7
|
results: T[];
|
|
8
8
|
/** Loading state */
|
|
9
9
|
isLoading: boolean;
|
|
10
|
-
/**
|
|
11
|
-
error:
|
|
10
|
+
/** The search's failure exactly as the data layer reported it; `null` or `undefined` when it did not fail. */
|
|
11
|
+
error: unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Renders a failed search inside the open dropdown. The consumer owns the failure's words and any
|
|
14
|
+
* retry, so the dropdown never shows a failure state of its own.
|
|
15
|
+
*/
|
|
16
|
+
renderError: (error: unknown) => React.ReactNode;
|
|
12
17
|
/** Called when a result is selected */
|
|
13
18
|
onSelect: (result: T) => void;
|
|
14
19
|
/** Called when search is cleared (after the value has been reset). Optional notification hook. */
|
|
@@ -27,12 +32,20 @@ export interface SearchDropdownProps<T> {
|
|
|
27
32
|
minChars?: number;
|
|
28
33
|
/** Message to show when no results found */
|
|
29
34
|
emptyMessage?: string;
|
|
35
|
+
/** What assistive technology hears when results arrive (default: "1 result" / "N results"). */
|
|
36
|
+
resultsAnnouncement?: (count: number) => string;
|
|
30
37
|
/** Custom render function for each result */
|
|
31
38
|
renderResult: (result: T, index: number) => React.ReactNode;
|
|
32
39
|
}
|
|
33
40
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
41
|
+
* A search box with a results dropdown, following the combobox pattern: the input keeps focus, the
|
|
42
|
+
* results are a listbox, and the arrow-highlighted result is the input's active descendant. Every
|
|
43
|
+
* instance carries its own ids, so several can share a page.
|
|
44
|
+
*
|
|
45
|
+
* Once the value is long enough the dropdown stays open through every settled state — results, an
|
|
46
|
+
* empty answer, or a failure — until the user dismisses it (Escape, a click outside, a selection).
|
|
47
|
+
* A dismissal holds for the value it was made on: re-rendered props never reopen it, while typing,
|
|
48
|
+
* a new value, or ArrowDown does.
|
|
36
49
|
*
|
|
37
50
|
* @example
|
|
38
51
|
* ```tsx
|
|
@@ -42,8 +55,8 @@ export interface SearchDropdownProps<T> {
|
|
|
42
55
|
* results={users}
|
|
43
56
|
* isLoading={isLoading}
|
|
44
57
|
* error={error}
|
|
58
|
+
* renderError={(error) => <MyErrorState error={error} />}
|
|
45
59
|
* onSelect={(user) => console.log(user)}
|
|
46
|
-
* onClear={() => setSearchValue('')}
|
|
47
60
|
* placeholder="Search users..."
|
|
48
61
|
* renderResult={(user) => (
|
|
49
62
|
* <div>{user.displayName}</div>
|
|
@@ -51,5 +64,5 @@ export interface SearchDropdownProps<T> {
|
|
|
51
64
|
* />
|
|
52
65
|
* ```
|
|
53
66
|
*/
|
|
54
|
-
export declare function SearchDropdown<T>({ value, onValueChange, results, isLoading, error, onSelect, onClear, placeholder, label, className, disabled, icon, minChars, emptyMessage, renderResult, }: SearchDropdownProps<T>): import("react").JSX.Element;
|
|
67
|
+
export declare function SearchDropdown<T>({ value, onValueChange, results, isLoading, error, renderError, onSelect, onClear, placeholder, label, className, disabled, icon, minChars, emptyMessage, resultsAnnouncement, renderResult, }: SearchDropdownProps<T>): import("react").JSX.Element;
|
|
55
68
|
//# sourceMappingURL=search-dropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-dropdown.d.ts","sourceRoot":"","sources":["../../../src/react/components/search-dropdown.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search-dropdown.d.ts","sourceRoot":"","sources":["../../../src/react/components/search-dropdown.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2BAA2B;IAC3B,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,8GAA8G;IAC9G,KAAK,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IACjD,uCAAuC;IACvC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,kGAAkG;IAClG,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAChD,6CAA6C;IAC7C,YAAY,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;CAC7D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,EAChC,KAAK,EACL,aAAa,EACb,OAAO,EACP,SAAS,EACT,KAAK,EACL,WAAW,EACX,QAAQ,EACR,OAAO,EACP,WAAyB,EACzB,KAAK,EACL,SAAS,EACT,QAAgB,EAChB,IAAqC,EACrC,QAAY,EACZ,YAAiC,EACjC,mBAAgD,EAChD,YAAY,GACb,EAAE,mBAAmB,CAAC,CAAC,CAAC,+BAkMxB"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState, useRef, useEffect } from 'react';
|
|
3
|
+
import { useState, useRef, useEffect, useId } from 'react';
|
|
4
4
|
import { Input } from './input.js';
|
|
5
5
|
import { Label } from './label.js';
|
|
6
6
|
import { X, Search } from 'lucide-react';
|
|
7
7
|
import { Spinner } from './spinner.js';
|
|
8
8
|
import { cn } from "../../lib/utils.js";
|
|
9
|
+
function defaultResultsAnnouncement(count) {
|
|
10
|
+
return count === 1 ? '1 result' : `${count} results`;
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
13
|
+
* A search box with a results dropdown, following the combobox pattern: the input keeps focus, the
|
|
14
|
+
* results are a listbox, and the arrow-highlighted result is the input's active descendant. Every
|
|
15
|
+
* instance carries its own ids, so several can share a page.
|
|
16
|
+
*
|
|
17
|
+
* Once the value is long enough the dropdown stays open through every settled state — results, an
|
|
18
|
+
* empty answer, or a failure — until the user dismisses it (Escape, a click outside, a selection).
|
|
19
|
+
* A dismissal holds for the value it was made on: re-rendered props never reopen it, while typing,
|
|
20
|
+
* a new value, or ArrowDown does.
|
|
12
21
|
*
|
|
13
22
|
* @example
|
|
14
23
|
* ```tsx
|
|
@@ -18,8 +27,8 @@ import { cn } from "../../lib/utils.js";
|
|
|
18
27
|
* results={users}
|
|
19
28
|
* isLoading={isLoading}
|
|
20
29
|
* error={error}
|
|
30
|
+
* renderError={(error) => <MyErrorState error={error} />}
|
|
21
31
|
* onSelect={(user) => console.log(user)}
|
|
22
|
-
* onClear={() => setSearchValue('')}
|
|
23
32
|
* placeholder="Search users..."
|
|
24
33
|
* renderResult={(user) => (
|
|
25
34
|
* <div>{user.displayName}</div>
|
|
@@ -27,68 +36,96 @@ import { cn } from "../../lib/utils.js";
|
|
|
27
36
|
* />
|
|
28
37
|
* ```
|
|
29
38
|
*/
|
|
30
|
-
export function SearchDropdown({ value, onValueChange, results, isLoading, error, onSelect, onClear, placeholder = 'Search...', label, className, disabled = false, icon = _jsx(Search, { className: "h-4 w-4" }), minChars = 3, emptyMessage = 'No results found', renderResult, }) {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
39
|
+
export function SearchDropdown({ value, onValueChange, results, isLoading, error, renderError, onSelect, onClear, placeholder = 'Search...', label, className, disabled = false, icon = _jsx(Search, { className: "h-4 w-4" }), minChars = 3, emptyMessage = 'No results found', resultsAnnouncement = defaultResultsAnnouncement, renderResult, }) {
|
|
40
|
+
const baseId = useId();
|
|
41
|
+
const inputId = `${baseId}-input`;
|
|
42
|
+
const labelId = `${baseId}-label`;
|
|
43
|
+
const listboxId = `${baseId}-listbox`;
|
|
44
|
+
const panelId = `${baseId}-panel`;
|
|
45
|
+
const hintId = `${baseId}-hint`;
|
|
46
|
+
const optionId = (index) => `${baseId}-option-${index}`;
|
|
47
|
+
const [dismissedFor, setDismissedFor] = useState(null);
|
|
48
|
+
// The highlight belongs to the value it was made on, so a new query starts with none, while a
|
|
49
|
+
// refreshed result list for the same query keeps it.
|
|
50
|
+
const [highlight, setHighlight] = useState(null);
|
|
33
51
|
const containerRef = useRef(null);
|
|
34
52
|
const inputRef = useRef(null);
|
|
53
|
+
const searchable = value.length >= minChars;
|
|
54
|
+
const isOpen = searchable && dismissedFor !== value;
|
|
55
|
+
const failed = error !== null && error !== undefined;
|
|
56
|
+
const showOptions = isOpen && !failed && !isLoading && results.length > 0;
|
|
57
|
+
const activeIndex = showOptions && highlight && highlight.value === value && highlight.index < results.length ? highlight.index : -1;
|
|
58
|
+
const showHint = value.length > 0 && !searchable;
|
|
59
|
+
const announcement = !isOpen || failed
|
|
60
|
+
? ''
|
|
61
|
+
: isLoading
|
|
62
|
+
? 'Searching...'
|
|
63
|
+
: results.length === 0
|
|
64
|
+
? emptyMessage
|
|
65
|
+
: resultsAnnouncement(results.length);
|
|
35
66
|
useEffect(() => {
|
|
67
|
+
if (!isOpen)
|
|
68
|
+
return;
|
|
36
69
|
const handleClickOutside = (event) => {
|
|
37
70
|
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
38
|
-
|
|
71
|
+
setDismissedFor(value);
|
|
39
72
|
}
|
|
40
73
|
};
|
|
41
74
|
document.addEventListener('mousedown', handleClickOutside);
|
|
42
75
|
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
43
|
-
}, []);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else {
|
|
49
|
-
setIsOpen(false);
|
|
50
|
-
}
|
|
51
|
-
}, [value, results, isLoading, error, minChars]);
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
setSelectedIndex(-1);
|
|
54
|
-
}, [results]);
|
|
76
|
+
}, [isOpen, value]);
|
|
77
|
+
const select = (result) => {
|
|
78
|
+
onSelect(result);
|
|
79
|
+
setDismissedFor(value);
|
|
80
|
+
};
|
|
55
81
|
const handleKeyDown = (e) => {
|
|
56
|
-
if (!isOpen || results.length === 0)
|
|
57
|
-
return;
|
|
58
82
|
switch (e.key) {
|
|
59
83
|
case 'ArrowDown':
|
|
84
|
+
if (!searchable)
|
|
85
|
+
return;
|
|
60
86
|
e.preventDefault();
|
|
61
|
-
|
|
87
|
+
if (!isOpen) {
|
|
88
|
+
setDismissedFor(null);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!showOptions)
|
|
92
|
+
return;
|
|
93
|
+
setHighlight({ value, index: activeIndex < results.length - 1 ? activeIndex + 1 : activeIndex });
|
|
62
94
|
break;
|
|
63
95
|
case 'ArrowUp':
|
|
96
|
+
if (!showOptions)
|
|
97
|
+
return;
|
|
64
98
|
e.preventDefault();
|
|
65
|
-
|
|
99
|
+
setHighlight({ value, index: activeIndex > 0 ? activeIndex - 1 : 0 });
|
|
66
100
|
break;
|
|
67
101
|
case 'Enter':
|
|
102
|
+
if (activeIndex < 0)
|
|
103
|
+
return;
|
|
68
104
|
e.preventDefault();
|
|
69
|
-
|
|
70
|
-
onSelect(results[selectedIndex]);
|
|
71
|
-
setIsOpen(false);
|
|
72
|
-
}
|
|
105
|
+
select(results[activeIndex]);
|
|
73
106
|
break;
|
|
74
107
|
case 'Escape':
|
|
108
|
+
// Escape never falls through to the search field's own clear, which would skip onClear:
|
|
109
|
+
// it closes an open dropdown, and clears a closed one through handleClear.
|
|
75
110
|
e.preventDefault();
|
|
76
|
-
|
|
77
|
-
|
|
111
|
+
if (isOpen)
|
|
112
|
+
setDismissedFor(value);
|
|
113
|
+
else if (value)
|
|
114
|
+
handleClear();
|
|
78
115
|
break;
|
|
79
116
|
}
|
|
80
117
|
};
|
|
81
|
-
const handleResultClick = (result) => {
|
|
82
|
-
onSelect(result);
|
|
83
|
-
setIsOpen(false);
|
|
84
|
-
};
|
|
85
118
|
const handleClear = () => {
|
|
86
119
|
onValueChange('');
|
|
87
120
|
onClear?.();
|
|
88
|
-
|
|
121
|
+
setDismissedFor(null);
|
|
89
122
|
inputRef.current?.focus();
|
|
90
123
|
};
|
|
91
|
-
|
|
92
|
-
|
|
124
|
+
return (_jsxs("div", { ref: containerRef, className: cn('relative', className), children: [label && (_jsx(Label, { id: labelId, htmlFor: inputId, className: "mb-2 block", children: label })), _jsxs("div", { className: "relative", children: [_jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground", "aria-hidden": "true", children: icon }), _jsx(Input, { ref: inputRef, id: inputId, type: "search", role: "combobox", "aria-autocomplete": "list", "aria-expanded": isOpen, "aria-controls": isOpen ? (showOptions ? listboxId : panelId) : undefined, "aria-activedescendant": activeIndex >= 0 ? optionId(activeIndex) : undefined, "aria-describedby": showHint ? hintId : undefined, autoComplete: "off", value: value, onChange: (e) => {
|
|
125
|
+
setDismissedFor(null);
|
|
126
|
+
onValueChange(e.target.value);
|
|
127
|
+
}, onKeyDown: handleKeyDown, placeholder: placeholder, disabled: disabled, className: "pl-10 pr-10 [&::-webkit-search-cancel-button]:appearance-none" }), _jsx("div", { className: "absolute right-3 top-1/2 -translate-y-1/2", children: isLoading ? (_jsx(Spinner, { size: "xs", className: "text-muted-foreground" })) : value ? (_jsx("button", { type: "button", onClick: handleClear, className: "text-muted-foreground hover:text-foreground transition-colors", "aria-label": "Clear search", children: _jsx(X, { className: "h-4 w-4" }) })) : null })] }), isOpen && (_jsx("div", { id: panelId, className: "absolute z-50 w-full mt-1 bg-popover border rounded-md elevation-raised max-h-60 overflow-auto", children: failed ? (renderError(error)) : isLoading ? (_jsxs("div", { className: "px-3 py-2 text-sm text-muted-foreground flex items-center gap-2", children: [_jsx(Spinner, { size: "xs" }), "Searching..."] })) : results.length === 0 ? (_jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: emptyMessage })) : (_jsx("div", { role: "listbox", id: listboxId, "aria-labelledby": label ? labelId : undefined, "aria-label": label ? undefined : placeholder, children: results.map((result, index) => (_jsx("div", { id: optionId(index), role: "option", "aria-selected": index === activeIndex,
|
|
128
|
+
// Keeps focus in the input, where the combobox's keyboard handling lives.
|
|
129
|
+
onMouseDown: (e) => e.preventDefault(), onClick: () => select(result), onMouseEnter: () => setHighlight({ value, index }), className: cn('w-full text-left transition-colors cursor-pointer hover:bg-accent', index === activeIndex && 'bg-accent'), children: renderResult(result, index) }, index))) })) })), _jsx("div", { role: "status", "aria-live": "polite", className: "sr-only", children: announcement }), showHint && (_jsxs("p", { id: hintId, className: "text-xs text-muted-foreground mt-1", children: ["Type at least ", minChars, " characters to search"] }))] }));
|
|
93
130
|
}
|
|
94
131
|
//# sourceMappingURL=search-dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-dropdown.js","sourceRoot":"","sources":["../../../src/react/components/search-dropdown.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAmCxC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,cAAc,CAAI,EAChC,KAAK,EACL,aAAa,EACb,OAAO,EACP,SAAS,EACT,KAAK,EAC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';\nimport { Input } from './input.js';\nimport { Label } from './label.js';\nimport { X, Search } from 'lucide-react';\nimport { Spinner } from './spinner.js';\nimport { cn } from \"../../lib/utils.js\";\n\nexport interface SearchDropdownProps<T> {\n /** Current search value */\n value: string;\n /** Called when search value changes */\n onValueChange: (value: string) => void;\n /** Search results array */\n results: T[];\n /** Loading state */\n isLoading: boolean;\n /** Error message */\n error: string | null;\n /** Called when a result is selected */\n onSelect: (result: T) => void;\n /** Called when search is cleared (after the value has been reset). Optional notification hook. */\n onClear?: () => void;\n /** Placeholder text */\n placeholder?: string;\n /** Label for the input */\n label?: string;\n /** Custom className */\n className?: string;\n /** Disabled state */\n disabled?: boolean;\n /** Icon to show in input (default: Search) */\n icon?: React.ReactNode;\n /** Minimum characters before showing results (default: 3) */\n minChars?: number;\n /** Message to show when no results found */\n emptyMessage?: string;\n /** Custom render function for each result */\n renderResult: (result: T, index: number) => React.ReactNode;\n}\n\n/**\n * Generic search dropdown component with debounced input and keyboard navigation.\n * Supports any data type and custom rendering.\n * \n * @example\n * ```tsx\n * <SearchDropdown<User>\n * value={searchValue}\n * onValueChange={setSearchValue}\n * results={users}\n * isLoading={isLoading}\n * error={error}\n * onSelect={(user) => console.log(user)}\n * onClear={() => setSearchValue('')}\n * placeholder=\"Search users...\"\n * renderResult={(user) => (\n * <div>{user.displayName}</div>\n * )}\n * />\n * ```\n */\nexport function SearchDropdown<T>({\n value,\n onValueChange,\n results,\n isLoading,\n error,\n onSelect,\n onClear,\n placeholder = 'Search...',\n label,\n className,\n disabled = false,\n icon = <Search className=\"h-4 w-4\" />,\n minChars = 3,\n emptyMessage = 'No results found',\n renderResult,\n}: SearchDropdownProps<T>) {\n const [isOpen, setIsOpen] = useState(false);\n const [selectedIndex, setSelectedIndex] = useState(-1);\n const containerRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setIsOpen(false);\n }\n };\n\n document.addEventListener('mousedown', handleClickOutside);\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, []);\n\n useEffect(() => {\n if (value.length >= minChars && (results.length > 0 || isLoading || error)) {\n setIsOpen(true);\n } else {\n setIsOpen(false);\n }\n }, [value, results, isLoading, error, minChars]);\n\n useEffect(() => {\n setSelectedIndex(-1);\n }, [results]);\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (!isOpen || results.length === 0) return;\n\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n setSelectedIndex((prev) => (prev < results.length - 1 ? prev + 1 : prev));\n break;\n case 'ArrowUp':\n e.preventDefault();\n setSelectedIndex((prev) => (prev > 0 ? prev - 1 : 0));\n break;\n case 'Enter':\n e.preventDefault();\n if (selectedIndex >= 0 && selectedIndex < results.length) {\n onSelect(results[selectedIndex]);\n setIsOpen(false);\n }\n break;\n case 'Escape':\n e.preventDefault();\n setIsOpen(false);\n inputRef.current?.blur();\n break;\n }\n };\n\n const handleResultClick = (result: T) => {\n onSelect(result);\n setIsOpen(false);\n };\n\n const handleClear = () => {\n onValueChange('');\n onClear?.();\n setIsOpen(false);\n inputRef.current?.focus();\n };\n\n const showDropdown = isOpen && value.length >= minChars;\n\n return (\n <div ref={containerRef} className={cn('relative', className)}>\n {label && (\n <Label htmlFor=\"search-input\" className=\"mb-2 block\">\n {label}\n </Label>\n )}\n \n <div className=\"relative\">\n <div className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\">\n {icon}\n </div>\n \n <Input\n ref={inputRef}\n id=\"search-input\"\n type=\"text\"\n value={value}\n onChange={(e) => onValueChange(e.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n className=\"pl-10 pr-10\"\n />\n\n <div className=\"absolute right-3 top-1/2 -translate-y-1/2\">\n {isLoading ? (\n <Spinner size=\"xs\" className=\"text-muted-foreground\" />\n ) : value ? (\n <button\n type=\"button\"\n onClick={handleClear}\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\n aria-label=\"Clear search\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n ) : null}\n </div>\n </div>\n\n {showDropdown && (\n <div className=\"absolute z-50 w-full mt-1 bg-popover border rounded-md elevation-raised max-h-60 overflow-auto\">\n {error ? (\n <div className=\"px-3 py-2 text-sm text-destructive\">\n {error}\n </div>\n ) : isLoading ? (\n <div className=\"px-3 py-2 text-sm text-muted-foreground flex items-center gap-2\">\n <Spinner size=\"xs\" />\n Searching...\n </div>\n ) : results.length === 0 ? (\n <div className=\"px-3 py-2 text-sm text-muted-foreground\">\n {emptyMessage}\n </div>\n ) : (\n results.map((result, index) => (\n <button\n key={index}\n type=\"button\"\n onClick={() => handleResultClick(result)}\n onMouseEnter={() => setSelectedIndex(index)}\n className={cn(\n 'w-full text-left transition-colors cursor-pointer',\n 'hover:bg-accent focus:bg-accent focus:outline-hidden',\n selectedIndex === index && 'bg-accent'\n )}\n >\n {renderResult(result, index)}\n </button>\n ))\n )}\n </div>\n )}\n \n {value.length > 0 && value.length < minChars && (\n <p className=\"text-xs text-muted-foreground mt-1\">\n Type at least {minChars} characters to search\n </p>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"search-dropdown.js","sourceRoot":"","sources":["../../../src/react/components/search-dropdown.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,SAAS,0BA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CAAC,KAAK,CAAC,EACnB,IAAI,EAAC,QAAQ,mBACE,KAAK,KAAK,WAAW;wBACpC,0EAA0E;wBAC1E,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EACtC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAC7B,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAClD,SAAS,EAAE,EAAE,CACX,mEAAmE,EACnE,KAAK,KAAK,WAAW,IAAI,WAAW,CACrC,YAEA,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,IAbvB,KAAK,CAcN,CACP,CAAC,GACE,CACP,GACG,CACP,EAID,cAAK,IAAI,EAAC,QAAQ,eAAW,QAAQ,EAAC,SAAS,EAAC,SAAS,YACtD,YAAY,GACT,EAEL,QAAQ,IAAI,CACX,aAAG,EAAE,EAAE,MAAM,EAAE,SAAS,EAAC,oCAAoC,+BAC5C,QAAQ,6BACrB,CACL,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["'use client';\n\nimport { useState, useRef, useEffect, useId } from 'react';\nimport { Input } from './input.js';\nimport { Label } from './label.js';\nimport { X, Search } from 'lucide-react';\nimport { Spinner } from './spinner.js';\nimport { cn } from \"../../lib/utils.js\";\n\nfunction defaultResultsAnnouncement(count: number): string {\n return count === 1 ? '1 result' : `${count} results`;\n}\n\nexport interface SearchDropdownProps<T> {\n /** Current search value */\n value: string;\n /** Called when search value changes */\n onValueChange: (value: string) => void;\n /** Search results array */\n results: T[];\n /** Loading state */\n isLoading: boolean;\n /** The search's failure exactly as the data layer reported it; `null` or `undefined` when it did not fail. */\n error: unknown;\n /**\n * Renders a failed search inside the open dropdown. The consumer owns the failure's words and any\n * retry, so the dropdown never shows a failure state of its own.\n */\n renderError: (error: unknown) => React.ReactNode;\n /** Called when a result is selected */\n onSelect: (result: T) => void;\n /** Called when search is cleared (after the value has been reset). Optional notification hook. */\n onClear?: () => void;\n /** Placeholder text */\n placeholder?: string;\n /** Label for the input */\n label?: string;\n /** Custom className */\n className?: string;\n /** Disabled state */\n disabled?: boolean;\n /** Icon to show in input (default: Search) */\n icon?: React.ReactNode;\n /** Minimum characters before showing results (default: 3) */\n minChars?: number;\n /** Message to show when no results found */\n emptyMessage?: string;\n /** What assistive technology hears when results arrive (default: \"1 result\" / \"N results\"). */\n resultsAnnouncement?: (count: number) => string;\n /** Custom render function for each result */\n renderResult: (result: T, index: number) => React.ReactNode;\n}\n\n/**\n * A search box with a results dropdown, following the combobox pattern: the input keeps focus, the\n * results are a listbox, and the arrow-highlighted result is the input's active descendant. Every\n * instance carries its own ids, so several can share a page.\n *\n * Once the value is long enough the dropdown stays open through every settled state — results, an\n * empty answer, or a failure — until the user dismisses it (Escape, a click outside, a selection).\n * A dismissal holds for the value it was made on: re-rendered props never reopen it, while typing,\n * a new value, or ArrowDown does.\n *\n * @example\n * ```tsx\n * <SearchDropdown<User>\n * value={searchValue}\n * onValueChange={setSearchValue}\n * results={users}\n * isLoading={isLoading}\n * error={error}\n * renderError={(error) => <MyErrorState error={error} />}\n * onSelect={(user) => console.log(user)}\n * placeholder=\"Search users...\"\n * renderResult={(user) => (\n * <div>{user.displayName}</div>\n * )}\n * />\n * ```\n */\nexport function SearchDropdown<T>({\n value,\n onValueChange,\n results,\n isLoading,\n error,\n renderError,\n onSelect,\n onClear,\n placeholder = 'Search...',\n label,\n className,\n disabled = false,\n icon = <Search className=\"h-4 w-4\" />,\n minChars = 3,\n emptyMessage = 'No results found',\n resultsAnnouncement = defaultResultsAnnouncement,\n renderResult,\n}: SearchDropdownProps<T>) {\n const baseId = useId();\n const inputId = `${baseId}-input`;\n const labelId = `${baseId}-label`;\n const listboxId = `${baseId}-listbox`;\n const panelId = `${baseId}-panel`;\n const hintId = `${baseId}-hint`;\n const optionId = (index: number) => `${baseId}-option-${index}`;\n\n const [dismissedFor, setDismissedFor] = useState<string | null>(null);\n // The highlight belongs to the value it was made on, so a new query starts with none, while a\n // refreshed result list for the same query keeps it.\n const [highlight, setHighlight] = useState<{ value: string; index: number } | null>(null);\n const containerRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n\n const searchable = value.length >= minChars;\n const isOpen = searchable && dismissedFor !== value;\n const failed = error !== null && error !== undefined;\n const showOptions = isOpen && !failed && !isLoading && results.length > 0;\n const activeIndex =\n showOptions && highlight && highlight.value === value && highlight.index < results.length ? highlight.index : -1;\n const showHint = value.length > 0 && !searchable;\n const announcement =\n !isOpen || failed\n ? ''\n : isLoading\n ? 'Searching...'\n : results.length === 0\n ? emptyMessage\n : resultsAnnouncement(results.length);\n\n useEffect(() => {\n if (!isOpen) return;\n const handleClickOutside = (event: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setDismissedFor(value);\n }\n };\n document.addEventListener('mousedown', handleClickOutside);\n return () => document.removeEventListener('mousedown', handleClickOutside);\n }, [isOpen, value]);\n\n const select = (result: T) => {\n onSelect(result);\n setDismissedFor(value);\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n switch (e.key) {\n case 'ArrowDown':\n if (!searchable) return;\n e.preventDefault();\n if (!isOpen) {\n setDismissedFor(null);\n return;\n }\n if (!showOptions) return;\n setHighlight({ value, index: activeIndex < results.length - 1 ? activeIndex + 1 : activeIndex });\n break;\n case 'ArrowUp':\n if (!showOptions) return;\n e.preventDefault();\n setHighlight({ value, index: activeIndex > 0 ? activeIndex - 1 : 0 });\n break;\n case 'Enter':\n if (activeIndex < 0) return;\n e.preventDefault();\n select(results[activeIndex]);\n break;\n case 'Escape':\n // Escape never falls through to the search field's own clear, which would skip onClear:\n // it closes an open dropdown, and clears a closed one through handleClear.\n e.preventDefault();\n if (isOpen) setDismissedFor(value);\n else if (value) handleClear();\n break;\n }\n };\n\n const handleClear = () => {\n onValueChange('');\n onClear?.();\n setDismissedFor(null);\n inputRef.current?.focus();\n };\n\n return (\n <div ref={containerRef} className={cn('relative', className)}>\n {label && (\n <Label id={labelId} htmlFor={inputId} className=\"mb-2 block\">\n {label}\n </Label>\n )}\n\n <div className=\"relative\">\n <div className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\" aria-hidden=\"true\">\n {icon}\n </div>\n\n <Input\n ref={inputRef}\n id={inputId}\n type=\"search\"\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-expanded={isOpen}\n aria-controls={isOpen ? (showOptions ? listboxId : panelId) : undefined}\n aria-activedescendant={activeIndex >= 0 ? optionId(activeIndex) : undefined}\n aria-describedby={showHint ? hintId : undefined}\n autoComplete=\"off\"\n value={value}\n onChange={(e) => {\n setDismissedFor(null);\n onValueChange(e.target.value);\n }}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n disabled={disabled}\n className=\"pl-10 pr-10 [&::-webkit-search-cancel-button]:appearance-none\"\n />\n\n <div className=\"absolute right-3 top-1/2 -translate-y-1/2\">\n {isLoading ? (\n <Spinner size=\"xs\" className=\"text-muted-foreground\" />\n ) : value ? (\n <button\n type=\"button\"\n onClick={handleClear}\n className=\"text-muted-foreground hover:text-foreground transition-colors\"\n aria-label=\"Clear search\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n ) : null}\n </div>\n </div>\n\n {isOpen && (\n <div id={panelId} className=\"absolute z-50 w-full mt-1 bg-popover border rounded-md elevation-raised max-h-60 overflow-auto\">\n {failed ? (\n renderError(error)\n ) : isLoading ? (\n <div className=\"px-3 py-2 text-sm text-muted-foreground flex items-center gap-2\">\n <Spinner size=\"xs\" />\n Searching...\n </div>\n ) : results.length === 0 ? (\n <div className=\"px-3 py-2 text-sm text-muted-foreground\">\n {emptyMessage}\n </div>\n ) : (\n <div\n role=\"listbox\"\n id={listboxId}\n aria-labelledby={label ? labelId : undefined}\n aria-label={label ? undefined : placeholder}\n >\n {results.map((result, index) => (\n <div\n key={index}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === activeIndex}\n // Keeps focus in the input, where the combobox's keyboard handling lives.\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => select(result)}\n onMouseEnter={() => setHighlight({ value, index })}\n className={cn(\n 'w-full text-left transition-colors cursor-pointer hover:bg-accent',\n index === activeIndex && 'bg-accent'\n )}\n >\n {renderResult(result, index)}\n </div>\n ))}\n </div>\n )}\n </div>\n )}\n\n {/* Always mounted, so every change of the open panel's state is announced. A failure is\n announced by the consumer's renderError. */}\n <div role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {announcement}\n </div>\n\n {showHint && (\n <p id={hintId} className=\"text-xs text-muted-foreground mt-1\">\n Type at least {minChars} characters to search\n </p>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
import type { DeclaredInputFormat } from "@ttt-productions/input-format-core";
|
|
3
|
+
/**
|
|
4
|
+
* A multi-line free-text input: its declaration is required, and its length bounds come only from
|
|
5
|
+
* that declaration (ENG-005), so `maxLength`, `minLength`, and `required` are not props.
|
|
6
|
+
*/
|
|
7
|
+
export type TextareaProps = Omit<React.ComponentPropsWithoutRef<"textarea">, "maxLength" | "minLength" | "required"> & {
|
|
8
|
+
inputFormat: DeclaredInputFormat;
|
|
9
|
+
};
|
|
10
|
+
declare const Textarea: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "maxLength" | "minLength" | "required"> & {
|
|
11
|
+
inputFormat: DeclaredInputFormat;
|
|
12
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
3
13
|
export { Textarea };
|
|
4
14
|
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../../src/react/components/textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../../src/react/components/textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAI7E;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC,UAAU,CAAC,EAAE,WAAW,GAAG,WAAW,GAAG,UAAU,CAAC,GAAG;IACrH,WAAW,EAAE,mBAAmB,CAAA;CACjC,CAAA;AAED,QAAA,MAAM,QAAQ;iBAHC,mBAAmB;6CAiBjC,CAAA;AAGD,OAAO,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../../lib/utils.js";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { formatControlAttributes } from "./format-control.js";
|
|
6
|
+
const Textarea = React.forwardRef(({ className, inputFormat, ...props }, ref) => {
|
|
7
|
+
return (_jsx("textarea", { className: cn("flex min-h-[80px] w-full rounded-md border-2 border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", className), ref: ref, ...props, ...formatControlAttributes(inputFormat, props) }));
|
|
7
8
|
});
|
|
8
9
|
Textarea.displayName = "Textarea";
|
|
9
10
|
export { Textarea };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../src/react/components/textarea.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"textarea.js","sourceRoot":"","sources":["../../../src/react/components/textarea.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAU7D,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAC/B,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IAC5C,OAAO,CACL,mBACE,SAAS,EAAE,EAAE,CACX,uTAAuT,EACvT,SAAS,CACV,EACD,GAAG,EAAE,GAAG,KACJ,KAAK,KACL,uBAAuB,CAAC,WAAW,EAAE,KAAK,CAAC,GAC/C,CACH,CAAA;AACH,CAAC,CACF,CAAA;AACD,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAE,CAAA","sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport type { DeclaredInputFormat } from \"@ttt-productions/input-format-core\"\nimport { cn } from \"../../lib/utils.js\"\nimport { formatControlAttributes } from \"./format-control.js\"\n\n/**\n * A multi-line free-text input: its declaration is required, and its length bounds come only from\n * that declaration (ENG-005), so `maxLength`, `minLength`, and `required` are not props.\n */\nexport type TextareaProps = Omit<React.ComponentPropsWithoutRef<\"textarea\">, \"maxLength\" | \"minLength\" | \"required\"> & {\n inputFormat: DeclaredInputFormat\n}\n\nconst Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(\n ({ className, inputFormat, ...props }, ref) => {\n return (\n <textarea\n className={cn(\n \"flex min-h-[80px] w-full rounded-md border-2 border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\n className\n )}\n ref={ref}\n {...props}\n {...formatControlAttributes(inputFormat, props)}\n />\n )\n }\n)\nTextarea.displayName = \"Textarea\"\n\nexport { Textarea }\n"]}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { SpinnerProps, SpinnerSize } from "./components/spinner.js";
|
|
|
4
4
|
export { Spinner } from "./components/spinner.js";
|
|
5
5
|
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from "./components/card.js";
|
|
6
6
|
export { Label } from "./components/label.js";
|
|
7
|
+
export type { TextareaProps } from "./components/textarea.js";
|
|
7
8
|
export { Textarea } from "./components/textarea.js";
|
|
8
9
|
export { Skeleton } from "./components/skeleton.js";
|
|
9
10
|
export { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription } from "./components/dialog.js";
|
|
@@ -17,6 +18,7 @@ export { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, Toas
|
|
|
17
18
|
export { Toaster } from "./components/toaster.js";
|
|
18
19
|
export type { ToastVariant, ToasterToast } from "./hooks/use-toast.js";
|
|
19
20
|
export { toast, useToast } from "./hooks/use-toast.js";
|
|
21
|
+
export type { InputProps, FreeTextInputProps, NonFreeTextInputProps, NonFreeTextEntry, BuiltInFormatInputProps, BuiltInFormatInputType } from "./components/input.js";
|
|
20
22
|
export { Input } from "./components/input.js";
|
|
21
23
|
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton } from "./components/select.js";
|
|
22
24
|
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./components/tabs.js";
|
|
@@ -34,6 +36,8 @@ export { Progress } from "./components/progress.js";
|
|
|
34
36
|
export { Slider } from "./components/slider.js";
|
|
35
37
|
export type { DatePickerProps } from "./components/date-picker.js";
|
|
36
38
|
export { DatePicker } from "./components/date-picker.js";
|
|
39
|
+
export type { DateTimePickerProps, DateTimePickerTime } from "./components/date-time-picker.js";
|
|
40
|
+
export { DateTimePicker } from "./components/date-time-picker.js";
|
|
37
41
|
export { ScrollArea, ScrollBar } from "./components/scroll-area.js";
|
|
38
42
|
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption } from "./components/table.js";
|
|
39
43
|
export { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from "./components/sheet.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACpL,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,qBAAqB,EAA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AqB,EAAE,MAAM,6BAA6B,CAAC;AAGtF,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,YAAY,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,YAAY,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAErF,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,YAAY,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,YAAY,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAIpF,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErG,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAKhG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACtH,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/react/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { RadioGroup, RadioGroupItem } from "./components/radio-group.js";
|
|
|
29
29
|
export { Progress } from "./components/progress.js";
|
|
30
30
|
export { Slider } from "./components/slider.js";
|
|
31
31
|
export { DatePicker } from "./components/date-picker.js";
|
|
32
|
+
export { DateTimePicker } from "./components/date-time-picker.js";
|
|
32
33
|
export { ScrollArea, ScrollBar } from "./components/scroll-area.js";
|
|
33
34
|
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption } from "./components/table.js";
|
|
34
35
|
export { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from "./components/sheet.js";
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACpL,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAA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AE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,yBAAyB;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,kFAAkF;AAClF,iEAAiE;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,uFAAuF;AACvF,wFAAwF;AACxF,gCAAgC;AAChC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["\"use client\";\n\nexport type { ButtonProps } from \"./components/button.js\";\nexport { Button, buttonVariants } from \"./components/button.js\";\nexport type { SpinnerProps, SpinnerSize } from \"./components/spinner.js\";\nexport { Spinner } from \"./components/spinner.js\";\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from \"./components/card.js\";\nexport { Label } from \"./components/label.js\";\nexport { Textarea } from \"./components/textarea.js\";\nexport { Skeleton } from \"./components/skeleton.js\";\nexport { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription } from \"./components/dialog.js\";\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor } from \"./components/popover.js\";\nexport { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup } from \"./components/dropdown-menu.js\";\nexport { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarLabel, MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem, MenubarPortal, MenubarSubContent, MenubarSubTrigger, MenubarGroup, MenubarSub, MenubarShortcut } from \"./components/menubar.js\";\nexport { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from \"./components/alert-dialog.js\";\nexport { Alert, AlertTitle, AlertDescription } from \"./components/alert.js\";\nexport type { ToastProps, ToastActionElement } from \"./components/toast.js\";\nexport { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction } from \"./components/toast.js\";\nexport { Toaster } from \"./components/toaster.js\";\nexport type { ToastVariant, ToasterToast } from \"./hooks/use-toast.js\";\nexport { toast, useToast } from \"./hooks/use-toast.js\";\nexport { Input } from \"./components/input.js\";\nexport { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton } from \"./components/select.js\";\nexport { Tabs, TabsList, TabsTrigger, TabsContent } from \"./components/tabs.js\";\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from \"./components/tooltip.js\";\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from \"./components/form.js\";\nexport { Checkbox } from \"./components/checkbox.js\";\nexport { Switch } from \"./components/switch.js\";\nexport type { BadgeProps } from \"./components/badge.js\";\nexport { Badge, badgeVariants } from \"./components/badge.js\";\nexport { Avatar, AvatarImage, AvatarFallback } from \"./components/avatar.js\";\nexport { Separator } from \"./components/separator.js\";\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from \"./components/accordion.js\";\nexport { RadioGroup, RadioGroupItem } from \"./components/radio-group.js\";\nexport { Progress } from \"./components/progress.js\";\nexport { Slider } from \"./components/slider.js\";\nexport type { DatePickerProps } from \"./components/date-picker.js\";\nexport { DatePicker } from \"./components/date-picker.js\";\nexport { ScrollArea, ScrollBar } from \"./components/scroll-area.js\";\nexport { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption } from \"./components/table.js\";\nexport { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from \"./components/sheet.js\";\nexport { Collapsible, CollapsibleTrigger, CollapsibleContent } from \"./components/collapsible.js\";\nexport type { SearchDropdownProps } from \"./components/search-dropdown.js\";\nexport { SearchDropdown } from \"./components/search-dropdown.js\";\n\nexport type { ConsequenceDialogProps, ConsequenceDialogReason, ConsequenceDialogTypedConfirmation } from \"./components/consequence-dialog.js\";\nexport { ConsequenceDialog } from \"./components/consequence-dialog.js\";\n\nexport type { MaxWidthOption, ScreenAdaptiveViewProps } from \"./components/layout/screen-adaptive-view.js\";\nexport { ScreenAdaptiveView } from \"./components/layout/screen-adaptive-view.js\";\n\nexport { useMediaQuery } from \"./hooks/use-media-query.js\";\n\nexport { useAsyncAction } from \"./hooks/use-async-action.js\";\nexport type { AsyncAction, UseAsyncActionOptions } from \"./hooks/use-async-action.js\";\n\n// Shared building blocks\nexport { RelativeTime } from \"./components/relative-time.js\";\nexport type { RelativeTimeProps } from \"./components/relative-time.js\";\n\nexport { EndOfListIndicator } from \"./components/end-of-list-indicator.js\";\nexport type { EndOfListIndicatorProps } from \"./components/end-of-list-indicator.js\";\n\nexport { ScrollToTopButton } from \"./components/scroll-to-top-button.js\";\nexport type { ScrollToTopButtonProps } from \"./components/scroll-to-top-button.js\";\n\nexport { ChunkErrorRecovery } from \"./components/chunk-error-recovery.js\";\nexport type { ChunkErrorRecoveryProps } from \"./components/chunk-error-recovery.js\";\n\n// List pagination — the one Previous / counter / Next control plus the page-state\n// hooks for its two flavors (known total, and cursor/`hasMore`).\nexport { ListPagination } from \"./components/list-pagination.js\";\nexport type { ListPaginationProps } from \"./components/list-pagination.js\";\n\nexport { usePagedList } from \"./hooks/use-paged-list.js\";\nexport type { ListPaginationState, PagedList, UsePagedListOptions } from \"./hooks/use-paged-list.js\";\n\nexport { useCursorPage } from \"./hooks/use-cursor-page.js\";\nexport type { CursorPage, CursorPager, UseCursorPageOptions } from \"./hooks/use-cursor-page.js\";\n\n// Return-scroll: restore a list's window offset when the user comes back to it after a\n// route change (save on leave, restore once on an eligible + ready return, keyed by the\n// caller's canonical list URL).\nexport { useReturnScroll, saveReturnScroll, clearReturnScroll, readReturnScroll } from \"./hooks/use-return-scroll.js\";\nexport type { ReturnScrollEntry, UseReturnScrollOptions, UseReturnScrollResult } from \"./hooks/use-return-scroll.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CA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,uBAAuB,CAAC;AACjI,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzK,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAElG,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAGvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAG7D,yBAAyB;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAG1E,kFAAkF;AAClF,iEAAiE;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D,uFAAuF;AACvF,wFAAwF;AACxF,gCAAgC;AAChC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["\"use client\";\n\nexport type { ButtonProps } from \"./components/button.js\";\nexport { Button, buttonVariants } from \"./components/button.js\";\nexport type { SpinnerProps, SpinnerSize } from \"./components/spinner.js\";\nexport { Spinner } from \"./components/spinner.js\";\nexport { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from \"./components/card.js\";\nexport { Label } from \"./components/label.js\";\nexport type { TextareaProps } from \"./components/textarea.js\";\nexport { Textarea } from \"./components/textarea.js\";\nexport { Skeleton } from \"./components/skeleton.js\";\nexport { Dialog, DialogPortal, DialogOverlay, DialogClose, DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription } from \"./components/dialog.js\";\nexport { Popover, PopoverTrigger, PopoverContent, PopoverAnchor } from \"./components/popover.js\";\nexport { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup } from \"./components/dropdown-menu.js\";\nexport { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarLabel, MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem, MenubarPortal, MenubarSubContent, MenubarSubTrigger, MenubarGroup, MenubarSub, MenubarShortcut } from \"./components/menubar.js\";\nexport { AlertDialog, AlertDialogPortal, AlertDialogOverlay, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel } from \"./components/alert-dialog.js\";\nexport { Alert, AlertTitle, AlertDescription } from \"./components/alert.js\";\nexport type { ToastProps, ToastActionElement } from \"./components/toast.js\";\nexport { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction } from \"./components/toast.js\";\nexport { Toaster } from \"./components/toaster.js\";\nexport type { ToastVariant, ToasterToast } from \"./hooks/use-toast.js\";\nexport { toast, useToast } from \"./hooks/use-toast.js\";\nexport type { InputProps, FreeTextInputProps, NonFreeTextInputProps, NonFreeTextEntry, BuiltInFormatInputProps, BuiltInFormatInputType } from \"./components/input.js\";\nexport { Input } from \"./components/input.js\";\nexport { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton } from \"./components/select.js\";\nexport { Tabs, TabsList, TabsTrigger, TabsContent } from \"./components/tabs.js\";\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from \"./components/tooltip.js\";\nexport { useFormField, Form, FormItem, FormLabel, FormControl, FormDescription, FormMessage, FormField } from \"./components/form.js\";\nexport { Checkbox } from \"./components/checkbox.js\";\nexport { Switch } from \"./components/switch.js\";\nexport type { BadgeProps } from \"./components/badge.js\";\nexport { Badge, badgeVariants } from \"./components/badge.js\";\nexport { Avatar, AvatarImage, AvatarFallback } from \"./components/avatar.js\";\nexport { Separator } from \"./components/separator.js\";\nexport { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from \"./components/accordion.js\";\nexport { RadioGroup, RadioGroupItem } from \"./components/radio-group.js\";\nexport { Progress } from \"./components/progress.js\";\nexport { Slider } from \"./components/slider.js\";\nexport type { DatePickerProps } from \"./components/date-picker.js\";\nexport { DatePicker } from \"./components/date-picker.js\";\nexport type { DateTimePickerProps, DateTimePickerTime } from \"./components/date-time-picker.js\";\nexport { DateTimePicker } from \"./components/date-time-picker.js\";\nexport { ScrollArea, ScrollBar } from \"./components/scroll-area.js\";\nexport { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption } from \"./components/table.js\";\nexport { Sheet, SheetPortal, SheetOverlay, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription } from \"./components/sheet.js\";\nexport { Collapsible, CollapsibleTrigger, CollapsibleContent } from \"./components/collapsible.js\";\nexport type { SearchDropdownProps } from \"./components/search-dropdown.js\";\nexport { SearchDropdown } from \"./components/search-dropdown.js\";\n\nexport type { ConsequenceDialogProps, ConsequenceDialogReason, ConsequenceDialogTypedConfirmation } from \"./components/consequence-dialog.js\";\nexport { ConsequenceDialog } from \"./components/consequence-dialog.js\";\n\nexport type { MaxWidthOption, ScreenAdaptiveViewProps } from \"./components/layout/screen-adaptive-view.js\";\nexport { ScreenAdaptiveView } from \"./components/layout/screen-adaptive-view.js\";\n\nexport { useMediaQuery } from \"./hooks/use-media-query.js\";\n\nexport { useAsyncAction } from \"./hooks/use-async-action.js\";\nexport type { AsyncAction, UseAsyncActionOptions } from \"./hooks/use-async-action.js\";\n\n// Shared building blocks\nexport { RelativeTime } from \"./components/relative-time.js\";\nexport type { RelativeTimeProps } from \"./components/relative-time.js\";\n\nexport { EndOfListIndicator } from \"./components/end-of-list-indicator.js\";\nexport type { EndOfListIndicatorProps } from \"./components/end-of-list-indicator.js\";\n\nexport { ScrollToTopButton } from \"./components/scroll-to-top-button.js\";\nexport type { ScrollToTopButtonProps } from \"./components/scroll-to-top-button.js\";\n\nexport { ChunkErrorRecovery } from \"./components/chunk-error-recovery.js\";\nexport type { ChunkErrorRecoveryProps } from \"./components/chunk-error-recovery.js\";\n\n// List pagination — the one Previous / counter / Next control plus the page-state\n// hooks for its two flavors (known total, and cursor/`hasMore`).\nexport { ListPagination } from \"./components/list-pagination.js\";\nexport type { ListPaginationProps } from \"./components/list-pagination.js\";\n\nexport { usePagedList } from \"./hooks/use-paged-list.js\";\nexport type { ListPaginationState, PagedList, UsePagedListOptions } from \"./hooks/use-paged-list.js\";\n\nexport { useCursorPage } from \"./hooks/use-cursor-page.js\";\nexport type { CursorPage, CursorPager, UseCursorPageOptions } from \"./hooks/use-cursor-page.js\";\n\n// Return-scroll: restore a list's window offset when the user comes back to it after a\n// route change (save on leave, restore once on an eligible + ready return, keyed by the\n// caller's canonical list URL).\nexport { useReturnScroll, saveReturnScroll, clearReturnScroll, readReturnScroll } from \"./hooks/use-return-scroll.js\";\nexport type { ReturnScrollEntry, UseReturnScrollOptions, UseReturnScrollResult } from \"./hooks/use-return-scroll.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttt-productions/ui-core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.21",
|
|
4
4
|
"description": "Shared UI components for TTT Productions projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react-dom": ">=19.0.0",
|
|
49
49
|
"react-hook-form": ">=7.0.0",
|
|
50
50
|
"@hookform/resolvers": ">=3.0.0",
|
|
51
|
-
"@ttt-productions/firebase-helpers": "^0.12.
|
|
51
|
+
"@ttt-productions/firebase-helpers": "^0.12.10",
|
|
52
52
|
"lucide-react": "^1.30.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
90
90
|
"@radix-ui/react-toast": "^1.2.15",
|
|
91
91
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
92
|
+
"@ttt-productions/input-format-core": "^0.1.1",
|
|
92
93
|
"class-variance-authority": "^0.7.0",
|
|
93
94
|
"clsx": "^2.1.1",
|
|
94
95
|
"tailwind-merge": "^3.6.0"
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
"react-dom": "^19.2.0",
|
|
101
102
|
"react-hook-form": "^7.69.0",
|
|
102
103
|
"@hookform/resolvers": "^5.2.2",
|
|
103
|
-
"@ttt-productions/firebase-helpers": "^0.12.
|
|
104
|
+
"@ttt-productions/firebase-helpers": "^0.12.10",
|
|
104
105
|
"lucide-react": "^1.30.0"
|
|
105
106
|
},
|
|
106
107
|
"author": "DJ (TTT Productions)",
|