@prenta/plugin-navigation 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,240 @@
1
+ # @actuate-media/plugin-navigation
2
+
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5eea995: Product rename: ActuateCMS is now **Prenta**. Every package moves from the
8
+ `@actuate-media/*` scope to `@prenta/*` with simplified names (`@prenta/core`,
9
+ `@prenta/admin`, `create-prenta`), and version numbers continue from where the
10
+ old scope left off.
11
+
12
+ This is a clean break — no backwards-compat aliases:
13
+ - **npm packages**: `@actuate-media/cms-core` → `@prenta/core`,
14
+ `@actuate-media/cms-admin` → `@prenta/admin`, all other packages keep their
15
+ suffix under `@prenta/*`. `create-actuate-cms` → `create-prenta`
16
+ (`npm create prenta`), `create-actuate-astro` → `create-prenta-astro`.
17
+ CLI bins: `actuate`/`actuate-cms` → `prenta`/`prenta-cms`; `actuate-mcp` →
18
+ `prenta-mcp`.
19
+ - **Database**: migration `0012_rename_to_prenta` renames all 36 `actuate_*`
20
+ tables to `prenta_*` in place (plus prefixed constraints, indexes, and
21
+ sequences). Run `prisma migrate deploy` when upgrading.
22
+ - **Runtime identifiers**: `getActuateConfig` → `getPrentaConfig`,
23
+ `handleActuateAPI` → `handlePrentaAPI`, `ActuateClient` → `PrentaClient`,
24
+ `ActuateDB` → `PrentaDB`, config file `actuate.config.ts` →
25
+ `prenta.config.ts`, CSS scopes `.actuate-admin`/`.actuate-canvas` →
26
+ `.prenta-admin`/`.prenta-canvas`, preview protocol `actuate-preview:*` →
27
+ `prenta-preview:*`, webhook headers `X-Actuate-*` → `X-Prenta-*`, session
28
+ cookie `actuate_session` → `prenta_session`, env vars `ACTUATE_*` →
29
+ `PRENTA_*`, purge route `/api/actuate/purge` → `/api/prenta/purge`.
30
+ - **Sessions and webhooks**: all sessions reset on upgrade (cookie + JWT issuer
31
+ changed); webhook consumers must re-verify signatures against the new
32
+ `X-Prenta-*` headers.
33
+
34
+ The old `@actuate-media/*` packages are deprecated on npm and will receive no
35
+ further releases.
36
+
37
+ ## 0.2.0
38
+
39
+ ### Minor Changes
40
+
41
+ - 258cbc3: Warn when navigation items link to unpublished or missing internal pages (soft warnings in MCP `validate_navigation_tree`, admin nav builder, and `POST /navigations/validate-targets`).
42
+
43
+ ## 0.1.0
44
+
45
+ ### Minor Changes
46
+
47
+ - 98a5149: Remove the inert `maxDepth` plugin-config option.
48
+
49
+ `navigationPlugin({ maxDepth })` accepted the option but never wired it anywhere —
50
+ `PluginDefinition` has no channel to carry a plugin-level option to the admin UI,
51
+ so a configured `maxDepth` silently did nothing. Nesting depth is controlled by
52
+ the `NavBuilder` component's `maxDepth` prop (default 5), which is unchanged.
53
+ `navigationPlugin()` now takes no arguments; the `NavigationPluginConfig` type is
54
+ removed. (Breaking only for code that passed the no-op option.)
55
+
56
+ ## 0.0.16
57
+
58
+ ### Patch Changes
59
+
60
+ - daf91b4: Fix `outdentItem` corrupting the nav tree on a deep outdent.
61
+
62
+ When the outdented node's parent was itself nested, the recursion threaded the
63
+ grandparent array as `parent` and spliced against it with a `-1` index —
64
+ dropping the parent's sibling and misplacing the promoted node. Since the parent
65
+ is always an element of the current array at its own index, the spurious `parent`
66
+ parameter is removed and the splice uses that index directly. The promoted node
67
+ now lands beside its former parent and siblings are preserved.
68
+
69
+ ## 0.0.15
70
+
71
+ ### Patch Changes
72
+
73
+ - e25cd48: Standardize React peer ranges to `^18.0.0 || ^19.0.0`.
74
+
75
+ Plugin React peer ranges were inconsistent: `plugin-ai`, `plugin-commerce`, and
76
+ `plugin-seo` pinned `react: ^19.2.0` (excluding React 18, which `cms-core`
77
+ supports via `react >=18.0.0`), while the others used `^18.0.0 || ^19.2.0`
78
+ (excluding React 19.0/19.1). Either produced an `ERESOLVE` install failure for
79
+ consumers on the excluded versions. All bundled plugins now declare `react`
80
+ (and `react-dom` where already peered) as `^18.0.0 || ^19.0.0`.
81
+
82
+ ## 0.0.14
83
+
84
+ ### Patch Changes
85
+
86
+ - c231dd0: Add `definePlugin` and migrate all 10 plugins onto the canonical `PluginDefinition` contract.
87
+
88
+ cms-core already exported `PluginDefinition`, but every plugin hand-rolled a
89
+ local `ActuatePlugin` interface — a lossy subset that dropped `version`/`init`
90
+ and, in blocks/email/ai, widened hook payloads to `unknown[]`/`event: string`.
91
+ That's copy-paste drift with no shared source of truth.
92
+
93
+ `cms-core` now exports `definePlugin(plugin: PluginDefinition)` (an identity
94
+ helper like `defineConfig`), and each plugin imports the canonical type instead
95
+ of its own: the local `ActuatePlugin` interfaces are deleted, factory return
96
+ types are `PluginDefinition`, and the widened `hooks.ts` types are retyped as
97
+ `PluginHook[]`. Type-only change — no runtime behavior, plugin `name`, or config
98
+ options changed. Net −69 lines.
99
+
100
+ - 325694f: Import `definePlugin` from the lightweight `@actuate-media/cms-core/config`
101
+ entry instead of the barrel.
102
+
103
+ The plugin-definition migration imported the `definePlugin` **value** from
104
+ `@actuate-media/cms-core`, which pulls the entire cms-core barrel (graphql,
105
+ sharp, sentry, codegen) into every plugin's runtime — bundle bloat for
106
+ consumers and, under parallel test load, a timeout. The `/config` subpath exists
107
+ precisely to avoid the barrel. Types stay as erased `import type`, so nothing
108
+ heavy is loaded. No API or behavior change.
109
+
110
+ ## 0.0.13
111
+
112
+ ### Patch Changes
113
+
114
+ - 041a228: Add the MIT `license` field to every published package (previously missing) and correct `repository.url` to `github.com/actuate-media/actuatecms` (13 packages carried the wrong org).
115
+ - de419f2: Give plugin hooks a frozen, typed event contract. cms-core now exports
116
+ `PluginHook`, `PluginHookEvent`, and `PluginHookPayload` (document + upload
117
+ variants) as the single source of truth, and dispatches a complete, consistent
118
+ set of events: `afterCreate` / `afterUpdate` / `afterDelete` — each also in a
119
+ collection-namespaced form (`afterUpdate:navigations`, `afterCreate:orders`) —
120
+ plus `afterUpload` (fired post-upload from the media route). Every handler now
121
+ receives one typed payload; document field values live on `payload.data`.
122
+
123
+ Previously core fired only bare `afterCreate`/`afterUpdate` with the raw row, so
124
+ several shipped plugins' hooks were dead: `plugin-media`'s `afterUpload` never
125
+ fired, `plugin-navigation` read fields that didn't exist, and the namespaced
126
+ events `plugin-forms`/`plugin-commerce` declared were never dispatched. Each
127
+ plugin has been aligned to the shared type and dispatched events (and
128
+ `plugin-redirects`' request-time `onRedirectMatch` hook — which the lifecycle
129
+ bus never dispatched — was removed). Undispatched event names are now a
130
+ compile-time error.
131
+
132
+ ## 0.0.12
133
+
134
+ ### Patch Changes
135
+
136
+ - 854152d: Developer experience improvements from external-consumer feedback:
137
+ - Every published package now ships its `CHANGELOG.md` in the npm tarball, and packages that were missing a `README.md` (cli, cms-admin, cms-core, import, platform-vercel, all plugins, sections-react) now have one — so release notes and usage docs are visible on npmjs.com and in `node_modules`.
138
+ - New client-safe form validation entry point: `@actuate-media/cms-core/forms/client` exports `validateFormFieldClient()`, `validateFormValuesClient()`, visibility/conditional helpers, and the exact `FORM_EMAIL_RE` / `FORM_PHONE_RE` regexes the server enforces — zero Node dependencies, so public-site forms can mirror server rules without reimplementing them. The server validator now imports the same primitives, so client and server can never drift.
139
+
140
+ ## 0.0.11
141
+
142
+ ### Patch Changes
143
+
144
+ - b5de8dd: Fix ESM module resolution and dependency duplication issues reported during consumer integration.
145
+ - Add "default" export condition to all platform and plugin packages so they resolve correctly from require() contexts (fixes ERR_PACKAGE_PATH_NOT_EXPORTED in next.config.ts and serverless functions).
146
+ - Move @actuate-media/cms-core from direct dependencies to peerDependencies across all packages to prevent duplicate installations when consumer version ranges don't exactly match the pinned version.
147
+ - Add "prepack" lifecycle script to create-actuate-cms to guarantee dist/ is built before npm publishes the package (fixes empty dist/ in v0.4.0).
148
+
149
+ ## 0.0.10
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [54c7a3b]
154
+ - @actuate-media/cms-core@0.6.0
155
+
156
+ ## 0.0.9
157
+
158
+ ### Patch Changes
159
+
160
+ - Updated dependencies [c08cf8b]
161
+ - Updated dependencies [80aa939]
162
+ - @actuate-media/cms-core@0.5.0
163
+
164
+ ## 0.0.8
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [f2cf7d7]
169
+ - @actuate-media/cms-core@0.4.0
170
+
171
+ ## 0.0.7
172
+
173
+ ### Patch Changes
174
+
175
+ - Updated dependencies [0621037]
176
+ - @actuate-media/cms-core@0.3.1
177
+
178
+ ## 0.0.6
179
+
180
+ ### Patch Changes
181
+
182
+ - Updated dependencies [4e3a5eb]
183
+ - @actuate-media/cms-core@0.3.0
184
+
185
+ ## 0.0.5
186
+
187
+ ### Patch Changes
188
+
189
+ - Updated dependencies
190
+ - @actuate-media/cms-core@0.2.3
191
+
192
+ ## 0.0.4
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies
197
+ - @actuate-media/cms-core@0.2.2
198
+
199
+ ## 0.0.3
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies
204
+ - @actuate-media/cms-core@0.2.1
205
+
206
+ ## 0.0.2
207
+
208
+ ### Patch Changes
209
+
210
+ - 3fd38a2: Fix all 13 integration issues discovered during MaidPro.co deployment
211
+
212
+ **cms-core:**
213
+ - Add .js extensions to all ESM relative imports (58 files)
214
+ - Replace workspace:\* with versioned deps in all packages
215
+ - Add sideEffects:false for proper tree-shaking
216
+ - Subpath exports (/config, /api, /middleware, /next) avoid barrel side effects
217
+ - Stats/search routes use safeCount/safeFindMany for missing Prisma models
218
+ - Ship prisma/cms-schema.prisma with all required CMS models
219
+ - Accept both CMS_SECRET and CMS_SESSION_SECRET with clear error messages
220
+ - Fix hardcoded /admin paths in OAuth flow (now uses getAdminPath())
221
+ - Loosen withActuateCMS and createCMSMiddleware parameter types
222
+ - Auto-inject transpilePackages and serverExternalPackages in withActuateCMS
223
+ - Unify PluginDefinition with ActuatePlugin interface
224
+
225
+ **cms-admin:**
226
+ - Scope all 40+ CSS theme variables to .actuate-admin instead of :root
227
+ - ThemeProvider applies dark class to .actuate-admin, not document.documentElement
228
+ - Scaffold uses (admin)/(site) route groups for full CSS/script isolation
229
+ - Sidebar branding supports custom logo via config.admin.branding
230
+
231
+ **platform-vercel:**
232
+ - Email adapter accepts both `from` and `defaultFrom`
233
+
234
+ **All plugin/platform packages:**
235
+ - Fix ESM .js extensions in compiled output
236
+ - Replace workspace:\* with ^0.1.0 for publishable deps
237
+
238
+ - Updated dependencies [682dac7]
239
+ - Updated dependencies [3fd38a2]
240
+ - @actuate-media/cms-core@0.2.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Actuate Media
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @prenta/plugin-navigation
2
+
3
+ Navigation menus for [Prenta CMS](https://github.com/actuate-media/prenta)
4
+ — editable nav collections consumed by your site header/footer.
5
+
6
+ ```bash
7
+ npm install @prenta/plugin-navigation
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```ts
13
+ import { navigationPlugin } from '@prenta/plugin-navigation'
14
+
15
+ export default defineConfig({
16
+ plugins: [navigationPlugin()],
17
+ // ...
18
+ })
19
+ ```
20
+
21
+ ## Release notes
22
+
23
+ See [CHANGELOG.md](./CHANGELOG.md) (shipped with the package) or the
24
+ [GitHub releases](https://github.com/actuate-media/prenta/releases).
25
+
26
+ ## License
27
+
28
+ MIT
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,156 @@
1
+ import { describe, it, expect, vi, afterEach } from 'vitest';
2
+ import { navigationPlugin, navigationHooks } from '../index.js';
3
+ import { navigationCollections } from '../collections.js';
4
+ function setConfig(config) {
5
+ ;
6
+ globalThis.__prentaConfig = config;
7
+ }
8
+ function docPayload(overrides = {}) {
9
+ return {
10
+ id: 'nav_1',
11
+ collection: 'navigations',
12
+ slug: 'main',
13
+ status: 'published',
14
+ data: { name: 'Main Navigation', items: [] },
15
+ ...overrides,
16
+ };
17
+ }
18
+ afterEach(() => {
19
+ setConfig(undefined);
20
+ });
21
+ describe('navigation', () => {
22
+ describe('structure', () => {
23
+ it('returns name navigation', () => {
24
+ expect(navigationPlugin().name).toBe('navigation');
25
+ });
26
+ it('exposes fields, collections, and admin nav', () => {
27
+ const plugin = navigationPlugin();
28
+ expect(plugin.fields).toBeDefined();
29
+ expect(typeof plugin.fields).toBe('object');
30
+ expect(plugin.collections).toBeDefined();
31
+ expect(Object.keys(plugin.collections ?? {}).length).toBeGreaterThan(0);
32
+ expect(plugin.adminNavItems).toEqual([
33
+ { label: 'Navigation', icon: 'menu', path: '/navigations' },
34
+ ]);
35
+ });
36
+ it('exposes navigation hooks on the plugin', () => {
37
+ const plugin = navigationPlugin();
38
+ expect(plugin.hooks).toBe(navigationHooks);
39
+ expect(plugin.hooks.length).toBeGreaterThan(0);
40
+ });
41
+ });
42
+ describe('afterUpdate hook', () => {
43
+ it('registers for the collection-namespaced afterUpdate:navigations event', () => {
44
+ expect(navigationHooks[0].event).toBe('afterUpdate:navigations');
45
+ });
46
+ it('invalidates the navigation cache via cache.onInvalidate', async () => {
47
+ const onInvalidate = vi.fn(async (_tags) => { });
48
+ setConfig({ cache: { onInvalidate } });
49
+ await navigationHooks[0].handler(docPayload({ id: 'nav_42' }));
50
+ expect(onInvalidate).toHaveBeenCalledTimes(1);
51
+ const tags = onInvalidate.mock.calls[0][0];
52
+ expect(tags).toContain('prenta:collection:navigations');
53
+ expect(tags).toContain('prenta:doc:nav_42');
54
+ });
55
+ it('emits EXACTLY the two narrow tags — no root and no path tags (#544)', async () => {
56
+ // #544 regression guard: a menu edit must invalidate ONLY the navigations
57
+ // collection tag and this doc's tag. Re-introducing the wholesale
58
+ // `prenta` root tag (which purged the entire site on every menu edit) or
59
+ // any `prenta:path:*` tag is the exact over-invalidation this pins shut.
60
+ const onInvalidate = vi.fn(async (_tags) => { });
61
+ setConfig({ cache: { onInvalidate } });
62
+ await navigationHooks[0].handler(docPayload({ id: 'nav_42' }));
63
+ const tags = onInvalidate.mock.calls[0][0];
64
+ expect(tags).toEqual(['prenta:collection:navigations', 'prenta:doc:nav_42']);
65
+ expect(tags).toHaveLength(2);
66
+ expect(tags.includes('prenta')).toBe(false);
67
+ expect(tags.every((t) => !t.startsWith('prenta:path:'))).toBe(true);
68
+ });
69
+ it('threads the document id through to the doc tag', async () => {
70
+ const onInvalidate = vi.fn(async (_tags) => { });
71
+ setConfig({ cache: { onInvalidate } });
72
+ await navigationHooks[0].handler(docPayload({ id: 'nav_footer_2026' }));
73
+ expect(onInvalidate.mock.calls[0][0]).toEqual([
74
+ 'prenta:collection:navigations',
75
+ 'prenta:doc:nav_footer_2026',
76
+ ]);
77
+ });
78
+ it('propagates a rejecting cache.onInvalidate out of the handler', async () => {
79
+ // Pins the CURRENT contract: the handler `await`s onInvalidate with no
80
+ // try/catch, so a rejection surfaces to the caller. (cms-core's
81
+ // runMatchingHooks wraps the call in try/catch and only logs, so an
82
+ // end-to-end write still succeeds — but a direct handler invocation, like
83
+ // this one, sees the rejection.) A future try/catch here would flip this
84
+ // to resolve and this test would catch that silent behavior change.
85
+ const onInvalidate = vi.fn(async (_tags) => {
86
+ throw new Error('boom');
87
+ });
88
+ setConfig({ cache: { onInvalidate } });
89
+ await expect(navigationHooks[0].handler(docPayload({ id: 'nav_err' }))).rejects.toThrow('boom');
90
+ // The id is still threaded correctly on the throwing path (onInvalidate is
91
+ // called with the canonical tags before it rejects).
92
+ expect(onInvalidate.mock.calls[0][0]).toContain('prenta:doc:nav_err');
93
+ });
94
+ it('no-ops safely when no cache is configured', async () => {
95
+ setConfig({});
96
+ await expect(navigationHooks[0].handler(docPayload())).resolves.toBeUndefined();
97
+ });
98
+ it('no-ops safely when no config is registered', async () => {
99
+ setConfig(undefined);
100
+ await expect(navigationHooks[0].handler(docPayload())).resolves.toBeUndefined();
101
+ });
102
+ });
103
+ describe('navigations collection contract', () => {
104
+ // These fields drive real cms-core write-validation and slug generation, so
105
+ // the config is behaviorally load-bearing: dropping `required`/`unique`, the
106
+ // slug `from`, the location whitelist, or `timestamps` silently breaks the
107
+ // CMS. Assert the contract, not just "a collection exists".
108
+ const nav = navigationCollections.navigations;
109
+ it('registers under the `navigations` slug', () => {
110
+ expect(nav.slug).toBe('navigations');
111
+ });
112
+ it('requires a menu name', () => {
113
+ const name = nav.fields.name;
114
+ expect(name.type).toBe('text');
115
+ expect(name.required).toBe(true);
116
+ });
117
+ it('derives a unique, required slug from the name', () => {
118
+ const slug = nav.fields.slug;
119
+ expect(slug.type).toBe('slug');
120
+ expect(slug.required).toBe(true);
121
+ expect(slug.unique).toBe(true);
122
+ if (slug.type === 'slug') {
123
+ expect(slug.from).toBe('name');
124
+ }
125
+ });
126
+ it('restricts location to exactly header/footer/sidebar/mobile', () => {
127
+ const location = nav.fields.location;
128
+ expect(location.type).toBe('select');
129
+ if (location.type === 'select') {
130
+ expect(location.options.map((o) => o.value)).toEqual([
131
+ 'header',
132
+ 'footer',
133
+ 'sidebar',
134
+ 'mobile',
135
+ ]);
136
+ }
137
+ });
138
+ it('enables timestamps and titles rows by name', () => {
139
+ expect(nav.timestamps).toBe(true);
140
+ expect(nav.admin?.useAsTitle).toBe('name');
141
+ });
142
+ it('surfaces this exact collection object through the plugin', () => {
143
+ // definePlugin is an identity pass-through, so the plugin must expose the
144
+ // very same collection the CMS reads — not a divergent copy.
145
+ const plugin = navigationPlugin();
146
+ expect(plugin.collections).toBe(navigationCollections);
147
+ expect(plugin.collections.navigations).toBe(nav);
148
+ });
149
+ });
150
+ // maxDepth is a NavBuilder component prop, not a plugin-config option, so the
151
+ // factory intentionally takes no arguments — there is nothing to thread.
152
+ it('takes no config options', () => {
153
+ expect(navigationPlugin).toHaveLength(0);
154
+ });
155
+ });
156
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAE5D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,SAAS,SAAS,CAAC,MAAe;IAChC,CAAC;IAAC,UAA2C,CAAC,cAAc,GAAG,MAAM,CAAA;AACvE,CAAC;AAED,SAAS,UAAU,CAAC,YAAgD,EAAE;IACpE,OAAO;QACL,EAAE,EAAE,OAAO;QACX,UAAU,EAAE,aAAa;QACzB,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,WAAW;QACnB,IAAI,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,EAAE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../src/__tests__/nav-builder.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,222 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { removeItem, findItemDepth, moveItemUp, moveItemDown, indentItem, outdentItem, } from '../admin/NavBuilder.js';
3
+ // The NavBuilder tree helpers are the plugin's only real branching logic. They
4
+ // are pure (no DOM) so they run in the configured node env. Each test builds a
5
+ // FRESH tree because `indentItem` mutates the promoted node's parent in place.
6
+ const ids = (items) => items.map((i) => i.id);
7
+ function findById(items, id) {
8
+ for (const item of items) {
9
+ if (item.id === id)
10
+ return item;
11
+ if (item.children) {
12
+ const found = findById(item.children, id);
13
+ if (found)
14
+ return found;
15
+ }
16
+ }
17
+ return undefined;
18
+ }
19
+ describe('NavBuilder tree helpers', () => {
20
+ describe('findItemDepth', () => {
21
+ const tree = () => [
22
+ { id: 'a', label: 'A', url: '/a' },
23
+ {
24
+ id: 'b',
25
+ label: 'B',
26
+ url: '/b',
27
+ children: [
28
+ { id: 'b1', label: 'B1', url: '/b1', children: [{ id: 'b1a', label: 'B1A', url: '/x' }] },
29
+ { id: 'b2', label: 'B2', url: '/b2' },
30
+ ],
31
+ },
32
+ ];
33
+ it('returns 0 for top-level items', () => {
34
+ expect(findItemDepth(tree(), 'a')).toBe(0);
35
+ expect(findItemDepth(tree(), 'b')).toBe(0);
36
+ });
37
+ it('returns 1 and 2 for progressively nested items', () => {
38
+ expect(findItemDepth(tree(), 'b1')).toBe(1);
39
+ expect(findItemDepth(tree(), 'b2')).toBe(1);
40
+ expect(findItemDepth(tree(), 'b1a')).toBe(2);
41
+ });
42
+ it('returns -1 for a missing id', () => {
43
+ expect(findItemDepth(tree(), 'nope')).toBe(-1);
44
+ });
45
+ });
46
+ describe('removeItem', () => {
47
+ const tree = () => [
48
+ { id: 'a', label: 'A', url: '/a' },
49
+ {
50
+ id: 'b',
51
+ label: 'B',
52
+ url: '/b',
53
+ children: [
54
+ { id: 'b1', label: 'B1', url: '/b1' },
55
+ { id: 'b2', label: 'B2', url: '/b2', children: [{ id: 'b2a', label: 'B2A', url: '/x' }] },
56
+ ],
57
+ },
58
+ { id: 'c', label: 'C', url: '/c' },
59
+ ];
60
+ it('prunes a deeply nested id while leaving every sibling intact', () => {
61
+ const result = removeItem(tree(), 'b2a');
62
+ expect(ids(result)).toEqual(['a', 'b', 'c']);
63
+ const b = findById(result, 'b');
64
+ expect(ids(b.children)).toEqual(['b1', 'b2']);
65
+ // b2's children array is emptied (not collapsed to undefined) by removeItem
66
+ expect(findById(result, 'b2').children).toHaveLength(0);
67
+ expect(findItemDepth(result, 'b2a')).toBe(-1);
68
+ });
69
+ it('removes a top-level id and keeps the other top-level siblings', () => {
70
+ expect(ids(removeItem(tree(), 'b'))).toEqual(['a', 'c']);
71
+ });
72
+ });
73
+ describe('moveItemUp', () => {
74
+ const tree = () => [
75
+ { id: 'A', label: 'A', url: '/a' },
76
+ { id: 'B', label: 'B', url: '/b' },
77
+ {
78
+ id: 'P',
79
+ label: 'P',
80
+ url: '/p',
81
+ children: [
82
+ { id: 'X', label: 'X', url: '/x' },
83
+ { id: 'Y', label: 'Y', url: '/y' },
84
+ { id: 'Z', label: 'Z', url: '/z' },
85
+ ],
86
+ },
87
+ ];
88
+ it('is a no-op for the first sibling (index 0 recurses without swapping)', () => {
89
+ expect(ids(moveItemUp(tree(), 'A'))).toEqual(['A', 'B', 'P']);
90
+ });
91
+ it('swaps a mid-list top-level sibling with the one above it', () => {
92
+ expect(ids(moveItemUp(tree(), 'B'))).toEqual(['B', 'A', 'P']);
93
+ });
94
+ it('recurses into children to swap a nested sibling', () => {
95
+ const result = moveItemUp(tree(), 'Y');
96
+ expect(ids(result)).toEqual(['A', 'B', 'P']);
97
+ expect(ids(findById(result, 'P').children)).toEqual(['Y', 'X', 'Z']);
98
+ });
99
+ it('is a no-op for the first nested child', () => {
100
+ const result = moveItemUp(tree(), 'X');
101
+ expect(ids(findById(result, 'P').children)).toEqual(['X', 'Y', 'Z']);
102
+ });
103
+ });
104
+ describe('moveItemDown', () => {
105
+ const tree = () => [
106
+ { id: 'A', label: 'A', url: '/a' },
107
+ { id: 'B', label: 'B', url: '/b' },
108
+ {
109
+ id: 'P',
110
+ label: 'P',
111
+ url: '/p',
112
+ children: [
113
+ { id: 'X', label: 'X', url: '/x' },
114
+ { id: 'Y', label: 'Y', url: '/y' },
115
+ { id: 'Z', label: 'Z', url: '/z' },
116
+ ],
117
+ },
118
+ ];
119
+ it('swaps a top-level item with the one below it', () => {
120
+ expect(ids(moveItemDown(tree(), 'A'))).toEqual(['B', 'A', 'P']);
121
+ });
122
+ it('is a no-op for the last top-level sibling', () => {
123
+ expect(ids(moveItemDown(tree(), 'P'))).toEqual(['A', 'B', 'P']);
124
+ });
125
+ it('recurses into children to swap a nested sibling', () => {
126
+ const result = moveItemDown(tree(), 'X');
127
+ expect(ids(findById(result, 'P').children)).toEqual(['Y', 'X', 'Z']);
128
+ });
129
+ it('is a no-op for the last nested child', () => {
130
+ const result = moveItemDown(tree(), 'Z');
131
+ expect(ids(findById(result, 'P').children)).toEqual(['X', 'Y', 'Z']);
132
+ });
133
+ });
134
+ describe('indentItem', () => {
135
+ it('makes an item a child of its previous sibling', () => {
136
+ const tree = [
137
+ { id: 'A', label: 'A', url: '/a' },
138
+ { id: 'B', label: 'B', url: '/b' },
139
+ { id: 'C', label: 'C', url: '/c' },
140
+ ];
141
+ const result = indentItem(tree, 'B');
142
+ expect(ids(result)).toEqual(['A', 'C']);
143
+ expect(ids(findById(result, 'A').children)).toEqual(['B']);
144
+ });
145
+ it('appends to the previous sibling`s existing children', () => {
146
+ const tree = [
147
+ { id: 'A', label: 'A', url: '/a', children: [{ id: 'A1', label: 'A1', url: '/a1' }] },
148
+ { id: 'B', label: 'B', url: '/b' },
149
+ ];
150
+ const result = indentItem(tree, 'B');
151
+ expect(ids(result)).toEqual(['A']);
152
+ expect(ids(findById(result, 'A').children)).toEqual(['A1', 'B']);
153
+ });
154
+ it('is a no-op for the first sibling (nothing to indent under)', () => {
155
+ const tree = [
156
+ { id: 'A', label: 'A', url: '/a' },
157
+ { id: 'B', label: 'B', url: '/b' },
158
+ ];
159
+ expect(ids(indentItem(tree, 'A'))).toEqual(['A', 'B']);
160
+ });
161
+ });
162
+ describe('outdentItem', () => {
163
+ it('promotes a lone child to just after its former parent and empties the parent', () => {
164
+ const tree = [
165
+ { id: 'P', label: 'P', url: '/p', children: [{ id: 'C', label: 'C', url: '/c' }] },
166
+ { id: 'Q', label: 'Q', url: '/q' },
167
+ ];
168
+ const result = outdentItem(tree, 'C');
169
+ expect(ids(result)).toEqual(['P', 'C', 'Q']);
170
+ // parent had only this child, so its children array collapses to undefined
171
+ expect(findById(result, 'P').children).toBeUndefined();
172
+ expect(findItemDepth(result, 'C')).toBe(0);
173
+ });
174
+ it('promotes one child while the parent keeps its remaining children', () => {
175
+ const tree = [
176
+ {
177
+ id: 'P',
178
+ label: 'P',
179
+ url: '/p',
180
+ children: [
181
+ { id: 'C1', label: 'C1', url: '/c1' },
182
+ { id: 'C2', label: 'C2', url: '/c2' },
183
+ ],
184
+ },
185
+ { id: 'Q', label: 'Q', url: '/q' },
186
+ ];
187
+ const result = outdentItem(tree, 'C1');
188
+ expect(ids(result)).toEqual(['P', 'C1', 'Q']);
189
+ expect(ids(findById(result, 'P').children)).toEqual(['C2']);
190
+ expect(findItemDepth(result, 'C1')).toBe(0);
191
+ });
192
+ it('is a no-op (same reference) when the id is not found', () => {
193
+ const tree = [
194
+ { id: 'P', label: 'P', url: '/p', children: [{ id: 'C', label: 'C', url: '/c' }] },
195
+ ];
196
+ expect(outdentItem(tree, 'missing')).toBe(tree);
197
+ });
198
+ // Deep outdent (the target's parent is itself nested): the promoted node
199
+ // must land beside its former parent inside the SAME array, preserving that
200
+ // parent's siblings. Reachable from the real UI — the outdent button shows
201
+ // at any depth > 0.
202
+ it('promotes a grandchild beside its parent and preserves the parent`s sibling', () => {
203
+ const tree = [
204
+ {
205
+ id: 'Root',
206
+ label: 'Root',
207
+ url: '/root',
208
+ children: [
209
+ { id: 'P', label: 'P', url: '/p', children: [{ id: 'C', label: 'C', url: '/c' }] },
210
+ { id: 'Q', label: 'Q', url: '/q' },
211
+ ],
212
+ },
213
+ ];
214
+ const result = outdentItem(tree, 'C');
215
+ const root = findById(result, 'Root');
216
+ expect(ids(root.children)).toEqual(['P', 'C', 'Q']);
217
+ expect(findById(result, 'P').children).toBeUndefined();
218
+ expect(findItemDepth(result, 'C')).toBe(1);
219
+ });
220
+ });
221
+ });
222
+ //# sourceMappingURL=nav-builder.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-builder.test.js","sourceRoot":"","sources":["../../src/__tests__/nav-builder.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EACL,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,UAAU,EACV,WAAW,GAEZ,MAAM,wBAAwB,CAAA;AAE/B,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAE/E,MAAM,GAAG,GAAG,CAAC,KAAgB,EAAY,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAElE,SAAS,QAAQ,CAAC,KAAgB,EAAE,EAAU;IAC5C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE;YAAE,OAAO,IAAI,CAAA;QAC/B,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;YACzC,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAA;QACzB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;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W,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YACrC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAE,CAAA;YACtC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;YACpD,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAE,CAAC,QAAQ,CAAC,CAAC,aAAa,EAAE,CAAA;YACvD,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC5C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,27 @@
1
+ export interface NavItem {
2
+ id: string;
3
+ label: string;
4
+ url: string;
5
+ target?: '_blank' | '_self';
6
+ children?: NavItem[];
7
+ }
8
+ interface NavBuilderProps {
9
+ items: NavItem[];
10
+ onChange: (items: NavItem[]) => void;
11
+ maxDepth?: number;
12
+ availablePages?: Array<{
13
+ id: string;
14
+ title: string;
15
+ url: string;
16
+ }>;
17
+ }
18
+ export declare function removeItem(items: NavItem[], targetId: string): NavItem[];
19
+ export declare function findItemDepth(items: NavItem[], targetId: string, depth?: number): number;
20
+ export declare function moveItemUp(items: NavItem[], targetId: string): NavItem[];
21
+ export declare function moveItemDown(items: NavItem[], targetId: string): NavItem[];
22
+ export declare function indentItem(items: NavItem[], targetId: string): NavItem[];
23
+ export declare function outdentItem(items: NavItem[], targetId: string): NavItem[];
24
+ /** Interactive tree builder for managing hierarchical navigation menus. */
25
+ export declare function NavBuilder({ items, onChange, maxDepth, availablePages }: NavBuilderProps): import("react/jsx-runtime").JSX.Element;
26
+ export {};
27
+ //# sourceMappingURL=NavBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavBuilder.d.ts","source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K,EAAE,QAAQ,EAAE,QAAY,EAAE,cAAc,EAAE,EAAE,eAAe,2CAmK5F"}
@@ -0,0 +1,205 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useState, useCallback } from 'react';
4
+ function generateId() {
5
+ return `nav-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
6
+ }
7
+ export function removeItem(items, targetId) {
8
+ return items
9
+ .filter((item) => item.id !== targetId)
10
+ .map((item) => ({
11
+ ...item,
12
+ children: item.children ? removeItem(item.children, targetId) : undefined,
13
+ }));
14
+ }
15
+ export function findItemDepth(items, targetId, depth = 0) {
16
+ for (const item of items) {
17
+ if (item.id === targetId)
18
+ return depth;
19
+ if (item.children) {
20
+ const found = findItemDepth(item.children, targetId, depth + 1);
21
+ if (found !== -1)
22
+ return found;
23
+ }
24
+ }
25
+ return -1;
26
+ }
27
+ export function moveItemUp(items, targetId) {
28
+ const idx = items.findIndex((item) => item.id === targetId);
29
+ if (idx > 0) {
30
+ const result = [...items];
31
+ [result[idx - 1], result[idx]] = [result[idx], result[idx - 1]];
32
+ return result;
33
+ }
34
+ return items.map((item) => ({
35
+ ...item,
36
+ children: item.children ? moveItemUp(item.children, targetId) : undefined,
37
+ }));
38
+ }
39
+ export function moveItemDown(items, targetId) {
40
+ const idx = items.findIndex((item) => item.id === targetId);
41
+ if (idx !== -1 && idx < items.length - 1) {
42
+ const result = [...items];
43
+ [result[idx], result[idx + 1]] = [result[idx + 1], result[idx]];
44
+ return result;
45
+ }
46
+ return items.map((item) => ({
47
+ ...item,
48
+ children: item.children ? moveItemDown(item.children, targetId) : undefined,
49
+ }));
50
+ }
51
+ export function indentItem(items, targetId) {
52
+ const idx = items.findIndex((item) => item.id === targetId);
53
+ if (idx > 0) {
54
+ const result = [...items];
55
+ const target = result.splice(idx, 1)[0];
56
+ const newParent = result[idx - 1];
57
+ newParent.children = [...(newParent.children ?? []), target];
58
+ return result;
59
+ }
60
+ return items.map((item) => ({
61
+ ...item,
62
+ children: item.children ? indentItem(item.children, targetId) : undefined,
63
+ }));
64
+ }
65
+ export function outdentItem(items, targetId) {
66
+ for (let i = 0; i < items.length; i++) {
67
+ const item = items[i];
68
+ if (item.children) {
69
+ const childIdx = item.children.findIndex((c) => c.id === targetId);
70
+ if (childIdx !== -1) {
71
+ // `target` is a direct child of `item`. Promote it to be `item`'s
72
+ // sibling, immediately after `item`, in THIS array. Because
73
+ // `item === items[i]`, the array that holds it is always `items` and
74
+ // its index is always `i` — no need to thread a `parent` array (doing
75
+ // so passed the grandparent level at depth and spliced with a -1 index,
76
+ // dropping the real sibling and misplacing the promoted node).
77
+ const target = item.children[childIdx];
78
+ const newChildren = item.children.filter((_, j) => j !== childIdx);
79
+ const updatedParent = {
80
+ ...item,
81
+ children: newChildren.length > 0 ? newChildren : undefined,
82
+ };
83
+ const result = [...items];
84
+ result.splice(i, 1, updatedParent);
85
+ result.splice(i + 1, 0, target);
86
+ return result;
87
+ }
88
+ const nested = outdentItem(item.children, targetId);
89
+ if (nested !== item.children) {
90
+ return items.map((it) => (it.id === item.id ? { ...it, children: nested } : it));
91
+ }
92
+ }
93
+ }
94
+ return items;
95
+ }
96
+ function NavItemRow({ item, depth, maxDepth, onRemove, onMoveUp, onMoveDown, onIndent, onOutdent, onUpdateLabel, onUpdateUrl, }) {
97
+ const btnStyle = {
98
+ background: 'none',
99
+ border: '1px solid #d1d5db',
100
+ borderRadius: 4,
101
+ padding: '2px 6px',
102
+ cursor: 'pointer',
103
+ fontSize: 12,
104
+ color: '#374151',
105
+ };
106
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { style: {
107
+ display: 'flex',
108
+ alignItems: 'center',
109
+ gap: 8,
110
+ padding: '6px 8px',
111
+ marginLeft: depth * 24,
112
+ border: '1px solid #e5e7eb',
113
+ borderRadius: 6,
114
+ marginBottom: 4,
115
+ background: '#fff',
116
+ }, children: [_jsx("span", { style: { cursor: 'grab', color: '#9ca3af' }, children: "\u2630" }), _jsx("input", { type: "text", value: item.label, onChange: (e) => onUpdateLabel(item.id, e.target.value), placeholder: "Label", style: {
117
+ flex: 1,
118
+ border: '1px solid #e5e7eb',
119
+ borderRadius: 4,
120
+ padding: '3px 8px',
121
+ fontSize: 13,
122
+ minWidth: 0,
123
+ } }), _jsx("input", { type: "text", value: item.url, onChange: (e) => onUpdateUrl(item.id, e.target.value), placeholder: "/url", style: {
124
+ flex: 1,
125
+ border: '1px solid #e5e7eb',
126
+ borderRadius: 4,
127
+ padding: '3px 8px',
128
+ fontSize: 13,
129
+ fontFamily: 'monospace',
130
+ minWidth: 0,
131
+ } }), _jsxs("div", { style: { display: 'flex', gap: 2 }, children: [_jsx("button", { style: btnStyle, onClick: () => onMoveUp(item.id), title: "Move up", children: "\u2191" }), _jsx("button", { style: btnStyle, onClick: () => onMoveDown(item.id), title: "Move down", children: "\u2193" }), depth < maxDepth - 1 && (_jsx("button", { style: btnStyle, onClick: () => onIndent(item.id), title: "Indent", children: "\u2192" })), depth > 0 && (_jsx("button", { style: btnStyle, onClick: () => onOutdent(item.id), title: "Outdent", children: "\u2190" })), _jsx("button", { style: { ...btnStyle, color: '#dc2626', borderColor: '#fecaca' }, onClick: () => onRemove(item.id), title: "Remove", children: "\u00D7" })] })] }), item.children?.map((child) => (_jsx(NavItemRow, { item: child, depth: depth + 1, maxDepth: maxDepth, onRemove: onRemove, onMoveUp: onMoveUp, onMoveDown: onMoveDown, onIndent: onIndent, onOutdent: onOutdent, onUpdateLabel: onUpdateLabel, onUpdateUrl: onUpdateUrl }, child.id)))] }));
132
+ }
133
+ /** Interactive tree builder for managing hierarchical navigation menus. */
134
+ export function NavBuilder({ items, onChange, maxDepth = 5, availablePages }) {
135
+ const [showPagePicker, setShowPagePicker] = useState(false);
136
+ const handleAdd = useCallback(() => {
137
+ onChange([...items, { id: generateId(), label: 'New Link', url: '/' }]);
138
+ }, [items, onChange]);
139
+ const handleAddPage = useCallback((page) => {
140
+ onChange([...items, { id: generateId(), label: page.title, url: page.url }]);
141
+ setShowPagePicker(false);
142
+ }, [items, onChange]);
143
+ const handleRemove = useCallback((id) => onChange(removeItem(items, id)), [items, onChange]);
144
+ const handleMoveUp = useCallback((id) => onChange(moveItemUp(items, id)), [items, onChange]);
145
+ const handleMoveDown = useCallback((id) => onChange(moveItemDown(items, id)), [items, onChange]);
146
+ const handleIndent = useCallback((id) => {
147
+ const depth = findItemDepth(items, id);
148
+ if (depth < maxDepth - 1) {
149
+ onChange(indentItem(items, id));
150
+ }
151
+ }, [items, maxDepth, onChange]);
152
+ const handleOutdent = useCallback((id) => onChange(outdentItem(items, id)), [items, onChange]);
153
+ const updateField = useCallback((id, field, value) => {
154
+ function update(navItems) {
155
+ return navItems.map((item) => {
156
+ if (item.id === id)
157
+ return { ...item, [field]: value };
158
+ if (item.children)
159
+ return { ...item, children: update(item.children) };
160
+ return item;
161
+ });
162
+ }
163
+ onChange(update(items));
164
+ }, [items, onChange]);
165
+ return (_jsxs("div", { className: "prenta-nav-builder", children: [_jsxs("div", { style: { marginBottom: 12 }, children: [items.map((item) => (_jsx(NavItemRow, { item: item, depth: 0, maxDepth: maxDepth, onRemove: handleRemove, onMoveUp: handleMoveUp, onMoveDown: handleMoveDown, onIndent: handleIndent, onOutdent: handleOutdent, onUpdateLabel: (id, label) => updateField(id, 'label', label), onUpdateUrl: (id, url) => updateField(id, 'url', url) }, item.id))), items.length === 0 && (_jsx("div", { style: {
166
+ textAlign: 'center',
167
+ padding: 32,
168
+ color: '#9ca3af',
169
+ border: '2px dashed #e5e7eb',
170
+ borderRadius: 8,
171
+ }, children: "No navigation items yet" }))] }), _jsxs("div", { style: { display: 'flex', gap: 8 }, children: [_jsx("button", { onClick: handleAdd, style: {
172
+ padding: '6px 16px',
173
+ background: '#3b82f6',
174
+ color: '#fff',
175
+ border: 'none',
176
+ borderRadius: 6,
177
+ cursor: 'pointer',
178
+ fontSize: 14,
179
+ fontWeight: 500,
180
+ }, children: "Add Link" }), availablePages && availablePages.length > 0 && (_jsx("button", { onClick: () => setShowPagePicker(!showPagePicker), style: {
181
+ padding: '6px 16px',
182
+ background: '#f3f4f6',
183
+ border: '1px solid #d1d5db',
184
+ borderRadius: 6,
185
+ cursor: 'pointer',
186
+ fontSize: 14,
187
+ }, children: "Add Page" }))] }), showPagePicker && availablePages && (_jsx("div", { style: {
188
+ marginTop: 8,
189
+ border: '1px solid #e5e7eb',
190
+ borderRadius: 6,
191
+ maxHeight: 200,
192
+ overflow: 'auto',
193
+ }, children: availablePages.map((page) => (_jsxs("button", { onClick: () => handleAddPage(page), style: {
194
+ display: 'block',
195
+ width: '100%',
196
+ textAlign: 'left',
197
+ padding: '8px 12px',
198
+ background: 'none',
199
+ border: 'none',
200
+ borderBottom: '1px solid #f3f4f6',
201
+ cursor: 'pointer',
202
+ fontSize: 14,
203
+ }, children: [_jsx("span", { style: { fontWeight: 500 }, children: page.title }), _jsx("span", { style: { color: '#9ca3af', marginLeft: 8, fontFamily: 'monospace', fontSize: 12 }, children: page.url })] }, page.id))) }))] }));
204
+ }
205
+ //# sourceMappingURL=NavBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavBuilder.js","sourceRoot":"","sources":["../../src/admin/NavBuilder.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAiBpD,SAAS,UAAU;IACjB,OAAO,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AACtE,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAgB,EAAE,QAAgB;IAC3D,OAAO,KAAK;SACT,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC;SACtC,GAAG,CAAC,CAAC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3 @@
1
+ import type { CollectionDefinition } from '@prenta/core';
2
+ export declare const navigationCollections: Record<string, CollectionDefinition>;
3
+ //# sourceMappingURL=collections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.d.ts","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAExD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CA6CtE,CAAA"}
@@ -0,0 +1,46 @@
1
+ export const navigationCollections = {
2
+ navigations: {
3
+ slug: 'navigations',
4
+ labels: { singular: 'Navigation', plural: 'Navigations' },
5
+ timestamps: true,
6
+ fields: {
7
+ name: {
8
+ type: 'text',
9
+ label: 'Menu Name',
10
+ required: true,
11
+ admin: {
12
+ placeholder: 'Main Navigation',
13
+ },
14
+ },
15
+ slug: {
16
+ type: 'slug',
17
+ label: 'Menu Slug',
18
+ from: 'name',
19
+ required: true,
20
+ unique: true,
21
+ },
22
+ items: {
23
+ type: 'nav',
24
+ label: 'Navigation Items',
25
+ admin: {
26
+ description: 'Nested tree of navigation links. Internal URLs warn when no published page matches.',
27
+ },
28
+ },
29
+ location: {
30
+ type: 'select',
31
+ label: 'Location',
32
+ options: [
33
+ { label: 'Header', value: 'header' },
34
+ { label: 'Footer', value: 'footer' },
35
+ { label: 'Sidebar', value: 'sidebar' },
36
+ { label: 'Mobile', value: 'mobile' },
37
+ ],
38
+ },
39
+ },
40
+ admin: {
41
+ useAsTitle: 'name',
42
+ group: 'Content',
43
+ },
44
+ },
45
+ };
46
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.js","sourceRoot":"","sources":["../src/collections.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAyC;IACzE,WAAW,EAAE;QACX,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE;QACzD,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE;YACN,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,WAAW;gBAClB,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE;oBACL,WAAW,EAAE,iBAAiB;iBAC/B;aACF;YACD,IAAI,EAAE;gBACJ,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,WAAW;gBAClB,IAAI,EAAE,MAAM;gBACZ,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE,IAAI;aACb;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,kBAAkB;gBACzB,KAAK,EAAE;oBACL,WAAW,EACT,qFAAqF;iBACxF;aACF;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,UAAU;gBACjB,OAAO,EAAE;oBACP,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;oBACpC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;oBACtC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;iBACrC;aACF;SACF;QACD,KAAK,EAAE;YACL,UAAU,EAAE,MAAM;YAClB,KAAK,EAAE,SAAS;SACjB;KACF;CACF,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { FieldDefinition } from '@prenta/core';
2
+ export declare const navigationFields: Record<string, FieldDefinition>;
3
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAEnD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAM,CAAA"}
package/dist/fields.js ADDED
@@ -0,0 +1,2 @@
1
+ export const navigationFields = {};
2
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAoC,EAAE,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { PluginHook } from '@prenta/core';
2
+ /**
3
+ * Navigation lifecycle hooks.
4
+ *
5
+ * cms-core dispatches document-lifecycle events both bare (`afterUpdate`) and
6
+ * collection-namespaced (`afterUpdate:navigations`). We register the namespaced
7
+ * variant so the handler only runs for navigation documents — no need to
8
+ * re-check the collection slug inside the handler.
9
+ *
10
+ * Handlers now receive a SINGLE typed payload. For document events the field
11
+ * values live on `payload.data`; `id`/`collection`/`slug`/`status` are
12
+ * top-level (see PluginDocumentHookPayload).
13
+ */
14
+ export declare const navigationHooks: PluginHook[];
15
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA6B,MAAM,cAAc,CAAA;AAGzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,UAAU,EAmBvC,CAAA"}
package/dist/hooks.js ADDED
@@ -0,0 +1,33 @@
1
+ import { getPrentaConfig, invalidationTagsForDocumentWrite } from '@prenta/core';
2
+ /**
3
+ * Navigation lifecycle hooks.
4
+ *
5
+ * cms-core dispatches document-lifecycle events both bare (`afterUpdate`) and
6
+ * collection-namespaced (`afterUpdate:navigations`). We register the namespaced
7
+ * variant so the handler only runs for navigation documents — no need to
8
+ * re-check the collection slug inside the handler.
9
+ *
10
+ * Handlers now receive a SINGLE typed payload. For document events the field
11
+ * values live on `payload.data`; `id`/`collection`/`slug`/`status` are
12
+ * top-level (see PluginDocumentHookPayload).
13
+ */
14
+ export const navigationHooks = [
15
+ {
16
+ event: 'afterUpdate:navigations',
17
+ handler: async (payload) => {
18
+ // Only the namespaced afterUpdate:navigations event reaches this handler,
19
+ // so the payload is always a document payload for the navigations collection.
20
+ const { id } = payload;
21
+ // Invalidate the navigation cache directly. The old injected
22
+ // `invalidateCache` callback no longer exists; instead we fire the host
23
+ // app's configured `cache.onInvalidate` (the same mechanism the action
24
+ // layer uses after every write) with the canonical navigation tags. This
25
+ // no-ops safely when the host hasn't wired a cache.
26
+ const onInvalidate = getPrentaConfig()?.cache?.onInvalidate;
27
+ if (onInvalidate) {
28
+ await onInvalidate(invalidationTagsForDocumentWrite('navigations', id));
29
+ }
30
+ },
31
+ },
32
+ ];
33
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,cAAc,CAAA;AAEhF;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAiB;IAC3C;QACE,KAAK,EAAE,yBAAyB;QAChC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YACzB,0EAA0E;YAC1E,8EAA8E;YAC9E,MAAM,EAAE,EAAE,EAAE,GAAG,OAAoC,CAAA;YAEnD,6DAA6D;YAC7D,wEAAwE;YACxE,uEAAuE;YACvE,yEAAyE;YACzE,oDAAoD;YACpD,MAAM,YAAY,GAAG,eAAe,EAAE,EAAE,KAAK,EAAE,YAAY,CAAA;YAC3D,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,YAAY,CAAC,gCAAgC,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAA;YACzE,CAAC;QACH,CAAC;KACF;CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { type PluginDefinition } from '@prenta/core/config';
2
+ /**
3
+ * Creates a navigation plugin for managing site menus and link trees.
4
+ *
5
+ * Nesting depth is controlled by the admin `NavBuilder` component's `maxDepth`
6
+ * prop (default 5), not by plugin config — there is no channel on
7
+ * `PluginDefinition` to carry a plugin-level option to the admin UI, so this
8
+ * factory intentionally takes no options rather than accepting one that does
9
+ * nothing.
10
+ */
11
+ export declare function navigationPlugin(): PluginDefinition;
12
+ export { navigationFields } from './fields.js';
13
+ export { navigationCollections } from './collections.js';
14
+ export { navigationHooks } from './hooks.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAKzE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAUnD;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import { definePlugin } from '@prenta/core/config';
2
+ import { navigationFields } from './fields.js';
3
+ import { navigationCollections } from './collections.js';
4
+ import { navigationHooks } from './hooks.js';
5
+ /**
6
+ * Creates a navigation plugin for managing site menus and link trees.
7
+ *
8
+ * Nesting depth is controlled by the admin `NavBuilder` component's `maxDepth`
9
+ * prop (default 5), not by plugin config — there is no channel on
10
+ * `PluginDefinition` to carry a plugin-level option to the admin UI, so this
11
+ * factory intentionally takes no options rather than accepting one that does
12
+ * nothing.
13
+ */
14
+ export function navigationPlugin() {
15
+ return definePlugin({
16
+ name: 'navigation',
17
+ fields: navigationFields,
18
+ collections: navigationCollections,
19
+ adminNavItems: [{ label: 'Navigation', icon: 'menu', path: '/navigations' }],
20
+ // Hooks take a single typed payload and use only cms-core-dispatched event
21
+ // names, so they can be passed straight through with no context adapter.
22
+ hooks: navigationHooks,
23
+ });
24
+ }
25
+ export { navigationFields } from './fields.js';
26
+ export { navigationCollections } from './collections.js';
27
+ export { navigationHooks } from './hooks.js';
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAyB,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,gBAAgB;QACxB,WAAW,EAAE,qBAAqB;QAClC,aAAa,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC;QAC5E,2EAA2E;QAC3E,yEAAyE;QACzE,KAAK,EAAE,eAAe;KACvB,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@prenta/plugin-navigation",
3
+ "version": "0.3.0",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/actuate-media/prenta.git",
8
+ "directory": "packages/plugin-navigation"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "type": "module",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "main": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
23
+ "files": [
24
+ "dist",
25
+ "CHANGELOG.md"
26
+ ],
27
+ "peerDependencies": {
28
+ "@prenta/core": ">=0.1.0",
29
+ "react": "^18.0.0 || ^19.0.0",
30
+ "react-dom": "^18.0.0 || ^19.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/react": "^19.0.0",
34
+ "@types/react-dom": "^19.0.0",
35
+ "react": "^19.2.0",
36
+ "react-dom": "^19.2.0",
37
+ "typescript": "^5.7.0",
38
+ "vitest": "^4.1.0",
39
+ "@prenta/core": "0.118.0"
40
+ },
41
+ "scripts": {
42
+ "build": "tsc --project tsconfig.json",
43
+ "type-check": "tsc --noEmit",
44
+ "test": "vitest run",
45
+ "clean": "rm -rf dist .turbo"
46
+ }
47
+ }