@flopay/ui 1.11.0 → 1.12.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
@@ -283,9 +283,9 @@ the shared classes in `components.css` (so they work in plain-CSS and Tailwind
283
283
  apps), add no runtime dependency, and need no provider or dashboard code: data
284
284
  wiring stays in the app.
285
285
 
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
286
+ `Switch`, `SlotTextField`, `VariablePicker` and `BlockList` use React state,
287
+ refs and effects, so in a Next.js App Router app render them from a Client
288
+ Component (a file that starts with `"use client"`). Importing other primitives such as
289
289
  `Button` from `@flopay/ui` in a Server Component is unaffected.
290
290
 
291
291
  #### Switch
@@ -392,6 +392,42 @@ import { PreviewFrame } from "@flopay/ui";
392
392
 
393
393
  The frame fills the container (at least 480px tall); size it with `className`.
394
394
 
395
+ #### BlockList
396
+
397
+ A reorderable list for the email block builder: a `ul` with one row per item,
398
+ rendered through `renderItem`. Each unlocked row has a drag handle (native
399
+ HTML5 drag and drop, no extra dependency) and native "Move up", "Move down" and
400
+ "Delete" buttons, so Tab, Enter and Space work. The handle is not focusable and
401
+ is hidden from screen readers; keyboard users reorder with the buttons. Focus
402
+ stays with the row: after a move, the moved row's button keeps it (its other
403
+ Move button if that one is now disabled), and after a delete the next unlocked
404
+ row's Delete takes it, so a block can be moved or deleted several times in a row.
405
+
406
+ ```tsx
407
+ import { BlockList } from "@flopay/ui";
408
+
409
+ const [blocks, setBlocks] = useState([
410
+ { id: "header", label: "Header", locked: true }, // never moves, no controls
411
+ { id: "intro", label: "Intro" },
412
+ { id: "button", label: "Button" },
413
+ { id: "footer", label: "Footer", locked: true },
414
+ ]);
415
+
416
+ <BlockList
417
+ items={blocks}
418
+ renderItem={(block) => <span>{block.label}</span>}
419
+ onChange={setBlocks} // new order, or the list without a deleted item
420
+ />;
421
+ ```
422
+
423
+ The list is controlled: each click, key press or drop calls `onChange` once
424
+ with a new array of your own item objects, and the rows move when you pass the
425
+ new `items`. Ids must be unique. Locked items never move, and nothing moves past
426
+ one: the first item can't move up, the last can't move down, and an item next
427
+ to a locked header or footer can't move past it. Those buttons are `disabled`,
428
+ and such drops are ignored. Dropping a row on another moves it to that row's
429
+ place. It renders to static markup on the server with no browser APIs.
430
+
395
431
  ## Design tokens
396
432
 
397
433
  `design-tokens.json` is the source of truth for the fourteen colors and base