@dowel-ui/react 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -8
- package/dist/components/ai-disclosure/ai-disclosure.d.ts +92 -0
- package/dist/components/ai-disclosure/ai-disclosure.d.ts.map +1 -0
- package/dist/components/ai-disclosure/ai-disclosure.js +122 -0
- package/dist/components/ai-disclosure/ai-disclosure.js.map +1 -0
- package/dist/components/ai-disclosure/index.d.ts +2 -0
- package/dist/components/ai-disclosure/index.js +2 -0
- package/dist/components/ai-disclosure/meta.js +17 -0
- package/dist/components/ai-disclosure/meta.js.map +1 -0
- package/dist/components/ai-extraction-review/ai-extraction-review.d.ts +52 -0
- package/dist/components/ai-extraction-review/ai-extraction-review.d.ts.map +1 -0
- package/dist/components/ai-extraction-review/ai-extraction-review.js +249 -0
- package/dist/components/ai-extraction-review/ai-extraction-review.js.map +1 -0
- package/dist/components/ai-extraction-review/extraction-model.d.ts +94 -0
- package/dist/components/ai-extraction-review/extraction-model.d.ts.map +1 -0
- package/dist/components/ai-extraction-review/extraction-model.js +91 -0
- package/dist/components/ai-extraction-review/extraction-model.js.map +1 -0
- package/dist/components/ai-extraction-review/index.d.ts +3 -0
- package/dist/components/ai-extraction-review/index.js +3 -0
- package/dist/components/ai-extraction-review/meta.js +17 -0
- package/dist/components/ai-extraction-review/meta.js.map +1 -0
- package/dist/components/ai-suggested-value/ai-suggested-value.d.ts +72 -0
- package/dist/components/ai-suggested-value/ai-suggested-value.d.ts.map +1 -0
- package/dist/components/ai-suggested-value/ai-suggested-value.js +126 -0
- package/dist/components/ai-suggested-value/ai-suggested-value.js.map +1 -0
- package/dist/components/ai-suggested-value/index.d.ts +2 -0
- package/dist/components/ai-suggested-value/index.js +2 -0
- package/dist/components/ai-suggested-value/meta.js +17 -0
- package/dist/components/ai-suggested-value/meta.js.map +1 -0
- package/dist/components/alert/alert.d.ts +1 -1
- package/dist/components/avatar/avatar.d.ts +1 -1
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/confirm-typed/confirm-typed.d.ts +47 -0
- package/dist/components/confirm-typed/confirm-typed.d.ts.map +1 -0
- package/dist/components/confirm-typed/confirm-typed.js +106 -0
- package/dist/components/confirm-typed/confirm-typed.js.map +1 -0
- package/dist/components/confirm-typed/index.d.ts +2 -0
- package/dist/components/confirm-typed/index.js +2 -0
- package/dist/components/confirm-typed/meta.js +17 -0
- package/dist/components/confirm-typed/meta.js.map +1 -0
- package/dist/components/cron-editor/cron-editor.d.ts +36 -0
- package/dist/components/cron-editor/cron-editor.d.ts.map +1 -0
- package/dist/components/cron-editor/cron-editor.js +493 -0
- package/dist/components/cron-editor/cron-editor.js.map +1 -0
- package/dist/components/cron-editor/cron-expression.d.ts +82 -0
- package/dist/components/cron-editor/cron-expression.d.ts.map +1 -0
- package/dist/components/cron-editor/cron-expression.js +352 -0
- package/dist/components/cron-editor/cron-expression.js.map +1 -0
- package/dist/components/cron-editor/index.d.ts +3 -0
- package/dist/components/cron-editor/index.js +3 -0
- package/dist/components/cron-editor/meta.js +17 -0
- package/dist/components/cron-editor/meta.js.map +1 -0
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/diff-viewer/diff-model.d.ts +69 -0
- package/dist/components/diff-viewer/diff-model.d.ts.map +1 -0
- package/dist/components/diff-viewer/diff-model.js +180 -0
- package/dist/components/diff-viewer/diff-model.js.map +1 -0
- package/dist/components/diff-viewer/diff-viewer.d.ts +42 -0
- package/dist/components/diff-viewer/diff-viewer.d.ts.map +1 -0
- package/dist/components/diff-viewer/diff-viewer.js +212 -0
- package/dist/components/diff-viewer/diff-viewer.js.map +1 -0
- package/dist/components/diff-viewer/index.d.ts +3 -0
- package/dist/components/diff-viewer/index.js +3 -0
- package/dist/components/diff-viewer/meta.js +17 -0
- package/dist/components/diff-viewer/meta.js.map +1 -0
- package/dist/components/dns-record/dns-record.d.ts +61 -0
- package/dist/components/dns-record/dns-record.d.ts.map +1 -0
- package/dist/components/dns-record/dns-record.js +227 -0
- package/dist/components/dns-record/dns-record.js.map +1 -0
- package/dist/components/dns-record/index.d.ts +2 -0
- package/dist/components/dns-record/index.js +2 -0
- package/dist/components/dns-record/meta.js +17 -0
- package/dist/components/dns-record/meta.js.map +1 -0
- package/dist/components/log-viewer/index.d.ts +3 -0
- package/dist/components/log-viewer/index.js +3 -0
- package/dist/components/log-viewer/log-stream.d.ts +68 -0
- package/dist/components/log-viewer/log-stream.d.ts.map +1 -0
- package/dist/components/log-viewer/log-stream.js +120 -0
- package/dist/components/log-viewer/log-stream.js.map +1 -0
- package/dist/components/log-viewer/log-viewer.d.ts +51 -0
- package/dist/components/log-viewer/log-viewer.d.ts.map +1 -0
- package/dist/components/log-viewer/log-viewer.js +284 -0
- package/dist/components/log-viewer/log-viewer.js.map +1 -0
- package/dist/components/log-viewer/meta.js +17 -0
- package/dist/components/log-viewer/meta.js.map +1 -0
- package/dist/components/permission-matrix/index.d.ts +3 -0
- package/dist/components/permission-matrix/index.js +3 -0
- package/dist/components/permission-matrix/meta.js +17 -0
- package/dist/components/permission-matrix/meta.js.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts +46 -0
- package/dist/components/permission-matrix/permission-matrix.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-matrix.js +199 -0
- package/dist/components/permission-matrix/permission-matrix.js.map +1 -0
- package/dist/components/permission-matrix/permission-model.d.ts +53 -0
- package/dist/components/permission-matrix/permission-model.d.ts.map +1 -0
- package/dist/components/permission-matrix/permission-model.js +64 -0
- package/dist/components/permission-matrix/permission-model.js.map +1 -0
- package/dist/components/progress/progress.d.ts +1 -1
- package/dist/components/secret-field/index.d.ts +2 -0
- package/dist/components/secret-field/index.js +2 -0
- package/dist/components/secret-field/meta.js +17 -0
- package/dist/components/secret-field/meta.js.map +1 -0
- package/dist/components/secret-field/secret-field.d.ts +58 -0
- package/dist/components/secret-field/secret-field.d.ts.map +1 -0
- package/dist/components/secret-field/secret-field.js +168 -0
- package/dist/components/secret-field/secret-field.js.map +1 -0
- package/dist/components/session-expiry/index.d.ts +2 -0
- package/dist/components/session-expiry/index.js +2 -0
- package/dist/components/session-expiry/meta.js +17 -0
- package/dist/components/session-expiry/meta.js.map +1 -0
- package/dist/components/session-expiry/session-expiry.d.ts +64 -0
- package/dist/components/session-expiry/session-expiry.d.ts.map +1 -0
- package/dist/components/session-expiry/session-expiry.js +185 -0
- package/dist/components/session-expiry/session-expiry.js.map +1 -0
- package/dist/components/shortcut-recorder/index.d.ts +3 -0
- package/dist/components/shortcut-recorder/index.js +3 -0
- package/dist/components/shortcut-recorder/meta.js +17 -0
- package/dist/components/shortcut-recorder/meta.js.map +1 -0
- package/dist/components/shortcut-recorder/shortcut-model.d.ts +67 -0
- package/dist/components/shortcut-recorder/shortcut-model.d.ts.map +1 -0
- package/dist/components/shortcut-recorder/shortcut-model.js +168 -0
- package/dist/components/shortcut-recorder/shortcut-model.js.map +1 -0
- package/dist/components/shortcut-recorder/shortcut-recorder.d.ts +47 -0
- package/dist/components/shortcut-recorder/shortcut-recorder.d.ts.map +1 -0
- package/dist/components/shortcut-recorder/shortcut-recorder.js +212 -0
- package/dist/components/shortcut-recorder/shortcut-recorder.js.map +1 -0
- package/dist/components/spinner/spinner.d.ts +1 -1
- package/dist/components/sync-status/index.d.ts +2 -0
- package/dist/components/sync-status/index.js +2 -0
- package/dist/components/sync-status/meta.js +17 -0
- package/dist/components/sync-status/meta.js.map +1 -0
- package/dist/components/sync-status/sync-status.d.ts +65 -0
- package/dist/components/sync-status/sync-status.d.ts.map +1 -0
- package/dist/components/sync-status/sync-status.js +103 -0
- package/dist/components/sync-status/sync-status.js.map +1 -0
- package/dist/components/time-range-picker/index.d.ts +3 -0
- package/dist/components/time-range-picker/index.js +3 -0
- package/dist/components/time-range-picker/meta.js +22 -0
- package/dist/components/time-range-picker/meta.js.map +1 -0
- package/dist/components/time-range-picker/time-expression.d.ts +88 -0
- package/dist/components/time-range-picker/time-expression.d.ts.map +1 -0
- package/dist/components/time-range-picker/time-expression.js +335 -0
- package/dist/components/time-range-picker/time-expression.js.map +1 -0
- package/dist/components/time-range-picker/time-range-picker.d.ts +65 -0
- package/dist/components/time-range-picker/time-range-picker.d.ts.map +1 -0
- package/dist/components/time-range-picker/time-range-picker.js +377 -0
- package/dist/components/time-range-picker/time-range-picker.js.map +1 -0
- package/dist/components/toast/toast.d.ts +1 -1
- package/dist/index.d.ts +36 -1
- package/dist/index.js +24 -3
- package/dist/registry/components.d.ts.map +1 -1
- package/dist/registry/components.js +78 -50
- package/dist/registry/components.js.map +1 -1
- package/package.json +6 -4
- package/src/components/ai-disclosure/ai-disclosure.tsx +244 -0
- package/src/components/ai-disclosure/index.ts +9 -0
- package/src/components/ai-disclosure/meta.ts +23 -0
- package/src/components/ai-extraction-review/ai-extraction-review.tsx +492 -0
- package/src/components/ai-extraction-review/extraction-model.ts +159 -0
- package/src/components/ai-extraction-review/index.ts +13 -0
- package/src/components/ai-extraction-review/meta.ts +24 -0
- package/src/components/ai-suggested-value/ai-suggested-value.tsx +295 -0
- package/src/components/ai-suggested-value/index.ts +6 -0
- package/src/components/ai-suggested-value/meta.ts +24 -0
- package/src/components/confirm-typed/confirm-typed.tsx +191 -0
- package/src/components/confirm-typed/index.ts +1 -0
- package/src/components/confirm-typed/meta.ts +22 -0
- package/src/components/cron-editor/cron-editor.tsx +676 -0
- package/src/components/cron-editor/cron-expression.ts +552 -0
- package/src/components/cron-editor/index.ts +23 -0
- package/src/components/cron-editor/meta.ts +23 -0
- package/src/components/diff-viewer/diff-model.ts +256 -0
- package/src/components/diff-viewer/diff-viewer.tsx +339 -0
- package/src/components/diff-viewer/index.ts +17 -0
- package/src/components/diff-viewer/meta.ts +20 -0
- package/src/components/dns-record/dns-record.tsx +315 -0
- package/src/components/dns-record/index.ts +7 -0
- package/src/components/dns-record/meta.ts +21 -0
- package/src/components/log-viewer/index.ts +21 -0
- package/src/components/log-viewer/log-stream.ts +176 -0
- package/src/components/log-viewer/log-viewer.tsx +424 -0
- package/src/components/log-viewer/meta.ts +21 -0
- package/src/components/permission-matrix/index.ts +14 -0
- package/src/components/permission-matrix/meta.ts +23 -0
- package/src/components/permission-matrix/permission-matrix.tsx +368 -0
- package/src/components/permission-matrix/permission-model.ts +120 -0
- package/src/components/secret-field/index.ts +6 -0
- package/src/components/secret-field/meta.ts +21 -0
- package/src/components/secret-field/secret-field.tsx +284 -0
- package/src/components/session-expiry/index.ts +9 -0
- package/src/components/session-expiry/meta.ts +23 -0
- package/src/components/session-expiry/session-expiry.tsx +321 -0
- package/src/components/shortcut-recorder/index.ts +19 -0
- package/src/components/shortcut-recorder/meta.ts +22 -0
- package/src/components/shortcut-recorder/shortcut-model.ts +204 -0
- package/src/components/shortcut-recorder/shortcut-recorder.tsx +336 -0
- package/src/components/sync-status/index.ts +9 -0
- package/src/components/sync-status/meta.ts +21 -0
- package/src/components/sync-status/sync-status.tsx +217 -0
- package/src/components/time-range-picker/index.ts +25 -0
- package/src/components/time-range-picker/meta.ts +22 -0
- package/src/components/time-range-picker/time-expression.ts +491 -0
- package/src/components/time-range-picker/time-range-picker.tsx +522 -0
- package/src/index.ts +14 -0
- package/src/registry/components.ts +28 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/confirm-typed/confirm-typed.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Type the name to confirm.
|
|
5
|
+
*
|
|
6
|
+
* The GitHub pattern for deleting a repository, and the one every product
|
|
7
|
+
* copies for the action that cannot be undone: the name of the thing has to
|
|
8
|
+
* pass through the reader's fingers before the button works. Trivial to
|
|
9
|
+
* build, absent from every component library, and usually built wrong in
|
|
10
|
+
* the one place it matters — what happens when the text does not match.
|
|
11
|
+
* The common version disables the button and says nothing, so a keyboard
|
|
12
|
+
* or screen reader user presses it, or presses Enter, and nothing happens
|
|
13
|
+
* at all.
|
|
14
|
+
*
|
|
15
|
+
* Here a mismatch is a thing that is said. The button stays reachable and
|
|
16
|
+
* pressing it, or Enter, before the text matches announces what was
|
|
17
|
+
* expected and marks the field invalid. The moment the text matches, that
|
|
18
|
+
* is announced too, once, so a reader knows the action has become
|
|
19
|
+
* available without watching the button change colour.
|
|
20
|
+
*
|
|
21
|
+
* Pasting is allowed. Blocking it is a popular piece of friction, and it
|
|
22
|
+
* punishes exactly the people who cannot type a long name easily — switch
|
|
23
|
+
* users, voice users, anyone with a tremor — while stopping nobody who can
|
|
24
|
+
* select-all and copy. The name is on screen either way; the point is that
|
|
25
|
+
* it passed through the reader's attention, not their keyboard.
|
|
26
|
+
*/
|
|
27
|
+
interface ConfirmTypedProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
28
|
+
/** The text that must be typed, exactly. */
|
|
29
|
+
expected: string;
|
|
30
|
+
/** What confirming does, as the button reads: "Delete project". */
|
|
31
|
+
action: string;
|
|
32
|
+
onConfirm: () => void;
|
|
33
|
+
/** While the action runs. The button stays focusable and says so. */
|
|
34
|
+
pending?: boolean;
|
|
35
|
+
/** Match regardless of case. Off by default: a name is a name. */
|
|
36
|
+
caseSensitive?: boolean;
|
|
37
|
+
variant?: "destructive" | "primary";
|
|
38
|
+
/** The typed text. Controlled, if you want it. */
|
|
39
|
+
value?: string;
|
|
40
|
+
onValueChange?: (value: string) => void;
|
|
41
|
+
/** The consequence, in a sentence or two, before the field. */
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
}
|
|
44
|
+
declare function ConfirmTyped({ className, expected, action, onConfirm, pending, caseSensitive, variant, value: valueProp, onValueChange, children, ...props }: ConfirmTypedProps): import("react").JSX.Element;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { ConfirmTyped, ConfirmTypedProps };
|
|
47
|
+
//# sourceMappingURL=confirm-typed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-typed.d.ts","names":[],"sources":["../../../src/components/confirm-typed/confirm-typed.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;UAwCiB,0BAA0B,KAAK;;EAE9C;;EAEA;EACA;;EAEA;;EAEA;EACA;;EAEA;EACA,iBAAiB;;EAEjB,WAAW;;iBAGG,eACd,WACA,UACA,QACA,WACA,SACA,eACA,SACA,OAAO,WACP,eACA,aACG,SACF,oCAAiB,IAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../../lib/utils.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { Input } from "../input/input.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useId, useRef, useState } from "react";
|
|
7
|
+
//#region src/components/confirm-typed/confirm-typed.tsx
|
|
8
|
+
function ConfirmTyped({ className, expected, action, onConfirm, pending = false, caseSensitive = true, variant = "destructive", value: valueProp, onValueChange, children, ...props }) {
|
|
9
|
+
const id = useId();
|
|
10
|
+
const inputRef = useRef(null);
|
|
11
|
+
const [uncontrolled, setUncontrolled] = useState("");
|
|
12
|
+
const value = valueProp ?? uncontrolled;
|
|
13
|
+
const [attempted, setAttempted] = useState(false);
|
|
14
|
+
const [announcement, setAnnouncement] = useState("");
|
|
15
|
+
const normalise = (text) => caseSensitive ? text.trim() : text.trim().toLowerCase();
|
|
16
|
+
const matched = value.length > 0 && normalise(value) === normalise(expected);
|
|
17
|
+
const [wasMatched, setWasMatched] = useState(matched);
|
|
18
|
+
if (wasMatched !== matched) {
|
|
19
|
+
setWasMatched(matched);
|
|
20
|
+
if (matched) {
|
|
21
|
+
setAnnouncement(`Matches. ${action} is available.`);
|
|
22
|
+
setAttempted(false);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const setValue = (next) => {
|
|
26
|
+
setUncontrolled(next);
|
|
27
|
+
onValueChange?.(next);
|
|
28
|
+
};
|
|
29
|
+
const attempt = () => {
|
|
30
|
+
if (pending) return;
|
|
31
|
+
if (matched) {
|
|
32
|
+
onConfirm();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setAttempted(true);
|
|
36
|
+
setAnnouncement(`Does not match. Type ${expected} exactly.`);
|
|
37
|
+
inputRef.current?.focus();
|
|
38
|
+
};
|
|
39
|
+
const onKeyDown = (event) => {
|
|
40
|
+
if (event.key !== "Enter" || event.nativeEvent.isComposing) return;
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
attempt();
|
|
43
|
+
};
|
|
44
|
+
const mismatch = attempted && !matched;
|
|
45
|
+
const hint = matched ? "Matches." : mismatch ? `Does not match. Type ${expected} exactly.` : caseSensitive ? "Type it exactly as shown." : "Type it as shown. Case does not matter.";
|
|
46
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
47
|
+
"data-slot": "confirm-typed",
|
|
48
|
+
"data-state": matched ? "matched" : mismatch ? "mismatched" : "idle",
|
|
49
|
+
className: cn("flex flex-col gap-2", className),
|
|
50
|
+
...props,
|
|
51
|
+
children: [
|
|
52
|
+
children,
|
|
53
|
+
/* @__PURE__ */ jsxs("label", {
|
|
54
|
+
htmlFor: `${id}-input`,
|
|
55
|
+
className: "text-sm",
|
|
56
|
+
children: [
|
|
57
|
+
"To confirm, type",
|
|
58
|
+
" ",
|
|
59
|
+
/* @__PURE__ */ jsx("strong", {
|
|
60
|
+
className: "rounded bg-muted px-1 py-0.5 font-mono text-xs font-medium select-all",
|
|
61
|
+
children: expected
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ jsx(Input, {
|
|
66
|
+
ref: inputRef,
|
|
67
|
+
id: `${id}-input`,
|
|
68
|
+
value,
|
|
69
|
+
autoComplete: "off",
|
|
70
|
+
autoCapitalize: "off",
|
|
71
|
+
spellCheck: false,
|
|
72
|
+
"aria-describedby": `${id}-hint`,
|
|
73
|
+
"aria-invalid": mismatch || void 0,
|
|
74
|
+
onChange: (event) => {
|
|
75
|
+
setValue(event.target.value);
|
|
76
|
+
},
|
|
77
|
+
onKeyDown
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsx("p", {
|
|
80
|
+
id: `${id}-hint`,
|
|
81
|
+
"data-slot": "confirm-typed-hint",
|
|
82
|
+
className: cn("text-xs", mismatch ? "text-destructive" : matched ? "text-success" : "text-muted-foreground"),
|
|
83
|
+
children: hint
|
|
84
|
+
}),
|
|
85
|
+
/* @__PURE__ */ jsx("span", {
|
|
86
|
+
role: "status",
|
|
87
|
+
"aria-live": "polite",
|
|
88
|
+
className: "sr-only",
|
|
89
|
+
children: announcement
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ jsx(Button, {
|
|
92
|
+
variant,
|
|
93
|
+
loading: pending,
|
|
94
|
+
"data-ready": matched || void 0,
|
|
95
|
+
"aria-describedby": matched ? void 0 : `${id}-hint`,
|
|
96
|
+
className: cn("self-start", !matched && !pending && "opacity-55"),
|
|
97
|
+
onClick: attempt,
|
|
98
|
+
children: pending ? `${action}…` : action
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { ConfirmTyped };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=confirm-typed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-typed.js","names":[],"sources":["../../../src/components/confirm-typed/confirm-typed.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n useId,\n useRef,\n useState,\n type ComponentPropsWithRef,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\n\nimport { Button } from \"@/components/button\";\nimport { Input } from \"@/components/input\";\nimport { cn } from \"@/lib/utils\";\n\n/**\n * Type the name to confirm.\n *\n * The GitHub pattern for deleting a repository, and the one every product\n * copies for the action that cannot be undone: the name of the thing has to\n * pass through the reader's fingers before the button works. Trivial to\n * build, absent from every component library, and usually built wrong in\n * the one place it matters — what happens when the text does not match.\n * The common version disables the button and says nothing, so a keyboard\n * or screen reader user presses it, or presses Enter, and nothing happens\n * at all.\n *\n * Here a mismatch is a thing that is said. The button stays reachable and\n * pressing it, or Enter, before the text matches announces what was\n * expected and marks the field invalid. The moment the text matches, that\n * is announced too, once, so a reader knows the action has become\n * available without watching the button change colour.\n *\n * Pasting is allowed. Blocking it is a popular piece of friction, and it\n * punishes exactly the people who cannot type a long name easily — switch\n * users, voice users, anyone with a tremor — while stopping nobody who can\n * select-all and copy. The name is on screen either way; the point is that\n * it passed through the reader's attention, not their keyboard.\n */\n\nexport interface ConfirmTypedProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** The text that must be typed, exactly. */\n expected: string;\n /** What confirming does, as the button reads: \"Delete project\". */\n action: string;\n onConfirm: () => void;\n /** While the action runs. The button stays focusable and says so. */\n pending?: boolean;\n /** Match regardless of case. Off by default: a name is a name. */\n caseSensitive?: boolean;\n variant?: \"destructive\" | \"primary\";\n /** The typed text. Controlled, if you want it. */\n value?: string;\n onValueChange?: (value: string) => void;\n /** The consequence, in a sentence or two, before the field. */\n children?: ReactNode;\n}\n\nexport function ConfirmTyped({\n className,\n expected,\n action,\n onConfirm,\n pending = false,\n caseSensitive = true,\n variant = \"destructive\",\n value: valueProp,\n onValueChange,\n children,\n ...props\n}: ConfirmTypedProps) {\n const id = useId();\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [uncontrolled, setUncontrolled] = useState(\"\");\n const value = valueProp ?? uncontrolled;\n\n const [attempted, setAttempted] = useState(false);\n const [announcement, setAnnouncement] = useState(\"\");\n\n // Surrounding whitespace never decides it: a trailing space is not a\n // different name, and a reader cannot see it to know why it failed.\n const normalise = (text: string) => (caseSensitive ? text.trim() : text.trim().toLowerCase());\n const matched = value.length > 0 && normalise(value) === normalise(expected);\n\n // Announce the match once, on the transition. Adjusted during render so the\n // announcement lands in the same commit as the state it describes.\n const [wasMatched, setWasMatched] = useState(matched);\n if (wasMatched !== matched) {\n setWasMatched(matched);\n if (matched) {\n setAnnouncement(`Matches. ${action} is available.`);\n setAttempted(false);\n }\n }\n\n const setValue = (next: string) => {\n setUncontrolled(next);\n onValueChange?.(next);\n };\n\n const attempt = () => {\n if (pending) return;\n if (matched) {\n onConfirm();\n return;\n }\n // Said, not swallowed. A press that does nothing tells a keyboard user\n // nothing; this one tells them what was expected.\n setAttempted(true);\n setAnnouncement(`Does not match. Type ${expected} exactly.`);\n inputRef.current?.focus();\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key !== \"Enter\" || event.nativeEvent.isComposing) return;\n event.preventDefault();\n attempt();\n };\n\n const mismatch = attempted && !matched;\n const hint = matched\n ? \"Matches.\"\n : mismatch\n ? `Does not match. Type ${expected} exactly.`\n : caseSensitive\n ? \"Type it exactly as shown.\"\n : \"Type it as shown. Case does not matter.\";\n\n return (\n <div\n data-slot=\"confirm-typed\"\n data-state={matched ? \"matched\" : mismatch ? \"mismatched\" : \"idle\"}\n className={cn(\"flex flex-col gap-2\", className)}\n {...props}\n >\n {children}\n\n <label htmlFor={`${id}-input`} className=\"text-sm\">\n To confirm, type{\" \"}\n <strong className=\"rounded bg-muted px-1 py-0.5 font-mono text-xs font-medium select-all\">\n {expected}\n </strong>\n </label>\n\n <Input\n ref={inputRef}\n id={`${id}-input`}\n value={value}\n autoComplete=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n aria-describedby={`${id}-hint`}\n aria-invalid={mismatch || undefined}\n onChange={(event) => {\n setValue(event.target.value);\n }}\n onKeyDown={onKeyDown}\n />\n\n <p\n id={`${id}-hint`}\n data-slot=\"confirm-typed-hint\"\n className={cn(\n \"text-xs\",\n mismatch ? \"text-destructive\" : matched ? \"text-success\" : \"text-muted-foreground\",\n )}\n >\n {hint}\n </p>\n\n {/* Present from the first render, so the first announcement is heard. */}\n <span role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {announcement}\n </span>\n\n <Button\n variant={variant}\n loading={pending}\n data-ready={matched || undefined}\n aria-describedby={matched ? undefined : `${id}-hint`}\n // Dimmed rather than disabled while the text does not match: it stays\n // reachable, and pressing it says why nothing happened.\n className={cn(\"self-start\", !matched && !pending && \"opacity-55\")}\n onClick={attempt}\n >\n {pending ? `${action}…` : action}\n </Button>\n </div>\n );\n}\n"],"mappings":";;;;;;;AA0DA,SAAgB,aAAa,EAC3B,WACA,UACA,QACA,WACA,UAAU,OACV,gBAAgB,MAChB,UAAU,eACV,OAAO,WACP,eACA,UACA,GAAG,SACiB;CACpB,MAAM,KAAK,MAAM;CACjB,MAAM,WAAW,OAAyB,IAAI;CAE9C,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CACnD,MAAM,QAAQ,aAAa;CAE3B,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,CAAC,cAAc,mBAAmB,SAAS,EAAE;CAInD,MAAM,aAAa,SAAkB,gBAAgB,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC,CAAC,YAAY;CAC3F,MAAM,UAAU,MAAM,SAAS,KAAK,UAAU,KAAK,MAAM,UAAU,QAAQ;CAI3E,MAAM,CAAC,YAAY,iBAAiB,SAAS,OAAO;CACpD,IAAI,eAAe,SAAS;EAC1B,cAAc,OAAO;EACrB,IAAI,SAAS;GACX,gBAAgB,YAAY,OAAO,eAAe;GAClD,aAAa,KAAK;EACpB;CACF;CAEA,MAAM,YAAY,SAAiB;EACjC,gBAAgB,IAAI;EACpB,gBAAgB,IAAI;CACtB;CAEA,MAAM,gBAAgB;EACpB,IAAI,SAAS;EACb,IAAI,SAAS;GACX,UAAU;GACV;EACF;EAGA,aAAa,IAAI;EACjB,gBAAgB,wBAAwB,SAAS,UAAU;EAC3D,SAAS,SAAS,MAAM;CAC1B;CAEA,MAAM,aAAa,UAA2C;EAC5D,IAAI,MAAM,QAAQ,WAAW,MAAM,YAAY,aAAa;EAC5D,MAAM,eAAe;EACrB,QAAQ;CACV;CAEA,MAAM,WAAW,aAAa,CAAC;CAC/B,MAAM,OAAO,UACT,aACA,WACE,wBAAwB,SAAS,aACjC,gBACE,8BACA;CAER,OACE,qBAAC,OAAD;EACE,aAAU;EACV,cAAY,UAAU,YAAY,WAAW,eAAe;EAC5D,WAAW,GAAG,uBAAuB,SAAS;EAC9C,GAAI;EAJN,UAAA;GAMG;GAED,qBAAC,SAAD;IAAO,SAAS,GAAG,GAAG;IAAS,WAAU;IAAzC,UAAA;KAAmD;KAChC;KACjB,oBAAC,UAAD;MAAQ,WAAU;MACf,UAAA;KACK,CAAA;IACH;;GAEP,oBAAC,OAAD;IACE,KAAK;IACL,IAAI,GAAG,GAAG;IACH;IACP,cAAa;IACb,gBAAe;IACf,YAAY;IACZ,oBAAkB,GAAG,GAAG;IACxB,gBAAc,YAAY,KAAA;IAC1B,WAAW,UAAU;KACnB,SAAS,MAAM,OAAO,KAAK;IAC7B;IACW;GACZ,CAAA;GAED,oBAAC,KAAD;IACE,IAAI,GAAG,GAAG;IACV,aAAU;IACV,WAAW,GACT,WACA,WAAW,qBAAqB,UAAU,iBAAiB,uBAC7D;IAEC,UAAA;GACA,CAAA;GAGH,oBAAC,QAAD;IAAM,MAAK;IAAS,aAAU;IAAS,WAAU;IAC9C,UAAA;GACG,CAAA;GAEN,oBAAC,QAAD;IACW;IACT,SAAS;IACT,cAAY,WAAW,KAAA;IACvB,oBAAkB,UAAU,KAAA,IAAY,GAAG,GAAG;IAG9C,WAAW,GAAG,cAAc,CAAC,WAAW,CAAC,WAAW,YAAY;IAChE,SAAS;IAER,UAAA,UAAU,GAAG,OAAO,KAAK;GACpB,CAAA;EACL;;AAET"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineMeta } from "../../registry/schema.js";
|
|
2
|
+
//#region src/components/confirm-typed/meta.ts
|
|
3
|
+
const meta = defineMeta({
|
|
4
|
+
name: "confirm-typed",
|
|
5
|
+
title: "Confirm Typed",
|
|
6
|
+
description: "Type the name to confirm — and be told, not ignored, when it does not match.",
|
|
7
|
+
category: "form",
|
|
8
|
+
status: "stable",
|
|
9
|
+
dependencies: [],
|
|
10
|
+
registryDependencies: ["button", "input"],
|
|
11
|
+
files: ["confirm-typed.tsx"],
|
|
12
|
+
a11y: "The button stays reachable while the text does not match, dimmed rather than disabled, and pressing it or Enter announces what was expected, marks the field invalid and returns focus to it — the common version disables the button and says nothing, so a keyboard user cannot tell whether anything happened. The match is announced once, on the transition, naming the action that became available, so nobody has to watch the button change colour. Typing itself stays silent, because a verdict on every keystroke is noise. The hint is the field's description and the button's, and the status region exists from the first render so the first announcement is heard. Pasting is allowed: blocking it punishes people who cannot type a long name easily and stops nobody who can select-all and copy."
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { meta };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","names":[],"sources":["../../../src/components/confirm-typed/meta.ts"],"sourcesContent":["import { defineMeta } from \"@/registry/schema\";\n\nexport const meta = defineMeta({\n name: \"confirm-typed\",\n title: \"Confirm Typed\",\n description: \"Type the name to confirm — and be told, not ignored, when it does not match.\",\n category: \"form\",\n status: \"stable\",\n dependencies: [],\n registryDependencies: [\"button\", \"input\"],\n files: [\"confirm-typed.tsx\"],\n a11y:\n \"The button stays reachable while the text does not match, dimmed rather than disabled, and \" +\n \"pressing it or Enter announces what was expected, marks the field invalid and returns focus \" +\n \"to it — the common version disables the button and says nothing, so a keyboard user cannot \" +\n \"tell whether anything happened. The match is announced once, on the transition, naming the \" +\n \"action that became available, so nobody has to watch the button change colour. Typing \" +\n \"itself stays silent, because a verdict on every keystroke is noise. The hint is the field's \" +\n \"description and the button's, and the status region exists from the first render so the \" +\n \"first announcement is heard. Pasting is allowed: blocking it punishes people who cannot \" +\n \"type a long name easily and stops nobody who can select-all and copy.\",\n});\n"],"mappings":";;AAEA,MAAa,OAAO,WAAW;CAC7B,MAAM;CACN,OAAO;CACP,aAAa;CACb,UAAU;CACV,QAAQ;CACR,cAAc,CAAC;CACf,sBAAsB,CAAC,UAAU,OAAO;CACxC,OAAO,CAAC,mBAAmB;CAC3B,MACE;AASJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
//#region src/components/cron-editor/cron-editor.d.ts
|
|
3
|
+
interface CronProps extends Omit<ComponentPropsWithRef<"div">, "defaultValue" | "onChange" | "children"> {
|
|
4
|
+
/** The expression. Controlled. */
|
|
5
|
+
value?: string;
|
|
6
|
+
defaultValue?: string;
|
|
7
|
+
onValueChange?: (expression: string) => void;
|
|
8
|
+
/** IANA zone the expression's times are in. Defaults to the runtime zone. */
|
|
9
|
+
timeZone?: string;
|
|
10
|
+
locale?: string;
|
|
11
|
+
/** The instant next runs are counted from. Pass one that changes when you refresh. */
|
|
12
|
+
now?: Date;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
declare function Cron({ className, value: valueProp, defaultValue, onValueChange, timeZone, locale, now, children, ...props }: CronProps): import("react").JSX.Element;
|
|
16
|
+
type CronBuilderProps = Omit<ComponentPropsWithRef<"div">, "children">;
|
|
17
|
+
declare function CronBuilder({ className, ...props }: CronBuilderProps): import("react").JSX.Element;
|
|
18
|
+
type CronExpressionProps = Omit<ComponentPropsWithRef<"div">, "children">;
|
|
19
|
+
/**
|
|
20
|
+
* The expression, editable, with its reading underneath — or the reason it is
|
|
21
|
+
* invalid. An invalid entry is never applied: the last valid schedule stands
|
|
22
|
+
* until the field says something that parses.
|
|
23
|
+
*/
|
|
24
|
+
declare function CronExpression({ className, ...props }: CronExpressionProps): import("react").JSX.Element;
|
|
25
|
+
interface CronNextRunsProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
26
|
+
count?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* When it will fire, in the zone it is defined in. The zone is in the
|
|
30
|
+
* heading because a time with no zone is the classic scheduling mistake, and
|
|
31
|
+
* a schedule that never runs says so rather than showing an empty list.
|
|
32
|
+
*/
|
|
33
|
+
declare function CronNextRuns({ className, count, ...props }: CronNextRunsProps): import("react").JSX.Element | null;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { Cron, CronBuilder, CronBuilderProps, CronExpression, CronExpressionProps, CronNextRuns, CronNextRunsProps, CronProps };
|
|
36
|
+
//# sourceMappingURL=cron-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cron-editor.d.ts","names":[],"sources":["../../../src/components/cron-editor/cron-editor.tsx"],"mappings":";;UA0EiB,kBAAkB,KACjC;;EAIA;EACA;EACA,iBAAiB;;EAEjB;EACA;;EAEA,MAAM;EACN,UAAU;;iBAGI,OACd,WACA,OAAO,WACP,cACA,eACA,UACA,QACA,KACA,aACG,SACF,4BAAS,IAAA;KAwKA,mBAAmB,KAAK;iBAEpB,cAAc,cAAc,SAAS,mCAAgB,IAAA;KA0QzD,sBAAsB,KAAK;;;;;;iBAOvB,iBAAiB,cAAc,SAAS,sCAAmB,IAAA;UAqE1D,0BAA0B,KAAK;EAC9C;;;;;;;iBAQc,eAAe,WAAW,UAAc,SAAS,oCAAiB,IAAA"}
|