@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/dist/index.cjs CHANGED
@@ -21,12 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
23
  Badge: () => Badge,
24
+ BlockList: () => BlockList,
24
25
  Button: () => Button,
25
26
  Card: () => Card,
26
27
  Checklist: () => Checklist,
27
28
  ChecklistRow: () => ChecklistRow,
28
29
  ChecklistSkeleton: () => ChecklistSkeleton,
29
30
  CodeArea: () => CodeArea,
31
+ ConfirmDialog: () => ConfirmDialog,
30
32
  Container: () => Container,
31
33
  EmptyState: () => EmptyState,
32
34
  Field: () => Field,
@@ -73,8 +75,194 @@ function Badge({
73
75
  ] });
74
76
  }
75
77
 
76
- // src/components/button.tsx
78
+ // src/components/block-list.tsx
79
+ var import_react = require("react");
77
80
  var import_jsx_runtime2 = require("react/jsx-runtime");
81
+ function canMove(items, from, to) {
82
+ if (from === to || to < 0 || to >= items.length) return false;
83
+ const low = Math.min(from, to);
84
+ const high = Math.max(from, to);
85
+ for (let index = low; index <= high; index += 1) {
86
+ if (items[index]?.locked) return false;
87
+ }
88
+ return true;
89
+ }
90
+ function moved(items, from, to) {
91
+ const next = items.slice();
92
+ const [item] = next.splice(from, 1);
93
+ next.splice(to, 0, item);
94
+ return next;
95
+ }
96
+ function focusWasLost() {
97
+ const active = document.activeElement;
98
+ return !active || active === document.body || active instanceof HTMLButtonElement && active.disabled;
99
+ }
100
+ function enabledButton(rows, at, label) {
101
+ return rows[at]?.querySelector(`button[aria-label="${label}"]:enabled`) ?? null;
102
+ }
103
+ function rowAfterDelete(items, deletedAt) {
104
+ for (let at = deletedAt; at < items.length; at += 1) {
105
+ if (!items[at]?.locked) return at;
106
+ }
107
+ for (let at = Math.min(deletedAt, items.length) - 1; at >= 0; at -= 1) {
108
+ if (!items[at]?.locked) return at;
109
+ }
110
+ return -1;
111
+ }
112
+ function focusTarget(rows, items, pending) {
113
+ if ("deletedAt" in pending) {
114
+ const at2 = rowAfterDelete(items, pending.deletedAt);
115
+ return at2 < 0 ? null : enabledButton(rows, at2, "Delete");
116
+ }
117
+ const at = items.findIndex((item) => item.id === pending.movedId);
118
+ if (at < 0) return null;
119
+ const other = pending.label === "Move up" ? "Move down" : "Move up";
120
+ return enabledButton(rows, at, pending.label) ?? enabledButton(rows, at, other) ?? enabledButton(rows, at, "Delete");
121
+ }
122
+ var icons = {
123
+ grip: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
124
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "6", cy: "4", r: "1.25" }),
125
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "10", cy: "4", r: "1.25" }),
126
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "6", cy: "8", r: "1.25" }),
127
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "10", cy: "8", r: "1.25" }),
128
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "6", cy: "12", r: "1.25" }),
129
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "10", cy: "12", r: "1.25" })
130
+ ] }),
131
+ up: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 12.5v-9M4 7.5l4-4 4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
132
+ down: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M8 3.5v9M4 8.5l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
133
+ delete: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M4.5 4.5l7 7M11.5 4.5l-7 7", fill: "none", stroke: "currentColor", strokeWidth: "1.5" })
134
+ };
135
+ function Icon({ name }) {
136
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
137
+ "svg",
138
+ {
139
+ className: "block-list-icon",
140
+ viewBox: "0 0 16 16",
141
+ fill: "currentColor",
142
+ strokeLinecap: "round",
143
+ strokeLinejoin: "round",
144
+ "aria-hidden": "true",
145
+ children: icons[name]
146
+ }
147
+ );
148
+ }
149
+ function BlockList({
150
+ items,
151
+ renderItem,
152
+ onChange,
153
+ className
154
+ }) {
155
+ const draggedId = (0, import_react.useRef)(null);
156
+ const list = (0, import_react.useRef)(null);
157
+ const pendingFocus = (0, import_react.useRef)(null);
158
+ (0, import_react.useLayoutEffect)(() => {
159
+ const pending = pendingFocus.current;
160
+ pendingFocus.current = null;
161
+ const rows = list.current?.children;
162
+ if (pending && rows && focusWasLost()) focusTarget(rows, items, pending)?.focus();
163
+ }, [items]);
164
+ const moveByButton = (id, index, label) => {
165
+ pendingFocus.current = { movedId: id, label };
166
+ onChange(moved(items, index, label === "Move up" ? index - 1 : index + 1));
167
+ };
168
+ const deleteByButton = (index) => {
169
+ pendingFocus.current = { deletedAt: index };
170
+ onChange(items.filter((_, other) => other !== index));
171
+ };
172
+ const dropSource = (index) => {
173
+ const from = items.findIndex((item) => item.id === draggedId.current);
174
+ return from >= 0 && canMove(items, from, index) ? from : -1;
175
+ };
176
+ const startDrag = (event, id) => {
177
+ draggedId.current = id;
178
+ pendingFocus.current = null;
179
+ const transfer = event.dataTransfer;
180
+ if (!transfer) return;
181
+ transfer.effectAllowed = "move";
182
+ transfer.setData("text/plain", id);
183
+ const row = event.currentTarget.closest("li");
184
+ if (row) transfer.setDragImage(row, 0, 0);
185
+ };
186
+ const endDrag = () => {
187
+ draggedId.current = null;
188
+ };
189
+ const dragOver = (event, index) => {
190
+ if (dropSource(index) < 0) return;
191
+ event.preventDefault();
192
+ const transfer = event.dataTransfer;
193
+ if (transfer) transfer.dropEffect = "move";
194
+ };
195
+ const drop = (event, index) => {
196
+ const from = dropSource(index);
197
+ draggedId.current = null;
198
+ if (from < 0) return;
199
+ event.preventDefault();
200
+ onChange(moved(items, from, index));
201
+ };
202
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { ref: list, className: cn("block-list", className), children: items.map((item, index) => (
203
+ // biome-ignore lint/a11y/noNoninteractiveElementInteractions: the row is only a pointer drop target for the handle's native drag; keyboard and screen-reader users reorder with the row's Move buttons, so it needs no role or focus of its own
204
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
205
+ "li",
206
+ {
207
+ className: cn("block-list-row", item.locked && "block-list-row-locked"),
208
+ onDragOver: (event) => dragOver(event, index),
209
+ onDrop: (event) => drop(event, index),
210
+ children: [
211
+ item.locked ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
212
+ "span",
213
+ {
214
+ className: "block-list-handle",
215
+ draggable: true,
216
+ "aria-hidden": "true",
217
+ onDragStart: (event) => startDrag(event, item.id),
218
+ onDragEnd: endDrag,
219
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "grip" })
220
+ }
221
+ ),
222
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "block-list-content", children: renderItem(item) }),
223
+ item.locked ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "block-list-controls", children: [
224
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
225
+ "button",
226
+ {
227
+ type: "button",
228
+ className: "block-list-button",
229
+ "aria-label": "Move up",
230
+ disabled: !canMove(items, index, index - 1),
231
+ onClick: () => moveByButton(item.id, index, "Move up"),
232
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "up" })
233
+ }
234
+ ),
235
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ className: "block-list-button",
240
+ "aria-label": "Move down",
241
+ disabled: !canMove(items, index, index + 1),
242
+ onClick: () => moveByButton(item.id, index, "Move down"),
243
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "down" })
244
+ }
245
+ ),
246
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
247
+ "button",
248
+ {
249
+ type: "button",
250
+ className: "block-list-button block-list-button-delete",
251
+ "aria-label": "Delete",
252
+ onClick: () => deleteByButton(index),
253
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { name: "delete" })
254
+ }
255
+ )
256
+ ] })
257
+ ]
258
+ },
259
+ item.id
260
+ )
261
+ )) });
262
+ }
263
+
264
+ // src/components/button.tsx
265
+ var import_jsx_runtime3 = require("react/jsx-runtime");
78
266
  var variantClass2 = {
79
267
  primary: "btn-primary",
80
268
  secondary: "btn-secondary",
@@ -87,7 +275,7 @@ function Button({
87
275
  type = "button",
88
276
  ...props
89
277
  }) {
90
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
278
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
91
279
  "button",
92
280
  {
93
281
  type,
@@ -98,9 +286,9 @@ function Button({
98
286
  }
99
287
 
100
288
  // src/components/card.tsx
101
- var import_jsx_runtime3 = require("react/jsx-runtime");
289
+ var import_jsx_runtime4 = require("react/jsx-runtime");
102
290
  function Card({ padding = "md", interactive = false, className, ...props }) {
103
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
291
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
104
292
  "div",
105
293
  {
106
294
  className: cn(
@@ -115,12 +303,12 @@ function Card({ padding = "md", interactive = false, className, ...props }) {
115
303
  }
116
304
 
117
305
  // src/components/checklist.tsx
118
- var import_react = require("react");
306
+ var import_react2 = require("react");
119
307
 
120
308
  // src/components/check-icon.tsx
121
- var import_jsx_runtime4 = require("react/jsx-runtime");
309
+ var import_jsx_runtime5 = require("react/jsx-runtime");
122
310
  function CheckIcon({ className }) {
123
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { className, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
311
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
124
312
  "path",
125
313
  {
126
314
  d: "M3.5 8.5l3 3 6-7",
@@ -133,9 +321,9 @@ function CheckIcon({ className }) {
133
321
  }
134
322
 
135
323
  // src/components/checklist.tsx
136
- var import_jsx_runtime5 = require("react/jsx-runtime");
324
+ var import_jsx_runtime6 = require("react/jsx-runtime");
137
325
  function Checklist({ children, className }) {
138
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { className: cn("checklist", className), children });
326
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: cn("checklist", className), children });
139
327
  }
140
328
  function ChecklistRow({
141
329
  label,
@@ -148,52 +336,52 @@ function ChecklistRow({
148
336
  className
149
337
  }) {
150
338
  const state = done ? statusLabels?.done ?? "Done" : statusLabels?.notDone ?? "Not done";
151
- const content = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
152
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: cn("checklist-tick", done && "checklist-tick-done"), "aria-hidden": "true", children: done ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckIcon, { className: "checklist-tick-icon" }) : null }),
153
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "checklist-row-label", children: label }),
154
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "visually-hidden", children: state }),
155
- optional ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Badge, { children: "Optional" }) : null,
156
- status ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "checklist-row-status", children: status }) : null
339
+ const content = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
340
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: cn("checklist-tick", done && "checklist-tick-done"), "aria-hidden": "true", children: done ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, { className: "checklist-tick-icon" }) : null }),
341
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "checklist-row-label", children: label }),
342
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "visually-hidden", children: state }),
343
+ optional ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Badge, { children: "Optional" }) : null,
344
+ status ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "checklist-row-status", children: status }) : null
157
345
  ] });
