@flopay/ui 1.11.0 → 1.13.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 CHANGED
@@ -117,6 +117,57 @@ visually hidden text, so it is never conveyed by colour alone: "Done" / "Not
117
117
  done" for a row, "Done" / "Current" / "Upcoming" for a step. Pass
118
118
  `statusLabels` to either to change that wording.
119
119
 
120
+ #### ConfirmDialog
121
+
122
+ A confirm/cancel alert dialog for a consent or destructive step. The caller owns
123
+ `open` and supplies all the wording; the dialog only reports which way the user
124
+ chose.
125
+
126
+ ```tsx
127
+ "use client";
128
+
129
+ import { useState } from "react";
130
+ import { Button, ConfirmDialog } from "@flopay/ui";
131
+
132
+ const [open, setOpen] = useState(false);
133
+ const [saving, setSaving] = useState(false);
134
+
135
+ <Button onClick={() => setOpen(true)}>Turn on reminders</Button>
136
+
137
+ <ConfirmDialog
138
+ open={open}
139
+ title="Send abandoned-cart emails?"
140
+ description={<p>Customers who leave a cart get a reminder. <a href="/terms">Terms</a></p>}
141
+ confirmLabel="Yes, send them"
142
+ cancelLabel="Not now"
143
+ confirming={saving}
144
+ onConfirm={async () => {
145
+ setSaving(true);
146
+ try {
147
+ await enableReminders();
148
+ setOpen(false);
149
+ } finally {
150
+ setSaving(false);
151
+ }
152
+ }}
153
+ onCancel={() => setOpen(false)}
154
+ />;
155
+ ```
156
+
157
+ Clear `confirming` when the request fails too (the `finally` above): while it is
158
+ set the dialog can't be confirmed, cancelled or dismissed, so a rejection that
159
+ leaves it `true` traps the user in the dialog.
160
+
161
+ While `open` it renders `role="alertdialog"` with `aria-modal="true"`, labelled
162
+ by `title` and described by `description` (text or a node); while closed it
163
+ renders nothing. Confirm calls `onConfirm`; Cancel, Escape and a click on the
164
+ backdrop call `onCancel`, and a click inside the panel does not, nor does a drag
165
+ that starts inside the panel and ends on the backdrop. Focus moves to
166
+ Cancel on open, Tab and Shift+Tab stay inside the dialog, and on close focus
167
+ goes back to the element that opened it. While `confirming`, both buttons are
168
+ disabled and Escape and the backdrop are ignored, so an in-flight request can't
169
+ be dismissed. It renders in place (no portal), so it server-renders as-is.
170
+
120
171
  ### 4. Marketing chrome (nav + footer)
121
172
 
122
173
  ```tsx
@@ -283,9 +334,9 @@ the shared classes in `components.css` (so they work in plain-CSS and Tailwind
283
334
  apps), add no runtime dependency, and need no provider or dashboard code: data
284
335
  wiring stays in the app.
285
336
 
286
- `Switch`, `SlotTextField` and `VariablePicker` use React state, refs and
287
- effects, so in a Next.js App Router app render them from a Client Component (a
288
- file that starts with `"use client"`). Importing other primitives such as
337
+ `Switch`, `SlotTextField`, `VariablePicker` and `BlockList` use React state,
338
+ refs and effects, so in a Next.js App Router app render them from a Client
339
+ Component (a file that starts with `"use client"`). Importing other primitives such as
289
340
  `Button` from `@flopay/ui` in a Server Component is unaffected.
290
341
 
291
342
  #### Switch
@@ -392,6 +443,42 @@ import { PreviewFrame } from "@flopay/ui";
392
443
 
393
444
  The frame fills the container (at least 480px tall); size it with `className`.
394
445
 
446
+ #### BlockList
447
+
448
+ A reorderable list for the email block builder: a `ul` with one row per item,
449
+ rendered through `renderItem`. Each unlocked row has a drag handle (native
450
+ HTML5 drag and drop, no extra dependency) and native "Move up", "Move down" and
451
+ "Delete" buttons, so Tab, Enter and Space work. The handle is not focusable and
452
+ is hidden from screen readers; keyboard users reorder with the buttons. Focus
453
+ stays with the row: after a move, the moved row's button keeps it (its other
454
+ Move button if that one is now disabled), and after a delete the next unlocked
455
+ row's Delete takes it, so a block can be moved or deleted several times in a row.
456
+
457
+ ```tsx
458
+ import { BlockList } from "@flopay/ui";
459
+
460
+ const [blocks, setBlocks] = useState([
461
+ { id: "header", label: "Header", locked: true }, // never moves, no controls
462
+ { id: "intro", label: "Intro" },
463
+ { id: "button", label: "Button" },
464
+ { id: "footer", label: "Footer", locked: true },
465
+ ]);
466
+
467
+ <BlockList
468
+ items={blocks}
469
+ renderItem={(block) => <span>{block.label}</span>}
470
+ onChange={setBlocks} // new order, or the list without a deleted item
471
+ />;
472
+ ```
473
+
474
+ The list is controlled: each click, key press or drop calls `onChange` once
475
+ with a new array of your own item objects, and the rows move when you pass the
476
+ new `items`. Ids must be unique. Locked items never move, and nothing moves past
477
+ one: the first item can't move up, the last can't move down, and an item next
478
+ to a locked header or footer can't move past it. Those buttons are `disabled`,
479
+ and such drops are ignored. Dropping a row on another moves it to that row's
480
+ place. It renders to static markup on the server with no browser APIs.
481
+
395
482
  ## Design tokens
396
483
 
397
484
  `design-tokens.json` is the source of truth for the fourteen colors and base