@justai/cuts 0.143.0 → 0.144.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/package.json +1 -1
- package/src/ConfirmSheet.astro +20 -1
package/package.json
CHANGED
package/src/ConfirmSheet.astro
CHANGED
|
@@ -16,6 +16,13 @@ import "./ground.css";
|
|
|
16
16
|
// something can end, the safe choice wears the most confident face. iOS system red for
|
|
17
17
|
// destruction. This is /me's "Erase everything?".
|
|
18
18
|
//
|
|
19
|
+
// A THIRD CHOICE, when the safe answer is not "do nothing" (`safeActionLabel`) — Apple's own
|
|
20
|
+
// multi-action sheet. Some destructive questions have a way OUT of the loss rather than only a
|
|
21
|
+
// way around it: "your work isn't saved yet" is answered best by saving it, not by cancelling and
|
|
22
|
+
// then hunting for the Save button. That action joins the grouped card ABOVE the destructive one,
|
|
23
|
+
// because a sheet reads top to bottom and the preserving path is the one to meet first. Cancel
|
|
24
|
+
// stays detached and boldest — the anatomy does not change, it gains one row.
|
|
25
|
+
//
|
|
19
26
|
// ASK (`ask` prop) — the alert/ATT genre, for INVITATIONS: both choices live INSIDE the grouped
|
|
20
27
|
// card, stacked; the action wears the preferred bold face (Apple's preferredAction) and takes
|
|
21
28
|
// the focus; the safe choice sits beneath it in calm regular weight — equal size, equal tap,
|
|
@@ -61,10 +68,19 @@ interface Props {
|
|
|
61
68
|
* remembered as a choice, so the chosen no is stored while a slip-away stores nothing and the
|
|
62
69
|
* ask returns next visit. */
|
|
63
70
|
cancelValue?: string;
|
|
71
|
+
/** Optional THIRD choice: an action that PRESERVES rather than ends, placed above the main action
|
|
72
|
+
* inside the grouped card and painted as the preferred path. Omit it and the sheet is exactly
|
|
73
|
+
* what it always was — same DOM, same ids, same returnValues. */
|
|
74
|
+
safeActionLabel?: string;
|
|
75
|
+
/** What returnValue that third choice reports. Default "safe": three answers need three words. */
|
|
76
|
+
safeActionValue?: string;
|
|
64
77
|
/** Anything else (data-* attributes, aria overrides) lands on the <dialog> itself. */
|
|
65
78
|
[key: string]: unknown;
|
|
66
79
|
}
|
|
67
|
-
const {
|
|
80
|
+
const {
|
|
81
|
+
id, title, body, actionLabel, cancelLabel, destructive = false, ask = false, cancelValue = "",
|
|
82
|
+
safeActionLabel, safeActionValue = "safe", ...rest
|
|
83
|
+
} = Astro.props;
|
|
68
84
|
---
|
|
69
85
|
|
|
70
86
|
<dialog class="confirm" id={id} aria-labelledby={title ? `${id}-t` : `${id}-b`} aria-describedby={`${id}-b`} {...rest}>
|
|
@@ -79,6 +95,9 @@ const { id, title, body, actionLabel, cancelLabel, destructive = false, ask = fa
|
|
|
79
95
|
on a closed dialog, noise about a focus that was never going to happen. Focus is the
|
|
80
96
|
OPENER's job now, at showModal time: ask → the invitation (CONSENT_JS does it),
|
|
81
97
|
destructive → the cancel (the consumer does it). The genre decides, as before. */}
|
|
98
|
+
{safeActionLabel && (
|
|
99
|
+
<button class="confirm-act preferred" id={`${id}-safe`} value={safeActionValue}>{safeActionLabel}</button>
|
|
100
|
+
)}
|
|
82
101
|
<button class:list={["confirm-act", { destructive, preferred: ask }]} id={`${id}-act`} value="confirm">{actionLabel}</button>
|
|
83
102
|
{ask && <button class="confirm-act quiet" id={`${id}-cancel`} value={cancelValue} formnovalidate>{cancelLabel}</button>}
|
|
84
103
|
</div>
|