158
346
  const Link = linkAs ?? "a";
159
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { className: cn("checklist-row", className), children: href ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Link, { href, className: "checklist-row-body checklist-row-link", children: content }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "checklist-row-body", children: content }) });
347
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { className: cn("checklist-row", className), children: href ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Link, { href, className: "checklist-row-body checklist-row-link", children: content }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "checklist-row-body", children: content }) });
160
348
  }
161
349
  function ChecklistSkeleton({ rows = 3, className }) {
162
- const labelId = (0, import_react.useId)();
163
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: cn("checklist-skeleton", className), role: "status", "aria-labelledby": labelId, children: [
164
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { id: labelId, className: "visually-hidden", children: "Loading" }),
350
+ const labelId = (0, import_react2.useId)();
351
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("checklist-skeleton", className), role: "status", "aria-labelledby": labelId, children: [
352
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { id: labelId, className: "visually-hidden", children: "Loading" }),
165
353
  Array.from({ length: rows }, (_, index) => (
166
354
  // biome-ignore lint/suspicious/noArrayIndexKey: identical stateless placeholders with no identity of their own, so the position is the only key
167
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "checklist-skeleton-row", "aria-hidden": "true", children: [
168
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "checklist-skeleton-tick" }),
169
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "checklist-skeleton-line" })
355
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "checklist-skeleton-row", "aria-hidden": "true", children: [
356
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "checklist-skeleton-tick" }),
357
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "checklist-skeleton-line" })
170
358
  ] }, index)
