@flopay/ui 1.10.2 → 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 +81 -3
- package/dist/index.cjs +363 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -2
- package/dist/index.d.ts +107 -2
- package/dist/index.mjs +354 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/components.css +303 -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(
|
|
@@ -65,28 +251,86 @@ function Card({ padding = "md", interactive = false, className, ...props }) {
|
|
|
65
251
|
);
|
|
66
252
|
}
|
|
67
253
|
|
|
68
|
-
// src/components/
|
|
254
|
+
// src/components/checklist.tsx
|
|
69
255
|
import { useId } from "react";
|
|
70
256
|
|
|
257
|
+
// src/components/check-icon.tsx
|
|
258
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
259
|
+
function CheckIcon({ className }) {
|
|
260
|
+
return /* @__PURE__ */ jsx5("svg", { className, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(
|
|
261
|
+
"path",
|
|
262
|
+
{
|
|
263
|
+
d: "M3.5 8.5l3 3 6-7",
|
|
264
|
+
stroke: "currentColor",
|
|
265
|
+
strokeWidth: "2",
|
|
266
|
+
strokeLinecap: "round",
|
|
267
|
+
strokeLinejoin: "round"
|
|
268
|
+
}
|
|
269
|
+
) });
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// src/components/checklist.tsx
|
|
273
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
274
|
+
function Checklist({ children, className }) {
|
|
275
|
+
return /* @__PURE__ */ jsx6("ul", { className: cn("checklist", className), children });
|
|
276
|
+
}
|
|
277
|
+
function ChecklistRow({
|
|
278
|
+
label,
|
|
279
|
+
done = false,
|
|
280
|
+
status,
|
|
281
|
+
optional = false,
|
|
282
|
+
href,
|
|
283
|
+
linkAs,
|
|
284
|
+
statusLabels,
|
|
285
|
+
className
|
|
286
|
+
}) {
|
|
287
|
+
const state = done ? statusLabels?.done ?? "Done" : statusLabels?.notDone ?? "Not done";
|
|
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
|
|
294
|
+
] });
|
|
295
|
+
const Link = linkAs ?? "a";
|
|
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 }) });
|
|
297
|
+
}
|
|
298
|
+
function ChecklistSkeleton({ rows = 3, className }) {
|
|
299
|
+
const labelId = useId();
|
|
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" }),
|
|
302
|
+
Array.from({ length: rows }, (_, index) => (
|
|
303
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: identical stateless placeholders with no identity of their own, so the position is the only key
|
|
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" })
|
|
307
|
+
] }, index)
|
|
308
|
+
))
|
|
309
|
+
] });
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/components/code-area.tsx
|
|
313
|
+
import { useId as useId2 } from "react";
|
|
314
|
+
|
|
71
315
|
// src/components/field.tsx
|
|
72
|
-
import { jsx as
|
|
316
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
73
317
|
function Input({ className, ...props }) {
|
|
74
|
-
return /* @__PURE__ */
|
|
318
|
+
return /* @__PURE__ */ jsx7("input", { className: cn("field", className), ...props });
|
|
75
319
|
}
|
|
76
320
|
function Label({ className, ...props }) {
|
|
77
|
-
return /* @__PURE__ */
|
|
321
|
+
return /* @__PURE__ */ jsx7("label", { className: cn("field-label", className), ...props });
|
|
78
322
|
}
|
|
79
323
|
function Field({ label, hint, error, htmlFor, className, children }) {
|
|
80
324
|
const message = error || hint;
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
label ? /* @__PURE__ */
|
|
325
|
+
return /* @__PURE__ */ jsxs4("div", { className: cn("field-group", className), children: [
|
|
326
|
+
label ? /* @__PURE__ */ jsx7(Label, { htmlFor, children: label }) : null,
|
|
83
327
|
children,
|
|
84
|
-
message ? /* @__PURE__ */
|
|
328
|
+
message ? /* @__PURE__ */ jsx7("span", { className: error ? "field-error" : "field-hint", children: message }) : null
|
|
85
329
|
] });
|
|
86
330
|
}
|
|
87
331
|
|
|
88
332
|
// src/components/code-area.tsx
|
|
89
|
-
import { jsx as
|
|
333
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
90
334
|
function CodeArea({
|
|
91
335
|
label,
|
|
92
336
|
hint,
|
|
@@ -99,9 +343,9 @@ function CodeArea({
|
|
|
99
343
|
name,
|
|
100
344
|
className
|
|
101
345
|
}) {
|
|
102
|
-
const generatedId =
|
|
346
|
+
const generatedId = useId2();
|
|
103
347
|
const controlId = id ?? generatedId;
|
|
104
|
-
return /* @__PURE__ */
|
|
348
|
+
return /* @__PURE__ */ jsx8(Field, { label, hint, error, htmlFor: controlId, className, children: /* @__PURE__ */ jsx8(
|
|
105
349
|
"textarea",
|
|
106
350
|
{
|
|
107
351
|
ref,
|
|
@@ -123,49 +367,49 @@ function CodeArea({
|
|
|
123
367
|
}
|
|
124
368
|
|
|
125
369
|
// src/components/container.tsx
|
|
126
|
-
import { jsx as
|
|
370
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
127
371
|
function Container({ className, ...props }) {
|
|
128
|
-
return /* @__PURE__ */
|
|
372
|
+
return /* @__PURE__ */ jsx9("div", { className: cn("container", className), ...props });
|
|
129
373
|
}
|
|
130
374
|
|
|
131
375
|
// src/components/feedback.tsx
|
|
132
|
-
import { jsx as
|
|
376
|
+
import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
133
377
|
function Spinner({ center = false, className, ...props }) {
|
|
134
|
-
const spinner = /* @__PURE__ */
|
|
135
|
-
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;
|
|
136
380
|
}
|
|
137
381
|
function EmptyState({ title, description, icon, className }) {
|
|
138
|
-
return /* @__PURE__ */
|
|
139
|
-
icon ? /* @__PURE__ */
|
|
140
|
-
/* @__PURE__ */
|
|
141
|
-
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
|
|
142
386
|
] });
|
|
143
387
|
}
|
|
144
388
|
|
|
145
389
|
// src/components/preview-frame.tsx
|
|
146
|
-
import { jsx as
|
|
390
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
147
391
|
function PreviewFrame({ html, title, className }) {
|
|
148
|
-
return /* @__PURE__ */
|
|
392
|
+
return /* @__PURE__ */ jsx11("div", { className: cn("preview-frame", className), children: /* @__PURE__ */ jsx11("iframe", { className: "preview-frame-iframe", title, srcDoc: html, sandbox: "" }) });
|
|
149
393
|
}
|
|
150
394
|
|
|
151
395
|
// src/components/section.tsx
|
|
152
|
-
import { jsx as
|
|
396
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
153
397
|
function Section({ className, ...props }) {
|
|
154
|
-
return /* @__PURE__ */
|
|
398
|
+
return /* @__PURE__ */ jsx12("section", { className: cn("section", className), ...props });
|
|
155
399
|
}
|
|
156
400
|
function SectionHeader({ label, title, description, className }) {
|
|
157
|
-
return /* @__PURE__ */
|
|
158
|
-
label ? /* @__PURE__ */
|
|
159
|
-
/* @__PURE__ */
|
|
160
|
-
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
|
|
161
405
|
] });
|
|
162
406
|
}
|
|
163
407
|
|
|
164
408
|
// src/components/slot-text-field.tsx
|
|
165
409
|
import {
|
|
166
410
|
useCallback,
|
|
167
|
-
useId as
|
|
168
|
-
useRef
|
|
411
|
+
useId as useId3,
|
|
412
|
+
useRef as useRef2
|
|
169
413
|
} from "react";
|
|
170
414
|
|
|
171
415
|
// src/components/text-selection.ts
|
|
@@ -204,7 +448,7 @@ function assignRef(ref, node) {
|
|
|
204
448
|
}
|
|
205
449
|
|
|
206
450
|
// src/components/slot-text-field.tsx
|
|
207
|
-
import { jsx as
|
|
451
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
208
452
|
var LINK_PLACEHOLDER = "https://";
|
|
209
453
|
function wrapWith(marker) {
|
|
210
454
|
return (selected) => ({
|
|
@@ -237,9 +481,9 @@ function SlotTextField({
|
|
|
237
481
|
name,
|
|
238
482
|
className
|
|
239
483
|
}) {
|
|
240
|
-
const generatedId =
|
|
484
|
+
const generatedId = useId3();
|
|
241
485
|
const controlId = id ?? generatedId;
|
|
242
|
-
const control =
|
|
486
|
+
const control = useRef2(null);
|
|
243
487
|
const setControl = useCallback(
|
|
244
488
|
(node) => {
|
|
245
489
|
control.current = node;
|
|
@@ -257,7 +501,7 @@ function SlotTextField({
|
|
|
257
501
|
className: multiline ? "field field-multiline" : "field",
|
|
258
502
|
"aria-invalid": error ? true : void 0
|
|
259
503
|
};
|
|
260
|
-
return /* @__PURE__ */
|
|
504
|
+
return /* @__PURE__ */ jsxs7(
|
|
261
505
|
Field,
|
|
262
506
|
{
|
|
263
507
|
label,
|
|
@@ -266,7 +510,7 @@ function SlotTextField({
|
|
|
266
510
|
htmlFor: controlId,
|
|
267
511
|
className,
|
|
268
512
|
children: [
|
|
269
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ jsx13("div", { className: "slot-toolbar", children: FORMATS.map((format) => /* @__PURE__ */ jsx13(
|
|
270
514
|
"button",
|
|
271
515
|
{
|
|
272
516
|
type: "button",
|
|
@@ -278,15 +522,59 @@ function SlotTextField({
|
|
|
278
522
|
},
|
|
279
523
|
format.name
|
|
280
524
|
)) }),
|
|
281
|
-
multiline ? /* @__PURE__ */
|
|
525
|
+
multiline ? /* @__PURE__ */ jsx13("textarea", { ref: setControl, rows: 4, ...shared }) : /* @__PURE__ */ jsx13("input", { ref: setControl, type: "text", ...shared })
|
|
282
526
|
]
|
|
283
527
|
}
|
|
284
528
|
);
|
|
285
529
|
}
|
|
286
530
|
|
|
531
|
+
// src/components/step-indicator.tsx
|
|
532
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
533
|
+
var defaultStatusLabels = {
|
|
534
|
+
done: "Done",
|
|
535
|
+
current: "Current",
|
|
536
|
+
upcoming: "Upcoming"
|
|
537
|
+
};
|
|
538
|
+
var markerClass = {
|
|
539
|
+
done: "step-indicator-marker-done",
|
|
540
|
+
current: "step-indicator-marker-current",
|
|
541
|
+
upcoming: ""
|
|
542
|
+
};
|
|
543
|
+
function StepIndicator({ steps, statusLabels, className }) {
|
|
544
|
+
return /* @__PURE__ */ jsx14("ol", { className: cn("step-indicator", className), children: steps.map((step, index) => /* @__PURE__ */ jsxs8(
|
|
545
|
+
"li",
|
|
546
|
+
{
|
|
547
|
+
className: "step-indicator-step",
|
|
548
|
+
"aria-current": step.status === "current" ? "step" : void 0,
|
|
549
|
+
children: [
|
|
550
|
+
/* @__PURE__ */ jsx14(
|
|
551
|
+
"span",
|
|
552
|
+
{
|
|
553
|
+
className: cn("step-indicator-marker", markerClass[step.status]),
|
|
554
|
+
"aria-hidden": "true",
|
|
555
|
+
children: step.status === "done" ? /* @__PURE__ */ jsx14(CheckIcon, { className: "step-indicator-icon" }) : index + 1
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
/* @__PURE__ */ jsx14(
|
|
559
|
+
"span",
|
|
560
|
+
{
|
|
561
|
+
className: cn(
|
|
562
|
+
"step-indicator-label",
|
|
563
|
+
step.status === "current" && "step-indicator-label-current"
|
|
564
|
+
),
|
|
565
|
+
children: step.label
|
|
566
|
+
}
|
|
567
|
+
),
|
|
568
|
+
/* @__PURE__ */ jsx14("span", { className: "visually-hidden", children: statusLabels?.[step.status] ?? defaultStatusLabels[step.status] })
|
|
569
|
+
]
|
|
570
|
+
},
|
|
571
|
+
index
|
|
572
|
+
)) });
|
|
573
|
+
}
|
|
574
|
+
|
|
287
575
|
// src/components/switch.tsx
|
|
288
|
-
import { useId as
|
|
289
|
-
import { jsx as
|
|
576
|
+
import { useId as useId4, useState } from "react";
|
|
577
|
+
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
290
578
|
function ignorePress(event) {
|
|
291
579
|
event.preventDefault();
|
|
292
580
|
}
|
|
@@ -302,7 +590,7 @@ function Switch({
|
|
|
302
590
|
name,
|
|
303
591
|
className
|
|
304
592
|
}) {
|
|
305
|
-
const generatedId =
|
|
593
|
+
const generatedId = useId4();
|
|
306
594
|
const controlId = id ?? generatedId;
|
|
307
595
|
const labelId = `${controlId}-label`;
|
|
308
596
|
const [ownChecked, setOwnChecked] = useState(defaultChecked);
|
|
@@ -313,8 +601,8 @@ function Switch({
|
|
|
313
601
|
if (checked === void 0) setOwnChecked(next);
|
|
314
602
|
onCheckedChange?.(next);
|
|
315
603
|
};
|
|
316
|
-
return /* @__PURE__ */
|
|
317
|
-
/* @__PURE__ */
|
|
604
|
+
return /* @__PURE__ */ jsxs9("span", { className: cn("switch", className), children: [
|
|
605
|
+
/* @__PURE__ */ jsx15(
|
|
318
606
|
"button",
|
|
319
607
|
{
|
|
320
608
|
type: "button",
|
|
@@ -328,10 +616,10 @@ function Switch({
|
|
|
328
616
|
disabled,
|
|
329
617
|
onMouseDown: loading ? ignorePress : void 0,
|
|
330
618
|
onClick: toggle,
|
|
331
|
-
children: /* @__PURE__ */
|
|
619
|
+
children: /* @__PURE__ */ jsx15("span", { className: "switch-thumb", "aria-hidden": "true" })
|
|
332
620
|
}
|
|
333
621
|
),
|
|
334
|
-
/* @__PURE__ */
|
|
622
|
+
/* @__PURE__ */ jsx15(
|
|
335
623
|
"label",
|
|
336
624
|
{
|
|
337
625
|
id: labelId,
|
|
@@ -340,19 +628,19 @@ function Switch({
|
|
|
340
628
|
children: label
|
|
341
629
|
}
|
|
342
630
|
),
|
|
343
|
-
loading ? /* @__PURE__ */
|
|
344
|
-
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
|
|
345
633
|
] });
|
|
346
634
|
}
|
|
347
635
|
|
|
348
636
|
// src/components/variable-picker.tsx
|
|
349
637
|
import {
|
|
350
638
|
useEffect,
|
|
351
|
-
useId as
|
|
352
|
-
useRef as
|
|
639
|
+
useId as useId5,
|
|
640
|
+
useRef as useRef3,
|
|
353
641
|
useState as useState2
|
|
354
642
|
} from "react";
|
|
355
|
-
import { jsx as
|
|
643
|
+
import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
356
644
|
function liquidToken(name) {
|
|
357
645
|
return `{{ ${name} }}`;
|
|
358
646
|
}
|
|
@@ -360,10 +648,10 @@ function keepFocus(event) {
|
|
|
360
648
|
event.preventDefault();
|
|
361
649
|
}
|
|
362
650
|
function VariablePicker({ variables, targetRef, className }) {
|
|
363
|
-
const menuId =
|
|
364
|
-
const trigger =
|
|
365
|
-
const menu =
|
|
366
|
-
const items =
|
|
651
|
+
const menuId = useId5();
|
|
652
|
+
const trigger = useRef3(null);
|
|
653
|
+
const menu = useRef3(null);
|
|
654
|
+
const items = useRef3([]);
|
|
367
655
|
const [open, setOpen] = useState2(false);
|
|
368
656
|
const [active, setActive] = useState2(0);
|
|
369
657
|
const count = variables.length;
|
|
@@ -419,8 +707,8 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
419
707
|
const onItemBlur = (event) => {
|
|
420
708
|
if (!menu.current?.contains(event.relatedTarget)) setOpen(false);
|
|
421
709
|
};
|
|
422
|
-
return /* @__PURE__ */
|
|
423
|
-
/* @__PURE__ */
|
|
710
|
+
return /* @__PURE__ */ jsxs10("div", { className: cn("variable-picker", className), children: [
|
|
711
|
+
/* @__PURE__ */ jsx16(
|
|
424
712
|
"button",
|
|
425
713
|
{
|
|
426
714
|
ref: trigger,
|
|
@@ -439,7 +727,7 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
439
727
|
children: "Insert variable"
|
|
440
728
|
}
|
|
441
729
|
),
|
|
442
|
-
open ? /* @__PURE__ */
|
|
730
|
+
open ? /* @__PURE__ */ jsx16(
|
|
443
731
|
"div",
|
|
444
732
|
{
|
|
445
733
|
ref: menu,
|
|
@@ -447,7 +735,7 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
447
735
|
role: "menu",
|
|
448
736
|
"aria-label": "Variables",
|
|
449
737
|
className: "variable-picker-menu",
|
|
450
|
-
children: variables.map((variable, index) => /* @__PURE__ */
|
|
738
|
+
children: variables.map((variable, index) => /* @__PURE__ */ jsxs10(
|
|
451
739
|
"button",
|
|
452
740
|
{
|
|
453
741
|
ref: (node) => {
|
|
@@ -462,8 +750,8 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
462
750
|
onKeyDown: (event) => onItemKeyDown(event, index),
|
|
463
751
|
onBlur: onItemBlur,
|
|
464
752
|
children: [
|
|
465
|
-
/* @__PURE__ */
|
|
466
|
-
/* @__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) })
|
|
467
755
|
]
|
|
468
756
|
},
|
|
469
757
|
variable.name
|
|
@@ -474,8 +762,12 @@ function VariablePicker({ variables, targetRef, className }) {
|
|
|
474
762
|
}
|
|
475
763
|
export {
|
|
476
764
|
Badge,
|
|
765
|
+
BlockList,
|
|
477
766
|
Button,
|
|
478
767
|
Card,
|
|
768
|
+
Checklist,
|
|
769
|
+
ChecklistRow,
|
|
770
|
+
ChecklistSkeleton,
|
|
479
771
|
CodeArea,
|
|
480
772
|
Container,
|
|
481
773
|
EmptyState,
|
|
@@ -487,6 +779,7 @@ export {
|
|
|
487
779
|
SectionHeader,
|
|
488
780
|
SlotTextField,
|
|
489
781
|
Spinner,
|
|
782
|
+
StepIndicator,
|
|
490
783
|
Switch,
|
|
491
784
|
VariablePicker,
|
|
492
785
|
cn
|