@drawnagency/primitives 0.1.61 → 0.1.63
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/{chunk-UQ4OYRW7.js → chunk-2BHPWO7M.js} +54 -166
- package/dist/chunk-4E66N6UV.js +10 -0
- package/dist/chunk-5THS4K5D.js +123 -0
- package/dist/{chunk-TG43X7JO.js → chunk-75P6HWPN.js} +29 -5
- package/dist/{chunk-ODCJQOVO.js → chunk-7IMQVDDJ.js} +1 -1
- package/dist/{chunk-4OX3Z7SB.js → chunk-FECCYOPJ.js} +32 -671
- package/dist/{chunk-WLMJCNU7.js → chunk-I5737FJY.js} +0 -8
- package/dist/chunk-QYQ3DQHI.js +1201 -0
- package/dist/{chunk-BT7STGDW.js → chunk-TEYTLQVH.js} +0 -15
- package/dist/chunk-VMDKWUMT.js +652 -0
- package/dist/{chunk-AM5LZD6Q.js → chunk-ZYXLNJ5M.js} +6 -5
- package/dist/components/brandguide/ColorSwatchSettings.d.ts +1 -1
- package/dist/components/brandguide/ColorSwatchSettings.d.ts.map +1 -1
- package/dist/components/brandguide/Colors.d.ts +1 -1
- package/dist/components/brandguide/Colors.d.ts.map +1 -1
- package/dist/components/editor/index.js +4 -2
- package/dist/components/primitives/IconPicker.d.ts +1 -7
- package/dist/components/primitives/IconPicker.d.ts.map +1 -1
- package/dist/components/primitives/index.js +10 -7
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/Colors/schema.d.ts +19 -0
- package/dist/components/sections/Colors/schema.d.ts.map +1 -0
- package/dist/components/sections/DoDontMedia/DoDontMediaBlock.d.ts +20 -0
- package/dist/components/sections/DoDontMedia/DoDontMediaBlock.d.ts.map +1 -0
- package/dist/components/sections/DoDontMedia/index.d.ts +45 -0
- package/dist/components/sections/DoDontMedia/index.d.ts.map +1 -0
- package/dist/components/sections/IconList/DoDontToggle.d.ts +14 -0
- package/dist/components/sections/IconList/DoDontToggle.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
- package/dist/components/sections/IconList/index.d.ts.map +1 -1
- package/dist/components/sections/Media/MediaBlock.d.ts +1 -3
- package/dist/components/sections/Media/MediaBlock.d.ts.map +1 -1
- package/dist/components/sections/Media/index.d.ts +0 -1
- package/dist/components/sections/Media/index.d.ts.map +1 -1
- package/dist/components/sections/all-sections.d.ts +54 -18
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/brand-guide.d.ts +84 -0
- package/dist/components/sections/brand-guide.d.ts.map +1 -0
- package/dist/components/sections/brand-guide.js +21 -0
- package/dist/components/sections/core-sections.d.ts +93 -0
- package/dist/components/sections/core-sections.d.ts.map +1 -0
- package/dist/components/sections/register-schemas.js +108 -1155
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/components/shell/view-branch.d.ts +12 -0
- package/dist/components/shell/view-branch.d.ts.map +1 -0
- package/dist/index.js +29 -33
- package/dist/lib/index.js +4 -4
- package/dist/lib/loader.d.ts.map +1 -1
- package/dist/lib/migrate-sections-transform.d.ts.map +1 -1
- package/dist/lib/migrate-sections-transform.js +1 -1
- package/dist/lib/registry.d.ts +6 -1
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/media/index.js +1 -1
- package/dist/schemas/index.js +3 -7
- package/dist/schemas/shared.d.ts +0 -17
- package/dist/schemas/shared.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/components/brandguide/ColorSwatchSettings.tsx +1 -1
- package/src/components/brandguide/Colors.tsx +1 -1
- package/src/components/primitives/IconPicker.tsx +27 -119
- package/src/components/sections/Colors/index.tsx +2 -1
- package/src/components/sections/Colors/schema.ts +24 -0
- package/src/components/sections/DoDontMedia/DoDontMediaBlock.tsx +35 -0
- package/src/components/sections/DoDontMedia/index.tsx +84 -0
- package/src/components/sections/IconList/DoDontToggle.tsx +76 -0
- package/src/components/sections/IconList/IconList.tsx +24 -14
- package/src/components/sections/IconList/index.tsx +1 -0
- package/src/components/sections/Media/MediaBlock.tsx +10 -11
- package/src/components/sections/Media/index.tsx +0 -15
- package/src/components/sections/all-sections.ts +7 -35
- package/src/components/sections/brand-guide.ts +13 -0
- package/src/components/sections/core-sections.ts +26 -0
- package/src/components/shell/EditorShell.tsx +7 -5
- package/src/components/shell/view-branch.ts +14 -0
- package/src/lib/loader.ts +10 -4
- package/src/lib/migrate-sections-transform.ts +33 -5
- package/src/lib/registry.ts +6 -1
- package/src/schemas/shared.ts +0 -18
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
brandGuideSectionDefs,
|
|
3
|
+
pluralize,
|
|
4
|
+
stripHtmlToPlainText,
|
|
5
|
+
truncate
|
|
6
|
+
} from "../../chunk-QYQ3DQHI.js";
|
|
7
|
+
import {
|
|
3
8
|
DeleteButton,
|
|
4
|
-
DragHandle
|
|
5
|
-
FormLabel,
|
|
6
|
-
Input,
|
|
9
|
+
DragHandle,
|
|
7
10
|
Popover,
|
|
8
11
|
PopoverItem,
|
|
9
12
|
SettingsButton,
|
|
@@ -12,54 +15,47 @@ import {
|
|
|
12
15
|
buildBlockDropData,
|
|
13
16
|
canDropBlock,
|
|
14
17
|
isBlockDragData
|
|
15
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-2BHPWO7M.js";
|
|
19
|
+
import "../../chunk-5THS4K5D.js";
|
|
16
20
|
import {
|
|
17
|
-
EditableGrid,
|
|
18
|
-
EditablePlainText,
|
|
19
21
|
EditableRichText,
|
|
22
|
+
defineHeadingSection
|
|
23
|
+
} from "../../chunk-FECCYOPJ.js";
|
|
24
|
+
import {
|
|
25
|
+
EditablePlainText,
|
|
20
26
|
MAX_CONTAINER_COLUMNS,
|
|
21
27
|
MediaBlock,
|
|
22
28
|
colSpanClass,
|
|
23
29
|
containerGridClass,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
import {
|
|
29
|
-
AddIcon,
|
|
30
|
-
DeleteIcon,
|
|
31
|
-
DragHandle,
|
|
32
|
-
IconButton
|
|
33
|
-
} from "../../chunk-WLMJCNU7.js";
|
|
30
|
+
spacerHiddenClass
|
|
31
|
+
} from "../../chunk-VMDKWUMT.js";
|
|
32
|
+
import "../../chunk-4E66N6UV.js";
|
|
33
|
+
import "../../chunk-I5737FJY.js";
|
|
34
34
|
import "../../chunk-CBWK3KPV.js";
|
|
35
35
|
import {
|
|
36
36
|
DEFAULT_LINK,
|
|
37
37
|
LinkValueSchema
|
|
38
38
|
} from "../../chunk-3DCG4DNU.js";
|
|
39
|
-
import
|
|
40
|
-
curatedIcons,
|
|
41
|
-
getIcon
|
|
42
|
-
} from "../../chunk-WDSVHKAH.js";
|
|
39
|
+
import "../../chunk-WDSVHKAH.js";
|
|
43
40
|
import {
|
|
44
41
|
sanitizeHtml
|
|
45
42
|
} from "../../chunk-53DKVAB6.js";
|
|
43
|
+
import "../../chunk-ZGFAYZWB.js";
|
|
46
44
|
import {
|
|
47
45
|
cn
|
|
48
46
|
} from "../../chunk-7EOSDFS3.js";
|
|
49
|
-
import "../../chunk-ZGFAYZWB.js";
|
|
50
47
|
import {
|
|
51
48
|
getSectionSchema
|
|
52
49
|
} from "../../chunk-TZQPOR5A.js";
|
|
50
|
+
import {
|
|
51
|
+
SingleMediaReferenceSchema
|
|
52
|
+
} from "../../chunk-TEYTLQVH.js";
|
|
53
53
|
import {
|
|
54
54
|
defineSection,
|
|
55
55
|
getSection,
|
|
56
56
|
registerRichText,
|
|
57
57
|
registerSchema
|
|
58
58
|
} from "../../chunk-VKAGMEKE.js";
|
|
59
|
-
import {
|
|
60
|
-
ColorItemSchema,
|
|
61
|
-
SingleMediaReferenceSchema
|
|
62
|
-
} from "../../chunk-BT7STGDW.js";
|
|
63
59
|
import "../../chunk-NSCT3AMV.js";
|
|
64
60
|
import "../../chunk-JSBRDJBE.js";
|
|
65
61
|
|
|
@@ -132,18 +128,6 @@ function Prose({ body, onChange }) {
|
|
|
132
128
|
);
|
|
133
129
|
}
|
|
134
130
|
|
|
135
|
-
// src/lib/text.ts
|
|
136
|
-
function stripHtmlToPlainText(html) {
|
|
137
|
-
return html.replace(/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi, "").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
138
|
-
}
|
|
139
|
-
function truncate(text, maxLength) {
|
|
140
|
-
if (text.length <= maxLength) return text;
|
|
141
|
-
return text.slice(0, maxLength) + "...";
|
|
142
|
-
}
|
|
143
|
-
function pluralize(n, word) {
|
|
144
|
-
return `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
131
|
// src/components/sections/Prose/index.tsx
|
|
148
132
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
149
133
|
var schema = z.object({
|
|
@@ -169,8 +153,7 @@ var schema2 = z2.object({
|
|
|
169
153
|
type: z2.literal("media"),
|
|
170
154
|
content: z2.object({
|
|
171
155
|
ref: SingleMediaReferenceSchema,
|
|
172
|
-
link: LinkValueSchema.optional()
|
|
173
|
-
dodont: z2.enum(["do", "dont"]).optional()
|
|
156
|
+
link: LinkValueSchema.optional()
|
|
174
157
|
}),
|
|
175
158
|
options: z2.object({
|
|
176
159
|
square: z2.boolean().optional(),
|
|
@@ -190,7 +173,6 @@ var Media_default = defineSection({
|
|
|
190
173
|
refValue: content.content.ref,
|
|
191
174
|
options: options ?? {},
|
|
192
175
|
link: content.content.link,
|
|
193
|
-
dodont: content.content.dodont,
|
|
194
176
|
isEditMode: !!onChange,
|
|
195
177
|
onRefChange: onChange ? (ref) => onChange({ ...content, content: { ...content.content, ref } }) : void 0
|
|
196
178
|
}
|
|
@@ -215,25 +197,12 @@ var Media_default = defineSection({
|
|
|
215
197
|
{ label: "Cover", value: "cover" }
|
|
216
198
|
]
|
|
217
199
|
},
|
|
218
|
-
link: { type: "link", label: "Link", default: DEFAULT_LINK, target: "content" }
|
|
219
|
-
dodont: {
|
|
220
|
-
type: "select",
|
|
221
|
-
label: "Do / Don't",
|
|
222
|
-
target: "content",
|
|
223
|
-
default: "",
|
|
224
|
-
emptyIsUndefined: true,
|
|
225
|
-
options: [
|
|
226
|
-
{ label: "None", value: "" },
|
|
227
|
-
{ label: "Do", value: "do" },
|
|
228
|
-
{ label: "Don't", value: "dont" }
|
|
229
|
-
]
|
|
230
|
-
}
|
|
200
|
+
link: { type: "link", label: "Link", default: DEFAULT_LINK, target: "content" }
|
|
231
201
|
},
|
|
232
202
|
inheritableSettings: ["square", "showCaption", "border", "objectFit"],
|
|
233
203
|
settingsTabs: [
|
|
234
204
|
{ label: "Display", fields: ["square", "showCaption", "border", "objectFit"] },
|
|
235
|
-
{ label: "Link", fields: ["link"] }
|
|
236
|
-
{ label: "Do / Don't", fields: ["dodont"] }
|
|
205
|
+
{ label: "Link", fields: ["link"] }
|
|
237
206
|
]
|
|
238
207
|
});
|
|
239
208
|
|
|
@@ -314,1025 +283,8 @@ var Button_default = defineSection({
|
|
|
314
283
|
}
|
|
315
284
|
});
|
|
316
285
|
|
|
317
|
-
// src/components/sections/Colors/index.tsx
|
|
318
|
-
import { z as z4 } from "zod";
|
|
319
|
-
import { Palette } from "lucide-react";
|
|
320
|
-
|
|
321
|
-
// src/components/brandguide/Colors.tsx
|
|
322
|
-
import { useState as useState2, useEffect } from "react";
|
|
323
|
-
import { Eye, EyeOff } from "lucide-react";
|
|
324
|
-
|
|
325
|
-
// src/components/brandguide/ColorSwatchSettings.tsx
|
|
326
|
-
import { useState } from "react";
|
|
327
|
-
import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
328
|
-
function mergeSpaces(spaces) {
|
|
329
|
-
return Object.assign({}, ...spaces);
|
|
330
|
-
}
|
|
331
|
-
function ColorSwatchSettings({ color, onChange }) {
|
|
332
|
-
const [localColor, setLocalColor] = useState(() => ({
|
|
333
|
-
...color,
|
|
334
|
-
spaces: [mergeSpaces(color.spaces)]
|
|
335
|
-
}));
|
|
336
|
-
const space = localColor.spaces[0] || {};
|
|
337
|
-
const update = (updated) => {
|
|
338
|
-
setLocalColor(updated);
|
|
339
|
-
onChange(updated);
|
|
340
|
-
};
|
|
341
|
-
const updateSpace = (key, value) => {
|
|
342
|
-
const newSpace = { ...space, [key]: value || void 0 };
|
|
343
|
-
update({ ...localColor, spaces: [newSpace] });
|
|
344
|
-
};
|
|
345
|
-
return /* @__PURE__ */ jsxs2("div", { className: "space-y-3", children: [
|
|
346
|
-
/* @__PURE__ */ jsx9(
|
|
347
|
-
Input,
|
|
348
|
-
{
|
|
349
|
-
label: "Name",
|
|
350
|
-
value: localColor.name || "",
|
|
351
|
-
onChange: (name) => update({ ...localColor, name })
|
|
352
|
-
}
|
|
353
|
-
),
|
|
354
|
-
["hex", "rgb", "cmyk", "pantone"].map((key) => /* @__PURE__ */ jsx9(
|
|
355
|
-
Input,
|
|
356
|
-
{
|
|
357
|
-
label: key.toUpperCase(),
|
|
358
|
-
value: space[key] || "",
|
|
359
|
-
onChange: (value) => updateSpace(key, value)
|
|
360
|
-
},
|
|
361
|
-
key
|
|
362
|
-
))
|
|
363
|
-
] });
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
// src/components/brandguide/Colors.tsx
|
|
367
|
-
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
368
|
-
function getContrastClass(hex) {
|
|
369
|
-
if (!hex) return "text-white";
|
|
370
|
-
const h = hex.replace("#", "");
|
|
371
|
-
if (h.length < 6) return "text-white";
|
|
372
|
-
const r = parseInt(h.substring(0, 2), 16);
|
|
373
|
-
const g = parseInt(h.substring(2, 4), 16);
|
|
374
|
-
const b = parseInt(h.substring(4, 6), 16);
|
|
375
|
-
const yiq = (r * 299 + g * 587 + b * 114) / 1e3;
|
|
376
|
-
return yiq >= 128 ? "text-black" : "text-white";
|
|
377
|
-
}
|
|
378
|
-
var createColorItem = () => ({
|
|
379
|
-
name: "",
|
|
380
|
-
spaces: [{ hex: "#cccccc" }]
|
|
381
|
-
});
|
|
382
|
-
function buildContent(colors, options) {
|
|
383
|
-
const { label, columns, collapsing, showLabel } = options;
|
|
384
|
-
return {
|
|
385
|
-
type: "colors",
|
|
386
|
-
content: { colors },
|
|
387
|
-
...label || columns || collapsing !== void 0 || showLabel !== void 0 ? { options: { label, columns, collapsing, showLabel } } : {}
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
function Colors({ colors, columns = 3, label, collapsing, showLabel = true, onChange, openModal }) {
|
|
391
|
-
if (onChange && openModal) {
|
|
392
|
-
return /* @__PURE__ */ jsx10(
|
|
393
|
-
ColorsEditable,
|
|
394
|
-
{
|
|
395
|
-
colors,
|
|
396
|
-
columns,
|
|
397
|
-
label,
|
|
398
|
-
collapsing,
|
|
399
|
-
showLabel,
|
|
400
|
-
onChange,
|
|
401
|
-
openModal
|
|
402
|
-
}
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
return /* @__PURE__ */ jsx10(ColorsView, { colors, columns, label, collapsing, showLabel });
|
|
406
|
-
}
|
|
407
|
-
function ColorsView({
|
|
408
|
-
colors,
|
|
409
|
-
columns,
|
|
410
|
-
label,
|
|
411
|
-
collapsing,
|
|
412
|
-
showLabel
|
|
413
|
-
}) {
|
|
414
|
-
const [expanded, setExpanded] = useState2(!collapsing);
|
|
415
|
-
const [copiedIndex, setCopiedIndex] = useState2(null);
|
|
416
|
-
const handleCopy = (value, colorIndex) => {
|
|
417
|
-
if (navigator.clipboard?.writeText) {
|
|
418
|
-
navigator.clipboard.writeText(value);
|
|
419
|
-
} else {
|
|
420
|
-
const ta = document.createElement("textarea");
|
|
421
|
-
ta.value = value;
|
|
422
|
-
ta.style.position = "fixed";
|
|
423
|
-
ta.style.opacity = "0";
|
|
424
|
-
document.body.appendChild(ta);
|
|
425
|
-
ta.select();
|
|
426
|
-
document.execCommand("copy");
|
|
427
|
-
document.body.removeChild(ta);
|
|
428
|
-
}
|
|
429
|
-
setCopiedIndex(colorIndex);
|
|
430
|
-
setTimeout(() => setCopiedIndex(null), 1500);
|
|
431
|
-
};
|
|
432
|
-
return /* @__PURE__ */ jsxs3("div", { children: [
|
|
433
|
-
(showLabel && !!label || collapsing) && /* @__PURE__ */ jsxs3("div", { className: "mb-4 flex items-center gap-2", children: [
|
|
434
|
-
showLabel && !!label && /* @__PURE__ */ jsx10("span", { className: "text-lg font-bold", children: label }),
|
|
435
|
-
collapsing && /* @__PURE__ */ jsxs3(
|
|
436
|
-
"button",
|
|
437
|
-
{
|
|
438
|
-
onClick: () => setExpanded(!expanded),
|
|
439
|
-
className: "cursor-pointer ml-auto flex items-center gap-1.5 text-sm text-base-contrast-light hover:text-base-contrast",
|
|
440
|
-
children: [
|
|
441
|
-
/* @__PURE__ */ jsx10("span", { children: expanded ? "Hide Details" : "Show Details" }),
|
|
442
|
-
expanded ? /* @__PURE__ */ jsx10(EyeOff, { size: 16 }) : /* @__PURE__ */ jsx10(Eye, { size: 16 })
|
|
443
|
-
]
|
|
444
|
-
}
|
|
445
|
-
)
|
|
446
|
-
] }),
|
|
447
|
-
/* @__PURE__ */ jsx10("div", { className: "@container", children: /* @__PURE__ */ jsx10("div", { className: cn("grid gap-4", containerGridClass[columns] || containerGridClass[3]), children: colors.map((color, i) => {
|
|
448
|
-
const hex = color.spaces[0]?.hex;
|
|
449
|
-
const contrast = getContrastClass(hex);
|
|
450
|
-
return /* @__PURE__ */ jsxs3("div", { className: "overflow-hidden rounded-md border border-base-200", children: [
|
|
451
|
-
/* @__PURE__ */ jsxs3("div", { className: cn("relative flex min-h-[80px] items-end p-3", contrast), style: { backgroundColor: hex || "#ccc" }, children: [
|
|
452
|
-
color.name && /* @__PURE__ */ jsx10("span", { className: "text-sm font-bold", children: color.name }),
|
|
453
|
-
copiedIndex === i && /* @__PURE__ */ jsx10("span", { className: cn(
|
|
454
|
-
"absolute top-2 right-2 rounded-full px-2.5 py-0.5 text-xs font-medium",
|
|
455
|
-
getContrastClass(hex) === "text-black" ? "bg-black/15 text-black" : "bg-white/25 text-white"
|
|
456
|
-
), children: "Copied!" })
|
|
457
|
-
] }),
|
|
458
|
-
expanded && /* @__PURE__ */ jsx10("div", { className: "space-y-1 bg-base-accent p-3 text-sm", children: color.spaces.map(
|
|
459
|
-
(space, j) => Object.entries(space).map(
|
|
460
|
-
([key, value]) => value ? /* @__PURE__ */ jsxs3("button", { onClick: () => handleCopy(value, i), className: "cursor-pointer flex w-full justify-between hover:text-primary", children: [
|
|
461
|
-
/* @__PURE__ */ jsx10("span", { className: "font-medium uppercase", children: key }),
|
|
462
|
-
/* @__PURE__ */ jsx10("span", { children: value })
|
|
463
|
-
] }, `${j}-${key}`) : null
|
|
464
|
-
)
|
|
465
|
-
) })
|
|
466
|
-
] }, i);
|
|
467
|
-
}) }) })
|
|
468
|
-
] });
|
|
469
|
-
}
|
|
470
|
-
function ColorsEditable({
|
|
471
|
-
colors,
|
|
472
|
-
columns,
|
|
473
|
-
label,
|
|
474
|
-
collapsing,
|
|
475
|
-
showLabel,
|
|
476
|
-
onChange,
|
|
477
|
-
openModal
|
|
478
|
-
}) {
|
|
479
|
-
const [expanded, setExpanded] = useState2(!collapsing);
|
|
480
|
-
const options = { label, columns, collapsing, showLabel };
|
|
481
|
-
useEffect(() => {
|
|
482
|
-
setExpanded(!collapsing);
|
|
483
|
-
}, [collapsing]);
|
|
484
|
-
const handleItemSettings = (index) => {
|
|
485
|
-
const color = colors[index];
|
|
486
|
-
openModal(
|
|
487
|
-
"Color Settings",
|
|
488
|
-
/* @__PURE__ */ jsx10(ColorSwatchSettings, { color, onChange: (updated) => {
|
|
489
|
-
const newColors = colors.map((c, i) => i === index ? updated : c);
|
|
490
|
-
onChange(buildContent(newColors, options));
|
|
491
|
-
} })
|
|
492
|
-
);
|
|
493
|
-
};
|
|
494
|
-
return /* @__PURE__ */ jsxs3("div", { children: [
|
|
495
|
-
(showLabel && !!label || collapsing) && /* @__PURE__ */ jsxs3("div", { className: "mb-4 flex items-center gap-2", children: [
|
|
496
|
-
showLabel && !!label && /* @__PURE__ */ jsx10(
|
|
497
|
-
EditablePlainText,
|
|
498
|
-
{
|
|
499
|
-
tag: "span",
|
|
500
|
-
value: label,
|
|
501
|
-
onChange: (newLabel) => onChange(buildContent(colors, { ...options, label: newLabel })),
|
|
502
|
-
isEditMode: true,
|
|
503
|
-
className: "text-lg font-bold"
|
|
504
|
-
}
|
|
505
|
-
),
|
|
506
|
-
collapsing && /* @__PURE__ */ jsxs3(
|
|
507
|
-
"button",
|
|
508
|
-
{
|
|
509
|
-
onClick: () => setExpanded(!expanded),
|
|
510
|
-
className: "cursor-pointer ml-auto flex items-center gap-1.5 text-sm text-base-contrast-light hover:text-base-contrast",
|
|
511
|
-
children: [
|
|
512
|
-
/* @__PURE__ */ jsx10("span", { children: expanded ? "Hide Details" : "Show Details" }),
|
|
513
|
-
expanded ? /* @__PURE__ */ jsx10(EyeOff, { size: 16 }) : /* @__PURE__ */ jsx10(Eye, { size: 16 })
|
|
514
|
-
]
|
|
515
|
-
}
|
|
516
|
-
)
|
|
517
|
-
] }),
|
|
518
|
-
/* @__PURE__ */ jsx10(
|
|
519
|
-
EditableGrid,
|
|
520
|
-
{
|
|
521
|
-
items: colors,
|
|
522
|
-
columns,
|
|
523
|
-
onChange: (newColors) => onChange(buildContent(newColors, options)),
|
|
524
|
-
createItem: createColorItem,
|
|
525
|
-
isEditMode: true,
|
|
526
|
-
onItemSettings: handleItemSettings,
|
|
527
|
-
renderItem: (color, { index }) => /* @__PURE__ */ jsx10(
|
|
528
|
-
ColorSwatchEditable,
|
|
529
|
-
{
|
|
530
|
-
color,
|
|
531
|
-
index,
|
|
532
|
-
colors,
|
|
533
|
-
options,
|
|
534
|
-
onChange,
|
|
535
|
-
expanded
|
|
536
|
-
}
|
|
537
|
-
)
|
|
538
|
-
}
|
|
539
|
-
)
|
|
540
|
-
] });
|
|
541
|
-
}
|
|
542
|
-
function ColorSwatchEditable({
|
|
543
|
-
color,
|
|
544
|
-
index,
|
|
545
|
-
colors,
|
|
546
|
-
options,
|
|
547
|
-
onChange,
|
|
548
|
-
expanded
|
|
549
|
-
}) {
|
|
550
|
-
const hex = color.spaces[0]?.hex;
|
|
551
|
-
const contrast = getContrastClass(hex);
|
|
552
|
-
const updateColor = (updated) => {
|
|
553
|
-
const newColors = colors.map((c, i) => i === index ? updated : c);
|
|
554
|
-
onChange(buildContent(newColors, options));
|
|
555
|
-
};
|
|
556
|
-
return /* @__PURE__ */ jsxs3("div", { className: "overflow-hidden rounded-md border border-base-200", children: [
|
|
557
|
-
/* @__PURE__ */ jsx10("div", { className: cn("flex min-h-[80px] items-end p-3", contrast), style: { backgroundColor: hex || "#ccc" }, children: /* @__PURE__ */ jsx10(
|
|
558
|
-
EditablePlainText,
|
|
559
|
-
{
|
|
560
|
-
tag: "span",
|
|
561
|
-
value: color.name || "",
|
|
562
|
-
onChange: (name) => updateColor({ ...color, name }),
|
|
563
|
-
isEditMode: true,
|
|
564
|
-
placeholder: "Color name",
|
|
565
|
-
className: "text-sm font-bold"
|
|
566
|
-
}
|
|
567
|
-
) }),
|
|
568
|
-
expanded && /* @__PURE__ */ jsx10("div", { className: "space-y-1 bg-base-accent p-3 text-sm", children: color.spaces.map(
|
|
569
|
-
(space, j) => Object.entries(space).map(
|
|
570
|
-
([key, value]) => value ? /* @__PURE__ */ jsxs3("div", { className: "flex w-full justify-between", children: [
|
|
571
|
-
/* @__PURE__ */ jsx10("span", { className: "font-medium uppercase", children: key }),
|
|
572
|
-
/* @__PURE__ */ jsx10("span", { children: value })
|
|
573
|
-
] }, `${j}-${key}`) : null
|
|
574
|
-
)
|
|
575
|
-
) })
|
|
576
|
-
] });
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// src/components/sections/Colors/index.tsx
|
|
580
|
-
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
581
|
-
var schema4 = z4.object({
|
|
582
|
-
type: z4.literal("colors"),
|
|
583
|
-
content: z4.object({ colors: z4.array(ColorItemSchema) }),
|
|
584
|
-
options: z4.object({
|
|
585
|
-
label: z4.string().optional(),
|
|
586
|
-
columns: z4.number().int().min(2).max(4).optional(),
|
|
587
|
-
collapsing: z4.boolean().optional(),
|
|
588
|
-
showLabel: z4.boolean().optional()
|
|
589
|
-
}).optional()
|
|
590
|
-
});
|
|
591
|
-
var Colors_default = defineSection({
|
|
592
|
-
type: "colors",
|
|
593
|
-
label: "Colors",
|
|
594
|
-
icon: /* @__PURE__ */ jsx11(Palette, { size: 18 }),
|
|
595
|
-
schema: schema4,
|
|
596
|
-
component: ({ content, options, onChange, openModal }) => /* @__PURE__ */ jsx11(
|
|
597
|
-
Colors,
|
|
598
|
-
{
|
|
599
|
-
colors: content.content.colors,
|
|
600
|
-
columns: options?.columns,
|
|
601
|
-
label: options?.label,
|
|
602
|
-
collapsing: options?.collapsing,
|
|
603
|
-
showLabel: options?.showLabel,
|
|
604
|
-
onChange: onChange ? (c) => onChange(c) : void 0,
|
|
605
|
-
openModal
|
|
606
|
-
}
|
|
607
|
-
),
|
|
608
|
-
defaults: () => ({
|
|
609
|
-
type: "colors",
|
|
610
|
-
content: { colors: [{ spaces: [{ hex: "#000000" }] }] }
|
|
611
|
-
}),
|
|
612
|
-
getLabel: (content) => pluralize(content.content.colors.length, "color"),
|
|
613
|
-
getThumbnails: (content) => content.content.colors.filter((c) => c.spaces[0]?.hex).map((c) => ({ type: "color", value: c.spaces[0].hex })),
|
|
614
|
-
settings: {
|
|
615
|
-
columns: {
|
|
616
|
-
type: "select",
|
|
617
|
-
label: "Columns",
|
|
618
|
-
default: "3",
|
|
619
|
-
coerce: "number",
|
|
620
|
-
options: [{ label: "2", value: "2" }, { label: "3", value: "3" }, { label: "4", value: "4" }]
|
|
621
|
-
},
|
|
622
|
-
label: { type: "text", label: "Label", default: "", placeholder: "Color Section Label" },
|
|
623
|
-
showLabel: { type: "checkbox", label: "Show label", default: true },
|
|
624
|
-
collapsing: { type: "checkbox", label: "Collapsing layout", default: false }
|
|
625
|
-
}
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
// src/components/sections/IconList/index.tsx
|
|
629
|
-
import { z as z5 } from "zod";
|
|
630
|
-
import { List } from "lucide-react";
|
|
631
|
-
|
|
632
|
-
// src/components/sections/IconList/IconList.tsx
|
|
633
|
-
import { useRef as useRef2, useEffect as useEffect3, useState as useState4, useCallback } from "react";
|
|
634
|
-
import { CopyPlus, Pencil } from "lucide-react";
|
|
635
|
-
|
|
636
|
-
// src/components/primitives/IconPicker.tsx
|
|
637
|
-
import { useEffect as useEffect2, useRef, useState as useState3 } from "react";
|
|
638
|
-
import { Check, X } from "lucide-react";
|
|
639
|
-
import { Fragment, jsx as jsx12, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
640
|
-
function IconPicker({
|
|
641
|
-
selected,
|
|
642
|
-
onSelect,
|
|
643
|
-
onClose,
|
|
644
|
-
showRemove = true,
|
|
645
|
-
allowDoDont = false,
|
|
646
|
-
dodont,
|
|
647
|
-
onSelectDoDont
|
|
648
|
-
}) {
|
|
649
|
-
const panelRef = useRef(null);
|
|
650
|
-
const [mode, setMode] = useState3(dodont ? "dodont" : "none");
|
|
651
|
-
useEffect2(() => {
|
|
652
|
-
function handleMouseDown(e) {
|
|
653
|
-
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
654
|
-
onClose();
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
document.addEventListener("mousedown", handleMouseDown);
|
|
658
|
-
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
659
|
-
}, [onClose]);
|
|
660
|
-
const showDoDont = allowDoDont && mode === "dodont";
|
|
661
|
-
return /* @__PURE__ */ jsxs4(
|
|
662
|
-
"div",
|
|
663
|
-
{
|
|
664
|
-
ref: panelRef,
|
|
665
|
-
className: "absolute z-50 w-56 rounded-lg border border-base-200 bg-base p-2 shadow-lg",
|
|
666
|
-
children: [
|
|
667
|
-
allowDoDont && /* @__PURE__ */ jsxs4("div", { role: "tablist", "aria-label": "Icon mode", className: "mb-2 flex gap-1 rounded-md bg-base-200 p-0.5", children: [
|
|
668
|
-
/* @__PURE__ */ jsx12(
|
|
669
|
-
"button",
|
|
670
|
-
{
|
|
671
|
-
type: "button",
|
|
672
|
-
role: "tab",
|
|
673
|
-
"aria-label": "None",
|
|
674
|
-
"aria-selected": mode === "none",
|
|
675
|
-
className: cn(
|
|
676
|
-
"cursor-pointer flex-1 rounded px-2 py-1 text-xs font-medium transition-colors",
|
|
677
|
-
mode === "none" ? "bg-base text-base-contrast shadow-sm" : "text-base-contrast-light hover:text-base-contrast"
|
|
678
|
-
),
|
|
679
|
-
onClick: () => {
|
|
680
|
-
setMode("none");
|
|
681
|
-
onSelectDoDont?.(void 0);
|
|
682
|
-
},
|
|
683
|
-
children: "None"
|
|
684
|
-
}
|
|
685
|
-
),
|
|
686
|
-
/* @__PURE__ */ jsx12(
|
|
687
|
-
"button",
|
|
688
|
-
{
|
|
689
|
-
type: "button",
|
|
690
|
-
role: "tab",
|
|
691
|
-
"aria-label": "Do / Don't",
|
|
692
|
-
"aria-selected": mode === "dodont",
|
|
693
|
-
className: cn(
|
|
694
|
-
"cursor-pointer flex-1 rounded px-2 py-1 text-xs font-medium transition-colors",
|
|
695
|
-
mode === "dodont" ? "bg-base text-base-contrast shadow-sm" : "text-base-contrast-light hover:text-base-contrast"
|
|
696
|
-
),
|
|
697
|
-
onClick: () => setMode("dodont"),
|
|
698
|
-
children: "Do / Don't"
|
|
699
|
-
}
|
|
700
|
-
)
|
|
701
|
-
] }),
|
|
702
|
-
showDoDont ? /* @__PURE__ */ jsxs4("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
703
|
-
/* @__PURE__ */ jsxs4(
|
|
704
|
-
"button",
|
|
705
|
-
{
|
|
706
|
-
type: "button",
|
|
707
|
-
"aria-label": "Do",
|
|
708
|
-
className: cn(
|
|
709
|
-
"cursor-pointer flex flex-col items-center justify-center gap-1 rounded py-2 transition-colors",
|
|
710
|
-
"text-green-600 hover:bg-base-accent",
|
|
711
|
-
dodont === "do" && "ring-2 ring-primary bg-base-accent"
|
|
712
|
-
),
|
|
713
|
-
onClick: () => onSelectDoDont?.("do"),
|
|
714
|
-
children: [
|
|
715
|
-
/* @__PURE__ */ jsx12(Check, { size: 20 }),
|
|
716
|
-
/* @__PURE__ */ jsx12("span", { className: "text-xs font-medium", children: "Do" })
|
|
717
|
-
]
|
|
718
|
-
}
|
|
719
|
-
),
|
|
720
|
-
/* @__PURE__ */ jsxs4(
|
|
721
|
-
"button",
|
|
722
|
-
{
|
|
723
|
-
type: "button",
|
|
724
|
-
"aria-label": "Don't",
|
|
725
|
-
className: cn(
|
|
726
|
-
"cursor-pointer flex flex-col items-center justify-center gap-1 rounded py-2 transition-colors",
|
|
727
|
-
"text-red-600 hover:bg-base-accent",
|
|
728
|
-
dodont === "dont" && "ring-2 ring-primary bg-base-accent"
|
|
729
|
-
),
|
|
730
|
-
onClick: () => onSelectDoDont?.("dont"),
|
|
731
|
-
children: [
|
|
732
|
-
/* @__PURE__ */ jsx12(X, { size: 20 }),
|
|
733
|
-
/* @__PURE__ */ jsx12("span", { className: "text-xs font-medium", children: "Don't" })
|
|
734
|
-
]
|
|
735
|
-
}
|
|
736
|
-
)
|
|
737
|
-
] }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
738
|
-
/* @__PURE__ */ jsx12("div", { className: "grid grid-cols-5 gap-1", children: curatedIcons.map((entry) => {
|
|
739
|
-
const Icon = entry.icon;
|
|
740
|
-
const isSelected = selected === entry.id;
|
|
741
|
-
return /* @__PURE__ */ jsx12(
|
|
742
|
-
"button",
|
|
743
|
-
{
|
|
744
|
-
"aria-label": entry.label,
|
|
745
|
-
className: cn(
|
|
746
|
-
"cursor-pointer flex h-9 w-9 items-center justify-center rounded transition-colors",
|
|
747
|
-
"text-base-contrast-light hover:bg-base-accent hover:text-base-contrast",
|
|
748
|
-
isSelected && "ring-2 ring-primary bg-base-accent text-primary"
|
|
749
|
-
),
|
|
750
|
-
onClick: () => onSelect(entry.id),
|
|
751
|
-
children: /* @__PURE__ */ jsx12(Icon, { size: 18 })
|
|
752
|
-
},
|
|
753
|
-
entry.id
|
|
754
|
-
);
|
|
755
|
-
}) }),
|
|
756
|
-
showRemove && /* @__PURE__ */ jsx12(
|
|
757
|
-
"button",
|
|
758
|
-
{
|
|
759
|
-
className: "cursor-pointer mt-2 w-full rounded px-2 py-1.5 text-center text-xs text-base-contrast-light hover:bg-base-accent hover:text-base-contrast",
|
|
760
|
-
onClick: () => onSelect(null),
|
|
761
|
-
children: "Remove icon"
|
|
762
|
-
}
|
|
763
|
-
)
|
|
764
|
-
] })
|
|
765
|
-
]
|
|
766
|
-
}
|
|
767
|
-
);
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
// src/components/sections/IconList/IconList.tsx
|
|
771
|
-
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
772
|
-
function IconList({
|
|
773
|
-
items,
|
|
774
|
-
icon = null,
|
|
775
|
-
showLabel = true,
|
|
776
|
-
stackText = false,
|
|
777
|
-
labelClassName = "font-bold text-base-contrast",
|
|
778
|
-
textClassName = "text-base-contrast-light",
|
|
779
|
-
iconClassName = "text-primary",
|
|
780
|
-
onChange,
|
|
781
|
-
onItemsChange
|
|
782
|
-
}) {
|
|
783
|
-
const isEditMode = !!onChange || !!onItemsChange;
|
|
784
|
-
const emitItems = useCallback(
|
|
785
|
-
(newItems) => {
|
|
786
|
-
onChange?.({
|
|
787
|
-
type: "icon_list",
|
|
788
|
-
content: { items: newItems },
|
|
789
|
-
options: { icon, showLabel, stackText }
|
|
790
|
-
});
|
|
791
|
-
onItemsChange?.(newItems);
|
|
792
|
-
},
|
|
793
|
-
[onChange, onItemsChange, icon, showLabel, stackText]
|
|
794
|
-
);
|
|
795
|
-
if (!isEditMode) {
|
|
796
|
-
return /* @__PURE__ */ jsx13(
|
|
797
|
-
ViewIconList,
|
|
798
|
-
{
|
|
799
|
-
items,
|
|
800
|
-
defaultIcon: icon,
|
|
801
|
-
showLabel,
|
|
802
|
-
stackText,
|
|
803
|
-
labelClassName,
|
|
804
|
-
textClassName,
|
|
805
|
-
iconClassName
|
|
806
|
-
}
|
|
807
|
-
);
|
|
808
|
-
}
|
|
809
|
-
return /* @__PURE__ */ jsx13(
|
|
810
|
-
EditIconList,
|
|
811
|
-
{
|
|
812
|
-
items,
|
|
813
|
-
defaultIcon: icon,
|
|
814
|
-
showLabel,
|
|
815
|
-
stackText,
|
|
816
|
-
labelClassName,
|
|
817
|
-
textClassName,
|
|
818
|
-
iconClassName,
|
|
819
|
-
onItemsChange: emitItems
|
|
820
|
-
}
|
|
821
|
-
);
|
|
822
|
-
}
|
|
823
|
-
function resolveIcon(item, defaultIcon) {
|
|
824
|
-
if (item.dodont === "do") return getIcon("check") ?? null;
|
|
825
|
-
if (item.dodont === "dont") return getIcon("x") ?? null;
|
|
826
|
-
const id = item.icon ?? defaultIcon;
|
|
827
|
-
return id ? getIcon(id) : null;
|
|
828
|
-
}
|
|
829
|
-
function resolveIconColor(item, iconClassName) {
|
|
830
|
-
if (item.dodont === "do") return "text-green-600";
|
|
831
|
-
if (item.dodont === "dont") return "text-red-600";
|
|
832
|
-
return iconClassName;
|
|
833
|
-
}
|
|
834
|
-
function ViewIconList({
|
|
835
|
-
items,
|
|
836
|
-
defaultIcon,
|
|
837
|
-
showLabel,
|
|
838
|
-
stackText,
|
|
839
|
-
labelClassName,
|
|
840
|
-
textClassName,
|
|
841
|
-
iconClassName
|
|
842
|
-
}) {
|
|
843
|
-
const hasAnyIcon = items.some((item) => resolveIcon(item, defaultIcon));
|
|
844
|
-
return /* @__PURE__ */ jsx13("div", { className: "grid gap-4 pb-4", children: items.map((item, i) => {
|
|
845
|
-
const iconEntry = resolveIcon(item, defaultIcon);
|
|
846
|
-
const iconColor = resolveIconColor(item, iconClassName);
|
|
847
|
-
return /* @__PURE__ */ jsxs5(
|
|
848
|
-
"div",
|
|
849
|
-
{
|
|
850
|
-
className: cn(
|
|
851
|
-
"grid gap-x-3",
|
|
852
|
-
hasAnyIcon ? "grid-cols-[24px_1fr]" : "grid-cols-1"
|
|
853
|
-
),
|
|
854
|
-
children: [
|
|
855
|
-
hasAnyIcon && /* @__PURE__ */ jsx13(
|
|
856
|
-
"div",
|
|
857
|
-
{
|
|
858
|
-
"data-testid": "icon-list-icon",
|
|
859
|
-
className: cn("flex items-start pt-0.5", iconColor),
|
|
860
|
-
children: iconEntry && /* @__PURE__ */ jsx13(iconEntry.icon, { size: 18 })
|
|
861
|
-
}
|
|
862
|
-
),
|
|
863
|
-
/* @__PURE__ */ jsxs5(
|
|
864
|
-
"div",
|
|
865
|
-
{
|
|
866
|
-
"data-testid": "icon-list-content",
|
|
867
|
-
className: stackText ? "flex flex-col" : void 0,
|
|
868
|
-
children: [
|
|
869
|
-
showLabel && /* @__PURE__ */ jsxs5("span", { className: labelClassName, children: [
|
|
870
|
-
item.label,
|
|
871
|
-
!stackText && " "
|
|
872
|
-
] }),
|
|
873
|
-
/* @__PURE__ */ jsx13("span", { className: textClassName, children: item.text })
|
|
874
|
-
]
|
|
875
|
-
}
|
|
876
|
-
)
|
|
877
|
-
]
|
|
878
|
-
},
|
|
879
|
-
i
|
|
880
|
-
);
|
|
881
|
-
}) });
|
|
882
|
-
}
|
|
883
|
-
function EditIconList({
|
|
884
|
-
items,
|
|
885
|
-
defaultIcon,
|
|
886
|
-
showLabel,
|
|
887
|
-
stackText,
|
|
888
|
-
labelClassName,
|
|
889
|
-
textClassName,
|
|
890
|
-
iconClassName,
|
|
891
|
-
onItemsChange
|
|
892
|
-
}) {
|
|
893
|
-
const { wrappedItems, onReorder, onAdd, onRemove } = useEditableCollection({
|
|
894
|
-
items,
|
|
895
|
-
onChange: onItemsChange,
|
|
896
|
-
createItem: () => ({ label: "", text: "" })
|
|
897
|
-
});
|
|
898
|
-
const [dragState, setDragState] = useState4({ sourceId: null, targetId: null });
|
|
899
|
-
const updateItem = useCallback(
|
|
900
|
-
(index, patch) => {
|
|
901
|
-
const updated = wrappedItems.map(
|
|
902
|
-
(w, i) => i === index ? { ...w.data, ...patch } : w.data
|
|
903
|
-
);
|
|
904
|
-
onItemsChange(updated);
|
|
905
|
-
},
|
|
906
|
-
[wrappedItems, onItemsChange]
|
|
907
|
-
);
|
|
908
|
-
const duplicateItem = useCallback(
|
|
909
|
-
(index) => {
|
|
910
|
-
const copy = { ...wrappedItems[index].data };
|
|
911
|
-
const next = [
|
|
912
|
-
...wrappedItems.slice(0, index + 1).map((w) => w.data),
|
|
913
|
-
copy,
|
|
914
|
-
...wrappedItems.slice(index + 1).map((w) => w.data)
|
|
915
|
-
];
|
|
916
|
-
onItemsChange(next);
|
|
917
|
-
},
|
|
918
|
-
[wrappedItems, onItemsChange]
|
|
919
|
-
);
|
|
920
|
-
const hasAnyIcon = true;
|
|
921
|
-
return /* @__PURE__ */ jsxs5("div", { className: "group/list relative grid gap-4 pb-4", children: [
|
|
922
|
-
wrappedItems.map((wrapped, index) => /* @__PURE__ */ jsx13(
|
|
923
|
-
EditableRow,
|
|
924
|
-
{
|
|
925
|
-
id: wrapped.id,
|
|
926
|
-
index,
|
|
927
|
-
item: wrapped.data,
|
|
928
|
-
defaultIcon,
|
|
929
|
-
hasAnyIcon,
|
|
930
|
-
showLabel,
|
|
931
|
-
stackText,
|
|
932
|
-
labelClassName,
|
|
933
|
-
textClassName,
|
|
934
|
-
iconClassName,
|
|
935
|
-
dragState,
|
|
936
|
-
setDragState,
|
|
937
|
-
onReorder,
|
|
938
|
-
onRemove,
|
|
939
|
-
onUpdateItem: (patch) => updateItem(index, patch),
|
|
940
|
-
onDuplicate: () => duplicateItem(index)
|
|
941
|
-
},
|
|
942
|
-
wrapped.id
|
|
943
|
-
)),
|
|
944
|
-
/* @__PURE__ */ jsx13(
|
|
945
|
-
TrailingDropZone,
|
|
946
|
-
{
|
|
947
|
-
index: wrappedItems.length,
|
|
948
|
-
dragState,
|
|
949
|
-
setDragState,
|
|
950
|
-
onReorder
|
|
951
|
-
}
|
|
952
|
-
),
|
|
953
|
-
/* @__PURE__ */ jsx13(
|
|
954
|
-
IconButton,
|
|
955
|
-
{
|
|
956
|
-
icon: /* @__PURE__ */ jsx13(AddIcon, { size: 16 }),
|
|
957
|
-
label: "Add item",
|
|
958
|
-
size: "lg",
|
|
959
|
-
intent: "primary",
|
|
960
|
-
onClick: onAdd,
|
|
961
|
-
className: "absolute -bottom-6 left-1/2 z-20 -translate-x-1/2 rounded-full border border-base-200 bg-base opacity-0 transition-opacity group-hover/list:opacity-100"
|
|
962
|
-
}
|
|
963
|
-
)
|
|
964
|
-
] });
|
|
965
|
-
}
|
|
966
|
-
function EditableRow({
|
|
967
|
-
id,
|
|
968
|
-
index,
|
|
969
|
-
item,
|
|
970
|
-
defaultIcon,
|
|
971
|
-
hasAnyIcon,
|
|
972
|
-
showLabel,
|
|
973
|
-
stackText,
|
|
974
|
-
labelClassName,
|
|
975
|
-
textClassName,
|
|
976
|
-
iconClassName,
|
|
977
|
-
dragState,
|
|
978
|
-
setDragState,
|
|
979
|
-
onReorder,
|
|
980
|
-
onRemove,
|
|
981
|
-
onUpdateItem,
|
|
982
|
-
onDuplicate
|
|
983
|
-
}) {
|
|
984
|
-
const rowRef = useRef2(null);
|
|
985
|
-
const handleRef = useRef2(null);
|
|
986
|
-
const [iconHover, setIconHover] = useState4(false);
|
|
987
|
-
const [pickerOpen, setPickerOpen] = useState4(false);
|
|
988
|
-
const [editingSuppressed, setEditingSuppressed] = useState4(false);
|
|
989
|
-
const iconEntry = resolveIcon(item, defaultIcon);
|
|
990
|
-
const effectiveIconId = item.icon ?? defaultIcon ?? null;
|
|
991
|
-
const iconColor = resolveIconColor(item, iconClassName);
|
|
992
|
-
useEffect3(() => {
|
|
993
|
-
const row = rowRef.current;
|
|
994
|
-
const handle = handleRef.current;
|
|
995
|
-
if (!row || !handle) return;
|
|
996
|
-
let cleanup;
|
|
997
|
-
let cancelled = false;
|
|
998
|
-
import("../../adapter-HH47ZPGM.js").then(({ draggable, dropTargetForElements }) => {
|
|
999
|
-
if (cancelled) return;
|
|
1000
|
-
const cleanupDraggable = draggable({
|
|
1001
|
-
element: handle,
|
|
1002
|
-
getInitialData: () => ({ dragType: "icon-list-row", id, index }),
|
|
1003
|
-
onDragStart: () => setDragState({ sourceId: id, targetId: null }),
|
|
1004
|
-
onDrop: () => setDragState({ sourceId: null, targetId: null })
|
|
1005
|
-
});
|
|
1006
|
-
const cleanupDropTarget = dropTargetForElements({
|
|
1007
|
-
element: row,
|
|
1008
|
-
canDrop: ({ source }) => source.data.dragType === "icon-list-row",
|
|
1009
|
-
getData: () => ({ id, index }),
|
|
1010
|
-
onDragEnter: () => setDragState((prev) => ({ ...prev, targetId: id })),
|
|
1011
|
-
onDragLeave: () => setDragState(
|
|
1012
|
-
(prev) => prev.targetId === id ? { ...prev, targetId: null } : prev
|
|
1013
|
-
),
|
|
1014
|
-
onDrop: ({ source }) => {
|
|
1015
|
-
const fromIndex = source.data.index;
|
|
1016
|
-
if (fromIndex !== index) onReorder(fromIndex, index);
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
cleanup = () => {
|
|
1020
|
-
cleanupDraggable();
|
|
1021
|
-
cleanupDropTarget();
|
|
1022
|
-
};
|
|
1023
|
-
});
|
|
1024
|
-
return () => {
|
|
1025
|
-
cancelled = true;
|
|
1026
|
-
cleanup?.();
|
|
1027
|
-
};
|
|
1028
|
-
}, [id, index, onReorder, setDragState]);
|
|
1029
|
-
const isDropTarget = dragState.targetId === id && dragState.sourceId !== id;
|
|
1030
|
-
const onEditableActivity = (e) => {
|
|
1031
|
-
const t = e.target;
|
|
1032
|
-
if (t.matches?.("input, textarea, [contenteditable], [contenteditable='true']")) {
|
|
1033
|
-
setEditingSuppressed(true);
|
|
1034
|
-
}
|
|
1035
|
-
};
|
|
1036
|
-
return /* @__PURE__ */ jsxs5(
|
|
1037
|
-
"div",
|
|
1038
|
-
{
|
|
1039
|
-
ref: rowRef,
|
|
1040
|
-
className: cn(
|
|
1041
|
-
"group/row relative grid gap-x-3",
|
|
1042
|
-
hasAnyIcon ? "grid-cols-[24px_1fr]" : "grid-cols-1",
|
|
1043
|
-
isDropTarget && "border-t-2 border-primary"
|
|
1044
|
-
),
|
|
1045
|
-
onFocusCapture: onEditableActivity,
|
|
1046
|
-
onInput: onEditableActivity,
|
|
1047
|
-
onMouseMove: () => setEditingSuppressed(false),
|
|
1048
|
-
children: [
|
|
1049
|
-
hasAnyIcon && /* @__PURE__ */ jsxs5(
|
|
1050
|
-
"div",
|
|
1051
|
-
{
|
|
1052
|
-
"data-testid": "icon-list-icon",
|
|
1053
|
-
className: cn("relative flex items-start pt-0.5", iconColor),
|
|
1054
|
-
onMouseEnter: () => setIconHover(true),
|
|
1055
|
-
onMouseLeave: () => setIconHover(false),
|
|
1056
|
-
children: [
|
|
1057
|
-
/* @__PURE__ */ jsx13(
|
|
1058
|
-
"button",
|
|
1059
|
-
{
|
|
1060
|
-
className: "cursor-pointer transition-opacity hover:opacity-70",
|
|
1061
|
-
"aria-label": "Change icon",
|
|
1062
|
-
onClick: () => setPickerOpen((prev) => !prev),
|
|
1063
|
-
children: iconHover && !pickerOpen ? /* @__PURE__ */ jsx13(Pencil, { size: 18, className: "text-base-contrast-light" }) : iconEntry ? /* @__PURE__ */ jsx13(iconEntry.icon, { size: 18 }) : /* @__PURE__ */ jsx13("span", { className: "flex h-[18px] w-[18px] items-center justify-center rounded-sm border border-dashed border-base-contrast-light/40" })
|
|
1064
|
-
}
|
|
1065
|
-
),
|
|
1066
|
-
pickerOpen && /* @__PURE__ */ jsx13("div", { className: "absolute top-full left-0 z-50 mt-1", children: /* @__PURE__ */ jsx13(
|
|
1067
|
-
IconPicker,
|
|
1068
|
-
{
|
|
1069
|
-
selected: effectiveIconId,
|
|
1070
|
-
showRemove: true,
|
|
1071
|
-
allowDoDont: true,
|
|
1072
|
-
dodont: item.dodont,
|
|
1073
|
-
onSelect: (newIcon) => {
|
|
1074
|
-
onUpdateItem({ icon: newIcon ?? void 0, dodont: void 0 });
|
|
1075
|
-
setPickerOpen(false);
|
|
1076
|
-
setIconHover(false);
|
|
1077
|
-
},
|
|
1078
|
-
onSelectDoDont: (v) => {
|
|
1079
|
-
onUpdateItem({ dodont: v });
|
|
1080
|
-
if (v !== void 0) {
|
|
1081
|
-
setPickerOpen(false);
|
|
1082
|
-
setIconHover(false);
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
onClose: () => {
|
|
1086
|
-
setPickerOpen(false);
|
|
1087
|
-
setIconHover(false);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
) })
|
|
1091
|
-
]
|
|
1092
|
-
}
|
|
1093
|
-
),
|
|
1094
|
-
/* @__PURE__ */ jsxs5("div", { className: stackText ? "flex flex-col" : void 0, children: [
|
|
1095
|
-
showLabel && /* @__PURE__ */ jsx13(
|
|
1096
|
-
EditablePlainText,
|
|
1097
|
-
{
|
|
1098
|
-
tag: "span",
|
|
1099
|
-
value: item.label,
|
|
1100
|
-
onChange: (label) => onUpdateItem({ label }),
|
|
1101
|
-
isEditMode: true,
|
|
1102
|
-
placeholder: "Label",
|
|
1103
|
-
className: cn(labelClassName, !stackText && "mr-1")
|
|
1104
|
-
}
|
|
1105
|
-
),
|
|
1106
|
-
/* @__PURE__ */ jsx13(
|
|
1107
|
-
EditablePlainText,
|
|
1108
|
-
{
|
|
1109
|
-
tag: "span",
|
|
1110
|
-
value: item.text,
|
|
1111
|
-
onChange: (text) => onUpdateItem({ text }),
|
|
1112
|
-
isEditMode: true,
|
|
1113
|
-
placeholder: "Text",
|
|
1114
|
-
className: textClassName
|
|
1115
|
-
}
|
|
1116
|
-
)
|
|
1117
|
-
] }),
|
|
1118
|
-
/* @__PURE__ */ jsxs5(
|
|
1119
|
-
"div",
|
|
1120
|
-
{
|
|
1121
|
-
className: cn(
|
|
1122
|
-
"absolute right-1 top-1 z-10 flex items-center gap-1",
|
|
1123
|
-
editingSuppressed ? "opacity-0 pointer-events-none" : "opacity-0 group-hover/row:opacity-100 no-hover:opacity-100"
|
|
1124
|
-
),
|
|
1125
|
-
children: [
|
|
1126
|
-
/* @__PURE__ */ jsx13(
|
|
1127
|
-
IconButton,
|
|
1128
|
-
{
|
|
1129
|
-
ref: handleRef,
|
|
1130
|
-
icon: /* @__PURE__ */ jsx13(DragHandle, { size: 14 }),
|
|
1131
|
-
label: "Drag to reorder",
|
|
1132
|
-
size: "sm",
|
|
1133
|
-
className: "cursor-grab rounded bg-base/80 p-1 shadow-sm text-base-contrast-light/80 hover:text-base-contrast active:cursor-grabbing",
|
|
1134
|
-
tabIndex: -1
|
|
1135
|
-
}
|
|
1136
|
-
),
|
|
1137
|
-
/* @__PURE__ */ jsx13(
|
|
1138
|
-
"button",
|
|
1139
|
-
{
|
|
1140
|
-
"aria-label": "Duplicate item",
|
|
1141
|
-
onClick: onDuplicate,
|
|
1142
|
-
className: "cursor-pointer rounded bg-base/80 p-1 shadow-sm text-base-contrast-light hover:text-primary",
|
|
1143
|
-
children: /* @__PURE__ */ jsx13(CopyPlus, { size: 14 })
|
|
1144
|
-
}
|
|
1145
|
-
),
|
|
1146
|
-
/* @__PURE__ */ jsx13(
|
|
1147
|
-
IconButton,
|
|
1148
|
-
{
|
|
1149
|
-
icon: /* @__PURE__ */ jsx13(DeleteIcon, { size: 14 }),
|
|
1150
|
-
label: "Delete item",
|
|
1151
|
-
size: "sm",
|
|
1152
|
-
intent: "destructive",
|
|
1153
|
-
onClick: () => onRemove(id),
|
|
1154
|
-
className: "bg-base/80 shadow-sm"
|
|
1155
|
-
}
|
|
1156
|
-
)
|
|
1157
|
-
]
|
|
1158
|
-
}
|
|
1159
|
-
)
|
|
1160
|
-
]
|
|
1161
|
-
}
|
|
1162
|
-
);
|
|
1163
|
-
}
|
|
1164
|
-
function TrailingDropZone({
|
|
1165
|
-
index,
|
|
1166
|
-
dragState,
|
|
1167
|
-
setDragState,
|
|
1168
|
-
onReorder
|
|
1169
|
-
}) {
|
|
1170
|
-
const ref = useRef2(null);
|
|
1171
|
-
const trailingId = "__trailing__";
|
|
1172
|
-
useEffect3(() => {
|
|
1173
|
-
const el = ref.current;
|
|
1174
|
-
if (!el) return;
|
|
1175
|
-
let cleanup;
|
|
1176
|
-
let cancelled = false;
|
|
1177
|
-
import("../../adapter-HH47ZPGM.js").then(({ dropTargetForElements }) => {
|
|
1178
|
-
if (cancelled) return;
|
|
1179
|
-
cleanup = dropTargetForElements({
|
|
1180
|
-
element: el,
|
|
1181
|
-
canDrop: ({ source }) => source.data.dragType === "icon-list-row",
|
|
1182
|
-
getData: () => ({ id: trailingId, index }),
|
|
1183
|
-
onDragEnter: () => setDragState((prev) => ({ ...prev, targetId: trailingId })),
|
|
1184
|
-
onDragLeave: () => setDragState(
|
|
1185
|
-
(prev) => prev.targetId === trailingId ? { ...prev, targetId: null } : prev
|
|
1186
|
-
),
|
|
1187
|
-
onDrop: ({ source }) => {
|
|
1188
|
-
const fromIndex = source.data.index;
|
|
1189
|
-
if (fromIndex !== index - 1) onReorder(fromIndex, index - 1);
|
|
1190
|
-
}
|
|
1191
|
-
});
|
|
1192
|
-
});
|
|
1193
|
-
return () => {
|
|
1194
|
-
cancelled = true;
|
|
1195
|
-
cleanup?.();
|
|
1196
|
-
};
|
|
1197
|
-
}, [index, onReorder, setDragState]);
|
|
1198
|
-
const isDropTarget = dragState.targetId === trailingId && dragState.sourceId !== null;
|
|
1199
|
-
return /* @__PURE__ */ jsx13(
|
|
1200
|
-
"div",
|
|
1201
|
-
{
|
|
1202
|
-
ref,
|
|
1203
|
-
className: cn("absolute bottom-0 left-0 right-0 h-4", isDropTarget && "border-t-2 border-primary")
|
|
1204
|
-
}
|
|
1205
|
-
);
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
// src/components/sections/IconList/IconListSettings.tsx
|
|
1209
|
-
import { useState as useState5 } from "react";
|
|
1210
|
-
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1211
|
-
function IconListSettings({
|
|
1212
|
-
icon: initialIcon,
|
|
1213
|
-
showLabel: initialShowLabel,
|
|
1214
|
-
stackText: initialStackText,
|
|
1215
|
-
onChange
|
|
1216
|
-
}) {
|
|
1217
|
-
const [icon, setIcon] = useState5(initialIcon);
|
|
1218
|
-
const [showLabel, setShowLabel] = useState5(initialShowLabel);
|
|
1219
|
-
const [stackText, setStackText] = useState5(initialStackText);
|
|
1220
|
-
const [pickerOpen, setPickerOpen] = useState5(false);
|
|
1221
|
-
const emit = (overrides) => onChange({ content: {}, options: { icon, showLabel, stackText, ...overrides } });
|
|
1222
|
-
const showIcons = icon !== null;
|
|
1223
|
-
const iconEntry = icon ? getIcon(icon) : null;
|
|
1224
|
-
return /* @__PURE__ */ jsxs6("div", { className: "space-y-4", children: [
|
|
1225
|
-
/* @__PURE__ */ jsxs6("div", { className: "relative", children: [
|
|
1226
|
-
/* @__PURE__ */ jsx14(FormLabel, { htmlFor: "icon-picker-btn", children: "Default Icon" }),
|
|
1227
|
-
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2", children: [
|
|
1228
|
-
/* @__PURE__ */ jsxs6(
|
|
1229
|
-
"button",
|
|
1230
|
-
{
|
|
1231
|
-
id: "icon-picker-btn",
|
|
1232
|
-
className: "cursor-pointer flex items-center gap-2 rounded border border-base-200 px-3 py-1.5 text-sm text-base-contrast-light hover:border-primary hover:text-primary",
|
|
1233
|
-
onClick: () => setPickerOpen((prev) => !prev),
|
|
1234
|
-
children: [
|
|
1235
|
-
iconEntry && /* @__PURE__ */ jsx14(iconEntry.icon, { size: 16 }),
|
|
1236
|
-
/* @__PURE__ */ jsx14("span", { children: iconEntry?.label ?? "None" })
|
|
1237
|
-
]
|
|
1238
|
-
}
|
|
1239
|
-
),
|
|
1240
|
-
icon && /* @__PURE__ */ jsx14(
|
|
1241
|
-
"button",
|
|
1242
|
-
{
|
|
1243
|
-
className: "cursor-pointer text-xs text-base-contrast-light hover:text-base-contrast",
|
|
1244
|
-
onClick: () => {
|
|
1245
|
-
setIcon(null);
|
|
1246
|
-
emit({ icon: null });
|
|
1247
|
-
},
|
|
1248
|
-
children: "Clear"
|
|
1249
|
-
}
|
|
1250
|
-
)
|
|
1251
|
-
] }),
|
|
1252
|
-
pickerOpen && /* @__PURE__ */ jsx14("div", { className: "absolute top-full left-0 z-50 mt-1", children: /* @__PURE__ */ jsx14(
|
|
1253
|
-
IconPicker,
|
|
1254
|
-
{
|
|
1255
|
-
selected: icon,
|
|
1256
|
-
onSelect: (newIcon) => {
|
|
1257
|
-
if (newIcon !== null) {
|
|
1258
|
-
setIcon(newIcon);
|
|
1259
|
-
emit({ icon: newIcon });
|
|
1260
|
-
}
|
|
1261
|
-
setPickerOpen(false);
|
|
1262
|
-
},
|
|
1263
|
-
onClose: () => setPickerOpen(false)
|
|
1264
|
-
}
|
|
1265
|
-
) })
|
|
1266
|
-
] }),
|
|
1267
|
-
/* @__PURE__ */ jsx14(
|
|
1268
|
-
Checkbox,
|
|
1269
|
-
{
|
|
1270
|
-
checked: showLabel,
|
|
1271
|
-
onChange: (v) => {
|
|
1272
|
-
setShowLabel(v);
|
|
1273
|
-
emit({ showLabel: v });
|
|
1274
|
-
},
|
|
1275
|
-
label: "Show labels"
|
|
1276
|
-
}
|
|
1277
|
-
),
|
|
1278
|
-
showLabel && /* @__PURE__ */ jsx14(
|
|
1279
|
-
Checkbox,
|
|
1280
|
-
{
|
|
1281
|
-
checked: stackText,
|
|
1282
|
-
onChange: (v) => {
|
|
1283
|
-
setStackText(v);
|
|
1284
|
-
emit({ stackText: v });
|
|
1285
|
-
},
|
|
1286
|
-
label: "Stack label above text"
|
|
1287
|
-
}
|
|
1288
|
-
)
|
|
1289
|
-
] });
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
// src/components/sections/IconList/index.tsx
|
|
1293
|
-
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1294
|
-
var IconListItemSchema = z5.object({
|
|
1295
|
-
label: z5.string(),
|
|
1296
|
-
text: z5.string(),
|
|
1297
|
-
icon: z5.string().optional(),
|
|
1298
|
-
dodont: z5.enum(["do", "dont"]).optional()
|
|
1299
|
-
});
|
|
1300
|
-
var schema5 = z5.object({
|
|
1301
|
-
type: z5.literal("icon_list"),
|
|
1302
|
-
content: z5.object({
|
|
1303
|
-
items: z5.array(IconListItemSchema)
|
|
1304
|
-
}),
|
|
1305
|
-
options: z5.object({
|
|
1306
|
-
icon: z5.string().nullable().optional(),
|
|
1307
|
-
showLabel: z5.boolean().optional(),
|
|
1308
|
-
stackText: z5.boolean().optional()
|
|
1309
|
-
}).optional()
|
|
1310
|
-
});
|
|
1311
|
-
var IconList_default = defineSection({
|
|
1312
|
-
type: "icon_list",
|
|
1313
|
-
label: "Icon List",
|
|
1314
|
-
icon: /* @__PURE__ */ jsx15(List, { size: 18 }),
|
|
1315
|
-
schema: schema5,
|
|
1316
|
-
component: ({ content, options, onChange }) => /* @__PURE__ */ jsx15(
|
|
1317
|
-
IconList,
|
|
1318
|
-
{
|
|
1319
|
-
items: content.content.items,
|
|
1320
|
-
icon: options?.icon,
|
|
1321
|
-
showLabel: options?.showLabel,
|
|
1322
|
-
stackText: options?.stackText,
|
|
1323
|
-
onChange: onChange ? (c) => onChange(c) : void 0
|
|
1324
|
-
}
|
|
1325
|
-
),
|
|
1326
|
-
defaults: () => ({
|
|
1327
|
-
type: "icon_list",
|
|
1328
|
-
content: { items: [{ label: "", text: "" }] }
|
|
1329
|
-
}),
|
|
1330
|
-
getLabel: (content) => pluralize(content.content.items.length, "icon"),
|
|
1331
|
-
settingsForm: IconListSettings
|
|
1332
|
-
});
|
|
1333
|
-
|
|
1334
286
|
// src/components/sections/Container/index.tsx
|
|
1335
|
-
import { z as
|
|
287
|
+
import { z as z4 } from "zod";
|
|
1336
288
|
import { LayoutTemplate } from "lucide-react";
|
|
1337
289
|
|
|
1338
290
|
// src/components/sections/Container/Container.tsx
|
|
@@ -1340,19 +292,19 @@ import "react";
|
|
|
1340
292
|
|
|
1341
293
|
// src/components/editor/ChildBlockWrapper.tsx
|
|
1342
294
|
import { forwardRef } from "react";
|
|
1343
|
-
import { CopyPlus
|
|
295
|
+
import { CopyPlus } from "lucide-react";
|
|
1344
296
|
|
|
1345
297
|
// src/components/editor/ColSpanControl.tsx
|
|
1346
|
-
import { useRef
|
|
298
|
+
import { useRef, useState } from "react";
|
|
1347
299
|
import { Columns3 } from "lucide-react";
|
|
1348
|
-
import { jsx as
|
|
300
|
+
import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1349
301
|
function ColSpanControl({ colSpan, columns, onChange }) {
|
|
1350
|
-
const buttonRef =
|
|
1351
|
-
const [open, setOpen] =
|
|
302
|
+
const buttonRef = useRef(null);
|
|
303
|
+
const [open, setOpen] = useState(false);
|
|
1352
304
|
if (columns <= 1) return null;
|
|
1353
305
|
const current = Math.min(Math.max(colSpan, 1), columns);
|
|
1354
|
-
return /* @__PURE__ */
|
|
1355
|
-
/* @__PURE__ */
|
|
306
|
+
return /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
|
|
307
|
+
/* @__PURE__ */ jsx9(
|
|
1356
308
|
"button",
|
|
1357
309
|
{
|
|
1358
310
|
ref: buttonRef,
|
|
@@ -1362,10 +314,10 @@ function ColSpanControl({ colSpan, columns, onChange }) {
|
|
|
1362
314
|
"aria-expanded": open,
|
|
1363
315
|
onClick: () => setOpen((v) => !v),
|
|
1364
316
|
className: "pointer-events-auto inline-flex cursor-pointer items-center gap-1 rounded p-1 text-xs text-base-contrast-light hover:text-primary",
|
|
1365
|
-
children: /* @__PURE__ */
|
|
317
|
+
children: /* @__PURE__ */ jsx9(Columns3, { size: 14 })
|
|
1366
318
|
}
|
|
1367
319
|
),
|
|
1368
|
-
/* @__PURE__ */
|
|
320
|
+
/* @__PURE__ */ jsx9(Popover, { isOpen: open, onClose: () => setOpen(false), anchorRef: buttonRef, className: "min-w-28", children: /* @__PURE__ */ jsx9("ul", { role: "list", className: "py-1", children: Array.from({ length: columns }, (_, i) => i + 1).map((span) => /* @__PURE__ */ jsx9("li", { children: /* @__PURE__ */ jsxs2(
|
|
1369
321
|
PopoverItem,
|
|
1370
322
|
{
|
|
1371
323
|
"aria-current": span === current,
|
|
@@ -1384,7 +336,7 @@ function ColSpanControl({ colSpan, columns, onChange }) {
|
|
|
1384
336
|
}
|
|
1385
337
|
|
|
1386
338
|
// src/components/editor/ChildBlockWrapper.tsx
|
|
1387
|
-
import { jsx as
|
|
339
|
+
import { jsx as jsx10, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1388
340
|
var ChildBlockWrapper = forwardRef(
|
|
1389
341
|
function ChildBlockWrapper2({
|
|
1390
342
|
label,
|
|
@@ -1400,7 +352,7 @@ var ChildBlockWrapper = forwardRef(
|
|
|
1400
352
|
onOpenSettings,
|
|
1401
353
|
children
|
|
1402
354
|
}, ref) {
|
|
1403
|
-
return /* @__PURE__ */
|
|
355
|
+
return /* @__PURE__ */ jsxs3(
|
|
1404
356
|
"div",
|
|
1405
357
|
{
|
|
1406
358
|
ref,
|
|
@@ -1410,39 +362,39 @@ var ChildBlockWrapper = forwardRef(
|
|
|
1410
362
|
"hover:outline hover:outline-2 hover:outline-primary/30"
|
|
1411
363
|
),
|
|
1412
364
|
children: [
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
/* @__PURE__ */
|
|
1415
|
-
/* @__PURE__ */
|
|
1416
|
-
/* @__PURE__ */
|
|
1417
|
-
hasSettings && onOpenSettings && /* @__PURE__ */
|
|
1418
|
-
/* @__PURE__ */
|
|
365
|
+
/* @__PURE__ */ jsxs3("div", { className: "absolute top-0 left-0 -translate-x-full z-20 flex flex-col items-center gap-1 opacity-0 transition-opacity group-hover/childblock:opacity-100 group-focus-within/childblock:opacity-100 pointer-events-none", children: [
|
|
366
|
+
/* @__PURE__ */ jsx10("span", { className: "sr-only", children: label }),
|
|
367
|
+
/* @__PURE__ */ jsx10("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx10(DragHandle, { ref: dragHandleRef }) }),
|
|
368
|
+
/* @__PURE__ */ jsx10("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx10(ColSpanControl, { colSpan, columns, onChange: onColSpanChange }) }),
|
|
369
|
+
hasSettings && onOpenSettings && /* @__PURE__ */ jsx10("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx10(SettingsButton, { onClick: onOpenSettings }) }),
|
|
370
|
+
/* @__PURE__ */ jsx10("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx10(
|
|
1419
371
|
"button",
|
|
1420
372
|
{
|
|
1421
373
|
type: "button",
|
|
1422
374
|
"aria-label": "Duplicate block",
|
|
1423
375
|
onClick: onDuplicate,
|
|
1424
376
|
className: "cursor-pointer rounded p-1 text-base-contrast-light hover:text-primary",
|
|
1425
|
-
children: /* @__PURE__ */
|
|
377
|
+
children: /* @__PURE__ */ jsx10(CopyPlus, { size: 16 })
|
|
1426
378
|
}
|
|
1427
379
|
) }),
|
|
1428
|
-
/* @__PURE__ */
|
|
380
|
+
/* @__PURE__ */ jsx10("div", { className: "pointer-events-auto", children: /* @__PURE__ */ jsx10(DeleteButton, { onDelete }) })
|
|
1429
381
|
] }),
|
|
1430
|
-
closestEdge === "left" && /* @__PURE__ */
|
|
382
|
+
closestEdge === "left" && /* @__PURE__ */ jsx10(
|
|
1431
383
|
"div",
|
|
1432
384
|
{
|
|
1433
385
|
"data-drop-edge": "left",
|
|
1434
386
|
className: "absolute bottom-0 left-0 top-0 z-10 w-0.5 -translate-x-1 bg-primary"
|
|
1435
387
|
}
|
|
1436
388
|
),
|
|
1437
|
-
closestEdge === "right" && /* @__PURE__ */
|
|
389
|
+
closestEdge === "right" && /* @__PURE__ */ jsx10(
|
|
1438
390
|
"div",
|
|
1439
391
|
{
|
|
1440
392
|
"data-drop-edge": "right",
|
|
1441
393
|
className: "absolute bottom-0 right-0 top-0 z-10 w-0.5 translate-x-1 bg-primary"
|
|
1442
394
|
}
|
|
1443
395
|
),
|
|
1444
|
-
closestEdge === "top" && /* @__PURE__ */
|
|
1445
|
-
closestEdge === "bottom" && /* @__PURE__ */
|
|
396
|
+
closestEdge === "top" && /* @__PURE__ */ jsx10("div", { "data-drop-edge": "top", className: "absolute left-0 right-0 top-0 z-10 h-0.5 -translate-y-1 bg-primary" }),
|
|
397
|
+
closestEdge === "bottom" && /* @__PURE__ */ jsx10("div", { "data-drop-edge": "bottom", className: "absolute left-0 right-0 bottom-0 z-10 h-0.5 translate-y-1 bg-primary" }),
|
|
1446
398
|
children
|
|
1447
399
|
]
|
|
1448
400
|
}
|
|
@@ -1451,13 +403,13 @@ var ChildBlockWrapper = forwardRef(
|
|
|
1451
403
|
);
|
|
1452
404
|
|
|
1453
405
|
// src/hooks/useBlockDnd.ts
|
|
1454
|
-
import { useEffect
|
|
406
|
+
import { useEffect, useRef as useRef2, useState as useState2 } from "react";
|
|
1455
407
|
function useBlockDnd({ blockId, containerId, index, isContainer, allowedEdges, enabled }) {
|
|
1456
|
-
const dragRef =
|
|
1457
|
-
const handleRef =
|
|
1458
|
-
const [closestEdge, setClosestEdge] =
|
|
1459
|
-
const [isDragging, setIsDragging] =
|
|
1460
|
-
|
|
408
|
+
const dragRef = useRef2(null);
|
|
409
|
+
const handleRef = useRef2(null);
|
|
410
|
+
const [closestEdge, setClosestEdge] = useState2(null);
|
|
411
|
+
const [isDragging, setIsDragging] = useState2(false);
|
|
412
|
+
useEffect(() => {
|
|
1461
413
|
const element = dragRef.current;
|
|
1462
414
|
const handle = handleRef.current;
|
|
1463
415
|
if (!element || !enabled) return;
|
|
@@ -1513,9 +465,9 @@ function useBlockDnd({ blockId, containerId, index, isContainer, allowedEdges, e
|
|
|
1513
465
|
return { dragRef, handleRef, closestEdge, isDragging };
|
|
1514
466
|
}
|
|
1515
467
|
function useBlockDropZone({ containerId, index, toColumn, allowedEdges, enabled }) {
|
|
1516
|
-
const dropRef =
|
|
1517
|
-
const [closestEdge, setClosestEdge] =
|
|
1518
|
-
|
|
468
|
+
const dropRef = useRef2(null);
|
|
469
|
+
const [closestEdge, setClosestEdge] = useState2(null);
|
|
470
|
+
useEffect(() => {
|
|
1519
471
|
const element = dropRef.current;
|
|
1520
472
|
if (!element || !enabled) return;
|
|
1521
473
|
let cleanup;
|
|
@@ -1612,7 +564,7 @@ function trimTrailingSpacers(container) {
|
|
|
1612
564
|
}
|
|
1613
565
|
|
|
1614
566
|
// src/components/sections/Container/Container.tsx
|
|
1615
|
-
import { jsx as
|
|
567
|
+
import { jsx as jsx11, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1616
568
|
var ROW_EDGES = ["left", "right"];
|
|
1617
569
|
var COL_EDGES = ["top", "bottom"];
|
|
1618
570
|
function ContainerChild({
|
|
@@ -1643,14 +595,14 @@ function ContainerChild({
|
|
|
1643
595
|
allowedEdges: flow === "column" ? COL_EDGES : ROW_EDGES,
|
|
1644
596
|
enabled: true
|
|
1645
597
|
});
|
|
1646
|
-
return /* @__PURE__ */
|
|
598
|
+
return /* @__PURE__ */ jsx11(
|
|
1647
599
|
"div",
|
|
1648
600
|
{
|
|
1649
601
|
ref: dragRef,
|
|
1650
602
|
className: cellClass,
|
|
1651
603
|
"data-child-index": index,
|
|
1652
604
|
"data-child-id": child.id,
|
|
1653
|
-
children: /* @__PURE__ */
|
|
605
|
+
children: /* @__PURE__ */ jsx11(
|
|
1654
606
|
ChildBlockWrapper,
|
|
1655
607
|
{
|
|
1656
608
|
label,
|
|
@@ -1664,7 +616,7 @@ function ContainerChild({
|
|
|
1664
616
|
onDuplicate,
|
|
1665
617
|
onColSpanChange,
|
|
1666
618
|
onOpenSettings,
|
|
1667
|
-
children: /* @__PURE__ */
|
|
619
|
+
children: /* @__PURE__ */ jsx11(
|
|
1668
620
|
ChildComp,
|
|
1669
621
|
{
|
|
1670
622
|
content: child,
|
|
@@ -1692,7 +644,7 @@ function EmptyColumnCell({
|
|
|
1692
644
|
enabled: true
|
|
1693
645
|
});
|
|
1694
646
|
const active = closestEdge !== null;
|
|
1695
|
-
return /* @__PURE__ */
|
|
647
|
+
return /* @__PURE__ */ jsx11(
|
|
1696
648
|
"div",
|
|
1697
649
|
{
|
|
1698
650
|
ref: dropRef,
|
|
@@ -1730,7 +682,7 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1730
682
|
flow === "column" && "grid-flow-col"
|
|
1731
683
|
);
|
|
1732
684
|
if (!editable) {
|
|
1733
|
-
return /* @__PURE__ */
|
|
685
|
+
return /* @__PURE__ */ jsx11("div", { className: "@container", children: /* @__PURE__ */ jsx11("div", { className: gridClass, children: children.map((child, index) => {
|
|
1734
686
|
const def = getSection(child.type);
|
|
1735
687
|
if (!def) return null;
|
|
1736
688
|
const Child = def.component;
|
|
@@ -1741,7 +693,7 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1741
693
|
colSpanClass[columns]?.[Math.min(span, columns)] || void 0,
|
|
1742
694
|
child.type === "spacer" && spacerHiddenClass[columns]
|
|
1743
695
|
);
|
|
1744
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsx11("div", { className: cellClass, children: /* @__PURE__ */ jsx11(Child, { content: child, options: mergedOptions, isEditMode }) }, child.id ?? index);
|
|
1745
697
|
}) }) });
|
|
1746
698
|
}
|
|
1747
699
|
function columnStartOf(index) {
|
|
@@ -1755,7 +707,7 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1755
707
|
const def = getSection(child.type);
|
|
1756
708
|
if (!def) return null;
|
|
1757
709
|
if (isSpacer(child)) {
|
|
1758
|
-
return /* @__PURE__ */
|
|
710
|
+
return /* @__PURE__ */ jsx11(
|
|
1759
711
|
EmptyColumnCell,
|
|
1760
712
|
{
|
|
1761
713
|
containerId: container.id,
|
|
@@ -1783,12 +735,12 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1783
735
|
const CustomForm = def.settingsForm;
|
|
1784
736
|
openModal(
|
|
1785
737
|
`${def.label} Settings`,
|
|
1786
|
-
/* @__PURE__ */
|
|
738
|
+
/* @__PURE__ */ jsx11(CustomForm, { ...seed, onChange: applyResult })
|
|
1787
739
|
);
|
|
1788
740
|
} else if (def.settings) {
|
|
1789
741
|
openModal(
|
|
1790
742
|
`${def.label} Settings`,
|
|
1791
|
-
/* @__PURE__ */
|
|
743
|
+
/* @__PURE__ */ jsx11(
|
|
1792
744
|
SettingsForm,
|
|
1793
745
|
{
|
|
1794
746
|
schema: def.settings,
|
|
@@ -1800,7 +752,7 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1800
752
|
);
|
|
1801
753
|
}
|
|
1802
754
|
} : void 0;
|
|
1803
|
-
return /* @__PURE__ */
|
|
755
|
+
return /* @__PURE__ */ jsx11(
|
|
1804
756
|
ContainerChild,
|
|
1805
757
|
{
|
|
1806
758
|
containerId: container.id,
|
|
@@ -1826,9 +778,9 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1826
778
|
}
|
|
1827
779
|
const occupied = occupiedColumns(children, columns);
|
|
1828
780
|
const emptyCols = occupied < columns ? columns - occupied : 0;
|
|
1829
|
-
return /* @__PURE__ */
|
|
781
|
+
return /* @__PURE__ */ jsx11("div", { className: "@container", children: /* @__PURE__ */ jsxs4("div", { className: gridClass, children: [
|
|
1830
782
|
children.map(renderEditChild),
|
|
1831
|
-
Array.from({ length: emptyCols }, (_, i) => /* @__PURE__ */
|
|
783
|
+
Array.from({ length: emptyCols }, (_, i) => /* @__PURE__ */ jsx11(
|
|
1832
784
|
EmptyColumnCell,
|
|
1833
785
|
{
|
|
1834
786
|
containerId: container.id,
|
|
@@ -1841,8 +793,8 @@ function Container({ content, isEditMode, onChange, openModal }) {
|
|
|
1841
793
|
}
|
|
1842
794
|
|
|
1843
795
|
// src/components/sections/Container/ContainerSettingsForm.tsx
|
|
1844
|
-
import { useState as
|
|
1845
|
-
import { jsx as
|
|
796
|
+
import { useState as useState3 } from "react";
|
|
797
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1846
798
|
function inheritableSchema(children) {
|
|
1847
799
|
const out = {};
|
|
1848
800
|
for (const child of children) {
|
|
@@ -1862,8 +814,8 @@ function ContainerSettingsForm({
|
|
|
1862
814
|
children = [],
|
|
1863
815
|
onChange
|
|
1864
816
|
}) {
|
|
1865
|
-
const [layout, setLayout] =
|
|
1866
|
-
const [defaults, setDefaults] =
|
|
817
|
+
const [layout, setLayout] = useState3({ columns, flow });
|
|
818
|
+
const [defaults, setDefaults] = useState3(childDefaults);
|
|
1867
819
|
const childSchema = inheritableSchema(children);
|
|
1868
820
|
const hasChildDefaults = Object.keys(childSchema).length > 0;
|
|
1869
821
|
function emit(nextLayout, nextDefaults) {
|
|
@@ -1892,10 +844,10 @@ function ContainerSettingsForm({
|
|
|
1892
844
|
]
|
|
1893
845
|
}
|
|
1894
846
|
};
|
|
1895
|
-
return /* @__PURE__ */
|
|
1896
|
-
/* @__PURE__ */
|
|
1897
|
-
/* @__PURE__ */
|
|
1898
|
-
/* @__PURE__ */
|
|
847
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col gap-6", children: [
|
|
848
|
+
/* @__PURE__ */ jsxs5("fieldset", { className: "flex flex-col gap-4", children: [
|
|
849
|
+
/* @__PURE__ */ jsx12("legend", { className: "mb-2 text-sm font-semibold text-base-contrast", children: "Layout" }),
|
|
850
|
+
/* @__PURE__ */ jsx12(
|
|
1899
851
|
SettingsForm,
|
|
1900
852
|
{
|
|
1901
853
|
schema: layoutSchema,
|
|
@@ -1911,9 +863,9 @@ function ContainerSettingsForm({
|
|
|
1911
863
|
}
|
|
1912
864
|
)
|
|
1913
865
|
] }),
|
|
1914
|
-
hasChildDefaults && /* @__PURE__ */
|
|
1915
|
-
/* @__PURE__ */
|
|
1916
|
-
/* @__PURE__ */
|
|
866
|
+
hasChildDefaults && /* @__PURE__ */ jsxs5("fieldset", { className: "flex flex-col gap-4 border-t border-base-200 pt-4", children: [
|
|
867
|
+
/* @__PURE__ */ jsx12("legend", { className: "mb-2 text-sm font-semibold text-base-contrast", children: "Apply to all items" }),
|
|
868
|
+
/* @__PURE__ */ jsx12(
|
|
1917
869
|
SettingsForm,
|
|
1918
870
|
{
|
|
1919
871
|
schema: childSchema,
|
|
@@ -1930,16 +882,16 @@ function ContainerSettingsForm({
|
|
|
1930
882
|
}
|
|
1931
883
|
|
|
1932
884
|
// src/components/sections/Container/index.tsx
|
|
1933
|
-
import { jsx as
|
|
1934
|
-
var
|
|
1935
|
-
type:
|
|
1936
|
-
content:
|
|
1937
|
-
columns:
|
|
1938
|
-
flow:
|
|
1939
|
-
childDefaults:
|
|
885
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
886
|
+
var schema4 = z4.object({
|
|
887
|
+
type: z4.literal("container"),
|
|
888
|
+
content: z4.object({
|
|
889
|
+
columns: z4.number().int().min(1).max(MAX_CONTAINER_COLUMNS).default(1),
|
|
890
|
+
flow: z4.enum(["row", "column"]).default("row"),
|
|
891
|
+
childDefaults: z4.record(z4.string(), z4.unknown()).optional(),
|
|
1940
892
|
// Recursive: children are full blocks. z.lazy defers evaluation to parse
|
|
1941
893
|
// time, by which point every section schema (incl. container) is registered.
|
|
1942
|
-
children:
|
|
894
|
+
children: z4.array(z4.lazy(() => getSectionSchema())).default([])
|
|
1943
895
|
}).transform((c) => ({
|
|
1944
896
|
...c,
|
|
1945
897
|
children: c.children.map(
|
|
@@ -1950,9 +902,9 @@ var schema6 = z6.object({
|
|
|
1950
902
|
var Container_default = defineSection({
|
|
1951
903
|
type: "container",
|
|
1952
904
|
label: "Container",
|
|
1953
|
-
icon: /* @__PURE__ */
|
|
1954
|
-
schema:
|
|
1955
|
-
component: ({ content, onChange, isEditMode, openModal }) => /* @__PURE__ */
|
|
905
|
+
icon: /* @__PURE__ */ jsx13(LayoutTemplate, { size: 18 }),
|
|
906
|
+
schema: schema4,
|
|
907
|
+
component: ({ content, onChange, isEditMode, openModal }) => /* @__PURE__ */ jsx13(Container, { content, isEditMode: !!isEditMode, onChange, openModal }),
|
|
1956
908
|
defaults: () => ({
|
|
1957
909
|
type: "container",
|
|
1958
910
|
content: { columns: 1, flow: "row", children: [] }
|
|
@@ -1962,44 +914,45 @@ var Container_default = defineSection({
|
|
|
1962
914
|
});
|
|
1963
915
|
|
|
1964
916
|
// src/components/sections/Spacer/index.tsx
|
|
1965
|
-
import { z as
|
|
917
|
+
import { z as z5 } from "zod";
|
|
1966
918
|
import { SquareDashed } from "lucide-react";
|
|
1967
919
|
|
|
1968
920
|
// src/components/sections/Spacer/Spacer.tsx
|
|
1969
|
-
import { jsx as
|
|
921
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1970
922
|
function Spacer() {
|
|
1971
|
-
return /* @__PURE__ */
|
|
923
|
+
return /* @__PURE__ */ jsx14("div", { "data-spacer": true, "aria-hidden": "true", className: "h-full" });
|
|
1972
924
|
}
|
|
1973
925
|
|
|
1974
926
|
// src/components/sections/Spacer/index.tsx
|
|
1975
|
-
import { jsx as
|
|
1976
|
-
var
|
|
1977
|
-
type:
|
|
1978
|
-
content:
|
|
927
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
928
|
+
var schema5 = z5.object({
|
|
929
|
+
type: z5.literal("spacer"),
|
|
930
|
+
content: z5.object({}).default({})
|
|
1979
931
|
});
|
|
1980
932
|
var Spacer_default = defineSection({
|
|
1981
933
|
type: "spacer",
|
|
1982
934
|
label: "Spacer",
|
|
1983
|
-
icon: /* @__PURE__ */
|
|
1984
|
-
schema:
|
|
1985
|
-
component: () => /* @__PURE__ */
|
|
935
|
+
icon: /* @__PURE__ */ jsx15(SquareDashed, { size: 18 }),
|
|
936
|
+
schema: schema5,
|
|
937
|
+
component: () => /* @__PURE__ */ jsx15(Spacer, {}),
|
|
1986
938
|
defaults: () => ({ type: "spacer", content: {} })
|
|
1987
939
|
});
|
|
1988
940
|
|
|
1989
|
-
// src/components/sections/
|
|
1990
|
-
var
|
|
941
|
+
// src/components/sections/core-sections.ts
|
|
942
|
+
var coreSectionDefs = [
|
|
1991
943
|
LinkHeading_default,
|
|
1992
944
|
SubHeading_default,
|
|
1993
945
|
SubSubHeading_default,
|
|
1994
946
|
Prose_default,
|
|
1995
947
|
Media_default,
|
|
1996
948
|
Button_default,
|
|
1997
|
-
Colors_default,
|
|
1998
|
-
IconList_default,
|
|
1999
949
|
Container_default,
|
|
2000
950
|
Spacer_default
|
|
2001
951
|
];
|
|
2002
952
|
|
|
953
|
+
// src/components/sections/all-sections.ts
|
|
954
|
+
var allSectionDefs = [...coreSectionDefs, ...brandGuideSectionDefs];
|
|
955
|
+
|
|
2003
956
|
// src/components/sections/register-schemas.ts
|
|
2004
957
|
var _ensured = false;
|
|
2005
958
|
function ensureSchemasRegistered() {
|