171
359
  ))
172
360
  ] });
173
361
  }
174
362
 
175
363
  // src/components/code-area.tsx
176
- var import_react2 = require("react");
364
+ var import_react3 = require("react");
177
365
 
178
366
  // src/components/field.tsx
179
- var import_jsx_runtime6 = require("react/jsx-runtime");
367
+ var import_jsx_runtime7 = require("react/jsx-runtime");
180
368
  function Input({ className, ...props }) {
181
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { className: cn("field", className), ...props });
369
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("input", { className: cn("field", className), ...props });
182
370
  }
183
371
  function Label({ className, ...props }) {
184
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { className: cn("field-label", className), ...props });
372
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { className: cn("field-label", className), ...props });
185
373
  }
186
374
  function Field({ label, hint, error, htmlFor, className, children }) {
187
375
  const message = error || hint;
188
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: cn("field-group", className), children: [
189
- label ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Label, { htmlFor, children: label }) : null,
376
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: cn("field-group", className), children: [
377
+ label ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Label, { htmlFor, children: label }) : null,
190
378
  children,
191
- message ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: error ? "field-error" : "field-hint", children: message }) : null
379
+ message ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: error ? "field-error" : "field-hint", children: message }) : null
192
380
  ] });
193
381
  }
194
382
 
