@drawnagency/primitives 0.1.96 → 0.1.97

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.
Files changed (73) hide show
  1. package/dist/{chunk-IFCQWC3G.js → chunk-5BFPJWIO.js} +2 -2
  2. package/dist/{chunk-CI624HRS.js → chunk-F2337B35.js} +1 -1
  3. package/dist/{chunk-CSVGCAIH.js → chunk-FOEZNEF5.js} +6 -6
  4. package/dist/chunk-HJSE6SK5.js +27 -0
  5. package/dist/{chunk-YUUUCDXN.js → chunk-II3X7GLJ.js} +1 -1
  6. package/dist/{chunk-DJAJRBPD.js → chunk-KPP2CFW6.js} +2 -2
  7. package/dist/{chunk-CS2ECR3U.js → chunk-QEHPGA5N.js} +23 -5
  8. package/dist/{chunk-SOILPZ7U.js → chunk-S4L3ZFKM.js} +1 -1
  9. package/dist/{chunk-RQPHPAT2.js → chunk-YDXBJR74.js} +2 -2
  10. package/dist/chunk-ZD6XGRQM.js +85 -0
  11. package/dist/collab/rebase.d.ts +20 -0
  12. package/dist/collab/rebase.d.ts.map +1 -1
  13. package/dist/collab/rebase.js +17 -0
  14. package/dist/components/editor/DropEdgeIndicator.d.ts +6 -1
  15. package/dist/components/editor/DropEdgeIndicator.d.ts.map +1 -1
  16. package/dist/components/editor/NavGroupRow.d.ts +21 -0
  17. package/dist/components/editor/NavGroupRow.d.ts.map +1 -0
  18. package/dist/components/editor/PagesModal.d.ts +7 -1
  19. package/dist/components/editor/PagesModal.d.ts.map +1 -1
  20. package/dist/components/editor/index.js +4 -4
  21. package/dist/components/primitives/index.js +6 -6
  22. package/dist/components/sections/brand-guide.js +5 -5
  23. package/dist/components/sections/register-schemas.js +9 -9
  24. package/dist/components/sections/register.js +9 -9
  25. package/dist/components/shared/Navigation.d.ts.map +1 -1
  26. package/dist/components/shell/EditorShell.d.ts.map +1 -1
  27. package/dist/hooks/useSortableNavRow.d.ts +27 -0
  28. package/dist/hooks/useSortableNavRow.d.ts.map +1 -0
  29. package/dist/index.js +22 -6
  30. package/dist/lib/dexie.d.ts.map +1 -1
  31. package/dist/lib/dexie.js +3 -1
  32. package/dist/lib/index.d.ts +1 -0
  33. package/dist/lib/index.d.ts.map +1 -1
  34. package/dist/lib/index.js +15 -4
  35. package/dist/lib/loader.d.ts +2 -2
  36. package/dist/lib/loader.d.ts.map +1 -1
  37. package/dist/lib/nav-tree.d.ts +63 -0
  38. package/dist/lib/nav-tree.d.ts.map +1 -0
  39. package/dist/lib/nav.d.ts +13 -2
  40. package/dist/lib/nav.d.ts.map +1 -1
  41. package/dist/lib/pages.d.ts +0 -1
  42. package/dist/lib/pages.d.ts.map +1 -1
  43. package/dist/lib/reorder.d.ts +24 -0
  44. package/dist/lib/reorder.d.ts.map +1 -1
  45. package/dist/media/index.js +2 -2
  46. package/dist/schemas/index.d.ts +1 -0
  47. package/dist/schemas/index.d.ts.map +1 -1
  48. package/dist/schemas/index.js +7 -1
  49. package/dist/schemas/nav.d.ts +40 -0
  50. package/dist/schemas/nav.d.ts.map +1 -0
  51. package/dist/schemas/site-config.d.ts +11 -1
  52. package/dist/schemas/site-config.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/src/collab/rebase.ts +35 -0
  55. package/src/components/editor/DropEdgeIndicator.tsx +15 -8
  56. package/src/components/editor/NavGroupRow.tsx +126 -0
  57. package/src/components/editor/PagesModal.tsx +150 -29
  58. package/src/components/shared/Navigation.tsx +51 -13
  59. package/src/components/shell/EditorShell.tsx +40 -10
  60. package/src/hooks/useSortableNavRow.ts +139 -0
  61. package/src/lib/dexie.ts +6 -1
  62. package/src/lib/index.ts +1 -0
  63. package/src/lib/loader.ts +31 -4
  64. package/src/lib/nav-tree.ts +192 -0
  65. package/src/lib/nav.ts +43 -10
  66. package/src/lib/pages.ts +14 -11
  67. package/src/lib/reorder.ts +56 -0
  68. package/src/schemas/index.ts +1 -0
  69. package/src/schemas/nav.ts +36 -0
  70. package/src/schemas/site-config.ts +9 -1
  71. package/dist/chunk-YBVK254P.js +0 -14
  72. /package/dist/{chunk-53DKVAB6.js → chunk-72CG6AA2.js} +0 -0
  73. /package/dist/{chunk-3HJDMFTB.js → chunk-XYCCXKVC.js} +0 -0
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * The site's authored navigation tree, persisted to `src/content/nav.json`.
5
+ *
6
+ * Deliberately NOT a key on index.json: `applyContentWrite` re-serializes the
7
+ * Zod-parsed index, so any writer running a package version that predates a new
8
+ * index key silently deletes it from disk. A sidecar is absent from an old
9
+ * writer's file list and survives untouched.
10
+ */
11
+ export const NavEntrySchema = z.discriminatedUnion("kind", [
12
+ z.object({
13
+ kind: z.literal("page"),
14
+ pageId: z.string().min(1),
15
+ }),
16
+ z.object({
17
+ kind: z.literal("group"),
18
+ id: z.string().min(1),
19
+ /** May be blank — agent-authored files can omit it; UI falls back to "Untitled group". */
20
+ label: z.string().default(""),
21
+ startCollapsed: z.boolean().default(false),
22
+ // Everything but `id` defaults: NavFileSchema is all-or-nothing, and the
23
+ // loader degrades a failed parse to a flat nav — so one agent-authored group
24
+ // missing a key would silently discard every group on the site.
25
+ pageIds: z.array(z.string().min(1)).default([]),
26
+ }),
27
+ ]);
28
+
29
+ export const NavFileSchema = z.object({
30
+ entries: z.array(NavEntrySchema),
31
+ });
32
+
33
+ export type NavEntry = z.infer<typeof NavEntrySchema>;
34
+ export type NavPageEntry = Extract<NavEntry, { kind: "page" }>;
35
+ export type NavGroupEntry = Extract<NavEntry, { kind: "group" }>;
36
+ export type NavFile = z.infer<typeof NavFileSchema>;
@@ -6,6 +6,7 @@ import { CORNER_RADIUS_OPTIONS } from "../lib/corner-radius";
6
6
  // site-config.ts is allowed to reach into its engine to wire the page-level
