@drawnagency/primitives 0.1.59 → 0.1.61
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/auth/capabilities.d.ts +16 -0
- package/dist/auth/capabilities.d.ts.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +3 -1
- package/dist/auth/types.d.ts +26 -22
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/chunk-4OX3Z7SB.js +1421 -0
- package/dist/{chunk-RFZNNCAS.js → chunk-53DKVAB6.js} +1 -61
- package/dist/chunk-677NTHAZ.js +27 -0
- package/dist/chunk-7EOSDFS3.js +10 -0
- package/dist/{chunk-NTGSA3TI.js → chunk-AM5LZD6Q.js} +7 -30
- package/dist/{chunk-ICLXLWQ5.js → chunk-BT7STGDW.js} +31 -23
- package/dist/{chunk-L2JJFOXD.js → chunk-CBWK3KPV.js} +5 -1
- package/dist/{chunk-V7JN2DDU.js → chunk-ODCJQOVO.js} +1 -1
- package/dist/chunk-TZQPOR5A.js +24 -0
- package/dist/{chunk-XTK4BR27.js → chunk-UNWNT52N.js} +13 -0
- package/dist/chunk-UQ4OYRW7.js +670 -0
- package/dist/chunk-WDSVHKAH.js +54 -0
- package/dist/chunk-WLMJCNU7.js +70 -0
- package/dist/chunk-ZGFAYZWB.js +8 -0
- package/dist/components/editor/DropEdgeIndicator.d.ts +8 -0
- package/dist/components/editor/DropEdgeIndicator.d.ts.map +1 -0
- package/dist/components/editor/PagesModal.d.ts.map +1 -1
- package/dist/components/editor/SectionOrderingModal.d.ts.map +1 -1
- package/dist/components/editor/index.js +640 -0
- package/dist/components/primitives/defineHeadingSection.d.ts +28 -0
- package/dist/components/primitives/defineHeadingSection.d.ts.map +1 -0
- package/dist/components/primitives/index.d.ts +10 -0
- package/dist/components/primitives/index.d.ts.map +1 -0
- package/dist/components/primitives/index.js +166 -0
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/Container/index.d.ts.map +1 -1
- package/dist/components/sections/IconList/IconList.d.ts +1 -6
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -1
- package/dist/components/sections/IconList/index.d.ts +11 -0
- package/dist/components/sections/IconList/index.d.ts.map +1 -1
- package/dist/components/sections/LinkHeading/index.d.ts.map +1 -1
- package/dist/components/sections/SubHeading/index.d.ts +0 -1
- package/dist/components/sections/SubHeading/index.d.ts.map +1 -1
- package/dist/components/sections/SubSubHeading/index.d.ts +0 -1
- package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -1
- package/dist/components/sections/all-sections.d.ts +0 -2
- package/dist/components/sections/all-sections.d.ts.map +1 -1
- package/dist/components/sections/register-schemas.js +376 -2453
- package/dist/components/shell/BugReportFAB.d.ts.map +1 -1
- package/dist/hooks/useEditorPublish.d.ts.map +1 -1
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -1
- package/dist/hooks/useSortableRow.d.ts +25 -0
- package/dist/hooks/useSortableRow.d.ts.map +1 -0
- package/dist/index.js +46 -37
- package/dist/lib/image-refs.d.ts +21 -0
- package/dist/lib/image-refs.d.ts.map +1 -0
- package/dist/lib/index.js +21 -14
- package/dist/lib/platform-broker.d.ts +14 -0
- package/dist/lib/platform-broker.d.ts.map +1 -0
- package/dist/lib/platform-broker.js +60 -0
- package/dist/lib/reorder.d.ts +12 -0
- package/dist/lib/reorder.d.ts.map +1 -0
- package/dist/lib/text.d.ts +2 -0
- package/dist/lib/text.d.ts.map +1 -1
- package/dist/media/index.js +3 -2
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/schemas/index.js +17 -17
- package/dist/schemas/link.js +13 -0
- package/dist/types/database.d.ts +46 -0
- package/dist/types/database.d.ts.map +1 -1
- package/package.json +14 -2
- package/src/auth/capabilities.ts +26 -0
- package/src/auth/index.ts +3 -0
- package/src/auth/types.ts +36 -26
- package/src/components/editor/DropEdgeIndicator.tsx +13 -0
- package/src/components/editor/PagesModal.tsx +12 -80
- package/src/components/editor/SectionOrderingModal.tsx +8 -78
- package/src/components/primitives/defineHeadingSection.tsx +56 -0
- package/src/components/primitives/index.ts +11 -0
- package/src/components/sections/Colors/index.tsx +2 -4
- package/src/components/sections/Container/index.tsx +2 -4
- package/src/components/sections/IconList/IconList.tsx +1 -7
- package/src/components/sections/IconList/index.tsx +11 -5
- package/src/components/sections/LinkHeading/index.tsx +5 -20
- package/src/components/sections/SubHeading/index.tsx +6 -23
- package/src/components/sections/SubSubHeading/index.tsx +6 -23
- package/src/components/shell/BugReportFAB.tsx +13 -9
- package/src/hooks/useEditorPublish.ts +71 -49
- package/src/hooks/useMediaPipeline.ts +11 -34
- package/src/hooks/useSortableRow.ts +99 -0
- package/src/lib/image-refs.ts +53 -0
- package/src/lib/platform-broker.ts +72 -0
- package/src/lib/reorder.ts +20 -0
- package/src/lib/text.ts +5 -0
- package/src/media/utils.ts +6 -1
- package/src/types/database.ts +41 -0
- package/dist/chunk-DKOUFIP6.js +0 -35
- /package/dist/{chunk-ZU2MKPTG.js → chunk-3DCG4DNU.js} +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EditableGrid,
|
|
3
|
+
EditablePlainText,
|
|
4
|
+
EditableRichText,
|
|
5
|
+
ImageDropZone,
|
|
6
|
+
LinkPopover,
|
|
7
|
+
MediaBlock,
|
|
8
|
+
ResolvedMedia,
|
|
9
|
+
defineHeadingSection,
|
|
10
|
+
useEditableCollection
|
|
11
|
+
} from "../../chunk-4OX3Z7SB.js";
|
|
12
|
+
import {
|
|
13
|
+
DeleteIcon,
|
|
14
|
+
DragHandle,
|
|
15
|
+
IconButton
|
|
16
|
+
} from "../../chunk-WLMJCNU7.js";
|
|
17
|
+
import "../../chunk-CBWK3KPV.js";
|
|
18
|
+
import "../../chunk-53DKVAB6.js";
|
|
19
|
+
import {
|
|
20
|
+
cn
|
|
21
|
+
} from "../../chunk-7EOSDFS3.js";
|
|
22
|
+
import "../../chunk-ZGFAYZWB.js";
|
|
23
|
+
import "../../chunk-VKAGMEKE.js";
|
|
24
|
+
import "../../chunk-BT7STGDW.js";
|
|
25
|
+
import "../../chunk-JSBRDJBE.js";
|
|
26
|
+
|
|
27
|
+
// src/components/primitives/EditableList.tsx
|
|
28
|
+
import { useRef, useEffect, useState } from "react";
|
|
29
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
30
|
+
function EditableList({
|
|
31
|
+
items,
|
|
32
|
+
onChange,
|
|
33
|
+
createItem,
|
|
34
|
+
isEditMode,
|
|
35
|
+
renderItem,
|
|
36
|
+
className
|
|
37
|
+
}) {
|
|
38
|
+
const { wrappedItems, onReorder, onAdd, onRemove } = useEditableCollection({
|
|
39
|
+
items,
|
|
40
|
+
onChange,
|
|
41
|
+
createItem
|
|
42
|
+
});
|
|
43
|
+
const [dragState, setDragState] = useState({ sourceId: null, targetId: null });
|
|
44
|
+
if (!isEditMode) {
|
|
45
|
+
return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-2", className), children: wrappedItems.map((wrapped, index) => /* @__PURE__ */ jsx("div", { children: renderItem(wrapped.data, { isEditMode: false, index }) }, wrapped.id)) });
|
|
46
|
+
}
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2", className), children: [
|
|
48
|
+
wrappedItems.map((wrapped, index) => /* @__PURE__ */ jsx(
|
|
49
|
+
ListRow,
|
|
50
|
+
{
|
|
51
|
+
id: wrapped.id,
|
|
52
|
+
index,
|
|
53
|
+
onReorder,
|
|
54
|
+
onRemove,
|
|
55
|
+
dragState,
|
|
56
|
+
setDragState,
|
|
57
|
+
children: renderItem(wrapped.data, { isEditMode: true, index })
|
|
58
|
+
},
|
|
59
|
+
wrapped.id
|
|
60
|
+
)),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
"button",
|
|
63
|
+
{
|
|
64
|
+
onClick: onAdd,
|
|
65
|
+
className: "cursor-pointer rounded border-2 border-dashed border-base-200 px-3 py-2 text-sm text-base-contrast-light hover:border-primary hover:text-primary",
|
|
66
|
+
children: "Add row"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
function ListRow({
|
|
72
|
+
id,
|
|
73
|
+
index,
|
|
74
|
+
onReorder,
|
|
75
|
+
onRemove,
|
|
76
|
+
dragState,
|
|
77
|
+
setDragState,
|
|
78
|
+
children
|
|
79
|
+
}) {
|
|
80
|
+
const rowRef = useRef(null);
|
|
81
|
+
const handleRef = useRef(null);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const row = rowRef.current;
|
|
84
|
+
const handle = handleRef.current;
|
|
85
|
+
if (!row || !handle) return;
|
|
86
|
+
let cleanup;
|
|
87
|
+
let cancelled = false;
|
|
88
|
+
import("../../adapter-HH47ZPGM.js").then(({ draggable, dropTargetForElements }) => {
|
|
89
|
+
if (cancelled) return;
|
|
90
|
+
const cleanupDraggable = draggable({
|
|
91
|
+
element: handle,
|
|
92
|
+
getInitialData: () => ({ dragType: "list-row", id, index }),
|
|
93
|
+
onDragStart: () => setDragState({ sourceId: id, targetId: null }),
|
|
94
|
+
onDrop: () => setDragState({ sourceId: null, targetId: null })
|
|
95
|
+
});
|
|
96
|
+
const cleanupDropTarget = dropTargetForElements({
|
|
97
|
+
element: row,
|
|
98
|
+
canDrop: ({ source }) => source.data.dragType === "list-row",
|
|
99
|
+
getData: () => ({ id, index }),
|
|
100
|
+
onDragEnter: () => setDragState((prev) => ({ ...prev, targetId: id })),
|
|
101
|
+
onDragLeave: () => setDragState((prev) => prev.targetId === id ? { ...prev, targetId: null } : prev),
|
|
102
|
+
onDrop: ({ source }) => {
|
|
103
|
+
const fromIndex = source.data.index;
|
|
104
|
+
if (fromIndex !== index) {
|
|
105
|
+
onReorder(fromIndex, index);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
cleanup = () => {
|
|
110
|
+
cleanupDraggable();
|
|
111
|
+
cleanupDropTarget();
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
return () => {
|
|
115
|
+
cancelled = true;
|
|
116
|
+
cleanup?.();
|
|
117
|
+
};
|
|
118
|
+
}, [id, index, onReorder, setDragState]);
|
|
119
|
+
const isDropTarget = dragState.targetId === id && dragState.sourceId !== id;
|
|
120
|
+
return /* @__PURE__ */ jsxs(
|
|
121
|
+
"div",
|
|
122
|
+
{
|
|
123
|
+
ref: rowRef,
|
|
124
|
+
className: cn(
|
|
125
|
+
"group/row relative flex items-center gap-2",
|
|
126
|
+
isDropTarget && "border-t-2 border-primary"
|
|
127
|
+
),
|
|
128
|
+
children: [
|
|
129
|
+
/* @__PURE__ */ jsx(
|
|
130
|
+
IconButton,
|
|
131
|
+
{
|
|
132
|
+
ref: handleRef,
|
|
133
|
+
icon: /* @__PURE__ */ jsx(DragHandle, { size: 14 }),
|
|
134
|
+
label: "Drag to reorder",
|
|
135
|
+
size: "sm",
|
|
136
|
+
className: "shrink-0 cursor-grab opacity-0 group-hover/row:opacity-100 no-hover:opacity-100",
|
|
137
|
+
tabIndex: -1
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children }),
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
IconButton,
|
|
143
|
+
{
|
|
144
|
+
icon: /* @__PURE__ */ jsx(DeleteIcon, { size: 14 }),
|
|
145
|
+
label: "Delete item",
|
|
146
|
+
size: "sm",
|
|
147
|
+
intent: "destructive",
|
|
148
|
+
onClick: () => onRemove(id),
|
|
149
|
+
className: "shrink-0 opacity-0 group-hover/row:opacity-100 no-hover:opacity-100"
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
EditableGrid,
|
|
158
|
+
EditableList,
|
|
159
|
+
EditablePlainText,
|
|
160
|
+
EditableRichText,
|
|
161
|
+
ImageDropZone,
|
|
162
|
+
LinkPopover,
|
|
163
|
+
MediaBlock,
|
|
164
|
+
ResolvedMedia,
|
|
165
|
+
defineHeadingSection
|
|
166
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/Colors/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/Colors/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,wBAkCG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/Container/index.tsx"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/Container/index.tsx"],"names":[],"mappings":";;;;;;;;;AAkCA,wBAcG"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { SectionContent } from "../../../schemas/sections";
|
|
2
|
-
|
|
3
|
-
label: string;
|
|
4
|
-
text: string;
|
|
5
|
-
icon?: string;
|
|
6
|
-
dodont?: "do" | "dont";
|
|
7
|
-
}
|
|
2
|
+
import type { IconListItem } from "./index";
|
|
8
3
|
interface Props {
|
|
9
4
|
items: IconListItem[];
|
|
10
5
|
icon?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconList.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/IconList/IconList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"IconList.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/IconList/IconList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAShE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,UAAU,KAAK;IACb,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,KAAK,EACL,IAAW,EACX,SAAgB,EAChB,SAAiB,EACjB,cAA+C,EAC/C,aAA0C,EAC1C,aAA8B,EAC9B,QAAQ,EACR,aAAa,GACd,EAAE,KAAK,2CAyCP"}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const IconListItemSchema: z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
text: z.ZodString;
|
|
5
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
6
|
+
dodont: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
do: "do";
|
|
8
|
+
dont: "dont";
|
|
9
|
+
}>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type IconListItem = z.infer<typeof IconListItemSchema>;
|
|
1
12
|
declare const _default: import("../../..").SectionDefinition<{
|
|
2
13
|
type: "icon_list";
|
|
3
14
|
content: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/IconList/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/IconList/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,kBAAkB;;;;;;;;iBAK7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;;;;;;;;;;;;;;;;;AAc9D,wBAoBG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/LinkHeading/index.tsx"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/LinkHeading/index.tsx"],"names":[],"mappings":";;;;;;AAGA,wBAQG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/SubHeading/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/SubHeading/index.tsx"],"names":[],"mappings":";;;;;;AAGA,wBASG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/SubSubHeading/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/sections/SubSubHeading/index.tsx"],"names":[],"mappings":";;;;;;AAGA,wBASG"}
|
|
@@ -20,13 +20,11 @@ export declare const allSectionDefs: (import("../..").SectionDefinition<{
|
|
|
20
20
|
type: "sub_heading";
|
|
21
21
|
content: {
|
|
22
22
|
heading: string;
|
|
23
|
-
excludeFromNav?: boolean | undefined;
|
|
24
23
|
};
|
|
25
24
|
}> | import("../..").SectionDefinition<{
|
|
26
25
|
type: "sub_sub_heading";
|
|
27
26
|
content: {
|
|
28
27
|
heading: string;
|
|
29
|
-
excludeFromNav?: boolean | undefined;
|
|
30
28
|
};
|
|
31
29
|
}> | import("../..").SectionDefinition<{
|
|
32
30
|
type: "prose";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"all-sections.d.ts","sourceRoot":"","sources":["../../../src/components/sections/all-sections.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AAKH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"all-sections.d.ts","sourceRoot":"","sources":["../../../src/components/sections/all-sections.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AAKH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAW1B,CAAC"}
|