195
383
  // src/components/code-area.tsx
196
- var import_jsx_runtime7 = require("react/jsx-runtime");
384
+ var import_jsx_runtime8 = require("react/jsx-runtime");
197
385
  function CodeArea({
198
386
  label,
199
387
  hint,
@@ -206,9 +394,9 @@ function CodeArea({
206
394
  name,
207
395
  className
208
396
  }) {
209
- const generatedId = (0, import_react2.useId)();
397
+ const generatedId = (0, import_react3.useId)();
210
398
  const controlId = id ?? generatedId;
211
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label, hint, error, htmlFor: controlId, className, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
399
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { label, hint, error, htmlFor: controlId, className, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
212
400
  "textarea",
213
401
  {
214
402
  ref,
@@ -229,47 +417,159 @@ function CodeArea({
229
417
  ) });
230
418
  }
231
419
 
420
+ // src/components/confirm-dialog.tsx
421
+ var import_react4 = require("react");
422
+ var import_jsx_runtime9 = require("react/jsx-runtime");
423
+ var FOCUSABLE = [
424
+ "a[href]",
425
+ "button:not([disabled])",
426
+ "input:not([disabled])",
427
+ "select:not([disabled])",
428
+ "textarea:not([disabled])",
429
+ '[tabindex]:not([tabindex="-1"])'
430
+ ].join(", ");
431
+ function nextFocusTarget(panel, backwards) {
432
+ const focusable = Array.from(panel.querySelectorAll(FOCUSABLE));
433
+ const last = focusable.length - 1;
434
+ if (last < 0) return panel;
435
+ const index = focusable.indexOf(document.activeElement);
436
+ if (backwards) return focusable[index <= 0 ? last : index - 1] ?? panel;
437
+ return focusable[index >= last ? 0 : index + 1] ?? panel;
438
+ }
439
+ function OpenConfirmDialog({
440
+ title,
441
+ description,
442
+ confirmLabel,
443
+ cancelLabel,
444
+ onConfirm,
445
+ onCancel,
446
+ confirming = false
447
+ }) {
448
+ const id = (0, import_react4.useId)();
449
+ const titleId = `${id}-title`;
450
+ const descriptionId = `${id}-description`;
451
+ const cancelId = `${id}-cancel`;
452
+ const panelRef = (0, import_react4.useRef)(null);
453
+ (0, import_react4.useEffect)(() => {
454
+ const opener = document.activeElement;
455
+ return () => {
456
+ if (opener instanceof HTMLElement && opener.isConnected) opener.focus();
457
+ };
458
+ }, []);
459
+ (0, import_react4.useEffect)(() => {
460
+ const panel = panelRef.current;
461
+ if (!panel) return;
462
+ const active = document.activeElement;
463
+ if (confirming) {
464
+ if (!panel.contains(active) || active instanceof HTMLButtonElement) panel.focus();
465
+ } else if (!panel.contains(active) || active === panel) {
466
+ document.getElementById(cancelId)?.focus();
467
+ }
468
+ }, [confirming, cancelId]);
469
+ (0, import_react4.useEffect)(() => {
470
+ function onKeyDown(event) {
471
+ const panel = panelRef.current;
472
+ if (!panel) return;
473
+ if (event.key === "Escape") {
474
+ if (!confirming) onCancel();
475
+ } else if (event.key === "Tab") {
476
+ event.preventDefault();
477
+ nextFocusTarget(panel, event.shiftKey).focus();
478
+ }
479
+ }
480
+ document.addEventListener("keydown", onKeyDown);
481
+ return () => document.removeEventListener("keydown", onKeyDown);
482
+ }, [confirming, onCancel]);
483
+ const pressStartedOnBackdrop = (0, import_react4.useRef)(false);
484
+ const onBackdropMouseDown = (event) => {
485
+ pressStartedOnBackdrop.current = event.target === event.currentTarget;
486
+ if (pressStartedOnBackdrop.current) event.preventDefault();
487
+ };
488
+ const onBackdropClick = (event) => {
489
+ const startedOnBackdrop = pressStartedOnBackdrop.current;
490
+ pressStartedOnBackdrop.current = false;
491
+ if (startedOnBackdrop && event.target === event.currentTarget && !confirming) onCancel();
492
+ };
493
+ return (
494
+ // biome-ignore lint/a11y/noNoninteractiveElementInteractions: the backdrop click is only a pointer shortcut for Cancel; keyboard and screen-reader users have the Cancel button and Escape, so the backdrop needs no role or focus of its own
495
+ // biome-ignore lint/a11y/noStaticElementInteractions: as above, the backdrop is a pointer-only shortcut for Cancel and must not be announced as a control
496
+ // biome-ignore lint/a11y/useKeyWithClickEvents: the keyboard equivalent of a backdrop click is Escape, handled by the document listener while open
497
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
498
+ "div",
499
+ {
500
+ className: "confirm-dialog-backdrop",
501
+ onMouseDown: onBackdropMouseDown,
502
+ onClick: onBackdropClick,
503
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
504
+ "div",
505
+ {
506
+ ref: panelRef,
507
+ role: "alertdialog",
508
+ "aria-modal": "true",
509
+ "aria-labelledby": titleId,
510
+ "aria-describedby": descriptionId,
511
+ tabIndex: -1,
512
+ className: "confirm-dialog",
513
+ children: [
514
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { id: titleId, className: "confirm-dialog-title", children: title }),
515
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { id: descriptionId, className: "confirm-dialog-description", children: description }),
516
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "confirm-dialog-actions", children: [
517
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { id: cancelId, variant: "outline", disabled: confirming, onClick: onCancel, children: cancelLabel }),
518
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Button, { variant: "primary", disabled: confirming, onClick: onConfirm, children: confirmLabel })
519
+ ] })
520
+ ]
521
+ }
522
+ )
523
+ }
524
+ )
525
+ );
526
+ }
527
+ function ConfirmDialog({ open, ...props }) {
528
+ if (!open) return null;
529
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(OpenConfirmDialog, { ...props });
530
+ }
531
+
232
532
  // src/components/container.tsx
