@drawnagency/primitives 0.1.79 → 0.1.81
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-RWMSDDQM.js → chunk-DKXISNJ2.js} +79 -26
- package/dist/{chunk-RSITF24B.js → chunk-EVNEMJZ6.js} +9 -3
- package/dist/{chunk-DR22HM44.js → chunk-FDBZZ4AT.js} +1 -1
- package/dist/{chunk-QB5Q23G2.js → chunk-FN4NKUZU.js} +1 -1
- package/dist/{chunk-EMGLZQCM.js → chunk-MBJUWOM2.js} +1 -1
- package/dist/{chunk-FRTJNS5F.js → chunk-P4ZNHZMP.js} +6 -6
- package/dist/{chunk-UNUJPLZV.js → chunk-PJOHAWNV.js} +1 -1
- package/dist/{chunk-2DDWWTRX.js → chunk-Q6LZOH5M.js} +1 -1
- package/dist/chunk-WP5UX4MI.js +63 -0
- package/dist/{chunk-3LNKOLZP.js → chunk-YKOLOZB2.js} +1 -1
- package/dist/{chunk-4XXLH5CL.js → chunk-ZEXR7JYQ.js} +19 -12
- package/dist/components/brandguide/Colors.d.ts +2 -1
- package/dist/components/brandguide/Colors.d.ts.map +1 -1
- package/dist/components/editor/PagesModal.d.ts +2 -0
- package/dist/components/editor/PagesModal.d.ts.map +1 -1
- package/dist/components/editor/index.js +6 -5
- package/dist/components/primitives/EditableGrid.d.ts +11 -1
- package/dist/components/primitives/EditableGrid.d.ts.map +1 -1
- package/dist/components/primitives/gridDrop.d.ts +18 -0
- package/dist/components/primitives/gridDrop.d.ts.map +1 -0
- package/dist/components/primitives/index.js +7 -6
- package/dist/components/primitives/useEditableCollection.d.ts +1 -0
- package/dist/components/primitives/useEditableCollection.d.ts.map +1 -1
- package/dist/components/sections/Colors/index.d.ts.map +1 -1
- package/dist/components/sections/brand-guide.js +7 -6
- package/dist/components/sections/register-schemas.js +10 -9
- package/dist/components/sections/register.js +10 -9
- package/dist/components/shell/DocInspector.d.ts +17 -0
- package/dist/components/shell/DocInspector.d.ts.map +1 -0
- package/dist/components/shell/DocumentEditorOverlay.d.ts +29 -0
- package/dist/components/shell/DocumentEditorOverlay.d.ts.map +1 -0
- package/dist/components/shell/DocumentPresentOverlay.d.ts +30 -0
- package/dist/components/shell/DocumentPresentOverlay.d.ts.map +1 -0
- package/dist/components/shell/EditorContext.d.ts +2 -0
- package/dist/components/shell/EditorContext.d.ts.map +1 -1
- package/dist/components/shell/EditorShell.d.ts +44 -0
- package/dist/components/shell/EditorShell.d.ts.map +1 -1
- package/dist/components/shell/HistoryToolbar.d.ts +8 -1
- package/dist/components/shell/HistoryToolbar.d.ts.map +1 -1
- package/dist/document/assets/fonts/albra-grotesk-bold.woff +0 -0
- package/dist/document/assets/fonts/albra-grotesk-regular.woff +0 -0
- package/dist/document/assets/fonts/kapra-neue-expanded-medium.woff +0 -0
- package/dist/document/assets/fonts/kapra-neue-expanded-regular.woff +0 -0
- package/dist/document/components/DocCoverPage.d.ts +11 -0
- package/dist/document/components/DocCoverPage.d.ts.map +1 -0
- package/dist/document/components/DocPage.d.ts +10 -0
- package/dist/document/components/DocPage.d.ts.map +1 -0
- package/dist/document/components/DocRail.d.ts +27 -0
- package/dist/document/components/DocRail.d.ts.map +1 -0
- package/dist/document/components/DocSectionPage.d.ts +12 -0
- package/dist/document/components/DocSectionPage.d.ts.map +1 -0
- package/dist/document/components/DocViewer.d.ts +18 -0
- package/dist/document/components/DocViewer.d.ts.map +1 -0
- package/dist/document/components/Wordmark.d.ts +4 -0
- package/dist/document/components/Wordmark.d.ts.map +1 -0
- package/dist/document/components/measure.d.ts +6 -0
- package/dist/document/components/measure.d.ts.map +1 -0
- package/dist/document/components/useDocPages.d.ts +12 -0
- package/dist/document/components/useDocPages.d.ts.map +1 -0
- package/dist/document/engine/blocks.d.ts +2 -0
- package/dist/document/engine/blocks.d.ts.map +1 -0
- package/dist/document/engine/harvest.d.ts +3 -0
- package/dist/document/engine/harvest.d.ts.map +1 -0
- package/dist/document/engine/masonry.d.ts +25 -0
- package/dist/document/engine/masonry.d.ts.map +1 -0
- package/dist/document/engine/paginate.d.ts +40 -0
- package/dist/document/engine/paginate.d.ts.map +1 -0
- package/dist/document/engine/settings.d.ts +70 -0
- package/dist/document/engine/settings.d.ts.map +1 -0
- package/dist/document/engine/types.d.ts +40 -0
- package/dist/document/engine/types.d.ts.map +1 -0
- package/dist/document/index.d.ts +13 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +881 -0
- package/dist/document/styles/document.css +208 -0
- package/dist/index.js +29 -28
- package/dist/lib/document-input.d.ts +25 -0
- package/dist/lib/document-input.d.ts.map +1 -0
- package/dist/lib/index.js +10 -9
- package/dist/lib/pages.d.ts +2 -0
- package/dist/lib/pages.d.ts.map +1 -1
- package/dist/lib/registry.d.ts +3 -0
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/media/index.js +4 -3
- package/dist/schemas/index.js +3 -2
- package/dist/schemas/site-config.d.ts +223 -1
- package/dist/schemas/site-config.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/components/brandguide/Colors.tsx +15 -5
- package/src/components/editor/PagesModal.tsx +16 -2
- package/src/components/primitives/EditableGrid.tsx +86 -24
- package/src/components/primitives/gridDrop.ts +26 -0
- package/src/components/primitives/useEditableCollection.ts +16 -1
- package/src/components/sections/Colors/index.tsx +2 -1
- package/src/components/shell/DocInspector.tsx +278 -0
- package/src/components/shell/DocumentEditorOverlay.tsx +169 -0
- package/src/components/shell/DocumentPresentOverlay.tsx +87 -0
- package/src/components/shell/EditorContext.tsx +6 -1
- package/src/components/shell/EditorShell.tsx +171 -10
- package/src/components/shell/HistoryToolbar.tsx +24 -2
- package/src/document/assets/fonts/albra-grotesk-bold.woff +0 -0
- package/src/document/assets/fonts/albra-grotesk-regular.woff +0 -0
- package/src/document/assets/fonts/kapra-neue-expanded-medium.woff +0 -0
- package/src/document/assets/fonts/kapra-neue-expanded-regular.woff +0 -0
- package/src/document/components/DocCoverPage.tsx +45 -0
- package/src/document/components/DocPage.tsx +40 -0
- package/src/document/components/DocRail.tsx +160 -0
- package/src/document/components/DocSectionPage.tsx +45 -0
- package/src/document/components/DocViewer.tsx +285 -0
- package/src/document/components/Wordmark.tsx +18 -0
- package/src/document/components/measure.tsx +105 -0
- package/src/document/components/useDocPages.ts +67 -0
- package/src/document/engine/blocks.ts +87 -0
- package/src/document/engine/harvest.ts +80 -0
- package/src/document/engine/masonry.ts +89 -0
- package/src/document/engine/paginate.ts +209 -0
- package/src/document/engine/settings.ts +77 -0
- package/src/document/engine/types.ts +54 -0
- package/src/document/index.ts +18 -0
- package/src/document/styles/document.css +208 -0
- package/src/lib/document-input.ts +57 -0
- package/src/lib/pages.ts +22 -0
- package/src/lib/registry.ts +3 -0
- package/src/schemas/site-config.ts +22 -7
- /package/dist/{chunk-4YEOTFVU.js → chunk-YBVK254P.js} +0 -0
|
@@ -10,7 +10,7 @@ export declare const SectionMetaSchema: z.ZodObject<{
|
|
|
10
10
|
access: z.ZodArray<z.ZodString>;
|
|
11
11
|
}, z.core.$strip>;
|
|
12
12
|
export type SectionMeta = z.infer<typeof SectionMetaSchema>;
|
|
13
|
-
export declare const RESERVED_SLUGS: readonly ["edit", "api", "login", "set-password", "404"];
|
|
13
|
+
export declare const RESERVED_SLUGS: readonly ["edit", "api", "login", "set-password", "404", "present"];
|
|
14
14
|
export declare const PageStatusSchema: z.ZodEnum<{
|
|
15
15
|
live: "live";
|
|
16
16
|
archived: "archived";
|
|
@@ -27,6 +27,46 @@ export declare const PageSchema: z.ZodObject<{
|
|
|
27
27
|
}>;
|
|
28
28
|
access: z.ZodArray<z.ZodString>;
|
|
29
29
|
order: z.ZodArray<z.ZodString>;
|
|
30
|
+
document: z.ZodOptional<z.ZodObject<{
|
|
31
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
32
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
33
|
+
client: z.ZodDefault<z.ZodString>;
|
|
34
|
+
project: z.ZodDefault<z.ZodString>;
|
|
35
|
+
dateLabel: z.ZodDefault<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
cover: z.ZodDefault<z.ZodObject<{
|
|
38
|
+
bgColor: z.ZodDefault<z.ZodString>;
|
|
39
|
+
accentColor: z.ZodDefault<z.ZodString>;
|
|
40
|
+
title: z.ZodDefault<z.ZodString>;
|
|
41
|
+
label: z.ZodDefault<z.ZodString>;
|
|
42
|
+
date: z.ZodDefault<z.ZodString>;
|
|
43
|
+
imageId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
sections: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
46
|
+
excluded: z.ZodDefault<z.ZodBoolean>;
|
|
47
|
+
textPlacement: z.ZodDefault<z.ZodEnum<{
|
|
48
|
+
top: "top";
|
|
49
|
+
leftColumn: "leftColumn";
|
|
50
|
+
}>>;
|
|
51
|
+
imagePlacement: z.ZodDefault<z.ZodEnum<{
|
|
52
|
+
fullWidth: "fullWidth";
|
|
53
|
+
right: "right";
|
|
54
|
+
}>>;
|
|
55
|
+
dropTextOverflow: z.ZodDefault<z.ZodBoolean>;
|
|
56
|
+
imageLayout: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
57
|
+
mode: z.ZodLiteral<"grid">;
|
|
58
|
+
rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
59
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>>;
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
mode: z.ZodLiteral<"masonry">;
|
|
62
|
+
flow: z.ZodDefault<z.ZodEnum<{
|
|
63
|
+
rows: "rows";
|
|
64
|
+
columns: "columns";
|
|
65
|
+
}>>;
|
|
66
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>>;
|
|
67
|
+
}, z.core.$strip>], "mode">>;
|
|
68
|
+
}, z.core.$strip>>>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
30
70
|
}, z.core.$strip>;
|
|
31
71
|
export type Page = z.infer<typeof PageSchema>;
|
|
32
72
|
declare const CanonicalIndexSchema: z.ZodObject<{
|
|
@@ -43,6 +83,46 @@ declare const CanonicalIndexSchema: z.ZodObject<{
|
|
|
43
83
|
}>;
|
|
44
84
|
access: z.ZodArray<z.ZodString>;
|
|
45
85
|
order: z.ZodArray<z.ZodString>;
|
|
86
|
+
document: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
88
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
89
|
+
client: z.ZodDefault<z.ZodString>;
|
|
90
|
+
project: z.ZodDefault<z.ZodString>;
|
|
91
|
+
dateLabel: z.ZodDefault<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
cover: z.ZodDefault<z.ZodObject<{
|
|
94
|
+
bgColor: z.ZodDefault<z.ZodString>;
|
|
95
|
+
accentColor: z.ZodDefault<z.ZodString>;
|
|
96
|
+
title: z.ZodDefault<z.ZodString>;
|
|
97
|
+
label: z.ZodDefault<z.ZodString>;
|
|
98
|
+
date: z.ZodDefault<z.ZodString>;
|
|
99
|
+
imageId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
100
|
+
}, z.core.$strip>>;
|
|
101
|
+
sections: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
102
|
+
excluded: z.ZodDefault<z.ZodBoolean>;
|
|
103
|
+
textPlacement: z.ZodDefault<z.ZodEnum<{
|
|
104
|
+
top: "top";
|
|
105
|
+
leftColumn: "leftColumn";
|
|
106
|
+
}>>;
|
|
107
|
+
imagePlacement: z.ZodDefault<z.ZodEnum<{
|
|
108
|
+
fullWidth: "fullWidth";
|
|
109
|
+
right: "right";
|
|
110
|
+
}>>;
|
|
111
|
+
dropTextOverflow: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
imageLayout: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
113
|
+
mode: z.ZodLiteral<"grid">;
|
|
114
|
+
rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
115
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>>;
|
|
116
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
117
|
+
mode: z.ZodLiteral<"masonry">;
|
|
118
|
+
flow: z.ZodDefault<z.ZodEnum<{
|
|
119
|
+
rows: "rows";
|
|
120
|
+
columns: "columns";
|
|
121
|
+
}>>;
|
|
122
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>>;
|
|
123
|
+
}, z.core.$strip>], "mode">>;
|
|
124
|
+
}, z.core.$strip>>>;
|
|
125
|
+
}, z.core.$strip>>;
|
|
46
126
|
}, z.core.$strip>>;
|
|
47
127
|
sections: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
48
128
|
type: z.ZodString;
|
|
@@ -71,6 +151,46 @@ export declare const IndexSchema: z.ZodPipe<z.ZodPipe<z.ZodObject<{
|
|
|
71
151
|
}>;
|
|
72
152
|
access: z.ZodArray<z.ZodString>;
|
|
73
153
|
order: z.ZodArray<z.ZodString>;
|
|
154
|
+
document: z.ZodOptional<z.ZodObject<{
|
|
155
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
156
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
157
|
+
client: z.ZodDefault<z.ZodString>;
|
|
158
|
+
project: z.ZodDefault<z.ZodString>;
|
|
159
|
+
dateLabel: z.ZodDefault<z.ZodString>;
|
|
160
|
+
}, z.core.$strip>>;
|
|
161
|
+
cover: z.ZodDefault<z.ZodObject<{
|
|
162
|
+
bgColor: z.ZodDefault<z.ZodString>;
|
|
163
|
+
accentColor: z.ZodDefault<z.ZodString>;
|
|
164
|
+
title: z.ZodDefault<z.ZodString>;
|
|
165
|
+
label: z.ZodDefault<z.ZodString>;
|
|
166
|
+
date: z.ZodDefault<z.ZodString>;
|
|
167
|
+
imageId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
168
|
+
}, z.core.$strip>>;
|
|
169
|
+
sections: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
170
|
+
excluded: z.ZodDefault<z.ZodBoolean>;
|
|
171
|
+
textPlacement: z.ZodDefault<z.ZodEnum<{
|
|
172
|
+
top: "top";
|
|
173
|
+
leftColumn: "leftColumn";
|
|
174
|
+
}>>;
|
|
175
|
+
imagePlacement: z.ZodDefault<z.ZodEnum<{
|
|
176
|
+
fullWidth: "fullWidth";
|
|
177
|
+
right: "right";
|
|
178
|
+
}>>;
|
|
179
|
+
dropTextOverflow: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
imageLayout: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
181
|
+
mode: z.ZodLiteral<"grid">;
|
|
182
|
+
rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
183
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>>;
|
|
184
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
185
|
+
mode: z.ZodLiteral<"masonry">;
|
|
186
|
+
flow: z.ZodDefault<z.ZodEnum<{
|
|
187
|
+
rows: "rows";
|
|
188
|
+
columns: "columns";
|
|
189
|
+
}>>;
|
|
190
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>>;
|
|
191
|
+
}, z.core.$strip>], "mode">>;
|
|
192
|
+
}, z.core.$strip>>>;
|
|
193
|
+
}, z.core.$strip>>;
|
|
74
194
|
}, z.core.$strip>>>;
|
|
75
195
|
sections: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
76
196
|
type: z.ZodString;
|
|
@@ -94,6 +214,37 @@ export declare const IndexSchema: z.ZodPipe<z.ZodPipe<z.ZodObject<{
|
|
|
94
214
|
status: "live" | "archived";
|
|
95
215
|
access: string[];
|
|
96
216
|
order: string[];
|
|
217
|
+
document?: {
|
|
218
|
+
enabled?: boolean | undefined;
|
|
219
|
+
meta?: {
|
|
220
|
+
client?: string | undefined;
|
|
221
|
+
project?: string | undefined;
|
|
222
|
+
dateLabel?: string | undefined;
|
|
223
|
+
} | undefined;
|
|
224
|
+
cover?: {
|
|
225
|
+
bgColor?: string | undefined;
|
|
226
|
+
accentColor?: string | undefined;
|
|
227
|
+
title?: string | undefined;
|
|
228
|
+
label?: string | undefined;
|
|
229
|
+
date?: string | undefined;
|
|
230
|
+
imageId?: string | null | undefined;
|
|
231
|
+
} | undefined;
|
|
232
|
+
sections?: Record<string, {
|
|
233
|
+
excluded?: boolean | undefined;
|
|
234
|
+
textPlacement?: "top" | "leftColumn" | undefined;
|
|
235
|
+
imagePlacement?: "fullWidth" | "right" | undefined;
|
|
236
|
+
dropTextOverflow?: boolean | undefined;
|
|
237
|
+
imageLayout?: {
|
|
238
|
+
mode: "grid";
|
|
239
|
+
rows?: 2 | 1 | 3 | undefined;
|
|
240
|
+
columns?: 2 | 4 | 3 | undefined;
|
|
241
|
+
} | {
|
|
242
|
+
mode: "masonry";
|
|
243
|
+
flow?: "rows" | "columns" | undefined;
|
|
244
|
+
columns?: 2 | 4 | 3 | 5 | 6 | undefined;
|
|
245
|
+
} | undefined;
|
|
246
|
+
}> | undefined;
|
|
247
|
+
} | undefined;
|
|
97
248
|
}[];
|
|
98
249
|
sections: Record<string, {
|
|
99
250
|
type: string;
|
|
@@ -118,6 +269,37 @@ export declare const IndexSchema: z.ZodPipe<z.ZodPipe<z.ZodObject<{
|
|
|
118
269
|
status: "live" | "archived";
|
|
119
270
|
access: string[];
|
|
120
271
|
order: string[];
|
|
272
|
+
document?: {
|
|
273
|
+
enabled: boolean;
|
|
274
|
+
meta: {
|
|
275
|
+
client: string;
|
|
276
|
+
project: string;
|
|
277
|
+
dateLabel: string;
|
|
278
|
+
};
|
|
279
|
+
cover: {
|
|
280
|
+
bgColor: string;
|
|
281
|
+
accentColor: string;
|
|
282
|
+
title: string;
|
|
283
|
+
label: string;
|
|
284
|
+
date: string;
|
|
285
|
+
imageId: string | null;
|
|
286
|
+
};
|
|
287
|
+
sections: Record<string, {
|
|
288
|
+
excluded: boolean;
|
|
289
|
+
textPlacement: "top" | "leftColumn";
|
|
290
|
+
imagePlacement: "fullWidth" | "right";
|
|
291
|
+
dropTextOverflow: boolean;
|
|
292
|
+
imageLayout: {
|
|
293
|
+
mode: "grid";
|
|
294
|
+
rows: 2 | 1 | 3;
|
|
295
|
+
columns: 2 | 4 | 3;
|
|
296
|
+
} | {
|
|
297
|
+
mode: "masonry";
|
|
298
|
+
flow: "rows" | "columns";
|
|
299
|
+
columns: 2 | 4 | 3 | 5 | 6;
|
|
300
|
+
};
|
|
301
|
+
}>;
|
|
302
|
+
} | undefined;
|
|
121
303
|
}[] | undefined;
|
|
122
304
|
lastModified?: string | null | undefined;
|
|
123
305
|
}>>, z.ZodObject<{
|
|
@@ -134,6 +316,46 @@ export declare const IndexSchema: z.ZodPipe<z.ZodPipe<z.ZodObject<{
|
|
|
134
316
|
}>;
|
|
135
317
|
access: z.ZodArray<z.ZodString>;
|
|
136
318
|
order: z.ZodArray<z.ZodString>;
|
|
319
|
+
document: z.ZodOptional<z.ZodObject<{
|
|
320
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
321
|
+
meta: z.ZodDefault<z.ZodObject<{
|
|
322
|
+
client: z.ZodDefault<z.ZodString>;
|
|
323
|
+
project: z.ZodDefault<z.ZodString>;
|
|
324
|
+
dateLabel: z.ZodDefault<z.ZodString>;
|
|
325
|
+
}, z.core.$strip>>;
|
|
326
|
+
cover: z.ZodDefault<z.ZodObject<{
|
|
327
|
+
bgColor: z.ZodDefault<z.ZodString>;
|
|
328
|
+
accentColor: z.ZodDefault<z.ZodString>;
|
|
329
|
+
title: z.ZodDefault<z.ZodString>;
|
|
330
|
+
label: z.ZodDefault<z.ZodString>;
|
|
331
|
+
date: z.ZodDefault<z.ZodString>;
|
|
332
|
+
imageId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
333
|
+
}, z.core.$strip>>;
|
|
334
|
+
sections: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
335
|
+
excluded: z.ZodDefault<z.ZodBoolean>;
|
|
336
|
+
textPlacement: z.ZodDefault<z.ZodEnum<{
|
|
337
|
+
top: "top";
|
|
338
|
+
leftColumn: "leftColumn";
|
|
339
|
+
}>>;
|
|
340
|
+
imagePlacement: z.ZodDefault<z.ZodEnum<{
|
|
341
|
+
fullWidth: "fullWidth";
|
|
342
|
+
right: "right";
|
|
343
|
+
}>>;
|
|
344
|
+
dropTextOverflow: z.ZodDefault<z.ZodBoolean>;
|
|
345
|
+
imageLayout: z.ZodDefault<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
346
|
+
mode: z.ZodLiteral<"grid">;
|
|
347
|
+
rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
348
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>>;
|
|
349
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
350
|
+
mode: z.ZodLiteral<"masonry">;
|
|
351
|
+
flow: z.ZodDefault<z.ZodEnum<{
|
|
352
|
+
rows: "rows";
|
|
353
|
+
columns: "columns";
|
|
354
|
+
}>>;
|
|
355
|
+
columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>, z.ZodLiteral<5>, z.ZodLiteral<6>]>>;
|
|
356
|
+
}, z.core.$strip>], "mode">>;
|
|
357
|
+
}, z.core.$strip>>>;
|
|
358
|
+
}, z.core.$strip>>;
|
|
137
359
|
}, z.core.$strip>>;
|
|
138
360
|
sections: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
139
361
|
type: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-config.d.ts","sourceRoot":"","sources":["../../src/schemas/site-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"site-config.d.ts","sourceRoot":"","sources":["../../src/schemas/site-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,iBAAiB;;;;;;;;;iBAI5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAQ5D,eAAO,MAAM,cAAc,qEAAsE,CAAC;AAWlG,eAAO,MAAM,gBAAgB;;;EAA+B,CAAC;AAE7D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AA0C9C,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6CtB,CAAC;AAEL,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAyE,CAAC;AAElG,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE7D,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAE1D;AAMD,eAAO,MAAM,iBAAiB;;;;;iBAM5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,mBAAmB;;;;;;;;;;;iBAwB5B,CAAC;AACL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4B3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drawnagency/primitives",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.81",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
"types": "./dist/components/primitives/index.d.ts",
|
|
85
85
|
"default": "./dist/components/primitives/index.js"
|
|
86
86
|
},
|
|
87
|
+
"./document": {
|
|
88
|
+
"types": "./dist/document/index.d.ts",
|
|
89
|
+
"default": "./dist/document/index.js"
|
|
90
|
+
},
|
|
87
91
|
"./auth": {
|
|
88
92
|
"types": "./dist/auth/index.d.ts",
|
|
89
93
|
"default": "./dist/auth/index.js"
|
|
@@ -17,6 +17,7 @@ interface Props {
|
|
|
17
17
|
showLabel?: boolean;
|
|
18
18
|
onChange?: (content: SectionContent) => void;
|
|
19
19
|
openModal?: (title: string, content: ReactNode) => void;
|
|
20
|
+
onDelete?: () => void;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function getContrastClass(hex: string | undefined): string {
|
|
@@ -49,7 +50,7 @@ function buildContent(
|
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
export default function Colors({ colors, columns = 3, label, collapsing, showLabel = true, onChange, openModal }: Props) {
|
|
53
|
+
export default function Colors({ colors, columns = 3, label, collapsing, showLabel = true, onChange, openModal, onDelete }: Props) {
|
|
53
54
|
if (onChange && openModal) {
|
|
54
55
|
return (
|
|
55
56
|
<ColorsEditable
|
|
@@ -60,6 +61,7 @@ export default function Colors({ colors, columns = 3, label, collapsing, showLab
|
|
|
60
61
|
showLabel={showLabel}
|
|
61
62
|
onChange={onChange}
|
|
62
63
|
openModal={openModal}
|
|
64
|
+
onDelete={onDelete}
|
|
63
65
|
/>
|
|
64
66
|
);
|
|
65
67
|
}
|
|
@@ -125,7 +127,7 @@ function ColorsView({
|
|
|
125
127
|
const hex = color.spaces[0]?.hex;
|
|
126
128
|
const contrast = getContrastClass(hex);
|
|
127
129
|
return (
|
|
128
|
-
<div key={i} className="overflow-hidden rounded-outer border border-base-200">
|
|
130
|
+
<div key={i} className="flex h-full flex-col overflow-hidden rounded-outer border border-base-200">
|
|
129
131
|
<div className={cn("relative flex min-h-[80px] items-end p-3", contrast)} style={{ backgroundColor: hex || "#ccc" }}>
|
|
130
132
|
{color.name && <span className="text-sm font-bold">{color.name}</span>}
|
|
131
133
|
{copiedIndex === i && (
|
|
@@ -138,7 +140,8 @@ function ColorsView({
|
|
|
138
140
|
)}
|
|
139
141
|
</div>
|
|
140
142
|
{expanded && (
|
|
141
|
-
|
|
143
|
+
// flex-1 so every swatch's label block grows to the tallest in its row.
|
|
144
|
+
<div className="flex-1 space-y-1 bg-base-accent p-3 text-sm">
|
|
142
145
|
{color.spaces.map((space, j) =>
|
|
143
146
|
Object.entries(space).map(([key, value]) =>
|
|
144
147
|
value ? (
|
|
@@ -168,6 +171,7 @@ function ColorsEditable({
|
|
|
168
171
|
showLabel,
|
|
169
172
|
onChange,
|
|
170
173
|
openModal,
|
|
174
|
+
onDelete,
|
|
171
175
|
}: {
|
|
172
176
|
colors: ColorItem[];
|
|
173
177
|
columns: number;
|
|
@@ -176,6 +180,7 @@ function ColorsEditable({
|
|
|
176
180
|
showLabel?: boolean;
|
|
177
181
|
onChange: (content: SectionContent) => void;
|
|
178
182
|
openModal: (title: string, content: ReactNode) => void;
|
|
183
|
+
onDelete?: () => void;
|
|
179
184
|
}) {
|
|
180
185
|
const [expanded, setExpanded] = useState(!collapsing);
|
|
181
186
|
const options = { label, columns, collapsing, showLabel };
|
|
@@ -224,6 +229,10 @@ function ColorsEditable({
|
|
|
224
229
|
<EditableGrid
|
|
225
230
|
items={colors}
|
|
226
231
|
columns={columns}
|
|
232
|
+
// Shared group lets a swatch be dragged from one colors section into another.
|
|
233
|
+
group="colors"
|
|
234
|
+
// When the last swatch is dragged out to another section, delete this now-empty one.
|
|
235
|
+
onEmptied={onDelete}
|
|
227
236
|
onChange={(newColors) => onChange(buildContent(newColors, options))}
|
|
228
237
|
createItem={createColorItem}
|
|
229
238
|
isEditMode={true}
|
|
@@ -267,7 +276,7 @@ function ColorSwatchEditable({
|
|
|
267
276
|
};
|
|
268
277
|
|
|
269
278
|
return (
|
|
270
|
-
<div className="overflow-hidden rounded-outer border border-base-200">
|
|
279
|
+
<div className="flex h-full flex-col overflow-hidden rounded-outer border border-base-200">
|
|
271
280
|
<div className={cn("flex min-h-[80px] items-end p-3", contrast)} style={{ backgroundColor: hex || "#ccc" }}>
|
|
272
281
|
<EditablePlainText
|
|
273
282
|
tag="span"
|
|
@@ -279,7 +288,8 @@ function ColorSwatchEditable({
|
|
|
279
288
|
/>
|
|
280
289
|
</div>
|
|
281
290
|
{expanded && (
|
|
282
|
-
|
|
291
|
+
// flex-1 so every swatch's label block grows to the tallest in its row.
|
|
292
|
+
<div className="flex-1 space-y-1 bg-base-accent p-3 text-sm">
|
|
283
293
|
{color.spaces.map((space, j) =>
|
|
284
294
|
Object.entries(space).map(([key, value]) =>
|
|
285
295
|
value ? (
|
|
@@ -2,6 +2,10 @@ import { useState, useEffect } from "react";
|
|
|
2
2
|
import { Check } from "lucide-react";
|
|
3
3
|
import type { SiteIndex, Page } from "../../schemas/site-config";
|
|
4
4
|
import type { Audience } from "../../auth/types";
|
|
5
|
+
// Sanctioned outside->inside import: document/ is a sealed subtree, but the
|
|
6
|
+
// Document mode toggle needs the patch shape it edits (mirrors the same
|
|
7
|
+
// sanctioned import in schemas/site-config.ts and lib/pages.ts).
|
|
8
|
+
import type { DocumentOptions } from "../../document/engine/settings";
|
|
5
9
|
import { Button } from "../shared/Button";
|
|
6
10
|
import { Input } from "../shared/Input";
|
|
7
11
|
import { Checkbox } from "../shared/Checkbox";
|
|
@@ -24,6 +28,7 @@ export interface PagesModalProps {
|
|
|
24
28
|
onSetArchived: (pageId: string, archived: boolean) => void;
|
|
25
29
|
onSetFields: (pageId: string, patch: Partial<Pick<Page, "title" | "slug" | "showInNav">>) => void;
|
|
26
30
|
onSetAudience: (pageId: string, access: string[]) => void;
|
|
31
|
+
onSetDocument: (pageId: string, patch: Partial<DocumentOptions>) => void;
|
|
27
32
|
onConfirmDelete: (pageId: string) => void;
|
|
28
33
|
}
|
|
29
34
|
|
|
@@ -71,6 +76,7 @@ export function PagesModal(props: PagesModalProps) {
|
|
|
71
76
|
}}
|
|
72
77
|
onSetFields={(patch) => props.onSetFields(page.id, patch)}
|
|
73
78
|
onSetAudience={(access) => props.onSetAudience(page.id, access)}
|
|
79
|
+
onSetDocument={(patch) => props.onSetDocument(page.id, patch)}
|
|
74
80
|
onRequestDelete={() =>
|
|
75
81
|
page.order.length === 0 ? props.onConfirmDelete(page.id) : setDeletingId(page.id)
|
|
76
82
|
}
|
|
@@ -105,14 +111,16 @@ export function PagesModal(props: PagesModalProps) {
|
|
|
105
111
|
}
|
|
106
112
|
|
|
107
113
|
function PageRow({
|
|
108
|
-
page, audiences, expanded, isNew, otherSlugs, dragIndex, onReorder, onToggleExpand, onSetHome, onSetArchived, onSetFields, onSetAudience, onRequestDelete,
|
|
114
|
+
page, audiences, expanded, isNew, otherSlugs, dragIndex, onReorder, onToggleExpand, onSetHome, onSetArchived, onSetFields, onSetAudience, onSetDocument, onRequestDelete,
|
|
109
115
|
}: {
|
|
110
116
|
page: Page; audiences: Audience[]; expanded: boolean;
|
|
111
117
|
isNew: boolean; otherSlugs: string[];
|
|
112
118
|
dragIndex?: number; onReorder: (fromIndex: number, toIndex: number) => void;
|
|
113
119
|
onToggleExpand: () => void; onSetHome: () => void; onSetArchived: (v: boolean) => void;
|
|
114
120
|
onSetFields: (patch: Partial<Pick<Page, "title" | "slug" | "showInNav">>) => void;
|
|
115
|
-
onSetAudience: (access: string[]) => void;
|
|
121
|
+
onSetAudience: (access: string[]) => void;
|
|
122
|
+
onSetDocument: (patch: Partial<DocumentOptions>) => void;
|
|
123
|
+
onRequestDelete: () => void;
|
|
116
124
|
}) {
|
|
117
125
|
const draggable = dragIndex !== undefined;
|
|
118
126
|
const { rowRef, handleRef, isDragging, closestEdge } = useSortableRow<HTMLDivElement, HTMLButtonElement>({
|
|
@@ -264,6 +272,12 @@ function PageRow({
|
|
|
264
272
|
className="shrink-0"
|
|
265
273
|
/>
|
|
266
274
|
</div>
|
|
275
|
+
<Checkbox
|
|
276
|
+
label="Document mode"
|
|
277
|
+
description="Adds a presentation view of this page."
|
|
278
|
+
checked={page.document?.enabled ?? false}
|
|
279
|
+
onChange={(enabled) => onSetDocument({ enabled })}
|
|
280
|
+
/>
|
|
267
281
|
<div className="flex items-center gap-2">
|
|
268
282
|
<Button
|
|
269
283
|
variant="secondary"
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { useRef, useEffect, useState, type ReactNode } from "react";
|
|
1
|
+
import { useRef, useEffect, useState, useId, type ReactNode } from "react";
|
|
2
2
|
import { ImageIcon } from "lucide-react";
|
|
3
3
|
import { AddIcon, DragHandle, DeleteIcon, SettingsIcon } from "../shared/icons";
|
|
4
4
|
import { IconButton } from "../shared/IconButton";
|
|
5
5
|
import { cn } from "../../lib/cn";
|
|
6
6
|
import { containerGridClass } from "../../lib/container-grid";
|
|
7
7
|
import { useEditableCollection } from "./useEditableCollection";
|
|
8
|
+
import { resolveDropIndex } from "./gridDrop";
|
|
8
9
|
|
|
9
10
|
interface EditableGridProps<T> {
|
|
10
11
|
items: T[];
|
|
@@ -17,6 +18,16 @@ interface EditableGridProps<T> {
|
|
|
17
18
|
onItemImageClick?: (index: number) => void;
|
|
18
19
|
chromeTopClass?: string;
|
|
19
20
|
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Items can be dragged BETWEEN two EditableGrids that share the same non-null
|
|
23
|
+
* `group` (e.g. two colors sections). Without a group, a grid only reorders
|
|
24
|
+
* its own items. Only pass the same group to grids whose item shape matches —
|
|
25
|
+
* a cross-grid drop inserts the source item verbatim into the destination.
|
|
26
|
+
*/
|
|
27
|
+
group?: string;
|
|
28
|
+
/** Called instead of removing the last item when it is dragged out to another
|
|
29
|
+
* grid — lets the owner tear down a now-empty container (e.g. delete the section). */
|
|
30
|
+
onEmptied?: () => void;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
export function EditableGrid<T>({
|
|
@@ -30,8 +41,11 @@ export function EditableGrid<T>({
|
|
|
30
41
|
onItemImageClick,
|
|
31
42
|
chromeTopClass,
|
|
32
43
|
className,
|
|
44
|
+
group,
|
|
45
|
+
onEmptied,
|
|
33
46
|
}: EditableGridProps<T>) {
|
|
34
|
-
const
|
|
47
|
+
const gridId = useId();
|
|
48
|
+
const { wrappedItems, onReorder, onAdd, onInsert, onInsertItem, onRemove } = useEditableCollection({
|
|
35
49
|
items,
|
|
36
50
|
onChange,
|
|
37
51
|
createItem,
|
|
@@ -44,18 +58,63 @@ export function EditableGrid<T>({
|
|
|
44
58
|
|
|
45
59
|
const [isDragging, setIsDragging] = useState(false);
|
|
46
60
|
|
|
61
|
+
// The drop transaction is centralized here (not in each GridCell) because this
|
|
62
|
+
// monitor is GLOBAL: it fires for every grid-cell drop on the page, so the
|
|
63
|
+
// source grid and destination grid each see the same drop and act on their own
|
|
64
|
+
// collection — source removes, destination inserts, same-grid reorders. Keep
|
|
65
|
+
// the latest handlers/config in a ref so the monitor can be set up once.
|
|
66
|
+
const cfgRef = useRef({ gridId, group, itemCount: wrappedItems.length, onReorder, onRemove, onInsertItem, onEmptied });
|
|
67
|
+
cfgRef.current = { gridId, group, itemCount: wrappedItems.length, onReorder, onRemove, onInsertItem, onEmptied };
|
|
68
|
+
|
|
47
69
|
useEffect(() => {
|
|
48
70
|
let cleanup: (() => void) | undefined;
|
|
49
71
|
let cancelled = false;
|
|
50
72
|
|
|
51
|
-
|
|
73
|
+
Promise.all([
|
|
74
|
+
import("@atlaskit/pragmatic-drag-and-drop/element/adapter"),
|
|
75
|
+
import("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge"),
|
|
76
|
+
]).then(([{ monitorForElements }, { extractClosestEdge }]) => {
|
|
52
77
|
if (cancelled) return;
|
|
53
78
|
cleanup = monitorForElements({
|
|
54
79
|
onDragStart: ({ source }) => {
|
|
55
80
|
if (source.data.dragType === "grid-cell") setIsDragging(true);
|
|
56
81
|
},
|
|
57
|
-
onDrop: ({ source }) => {
|
|
58
|
-
if (source.data.dragType
|
|
82
|
+
onDrop: ({ source, location }) => {
|
|
83
|
+
if (source.data.dragType !== "grid-cell") return;
|
|
84
|
+
setIsDragging(false);
|
|
85
|
+
// Every grid clears its own indicator on any drop — this is what stops
|
|
86
|
+
// the destination grid's drop line from sticking after a cross-grid drop.
|
|
87
|
+
setDragState({ sourceId: null, closestEdge: null });
|
|
88
|
+
|
|
89
|
+
const { gridId: my, group: myGroup, itemCount, onReorder, onRemove, onInsertItem, onEmptied } = cfgRef.current;
|
|
90
|
+
const srcGridId = source.data.gridId as string;
|
|
91
|
+
const target = location.current.dropTargets[0];
|
|
92
|
+
const dstGridId = target?.data.gridId as string | undefined;
|
|
93
|
+
|
|
94
|
+
// Same-grid reorder — only the owning grid acts on it.
|
|
95
|
+
if (srcGridId === my && dstGridId === my && target) {
|
|
96
|
+
const fromIndex = source.data.index as number;
|
|
97
|
+
const edge = extractClosestEdge(target.data) as "left" | "right" | null;
|
|
98
|
+
const toIndex = resolveDropIndex({ fromIndex, targetIndex: target.data.index as number, edge, sameCollection: true });
|
|
99
|
+
if (fromIndex !== toIndex) onReorder(fromIndex, toIndex);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Cross-grid transfer requires a shared group. The source grid removes
|
|
104
|
+
// its item; the destination grid inserts it. Two grids, two updates.
|
|
105
|
+
const crossAllowed = myGroup != null && source.data.group === myGroup;
|
|
106
|
+
if (!crossAllowed) return;
|
|
107
|
+
|
|
108
|
+
if (srcGridId === my && dstGridId && dstGridId !== my) {
|
|
109
|
+
// Dragging the last item out empties this grid — let the owner tear
|
|
110
|
+
// down the now-empty container instead of leaving it behind.
|
|
111
|
+
if (itemCount <= 1 && onEmptied) onEmptied();
|
|
112
|
+
else onRemove(source.data.id as string);
|
|
113
|
+
} else if (dstGridId === my && srcGridId !== my && target) {
|
|
114
|
+
const edge = extractClosestEdge(target.data) as "left" | "right" | null;
|
|
115
|
+
const toIndex = resolveDropIndex({ fromIndex: source.data.index as number, targetIndex: target.data.index as number, edge, sameCollection: false });
|
|
116
|
+
onInsertItem(toIndex, source.data.item as T);
|
|
117
|
+
}
|
|
59
118
|
},
|
|
60
119
|
});
|
|
61
120
|
});
|
|
@@ -88,9 +147,11 @@ export function EditableGrid<T>({
|
|
|
88
147
|
key={wrapped.id}
|
|
89
148
|
id={wrapped.id}
|
|
90
149
|
index={index}
|
|
150
|
+
gridId={gridId}
|
|
151
|
+
group={group}
|
|
152
|
+
item={wrapped.data}
|
|
91
153
|
isLast={index === wrappedItems.length - 1}
|
|
92
154
|
isDragging={isDragging}
|
|
93
|
-
onReorder={onReorder}
|
|
94
155
|
onRemove={onRemove}
|
|
95
156
|
onInsert={onInsert}
|
|
96
157
|
onSettings={onItemSettings ? () => onItemSettings(index) : undefined}
|
|
@@ -117,12 +178,14 @@ export function EditableGrid<T>({
|
|
|
117
178
|
);
|
|
118
179
|
}
|
|
119
180
|
|
|
120
|
-
function GridCell({
|
|
181
|
+
function GridCell<T>({
|
|
121
182
|
id,
|
|
122
183
|
index,
|
|
184
|
+
gridId,
|
|
185
|
+
group,
|
|
186
|
+
item,
|
|
123
187
|
isLast,
|
|
124
188
|
isDragging,
|
|
125
|
-
onReorder,
|
|
126
189
|
onRemove,
|
|
127
190
|
onInsert,
|
|
128
191
|
onSettings,
|
|
@@ -134,9 +197,11 @@ function GridCell({
|
|
|
134
197
|
}: {
|
|
135
198
|
id: string;
|
|
136
199
|
index: number;
|
|
200
|
+
gridId: string;
|
|
201
|
+
group?: string;
|
|
202
|
+
item: T;
|
|
137
203
|
isLast: boolean;
|
|
138
204
|
isDragging: boolean;
|
|
139
|
-
onReorder: (from: number, to: number) => void;
|
|
140
205
|
onRemove: (id: string) => void;
|
|
141
206
|
onInsert: (index: number) => void;
|
|
142
207
|
onSettings?: () => void;
|
|
@@ -165,17 +230,22 @@ function GridCell({
|
|
|
165
230
|
|
|
166
231
|
const cleanupDraggable = draggable({
|
|
167
232
|
element: handle,
|
|
168
|
-
|
|
233
|
+
// `item` rides along so a cross-grid destination can insert it verbatim.
|
|
234
|
+
getInitialData: () => ({ dragType: "grid-cell", gridId, group, id, index, item }),
|
|
169
235
|
onDragStart: () => setDragState({ sourceId: id, closestEdge: null }),
|
|
170
236
|
onDrop: () => setDragState({ sourceId: null, closestEdge: null }),
|
|
171
237
|
});
|
|
172
238
|
|
|
173
239
|
const cleanupDropTarget = dropTargetForElements({
|
|
174
240
|
element: cell,
|
|
175
|
-
|
|
241
|
+
// Accept a reorder within this grid, or a transfer from another grid in
|
|
242
|
+
// the same group. The actual move is performed by the grid-level monitor.
|
|
243
|
+
canDrop: ({ source }) =>
|
|
244
|
+
source.data.dragType === "grid-cell" &&
|
|
245
|
+
(source.data.gridId === gridId || (group != null && source.data.group === group)),
|
|
176
246
|
getData: ({ input, element }) =>
|
|
177
247
|
attachClosestEdge(
|
|
178
|
-
{ id, index },
|
|
248
|
+
{ gridId, id, index },
|
|
179
249
|
{ input, element, allowedEdges: ["left", "right"] },
|
|
180
250
|
),
|
|
181
251
|
onDragEnter: ({ self }) => {
|
|
@@ -189,16 +259,6 @@ function GridCell({
|
|
|
189
259
|
onDragLeave: () => {
|
|
190
260
|
setDragState((prev) => prev.closestEdge?.id === id ? { ...prev, closestEdge: null } : prev);
|
|
191
261
|
},
|
|
192
|
-
onDrop: ({ source, self }) => {
|
|
193
|
-
const fromIndex = source.data.index as number;
|
|
194
|
-
const edge = extractClosestEdge(self.data);
|
|
195
|
-
let toIndex = index;
|
|
196
|
-
if (edge === "right") toIndex = index + 1;
|
|
197
|
-
if (fromIndex < toIndex) toIndex--;
|
|
198
|
-
if (fromIndex !== toIndex) {
|
|
199
|
-
onReorder(fromIndex, toIndex);
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
262
|
});
|
|
203
263
|
|
|
204
264
|
cleanup = () => {
|
|
@@ -211,7 +271,7 @@ function GridCell({
|
|
|
211
271
|
cancelled = true;
|
|
212
272
|
cleanup?.();
|
|
213
273
|
};
|
|
214
|
-
}, [id, index,
|
|
274
|
+
}, [id, index, gridId, group, item, setDragState]);
|
|
215
275
|
|
|
216
276
|
const isCellDragging = dragState.sourceId === id;
|
|
217
277
|
const showLeftEdge = dragState.closestEdge?.id === id && dragState.closestEdge.edge === "left" && dragState.sourceId !== id;
|
|
@@ -221,7 +281,9 @@ function GridCell({
|
|
|
221
281
|
<div
|
|
222
282
|
ref={cellRef}
|
|
223
283
|
className={cn(
|
|
224
|
-
|
|
284
|
+
// h-full so a full-height renderItem (e.g. a colors swatch) fills the
|
|
285
|
+
// stretched grid track and can equalize height across the row.
|
|
286
|
+
"group/cell relative h-full",
|
|
225
287
|
isCellDragging && "opacity-50",
|
|
226
288
|
)}
|
|
227
289
|
>
|