7
7
  // document options block onto PageSchema.
8
8
  import { documentOptionsSchema } from "../document/engine/settings";
9
+ import type { NavEntry } from "./nav";
9
10
 
10
11
  export const StatusSchema = z.enum(["draft", "live", "archived", "published"]).transform(
11
12
  (val) => val === "published" ? "live" as const : val,
@@ -167,7 +168,14 @@ const CanonicalIndexSchema = z
167
168
 
168
169
  export const IndexSchema = RawIndexSchema.transform(normalizeRawIndex).pipe(CanonicalIndexSchema);
169
170
 
170
- export type SiteIndex = z.infer<typeof CanonicalIndexSchema>;
171
+ /**
172
+ * `nav` is a RUNTIME field only: it is loaded from the src/content/nav.json
173
+ * sidecar and attached by the loader, never parsed from or written to
174
+ * index.json. It is optional because most SiteIndex values (tests, legacy
175
+ * content, partial writes) have no nav — reads go through navEntries(), which
176
+ * reconciles a missing nav into a flat one.
177
+ */
178
+ export type SiteIndex = z.infer<typeof CanonicalIndexSchema> & { nav?: NavEntry[] };
171
179
 
172
180
  /** Parse + normalize any raw index (legacy or canonical) to the canonical shape. */
173
181
  export function normalizeSiteIndex(raw: unknown): SiteIndex {
@@ -1,14 +0,0 @@
1
- // src/lib/pages.ts
2
- function slugifyPageSlug(input) {
3
- return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
4
- }
5
- function audiencePasses(access, audience) {
6
- if (access.length === 0) return true;
7
- if (!audience) return true;
8
- return access.includes(audience);
9
- }
10
-
11
- export {
12
- slugifyPageSlug,
13
- audiencePasses
14
- };
File without changes
File without changes