233
- var import_jsx_runtime8 = require("react/jsx-runtime");
533
+ var import_jsx_runtime10 = require("react/jsx-runtime");
234
534
  function Container({ className, ...props }) {
235
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: cn("container", className), ...props });
535
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cn("container", className), ...props });
236
536
  }
237
537
 
238
538
  // src/components/feedback.tsx
239
- var import_jsx_runtime9 = require("react/jsx-runtime");
539
+ var import_jsx_runtime11 = require("react/jsx-runtime");
240
540
  function Spinner({ center = false, className, ...props }) {
241
- const spinner = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: cn("spinner", className), role: "status", "aria-label": "Loading", ...props });
242
- return center ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "spinner-center", children: spinner }) : spinner;
541
+ const spinner = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: cn("spinner", className), role: "status", "aria-label": "Loading", ...props });
542
+ return center ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "spinner-center", children: spinner }) : spinner;
243
543
  }
244
544
  function EmptyState({ title, description, icon, className }) {
245
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: cn("empty-state", className), children: [
246
- icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "empty-state-icon", children: icon }) : null,
247
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "empty-state-title", children: title }),
248
- description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "empty-state-desc", children: description }) : null
545
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("empty-state", className), children: [
546
+ icon ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "empty-state-icon", children: icon }) : null,
547
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: "empty-state-title", children: title }),
548
+ description ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "empty-state-desc", children: description }) : null
249
549
  ] });
