@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 +39 -3
- package/dist/index.cjs +277 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.mjs +262 -75
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/components.css +103 -0
package/dist/index.mjs
CHANGED
|
@@ -24,8 +24,194 @@ function Badge({
|
|
|
24
24
|
] });
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
// src/components/block-list.tsx
|
|
28
|
+
import { useLayoutEffect, useRef } from "react";
|
|
29
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
30
|
+
function canMove(items, from, to) {
|
|
31
|
+
if (from === to || to < 0 || to >= items.length) return false;
|
|
32
|
+
const low = Math.min(from, to);
|
|
33
|
+
const high = Math.max(from, to);
|
|
34
|
+
for (let index = low; index <= high; index += 1) {
|
|
35
|
+
if (items[index]?.locked) return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
function moved(items, from, to) {
|
|
40
|
+
const next = items.slice();
|
|
41
|
+
const [item] = next.splice(from, 1);
|
|
42
|
+
next.splice(to, 0, item);
|
|
43
|
+
return next;
|
|
44
|
+
}
|
|
45
|
+
function focusWasLost() {
|
|
46
|
+
const active = document.activeElement;
|
|
47
|
+
return !active || active === document.body || active instanceof HTMLButtonElement && active.disabled;
|
|
48
|
+
}
|
|
49
|
+
function enabledButton(rows, at, label) {
|
|
50
|
+
return rows[at]?.querySelector(`button[aria-label="${label}"]:enabled`) ?? null;
|
|
51
|
+
}
|
|
52
|
+
function rowAfterDelete(items, deletedAt) {
|
|
53
|
+
for (let at = deletedAt; at < items.length; at += 1) {
|
|
54
|
+
if (!items[at]?.locked) return at;
|
|
55
|
+
}
|
|
56
|
+
for (let at = Math.min(deletedAt, items.length) - 1; at >= 0; at -= 1) {
|
|
57
|
+
if (!items[at]?.locked) return at;
|
|
58
|
+
}
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
function focusTarget(rows, items, pending) {
|
|
62
|
+
if ("deletedAt" in pending) {
|
|
63
|
+
const at2 = rowAfterDelete(items, pending.deletedAt);
|
|
64
|
+
return at2 < 0 ? null : enabledButton(rows, at2, "Delete");
|
|
65
|
+
}
|
|
66
|
+
const at = items.findIndex((item) => item.id === pending.movedId);
|
|
67
|
+
if (at < 0) return null;
|
|
68
|
+
const other = pending.label === "Move up" ? "Move down" : "Move up";
|
|
69
|
+
return enabledButton(rows, at, pending.label) ?? enabledButton(rows, at, other) ?? enabledButton(rows, at, "Delete");
|
|
70
|
+
}
|
|
71
|
+
var icons = {
|
|
72
|
+
grip: /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
73
|
+
/* @__PURE__ */ jsx2("circle", { cx: "6", cy: "4", r: "1.25" }),
|
|
74
|
+
/* @__PURE__ */ jsx2("circle", { cx: "10", cy: "4", r: "1.25" }),
|
|
75
|
+
/* @__PURE__ */ jsx2("circle", { cx: "6", cy: "8", r: "1.25" }),
|
|
76
|
+
/* @__PURE__ */ jsx2("circle", { cx: "10", cy: "8", r: "1.25" }),
|
|
77
|
+
/* @__PURE__ */ jsx2("circle", { cx: "6", cy: "12", r: "1.25" }),
|
|
78
|
+
/* @__PURE__ */ jsx2("circle", { cx: "10", cy: "12", r: "1.25" })
|
|
79
|
+
] }),
|
|
80
|
+
up: /* @__PURE__ */ jsx2("path", { d: "M8 12.5v-9M4 7.5l4-4 4 4", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
81
|
+
down: /* @__PURE__ */ jsx2("path", { d: "M8 3.5v9M4 8.5l4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
82
|
+
delete: /* @__PURE__ */ jsx2("path", { d: "M4.5 4.5l7 7M11.5 4.5l-7 7", fill: "none", stroke: "currentColor", strokeWidth: "1.5" })
|
|
83
|
+
};
|
|
84
|
+
function Icon({ name }) {
|
|
85
|
+
return /* @__PURE__ */ jsx2(
|
|
86
|
+
"svg",
|
|
87
|
+
{
|
|
88
|
+
className: "block-list-icon",
|
|
89
|
+
viewBox: "0 0 16 16",
|
|
90
|
+
fill: "currentColor",
|
|
91
|
+
strokeLinecap: "round",
|
|
92
|
+
strokeLinejoin: "round",
|
|
93
|
+
"aria-hidden": "true",
|
|
94
|
+
children: icons[name]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function BlockList({
|
|
99
|
+
items,
|
|
100
|
+
renderItem,
|
|
101
|
+
onChange,
|
|
102
|
+
className
|
|
103
|
+
}) {
|
|
104
|
+
const draggedId = useRef(null);
|
|
105
|
+
const list = useRef(null);
|
|
106
|
+
const pendingFocus = useRef(null);
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
const pending = pendingFocus.current;
|
|
109
|
+
pendingFocus.current = null;
|
|
110
|
+
const rows = list.current?.children;
|
|
111
|
+
if (pending && rows && focusWasLost()) focusTarget(rows, items, pending)?.focus();
|
|
112
|
+
}, [items]);
|
|
113
|
+
const moveByButton = (id, index, label) => {
|
|
114
|
+
pendingFocus.current = { movedId: id, label };
|
|
115
|
+
onChange(moved(items, index, label === "Move up" ? index - 1 : index + 1));
|
|
116
|
+
};
|
|
117
|
+
const deleteByButton = (index) => {
|
|
118
|
+
pendingFocus.current = { deletedAt: index };
|
|
119
|
+
onChange(items.filter((_, other) => other !== index));
|
|
120
|
+
};
|
|
121
|
+
const dropSource = (index) => {
|
|
122
|
+
const from = items.findIndex((item) => item.id === draggedId.current);
|
|
123
|
+
return from >= 0 && canMove(items, from, index) ? from : -1;
|
|
124
|
+
};
|
|
125
|
+
const startDrag = (event, id) => {
|
|
126
|
+
draggedId.current = id;
|
|
127
|
+
pendingFocus.current = null;
|
|
128
|
+
const transfer = event.dataTransfer;
|
|
129
|
+
if (!transfer) return;
|
|
130
|
+
transfer.effectAllowed = "move";
|
|
131
|
+
transfer.setData("text/plain", id);
|
|
132
|
+
const row = event.currentTarget.closest("li");
|
|
133
|
+
if (row) transfer.setDragImage(row, 0, 0);
|
|
134
|
+
};
|
|
135
|
+
const endDrag = () => {
|
|
136
|
+
draggedId.current = null;
|
|
137
|
+
};
|
|
138
|
+
const dragOver = (event, index) => {
|
|
139
|
+
if (dropSource(index) < 0) return;
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
const transfer = event.dataTransfer;
|
|
142
|
+
if (transfer) transfer.dropEffect = "move";
|
|
143
|
+
};
|
|
144
|
+
const drop = (event, index) => {
|
|
145
|
+
const from = dropSource(index);
|
|
146
|
+
draggedId.current = null;
|
|
147
|
+
if (from < 0) return;
|
|
148
|
+
event.preventDefault();
|
|
149
|
+
onChange(moved(items, from, index));
|
|
150
|
+
};
|
|
151
|
+
return /* @__PURE__ */ jsx2("ul", { ref: list, className: cn("block-list", className), children: items.map((item, index) => (
|
|
152
|
+
// 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
|
|
153
|
+
/* @__PURE__ */ jsxs2(
|
|
154
|
+
"li",
|
|
155
|
+
{
|
|
156
|
+
className: cn("block-list-row", item.locked && "block-list-row-locked"),
|
|
157
|
+
onDragOver: (event) => dragOver(event, index),
|
|
158
|
+
onDrop: (event) => drop(event, index),
|
|
159
|
+
children: [
|
|
160
|
+
item.locked ? null : /* @__PURE__ */ jsx2(
|
|
161
|
+
"span",
|
|
162
|
+
{
|
|
163
|
+
className: "block-list-handle",
|
|
164
|
+
draggable: true,
|
|
165
|
+
"aria-hidden": "true",
|
|
166
|
+
onDragStart: (event) => startDrag(event, item.id),
|
|
167
|
+
onDragEnd: endDrag,
|
|
168
|
+
children: /* @__PURE__ */ jsx2(Icon, { name: "grip" })
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
/* @__PURE__ */ jsx2("div", { className: "block-list-content", children: renderItem(item) }),
|
|
172
|
+
item.locked ? null : /* @__PURE__ */ jsxs2("div", { className: "block-list-controls", children: [
|
|
173
|
+
/* @__PURE__ */ jsx2(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
type: "button",
|
|
177
|
+
className: "block-list-button",
|
|
178
|
+
"aria-label": "Move up",
|
|
179
|
+
disabled: !canMove(items, index, index - 1),
|
|
180
|
+
onClick: () => moveByButton(item.id, index, "Move up"),
|
|
181
|
+
children: /* @__PURE__ */ jsx2(Icon, { name: "up" })
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx2(
|
|
185
|
+
"button",
|
|
186
|
+
{
|
|
187
|
+
type: "button",
|
|
188
|
+
className: "block-list-button",
|
|
189
|
+
"aria-label": "Move down",
|
|
190
|
+
disabled: !canMove(items, index, index + 1),
|
|
191
|
+
onClick: () => moveByButton(item.id, index, "Move down"),
|
|
192
|
+
children: /* @__PURE__ */ jsx2(Icon, { name: "down" })
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ jsx2(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
type: "button",
|
|
199
|
+
className: "block-list-button block-list-button-delete",
|
|
200
|
+
"aria-label": "Delete",
|
|
201
|
+
onClick: () => deleteByButton(index),
|
|
202
|
+
children: /* @__PURE__ */ jsx2(Icon, { name: "delete" })
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] })
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
item.id
|
|
209
|
+
)
|
|
210
|
+
)) });
|
|
211
|
+
}
|
|
212
|
+
|
|
27
213
|
// src/components/button.tsx
|
|
28
|
-
import { jsx as
|
|
214
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
29
215
|
var variantClass2 = {
|
|
30
216
|
primary: "btn-primary",
|
|
31
217
|
secondary: "btn-secondary",
|
|
@@ -38,7 +224,7 @@ function Button({
|
|
|
38
224
|
type = "button",
|
|
39
225
|
...props
|
|
40
226
|
}) {
|
|
41
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ jsx3(
|
|
42
228
|
"button",
|
|
43
229
|
{
|
|
44
230
|
type,
|
|
@@ -49,9 +235,9 @@ function Button({
|
|
|
49
235
|
}
|
|
50
236
|
|
|
51
237
|
// src/components/card.tsx
|
|
52
|
-
import { jsx as
|
|
238
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
53
239
|
function Card({ padding = "md", interactive = false, className, ...props }) {
|
|
54
|
-
return /* @__PURE__ */
|
|
240
|
+
return /* @__PURE__ */ jsx4(
|
|
55
241
|
"div",
|
|
56
242
|
{
|
|
57
243
|
className: cn(
|
|
@@ -69,9 +255,9 @@ function Card({ padding = "md", interactive = false, className, ...props }) {
|
|
|
69
255
|
import { useId } from "react";
|
|
70
256
|
|
|
71
257
|
// src/components/check-icon.tsx
|
|
72
|
-
import { jsx as
|
|
258
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
73
259
|
function CheckIcon({ className }) {
|
|
74
|
-
return /* @__PURE__ */
|
|
260
|
+
return /* @__PURE__ */ jsx5("svg", { className, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(
|
|
75
261
|
"path",
|
|
76
262
|
{
|
|
77
263
|
d: "M3.5 8.5l3 3 6-7",
|
|
@@ -84,9 +270,9 @@ function CheckIcon({ className }) {
|
|
|
84
270
|
}
|
|
85
271
|
|
|
86
272
|
// src/components/checklist.tsx
|
|
87
|
-
import { Fragment, jsx as
|
|
273
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
88
274
|
function Checklist({ children, className }) {
|
|
89
|
-
return /* @__PURE__ */
|
|
275
|
+
return /* @__PURE__ */ jsx6("ul", { className: cn("checklist", className), children });
|
|
90
276
|
}
|
|
91
277
|
function ChecklistRow({
|
|
92
278
|
label,
|
|
@@ -99,25 +285,25 @@ function ChecklistRow({
|
|
|
99
285
|
className
|
|
100
286
|
}) {
|
|
101
287
|
const state = done ? statusLabels?.done ?? "Done" : statusLabels?.notDone ?? "Not done";
|
|
102
|
-
const content = /* @__PURE__ */
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
optional ? /* @__PURE__ */
|
|
107
|
-
status ? /* @__PURE__ */
|
|
288
|
+
const content = /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
289
|
+
/* @__PURE__ */ jsx6("span", { className: cn("checklist-tick", done && "checklist-tick-done"), "aria-hidden": "true", children: done ? /* @__PURE__ */ jsx6(CheckIcon, { className: "checklist-tick-icon" }) : null }),
|
|
290
|
+
/* @__PURE__ */ jsx6("span", { className: "checklist-row-label", children: label }),
|
|
291
|
+
/* @__PURE__ */ jsx6("span", { className: "visually-hidden", children: state }),
|
|
292
|
+
optional ? /* @__PURE__ */ jsx6(Badge, { children: "Optional" }) : null,
|
|
293
|
+
status ? /* @__PURE__ */ jsx6("span", { className: "checklist-row-status", children: status }) : null
|
|
108
294
|
] });
|
|
109
295
|
const Link = linkAs ?? "a";
|
|
110
|
-
return /* @__PURE__ */
|
|
296
|
+
return /* @__PURE__ */ jsx6("li", { className: cn("checklist-row", className), children: href ? /* @__PURE__ */ jsx6(Link, { href, className: "checklist-row-body checklist-row-link", children: content }) : /* @__PURE__ */ jsx6("div", { className: "checklist-row-body", children: content }) });
|
|
111
297
|
}
|
|
112
298
|
function ChecklistSkeleton({ rows = 3, className }) {
|
|
113
299
|
const labelId = useId();
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */
|
|
300
|
+
return /* @__PURE__ */ jsxs3("div", { className: cn("checklist-skeleton", className), role: "status", "aria-labelledby": labelId, children: [
|
|
301
|
+
/* @__PURE__ */ jsx6("span", { id: labelId, className: "visually-hidden", children: "Loading" }),
|
|
116
302
|
Array.from({ length: rows }, (_, index) => (
|
|
117
303
|
// biome-ignore lint/suspicious/noArrayIndexKey: identical stateless placeholders with no identity of their own, so the position is the only key
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ jsxs3("div", { className: "checklist-skeleton-row", "aria-hidden": "true", children: [
|
|
305
|
+
/* @__PURE__ */ jsx6("span", { className: "checklist-skeleton-tick" }),
|
|
306
|
+
/* @__PURE__ */ jsx6("span", { className: "checklist-skeleton-line" })
|
|
121
307
|
] }, index)
|
|
122
308
|
))
|
|
123
309
|
] });
|
|
@@ -127,24 +313,24 @@ function ChecklistSkeleton({ rows = 3, className }) {
|
|
|
127
313
|
import { useId as useId2 } from "react";
|
|
128
314
|
|
|
129
315
|
// src/components/field.tsx
|
|
130
|
-
import { jsx as
|
|
316
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
131
317
|
function Input({ className, ...props }) {
|
|
132
|
-
return /* @__PURE__ */
|
|
318
|
+
return /* @__PURE__ */ jsx7("input", { className: cn("field", className), ...props });
|
|
133
319
|
}
|
|
134
320
|
function Label({ className, ...props }) {
|
|
135
|
-
return /* @__PURE__ */
|
|
321
|
+
return /* @__PURE__ */ jsx7("label", { className: cn("field-label", className), ...props });
|
|
136
322
|
}
|
|
137
323
|
function Field({ label, hint, error, htmlFor, className, children }) {
|
|
138
324
|
const message = error || hint;
|
|
139
|
-
return /* @__PURE__ */
|
|
140
|
-
label ? /* @__PURE__ */
|
|
325
|
+
return /* @__PURE__ */ jsxs4("div", { className: cn("field-group", className), children: [
|
|
326
|
+
label ? /* @__PURE__ */ jsx7(Label, { htmlFor, children: label }) : null,
|
|
141
327
|
children,
|
|
142
|
-
message ? /* @__PURE__ */
|
|
328
|
+
message ? /* @__PURE__ */ jsx7("span", { className: error ? "field-error" : "field-hint", children: message }) : null
|
|
143
329
|
] });
|
|
144
330
|
}
|
|
145
331
|
|
|
146
332
|
// src/components/code-area.tsx
|
|
147
|
-
import { jsx as
|
|
333
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
148
334
|
function CodeArea({
|
|
149
335
|
label,
|
|
150
336
|
hint,
|
|
@@ -159,7 +345,7 @@ function CodeArea({
|
|
|
159
345
|
}) {
|
|
160
346
|
const generatedId = useId2();
|
|
161
347
|
const controlId = id ?? generatedId;
|
|
162
|
-
return /* @__PURE__ */
|
|
348
|
+
return /* @__PURE__ */ jsx8(Field, { label, hint, error, htmlFor: controlId, className, children: /* @__PURE__ */ jsx8(
|
|
163
349
|
"textarea",
|
|
164
350
|
{
|
|
165
351
|
ref,
|
|
@@ -181,41 +367,41 @@ function CodeArea({
|
|
|
181
367
|
}
|
|
182
368
|
|
|
183
369
|
// src/components/container.tsx
|
|
184
|
-
import { jsx as
|
|
370
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
185
371
|
function Container({ className, ...props }) {
|
|
186
|
-
return /* @__PURE__ */
|
|
372
|
+
return /* @__PURE__ */ jsx9("div", { className: cn("container", className), ...props });
|
|
187
373
|
}
|
|
188
374
|
|
|
189
375
|
// src/components/feedback.tsx
|
|
190
|
-
import { jsx as
|
|
376
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
191
377
|
function Spinner({ center = false, className, ...props }) {
|
|
192
|
-
const spinner = /* @__PURE__ */
|
|
193
|
-
return center ? /* @__PURE__ */
|
|
378
|
+
const spinner = /* @__PURE__ */ jsx10("span", { className: cn("spinner", className), role: "status", "aria-label": "Loading", ...props });
|
|
379
|
+
return center ? /* @__PURE__ */ jsx10("div", { className: "spinner-center", children: spinner }) : spinner;
|
|
194
380
|
}
|
|
195
381
|
function EmptyState({ title, description, icon, className }) {
|
|
196
|
-
return /* @__PURE__ */
|
|
197
|
-
icon ? /* @__PURE__ */
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
description ? /* @__PURE__ */
|
|
382
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("empty-state", className), children: [
|
|
383
|
+
icon ? /* @__PURE__ */ jsx10("div", { className: "empty-state-icon", children: icon }) : null,
|
|
384
|
+
/* @__PURE__ */ jsx10("h3", { className: "empty-state-title", children: title }),
|
|
385
|
+
description ? /* @__PURE__ */ jsx10("p", { className: "empty-state-desc", children: description }) : null
|
|
200
386
|
] });
|
|
201
387
|
}
|
|
202
388
|
|
|
203
389
|
// src/components/preview-frame.tsx
|
|
204
|
-
import { jsx as
|
|
390
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
205
391
|
function PreviewFrame({ html, title, className }) {
|
|
206
|
-
return /* @__PURE__ */
|
|
392
|
+
return /* @__PURE__ */ jsx11("div", { className: cn("preview-frame", className), children: /* @__PURE__ */ jsx11("iframe", { className: "preview-frame-iframe", title, srcDoc: html, sandbox: "" }) });
|
|
207
393
|
}
|
|
208
394
|
|
|
209
395
|
// src/components/section.tsx
|
|
210
|
-
import { jsx as
|
|
396
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
211
397
|
function Section({ className, ...props }) {
|
|
212
|
-
return /* @__PURE__ */
|
|
398
|
+
return /* @__PURE__ */ jsx12("section", { className: cn("section", className), ...props });
|
|
213
399
|
}
|
|
214
400
|
function SectionHeader({ label, title, description, className }) {
|
|
215
|
-
return /* @__PURE__ */
|
|
216
|
-
label ? /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
description ? /* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ jsxs6("div", { className: cn("section-center", className), children: [
|
|
402
|
+
label ? /* @__PURE__ */ jsx12("div", { className: "section-label", children: label }) : null,
|
|
403
|
+
/* @__PURE__ */ jsx12("h2", { className: "section-title", children: title }),
|
|
404
|
+
description ? /* @__PURE__ */ jsx12("p", { className: "section-desc", children: description }) : null
|
|
219
405
|
] });
|
|
220
406
|
}
|
|
221
407
|
|
|
@@ -223,7 +409,7 @@ function SectionHeader({ label, title, description, className }) {
|
|
|
223
409
|
import {
|
|
224
410
|
useCallback,
|
|
225
411
|
useId as useId3,
|
|
226
|
-
useRef
|
|
412
|
+
useRef as useRef2
|
|
227
413
|
} from "react";
|
|
228
414
|
|
|
229
415
|
// src/components/text-selection.ts
|
|
@@ -262,7 +448,7 @@ function assignRef(ref, node) {
|
|
|
262
448
|
}
|
|
263
449
|
|
|
264
450
|
// src/components/slot-text-field.tsx
|
|
265
|
-
import { jsx as
|
|
451
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
266
452
|
var LINK_PLACEHOLDER = "https://";
|
|
267
453
|
function wrapWith(marker) {
|
|
268
454
|
return (selected) => ({
|
|
@@ -297,7 +483,7 @@ function SlotTextField({
|
|
|
297
483
|
}) {
|
|
298
484
|
const generatedId = useId3();
|
|
299
485
|
const controlId = id ?? generatedId;
|
|
300
|
-
const control =
|
|
486
|
+
const control = useRef2(null);
|
|
301
487
|
const setControl = useCallback(
|
|
302
488
|
(node) => {
|
|
303
489
|
control.current = node;
|
|
@@ -315,7 +501,7 @@ function SlotTextField({
|
|
|
315
501
|
className: multiline ? "field field-multiline" : "field",
|
|
316
502
|
"aria-invalid": error ? true : void 0
|
|
317
503
|
};
|
|
318
|
-
return /* @__PURE__ */
|
|
504
|
+
return /* @__PURE__ */ jsxs7(
|
|
319
505
|
Field,
|
|
320
506
|
{
|
|
321
507
|
label,
|
|
@@ -324,7 +510,7 @@ function SlotTextField({
|
|
|
324
510
|
htmlFor: controlId,
|
|
325
511
|
className,
|
|
326
512
|
children: [
|
|
327
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ jsx13("div", { className: "slot-toolbar", children: FORMATS.map((format) => /* @__PURE__ */ jsx13(
|
|
328
514
|
"button",
|
|
329
515
|
{
|
|
330
516
|
type: "button",
|
|
@@ -336,14 +522,14 @@ function SlotTextField({
|
|
|
336
522
|
},
|
|
337
523
|
format.name
|
|
338
524
|
)) }),
|
|
339
|
-
multiline ? /* @__PURE__ */
|
|
525
|
+
multiline ? /* @__PURE__ */ jsx13("textarea", { ref: setControl, rows: 4, ...shared }) : /* @__PURE__ */ jsx13("input", { ref: setControl, type: "text", ...shared })
|
|
340
526
|
]
|
|
341
527
|
}
|
|
342
528
|
);
|
|
343
529
|
}
|
|
344
530
|
|
|
345
531
|
// src/components/step-indicator.tsx
|
|
346
|
-
import { jsx as
|
|
532
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
347
533
|
var defaultStatusLabels = {
|
|
348
534
|
done: "Done",
|
|
349
535
|
current: "Current",
|
|
@@ -355,21 +541,21 @@ var markerClass = {
|
|
|
355
541
|
upcoming: ""
|
|
356
542
|
};
|
|
357
543
|
function StepIndicator({ steps, statusLabels, className }) {
|
|
358
|
-
return /* @__PURE__ */
|
|
544
|
+
return /* @__PURE__ */ jsx14("ol", { className: cn("step-indicator", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs8(
|
|
359
545
|
"li",
|
|
360
546
|
{
|
|
361
547
|
className: "step-indicator-step",
|
|
362
548
|
"aria-current": step.status === "current" ? "step" : void 0,
|
|
363
549
|
children: [
|
|
364
|
-
/* @__PURE__ */
|
|
550
|
+
/* @__PURE__ */ jsx14(
|
|
365
551
|
"span",
|
|
366
552
|
{
|
|
367
553
|
className: cn("step-indicator-marker", markerClass[step.status]),
|
|
368
554
|
"aria-hidden": "true",
|
|
369
|
-
children: step.status === "done" ? /* @__PURE__ */
|
|
555
|
+
children: step.status === "done" ? /* @__PURE__ */ jsx14(CheckIcon, { className: "step-indicator-icon" }) : index + 1
|
|
370
556
|
}
|
|
371
557
|
),
|
|
372
|
-
/* @__PURE__ */
|
|
558
|
+
/* @__PURE__ */ jsx14(
|
|
373
559
|
"span",
|
|
374
560
|
{
|
|
375
561
|
className: cn(
|
|
@@ -379,7 +565,7 @@ function StepIndicator({ steps, statusLabels, className }) {
|
|
|
379
565
|
children: step.label
|
|
380
566
|
}
|
|
381
567
|
),
|
|
382
|
-
/* @__PURE__ */
|
|
568
|
+
/* @__PURE__ */ jsx14("span", { className: "visually-hidden", children: statusLabels?.[step.status] ?? defaultStatusLabels[step.status] })
|
|
383
569
|
]
|
|
384
570
|
},
|
|
385
571
|
index
|
|
@@ -388,7 +574,7 @@ function StepIndicator({ steps, statusLabels, className }) {
|
|
|
388
574
|
|
|
389
575
|
// src/components/switch.tsx
|
|
390
576
|
import { useId as useId4, useState } from "react";
|
|
391
|
-
import { jsx as
|
|
577
|
+
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
392
578
|
function ignorePress(event) {
|
|
393
579
|
event.preventDefault();
|
|
394
580
|
}
|
|
@@ -415,8 +601,8 @@ function Switch({
|
|
|
415
601
|
if (checked === void 0) setOwnChecked(next);
|
|
416
602
|
onCheckedChange?.(next);
|
|
417
603
|
};
|
|
418
|
-
return /* @__PURE__ */
|
|
419
|
-
/* @__PURE__ */
|
|
604
|
+
return /* @__PURE__ */ jsxs9("span", { className: cn("switch", className), children: [
|
|
605
|
+
/* @__PURE__ */ jsx15(
|
|
420
606
|
"button",
|
|
421
607
|
{
|
|
422
608
|
type: "button",
|
|
@@ -430,10 +616,10 @@ function Switch({
|
|
|
430
616
|
disabled,
|
|
431
617
|
onMouseDown: loading ? ignorePress : void 0,
|
|
432
618
|
onClick: toggle,
|
|
433
|
-
children: /* @__PURE__ */
|
|
619
|
+
children: /* @__PURE__ */ jsx15("span", { className: "switch-thumb", "aria-hidden": "true" })
|
|
434
620
|
}
|
|
435
621
|
),
|
|
436
|
-
/* @__PURE__ */
|
|
622
|
+
/* @__PURE__ */ jsx15(
|
|
437
623
|
"label",
|
|
438
624
|
{
|
|
439
625
|
id: labelId,
|
|
@@ -442,8 +628,8 @@ function Switch({
|
|
|
442
628
|
children: label
|
|
443
629
|
}
|
|
444
630
|
),
|
|
445
|
-
loading ? /* @__PURE__ */
|
|
446
|
-
name && isChecked && !disabled ? /* @__PURE__ */
|
|
631
|
+
loading ? /* @__PURE__ */ jsx15(Spinner, { className: "switch-spinner" }) : null,
|
|
632
|
+
name && isChecked && !disabled ? /* @__PURE__ */ jsx15("input", { type: "hidden", name, value: "on" }) : null
|
|
447
633
|
] });
|
|
448
634
|
}
|
|
449
635
|
|
|
@@ -451,10 +637,10 @@ function Switch({
|
|
|
451
637
|
import {
|
|
452
638
|
useEffect,
|
|
453
639
|
useId as useId5,
|
|
454
|
-
useRef as
|
|
640
|
+
useRef as useRef3,
|
|
455
641
|
useState as useState2
|
|
456
642
|
} from "react";
|
|
457
|
-
import { jsx as
|
|
643
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
458
644
|
function liquidToken(name) {
|
|
459
645
|
return `{{ ${name} }}`;
|
|
460
646
|
}
|
|
@@ -463,9 +649,9 @@ function keepFocus(event) {
|
|
|
463
649
|
}
|
|
464
650
|
function VariablePicker({ variables, targetRef, className }) {
|
|
465
651
|
const menuId = useId5();
|
|
466
|
-
const trigger =
|
|
467
|
-
const menu =
|
|
468
|
-
const items =
|
|
652
|
+
const trigger = useRef3(null);
|
|
653
|
+
const menu = useRef3(null);
|
|
654
|
+
const items = useRef3([]);
|
|
469
655
|
const [open, setOpen] = useState2(false);
|
|
470
656
|
const [active, setActive] = useState2(0);
|
|
471
657
|
const count = variables.length;
|
|
@@ -521,8 +707,8 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
521
707
|
const onItemBlur = (event) => {
|
|
522
708
|
if (!menu.current?.contains(event.relatedTarget)) setOpen(false);
|
|
523
709
|
};
|
|
524
|
-
return /* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */
|
|
710
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("variable-picker", className), children: [
|
|
711
|
+
/* @__PURE__ */ jsx16(
|
|
526
712
|
"button",
|
|
527
713
|
{
|
|
528
714
|
ref: trigger,
|
|
@@ -541,7 +727,7 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
541
727
|
children: "Insert variable"
|
|
542
728
|
}
|
|
543
729
|
),
|
|
544
|
-
open ? /* @__PURE__ */
|
|
730
|
+
open ? /* @__PURE__ */ jsx16(
|
|
545
731
|
"div",
|
|
546
732
|
{
|
|
547
733
|
ref: menu,
|
|
@@ -549,7 +735,7 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
549
735
|
role: "menu",
|
|
550
736
|
"aria-label": "Variables",
|
|
551
737
|
className: "variable-picker-menu",
|
|
552
|
-
children: variables.map((variable, index) => /* @__PURE__ */
|
|
738
|
+
children: variables.map((variable, index) => /* @__PURE__ */ jsxs10(
|
|
553
739
|
"button",
|
|
554
740
|
{
|
|
555
741
|
ref: (node) => {
|
|
@@ -564,8 +750,8 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
564
750
|
onKeyDown: (event) => onItemKeyDown(event, index),
|
|
565
751
|
onBlur: onItemBlur,
|
|
566
752
|
children: [
|
|
567
|
-
/* @__PURE__ */
|
|
568
|
-
/* @__PURE__ */
|
|
753
|
+
/* @__PURE__ */ jsx16("span", { className: "variable-picker-item-label", children: variable.label }),
|
|
754
|
+
/* @__PURE__ */ jsx16("code", { className: "variable-picker-item-token", children: liquidToken(variable.name) })
|
|
569
755
|
]
|
|
570
756
|
},
|
|
571
757
|
variable.name
|
|
@@ -576,6 +762,7 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
576
762
|
}
|
|
577
763
|
export {
|
|
578
764
|
Badge,
|
|
765
|
+
BlockList,
|
|
579
766
|
Button,
|
|
580
767
|
Card,
|
|
581
768
|
Checklist,
|