250
550
  }
251
551
 
252
552
  // src/components/preview-frame.tsx
253
- var import_jsx_runtime10 = require("react/jsx-runtime");
553
+ var import_jsx_runtime12 = require("react/jsx-runtime");
254
554
  function PreviewFrame({ html, title, className }) {
255
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: cn("preview-frame", className), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("iframe", { className: "preview-frame-iframe", title, srcDoc: html, sandbox: "" }) });
555
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: cn("preview-frame", className), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("iframe", { className: "preview-frame-iframe", title, srcDoc: html, sandbox: "" }) });
256
556
  }
257
557
 
258
558
  // src/components/section.tsx
259
- var import_jsx_runtime11 = require("react/jsx-runtime");
559
+ var import_jsx_runtime13 = require("react/jsx-runtime");
260
560
  function Section({ className, ...props }) {
261
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("section", { className: cn("section", className), ...props });
561
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("section", { className: cn("section", className), ...props });
262
562
  }
263
563
  function SectionHeader({ label, title, description, className }) {
264
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: cn("section-center", className), children: [
265
- label ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "section-label", children: label }) : null,
266
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: "section-title", children: title }),
267
- description ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "section-desc", children: description }) : null
564
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: cn("section-center", className), children: [
565
+ label ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "section-label", children: label }) : null,
566
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { className: "section-title", children: title }),
567
+ description ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "section-desc", children: description }) : null
268
568
  ] });
269
569
  }
270
570
 
271
571
  // src/components/slot-text-field.tsx
272
- var import_react3 = require("react");
572
+ var import_react5 = require("react");
273
573
 
274
574
  // src/components/text-selection.ts
275
575
  var watched = /* @__PURE__ */ new WeakSet();
@@ -307,7 +607,7 @@ function assignRef(ref, node) {
307
607
  }
308
608
 
309
609
  // src/components/slot-text-field.tsx
310
- var import_jsx_runtime12 = require("react/jsx-runtime");
610
+ var import_jsx_runtime14 = require("react/jsx-runtime");
311
611
  var LINK_PLACEHOLDER = "https://";
312
612
  function wrapWith(marker) {
313
613
  return (selected) => ({
@@ -340,10 +640,10 @@ function SlotTextField({
340
640
  name,
341
641
  className
342
642
  }) {
343
- const generatedId = (0, import_react3.useId)();
643
+ const generatedId = (0, import_react5.useId)();
344
644
  const controlId = id ?? generatedId;
345
- const control = (0, import_react3.useRef)(null);
346
- const setControl = (0, import_react3.useCallback)(
645
+ const control = (0, import_react5.useRef)(null);
646
+ const setControl = (0, import_react5.useCallback)(
347
647
  (node) => {
348
648
  control.current = node;
349
649
  if (node) watchFocus(node);
@@ -360,7 +660,7 @@ function SlotTextField({
360
660
  className: multiline ? "field field-multiline" : "field",
361
661
  "aria-invalid": error ? true : void 0
362
662
  };
363
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
663
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
364
664
  Field,
365
665
  {
366
666
  label,
@@ -369,7 +669,7 @@ function SlotTextField({
369
669
  htmlFor: controlId,
370
670
  className,
371
671
  children: [
372
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "slot-toolbar", children: FORMATS.map((format) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
672
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "slot-toolbar", children: FORMATS.map((format) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
373
673
  "button",
374
674
  {
375
675
  type: "button",
@@ -381,14 +681,14 @@ function SlotTextField({
381
681
  },
382
682
  format.name
383
683
  )) }),
384
- multiline ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("textarea", { ref: setControl, rows: 4, ...shared }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: setControl, type: "text", ...shared })
684
+ multiline ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("textarea", { ref: setControl, rows: 4, ...shared }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { ref: setControl, type: "text", ...shared })
385
685
  ]
386
686
  }
387
687
  );
388
688
  }
389
689
 
390
690
  // src/components/step-indicator.tsx
391
- var import_jsx_runtime13 = require("react/jsx-runtime");
691
+ var import_jsx_runtime15 = require("react/jsx-runtime");
392
692
  var defaultStatusLabels = {
393
693
  done: "Done",
394
694
  current: "Current",
@@ -400,21 +700,21 @@ var markerClass = {
400
700
  upcoming: ""
401
701
  };
402
702
  function StepIndicator({ steps, statusLabels, className }) {
403
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ol", { className: cn("step-indicator", className), children: steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
703
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("ol", { className: cn("step-indicator", className), children: steps.map((step, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
404
704
  "li",
405
705
  {
406
706
  className: "step-indicator-step",
407
707
  "aria-current": step.status === "current" ? "step" : void 0,
408
708
  children: [
409
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
709
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
410
710
  "span",
411
711
  {
412
712
  className: cn("step-indicator-marker", markerClass[step.status]),
413
713
  "aria-hidden": "true",
414
- children: step.status === "done" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CheckIcon, { className: "step-indicator-icon" }) : index + 1
714
+ children: step.status === "done" ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(CheckIcon, { className: "step-indicator-icon" }) : index + 1
415
715
  }
416
716
  ),
417
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
717
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
418
718
  "span",
419
719
  {
420
720
  className: cn(
@@ -424,7 +724,7 @@ function StepIndicator({ steps, statusLabels, className }) {
424
724
  children: step.label
425
725
  }
426
726
  ),
427
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "visually-hidden", children: statusLabels?.[step.status] ?? defaultStatusLabels[step.status] })
727
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "visually-hidden", children: statusLabels?.[step.status] ?? defaultStatusLabels[step.status] })
428
728
  ]
429
729
  },
430
730
  index
@@ -432,8 +732,8 @@ function StepIndicator({ steps, statusLabels, className }) {
432
732
  }
433
733
 
434
734
  // src/components/switch.tsx
435
- var import_react4 = require("react");
436
- var import_jsx_runtime14 = require("react/jsx-runtime");
735
+ var import_react6 = require("react");
736
+ var import_jsx_runtime16 = require("react/jsx-runtime");
437
737
  function ignorePress(event) {
438
738
  event.preventDefault();
439
739
  }
@@ -449,10 +749,10 @@ function Switch({
449
749
  name,
450
750
  className
451
751
  }) {
452
- const generatedId = (0, import_react4.useId)();
752
+ const generatedId = (0, import_react6.useId)();
453
753
  const controlId = id ?? generatedId;
454
754
  const labelId = `${controlId}-label`;
455
- const [ownChecked, setOwnChecked] = (0, import_react4.useState)(defaultChecked);
755
+ const [ownChecked, setOwnChecked] = (0, import_react6.useState)(defaultChecked);
456
756
  const isChecked = checked ?? ownChecked;
457
757
  const toggle = () => {
458
758
  if (loading) return;
@@ -460,8 +760,8 @@ function Switch({
460
760
  if (checked === void 0) setOwnChecked(next);
461
761
  onCheckedChange?.(next);
462
762
  };
463
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: cn("switch", className), children: [
464
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
763
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: cn("switch", className), children: [
764
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
465
765
  "button",
466
766
  {
467
767
  type: "button",
@@ -475,10 +775,10 @@ function Switch({
475
775
  disabled,
476
776
  onMouseDown: loading ? ignorePress : void 0,
477
777
  onClick: toggle,
478
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "switch-thumb", "aria-hidden": "true" })
778
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "switch-thumb", "aria-hidden": "true" })
479
779
  }
480
780
  ),
481
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
781
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
482
782
  "label",
483
783
  {
484
784
  id: labelId,
@@ -487,14 +787,14 @@ function Switch({
487
787
  children: label
488
788
  }
489
789
  ),
490
- loading ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Spinner, { className: "switch-spinner" }) : null,
491
- name && isChecked && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("input", { type: "hidden", name, value: "on" }) : null
790
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Spinner, { className: "switch-spinner" }) : null,
791
+ name && isChecked && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("input", { type: "hidden", name, value: "on" }) : null
492
792
  ] });
493
793
  }
494
794
 
495
795
  // src/components/variable-picker.tsx
496
- var import_react5 = require("react");
497
- var import_jsx_runtime15 = require("react/jsx-runtime");
796
+ var import_react7 = require("react");
797
+ var import_jsx_runtime17 = require("react/jsx-runtime");
498
798
  function liquidToken(name) {
499
799
  return `{{ ${name} }}`;
500
800
  }
@@ -502,17 +802,17 @@ function keepFocus(event) {
502
802
  event.preventDefault();
503
803
  }
504
804
  function VariablePicker({ variables, targetRef, className }) {
505
- const menuId = (0, import_react5.useId)();
506
- const trigger = (0, import_react5.useRef)(null);
507
- const menu = (0, import_react5.useRef)(null);
508
- const items = (0, import_react5.useRef)([]);
509
- const [open, setOpen] = (0, import_react5.useState)(false);
510
- const [active, setActive] = (0, import_react5.useState)(0);
805
+ const menuId = (0, import_react7.useId)();
806
+ const trigger = (0, import_react7.useRef)(null);
807
+ const menu = (0, import_react7.useRef)(null);
808
+ const items = (0, import_react7.useRef)([]);
809
+ const [open, setOpen] = (0, import_react7.useState)(false);
810
+ const [active, setActive] = (0, import_react7.useState)(0);
511
811
  const count = variables.length;
512
- (0, import_react5.useEffect)(() => {
812
+ (0, import_react7.useEffect)(() => {
513
813
  if (targetRef.current) watchFocus(targetRef.current);
514
814
  });
515
- (0, import_react5.useEffect)(() => {
815
+ (0, import_react7.useEffect)(() => {
516
816
  if (open) items.current[active]?.focus();
517
817
  }, [open, active]);
518
818
  const openAt = (index) => {
@@ -561,8 +861,8 @@ function VariablePicker({ variables, targetRef, className }) {
561
861
  const onItemBlur = (event) => {
562
862
  if (!menu.current?.contains(event.relatedTarget)) setOpen(false);
563
863
  };
564
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: cn("variable-picker", className), children: [
565
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
864
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: cn("variable-picker", className), children: [
865
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
566
866
  "button",
567
867
  {
568
868
  ref: trigger,
@@ -581,7 +881,7 @@ function VariablePicker({ variables, targetRef, className }) {
581
881
  children: "Insert variable"
582
882
  }
583
883
  ),
584
- open ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
884
+ open ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
585
885
  "div",
586
886
  {
587
887
  ref: menu,
@@ -589,7 +889,7 @@ function VariablePicker({ variables, targetRef, className }) {
589
889
  role: "menu",
590
890
  "aria-label": "Variables",
591
891
  className: "variable-picker-menu",
592
- children: variables.map((variable, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
892
+ children: variables.map((variable, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
593
893
  "button",
594
894
  {
595
895
  ref: (node) => {
@@ -604,8 +904,8 @@ function VariablePicker({ variables, targetRef, className }) {
604
904
  onKeyDown: (event) => onItemKeyDown(event, index),
605
905
  onBlur: onItemBlur,
606
906
  children: [
607
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "variable-picker-item-label", children: variable.label }),
608
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("code", { className: "variable-picker-item-token", children: liquidToken(variable.name) })
907
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "variable-picker-item-label", children: variable.label }),
908
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("code", { className: "variable-picker-item-token", children: liquidToken(variable.name) })
609
909
  ]
610
910
  },
611
911
  variable.name
@@ -617,12 +917,14 @@ function VariablePicker({ variables, targetRef, className }) {
617
917
  // Annotate the CommonJS export names for ESM import in node:
618
918
  0 && (module.exports = {
619
919
  Badge,
920
+ BlockList,
620
921
  Button,
621
922
  Card,
622
923
  Checklist,
623
924
  ChecklistRow,
624
925
  ChecklistSkeleton,
625
926
  CodeArea,
927
+ ConfirmDialog,
626
928
  Container,
627
929
  EmptyState,
628
930
  Field,