@aphexcms/cms-core 11.0.0 → 11.1.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.
Files changed (31) hide show
  1. package/dist/components/AdminApp.svelte +11 -1
  2. package/dist/components/AdminApp.svelte.d.ts.map +1 -1
  3. package/dist/components/admin/AgentChat.svelte +3 -2
  4. package/dist/components/admin/AgentChat.svelte.d.ts.map +1 -1
  5. package/dist/components/layout/sidebar/AppSidebar.svelte +105 -50
  6. package/dist/components/layout/sidebar/AppSidebar.svelte.d.ts.map +1 -1
  7. package/dist/components/layout/sidebar/NavGroup.svelte +151 -0
  8. package/dist/components/layout/sidebar/NavGroup.svelte.d.ts +31 -0
  9. package/dist/components/layout/sidebar/NavGroup.svelte.d.ts.map +1 -0
  10. package/dist/plugins/types.d.ts +6 -0
  11. package/dist/plugins/types.d.ts.map +1 -1
  12. package/dist/storage/adapters/local-storage-adapter.d.ts +1 -0
  13. package/dist/storage/adapters/local-storage-adapter.d.ts.map +1 -1
  14. package/dist/storage/adapters/local-storage-adapter.js +22 -4
  15. package/dist/storage/interfaces/storage.d.ts +6 -0
  16. package/dist/storage/interfaces/storage.d.ts.map +1 -1
  17. package/dist/types/sidebar.d.ts +39 -0
  18. package/dist/types/sidebar.d.ts.map +1 -1
  19. package/dist/utils/index.d.ts +1 -0
  20. package/dist/utils/index.d.ts.map +1 -1
  21. package/dist/utils/index.js +1 -0
  22. package/dist/utils/random-id.d.ts +17 -0
  23. package/dist/utils/random-id.d.ts.map +1 -0
  24. package/dist/utils/random-id.js +32 -0
  25. package/package.json +2 -2
  26. package/dist/components/layout/sidebar/NavMain.svelte +0 -112
  27. package/dist/components/layout/sidebar/NavMain.svelte.d.ts +0 -22
  28. package/dist/components/layout/sidebar/NavMain.svelte.d.ts.map +0 -1
  29. package/dist/components/layout/sidebar/NavSecondary.svelte +0 -69
  30. package/dist/components/layout/sidebar/NavSecondary.svelte.d.ts +0 -9
  31. package/dist/components/layout/sidebar/NavSecondary.svelte.d.ts.map +0 -1
@@ -458,7 +458,17 @@
458
458
  let contentWidth = $state(0);
459
459
 
460
460
  let layoutConfig = $derived.by(() => {
461
- const totalEditors = (currentView === 'editor' ? 1 : 0) + (editorStack.length > 0 ? 1 : 0);
461
+ // A stacked reference counts as a second editor *only when it is a real
462
+ // column*. In presentation mode it isn't — it renders as an `absolute`
463
+ // overlay **inside** the primary editor's container so the live preview
464
+ // stays visible behind it. Counting it here made the two compete for the
465
+ // same width, and opening the version panel (which subtracts 280px below)
466
+ // was enough to push `maxEditors` to 1. The expanded slot then went to the
467
+ // stacked editor, index 0 collapsed, and its container picked up `hidden` —
468
+ // taking the overlay nested inside it along with it. Both editors vanished
469
+ // and the version panel was left alone on the left of the row.
470
+ const stackIsOwnColumn = editorStack.length > 0 && !presentationModeOn;
471
+ const totalEditors = (currentView === 'editor' ? 1 : 0) + (stackIsOwnColumn ? 1 : 0);
462
472
 
463
473
  if (totalEditors === 0) {
464
474
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"AdminApp.svelte.d.ts","sourceRoot":"","sources":["../../src/lib/components/AdminApp.svelte.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,kBAAkB,CAAC;AAElE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGxC,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAE1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AA8BnE,UAAU,KAAK;IACd,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,aAAa,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CA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kBareDocumentUrls } from '../../ai/document-artifact-links';
62
62
  import { resolvePreviewTitle } from '../../utils/preview';
63
+ import { randomId } from '../../utils/random-id';
63
64
  import { notifyCollectionChanged } from '../../document-refresh.svelte';
64
65
 
65
66
  /** A suggestion can be a bare string, or `{ text, icon }` for a leading icon — the plain
@@ -211,7 +212,7 @@
211
212
  agentChatState.contextSentFor = currentDocKey;
212
213
  }
213
214
  const userTurn: Turn = {
214
- id: crypto.randomUUID(),
215
+ id: randomId(),
215
216
  role: 'user',
216
217
  text: message,
217
218
  status: 'complete',
@@ -219,7 +220,7 @@
219
220
  historyIndexBeforeTurn: agentChatState.history.length
220
221
  };
221
222
  const assistantTurn: Turn = {
222
- id: crypto.randomUUID(),
223
+ id: randomId(),
223
224
  role: 'assistant',
224
225
  text: '',
225
226
  status: 'streaming',
@@ -1 +1 @@
1
- {"version":3,"file":"AgentChat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/AgentChat.svelte.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAuBvC;0FAC0F;AAC1F,KAAK,UAAU,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAU9D,KAAK,gBAAgB,GAAI;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AAgyBH,QAAA,MAAM,SAAS,qCAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"AgentChat.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/admin/AgentChat.svelte.ts"],"names":[],"mappings":"AA4CA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAwBvC;0FAC0F;AAC1F,KAAK,UAAU,GAAG,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAU9D,KAAK,gBAAgB,GAAI;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC;AAiyBH,QAAA,MAAM,SAAS,qCAAwC,CAAC;AACxD,KAAK,SAAS,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC;AAC9C,eAAe,SAAS,CAAC"}
@@ -3,18 +3,13 @@
3
3
  Sidebar,
4
4
  SidebarContent,
5
5
  SidebarFooter,
6
- SidebarGroup,
7
- SidebarGroupLabel,
8
6
  SidebarHeader,
9
- SidebarMenu,
10
- SidebarMenuItem,
11
- SidebarMenuButton,
12
7
  SidebarRail
13
8
  } from '@aphexcms/ui/shadcn/sidebar';
14
9
  import OrganizationSwitcher from '../OrganizationSwitcher.svelte';
15
- import NavMain from './NavMain.svelte';
10
+ import NavGroup, { type NavGroupItem } from './NavGroup.svelte';
16
11
  import NavUser from './NavUser.svelte';
17
- import type { SidebarData } from '../../../types/sidebar';
12
+ import type { SidebarData, SidebarNavGroup } from '../../../types/sidebar';
18
13
  import type { ComponentProps } from 'svelte';
19
14
  import { page } from '$app/state';
20
15
  import type { AdminToolPart } from '../../../plugins/types';
@@ -30,13 +25,16 @@
30
25
  const pluginToolActive = $derived(activeView.startsWith('plugin:'));
31
26
  const isToolActive = (id: string) => activeView === `plugin:${id}`;
32
27
 
33
- function isNavActive(path: string, item: { url: string; exact?: boolean }): boolean {
28
+ function isNavActive(item: NavGroupItem): boolean {
29
+ // An item that leaves the studio is never a studio location.
30
+ if (item.newTab) return false;
31
+ const path = page.url.pathname;
34
32
  if (pluginToolActive && item.url === '/admin') return false;
35
33
  if (item.exact) return path === item.url;
36
34
  const matches = path === item.url || path.startsWith(item.url + '/');
37
35
  if (!matches) return false;
38
- // Longest-match wins when items nest (mirrors NavMain's default tiebreak).
39
- return !navMainItems.some(
36
+ // Longest-match wins when items nest.
37
+ return !allNavItems.some(
40
38
  (other) =>
41
39
  other !== item &&
42
40
  other.url.length > item.url.length &&
@@ -55,23 +53,72 @@
55
53
 
56
54
  let { data, onSignOut, sidebarTools = [], onSelectTool, ...restProps }: Props = $props();
57
55
 
58
- // Convert navItems to the format expected by NavMain
59
- const navMainItems = $derived(
60
- data?.navItems?.map((item) => ({
56
+ // Resolve the sidebar into an ordered list of groups. `navGroups` is the full
57
+ // expression of hierarchy; the three shorthand fields desugar into the default
58
+ // three tiers, so an app that sets none of this still gets a sensible sidebar.
59
+ const DEFAULT_TOOLS_GROUP = 'tools';
60
+
61
+ const resolvedGroups = $derived.by((): SidebarNavGroup[] => {
62
+ if (data?.navGroups?.length) return data.navGroups;
63
+
64
+ const groups: SidebarNavGroup[] = [
65
+ {
66
+ id: 'content',
67
+ label: 'Content',
68
+ items: data?.navItems?.length ? data.navItems : [{ href: '/admin', label: 'Content' }]
69
+ }
70
+ ];
71
+ if (data?.systemNavItems?.length)
72
+ groups.push({ id: 'system', label: 'System', items: data.systemNavItems });
73
+ if (data?.secondaryNavItems?.length)
74
+ groups.push({ id: 'secondary', placement: 'bottom', items: data.secondaryNavItems });
75
+ return groups;
76
+ });
77
+
78
+ const toNavItems = (group: SidebarNavGroup): NavGroupItem[] =>
79
+ (group.items ?? []).map((item) => ({
61
80
  title: item.label,
62
81
  url: item.href,
63
82
  icon: item.icon,
64
- isActive: false
65
- })) || [
66
- {
67
- title: 'Content',
68
- url: '/admin',
69
- icon: undefined,
70
- isActive: false,
71
- exact: true
72
- }
73
- ]
83
+ newTab: item.newTab,
84
+ isActive: false,
85
+ // The bare fallback nav is a single /admin item, which would otherwise
86
+ // prefix-match every admin page and stay lit everywhere.
87
+ exact: !data?.navGroups?.length && !data?.navItems?.length && item.href === '/admin'
88
+ }));
89
+
90
+ // A tool names a group by id. One that names nothing — or a group this app
91
+ // doesn't define — lands in the default Tools group rather than vanishing.
92
+ const groupIds = $derived(new Set(resolvedGroups.map((g) => g.id).filter(Boolean)));
93
+ const toolsFor = (groupId: string | undefined) =>
94
+ sidebarTools.filter((tool) => {
95
+ const target = tool.group && groupIds.has(tool.group) ? tool.group : DEFAULT_TOOLS_GROUP;
96
+ return target === groupId;
97
+ });
98
+
99
+ // Any tool that fell through to the default bucket, when the app hasn't defined
100
+ // a group with that id itself.
101
+ const orphanTools = $derived(
102
+ groupIds.has(DEFAULT_TOOLS_GROUP) ? [] : toolsFor(DEFAULT_TOOLS_GROUP)
74
103
  );
104
+
105
+ const renderedGroups = $derived(
106
+ resolvedGroups.map((group) => ({
107
+ group,
108
+ items: toNavItems(group),
109
+ tools: toolsFor(group.id)
110
+ }))
111
+ );
112
+
113
+ // Longest-match is judged across every group, not within one: 'Studio' (/admin)
114
+ // and 'Activity' (/admin/activity) can live in different groups, and a per-group
115
+ // tiebreak would light both up on the activity page.
116
+ const allNavItems = $derived(renderedGroups.flatMap((g) => g.items));
117
+
118
+ // Placement partitions the list regardless of declaration order, so a 'bottom'
119
+ // group declared first still pins to the bottom.
120
+ const topGroups = $derived(renderedGroups.filter((g) => g.group.placement !== 'bottom'));
121
+ const bottomGroups = $derived(renderedGroups.filter((g) => g.group.placement === 'bottom'));
75
122
  </script>
76
123
 
77
124
  <Sidebar collapsible="icon" {...restProps}>
@@ -87,34 +134,42 @@
87
134
  </SidebarHeader>
88
135
 
89
136
  <SidebarContent>
90
- <NavMain items={navMainItems} isActive={isNavActive} />
91
-
92
- <!-- Plugin admin tools placed in the sidebar (placement: 'sidebar'). Rendered
93
- from the plugin list at this persistent layout level, so the Tools nav
94
- stays visible across every admin page (settings included). -->
95
- {#if sidebarTools.length > 0}
96
- <SidebarGroup>
97
- <SidebarGroupLabel>Tools</SidebarGroupLabel>
98
- <SidebarMenu>
99
- {#each sidebarTools as tool (tool.id)}
100
- <SidebarMenuItem>
101
- <SidebarMenuButton
102
- onclick={() => onSelectTool?.(tool.id)}
103
- isActive={isToolActive(tool.id)}
104
- tooltipContent={tool.title}
105
- class="cursor-pointer"
106
- >
107
- {#if tool.icon}
108
- {@const Icon = tool.icon}
109
- <Icon class="h-4 w-4" />
110
- {/if}
111
- <span>{tool.title}</span>
112
- </SidebarMenuButton>
113
- </SidebarMenuItem>
114
- {/each}
115
- </SidebarMenu>
116
- </SidebarGroup>
137
+ {#each topGroups as { group, items, tools } (group.id ?? group.label)}
138
+ <NavGroup
139
+ {items}
140
+ {tools}
141
+ label={group.label}
142
+ isActive={isNavActive}
143
+ {isToolActive}
144
+ {onSelectTool}
145
+ />
146
+ {/each}
147
+
148
+ <!-- Plugin admin tools placed in the sidebar (placement: 'sidebar') that no
149
+ app-defined group claimed. Rendered at this persistent layout level, so
150
+ the Tools nav stays visible across every admin page (settings included). -->
151
+ {#if orphanTools.length > 0}
152
+ <NavGroup
153
+ items={[]}
154
+ tools={orphanTools}
155
+ label="Tools"
156
+ isActive={isNavActive}
157
+ {isToolActive}
158
+ {onSelectTool}
159
+ />
117
160
  {/if}
161
+
162
+ {#each bottomGroups as { group, items, tools } (group.id ?? group.label)}
163
+ <NavGroup
164
+ {items}
165
+ {tools}
166
+ label={group.label}
167
+ placement="bottom"
168
+ isActive={isNavActive}
169
+ {isToolActive}
170
+ {onSelectTool}
171
+ />
172
+ {/each}
118
173
  </SidebarContent>
119
174
 
120
175
  <SidebarFooter>
@@ -1 +1 @@
1
- {"version":3,"file":"AppSidebar.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/sidebar/AppSidebar.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,OAAO,EAUP,MAAM,6BAA6B,CAAC;AAItC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,C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CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,151 @@
1
+ <script lang="ts">
2
+ import * as Collapsible from '@aphexcms/ui/shadcn/collapsible';
3
+ import {
4
+ SidebarGroup,
5
+ SidebarGroupLabel,
6
+ SidebarMenu,
7
+ SidebarMenuItem,
8
+ SidebarMenuButton,
9
+ SidebarMenuSub,
10
+ SidebarMenuSubItem,
11
+ SidebarMenuSubButton
12
+ } from '@aphexcms/ui/shadcn/sidebar';
13
+ import { ChevronRight, type IconProps } from '@lucide/svelte';
14
+ import type { Component } from 'svelte';
15
+ import type { AdminToolPart } from '../../../plugins/types';
16
+
17
+ export type NavGroupItem = {
18
+ title: string;
19
+ url: string;
20
+ icon?: Component<IconProps>;
21
+ isActive?: boolean;
22
+ exact?: boolean;
23
+ /** Leaves the studio — open in a new tab and never light up as active. */
24
+ newTab?: boolean;
25
+ items?: {
26
+ title: string;
27
+ url: string;
28
+ }[];
29
+ };
30
+
31
+ type Props = {
32
+ items: NavGroupItem[];
33
+ label?: string;
34
+ /** `'bottom'` is the utility tier: pinned down, one size smaller. */
35
+ placement?: 'top' | 'bottom';
36
+ /** Plugin admin tools filed into this group. Rendered after the nav items. */
37
+ tools?: AdminToolPart[];
38
+ isActive?: (item: NavGroupItem) => boolean;
39
+ isToolActive?: (id: string) => boolean;
40
+ onSelectTool?: (id: string) => void;
41
+ };
42
+
43
+ let {
44
+ items,
45
+ label,
46
+ placement = 'top',
47
+ tools = [],
48
+ isActive,
49
+ isToolActive,
50
+ onSelectTool
51
+ }: Props = $props();
52
+
53
+ const demoted = $derived(placement === 'bottom');
54
+ // One `mt-auto` group wins the leftover space and pins itself (and everything
55
+ // declared after it) to the bottom.
56
+ const size = $derived(demoted ? ('sm' as const) : ('default' as const));
57
+ </script>
58
+
59
+ <SidebarGroup class={demoted ? 'mt-auto' : undefined}>
60
+ {#if label}
61
+ <SidebarGroupLabel>{label}</SidebarGroupLabel>
62
+ {/if}
63
+ <SidebarMenu>
64
+ {#each items as item (item.title)}
65
+ {#if item.items && item.items.length > 0}
66
+ <Collapsible.Root open={item.isActive} class="group/collapsible">
67
+ {#snippet child({ props })}
68
+ <SidebarMenuItem {...props}>
69
+ <Collapsible.Trigger>
70
+ {#snippet child({ props })}
71
+ <SidebarMenuButton {...props} tooltipContent={item.title} {size}>
72
+ {#if item.icon}
73
+ {@const Icon = item.icon}
74
+ <Icon class="h-4 w-4" />
75
+ {/if}
76
+ <span>{item.title}</span>
77
+ <ChevronRight
78
+ class="ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
79
+ />
80
+ </SidebarMenuButton>
81
+ {/snippet}
82
+ </Collapsible.Trigger>
83
+ <Collapsible.Content>
84
+ <SidebarMenuSub>
85
+ {#each item.items as subItem (subItem.title)}
86
+ <SidebarMenuSubItem>
87
+ <SidebarMenuSubButton>
88
+ {#snippet child({ props })}
89
+ <a href={subItem.url} {...props}>
90
+ <span>{subItem.title}</span>
91
+ </a>
92
+ {/snippet}
93
+ </SidebarMenuSubButton>
94
+ </SidebarMenuSubItem>
95
+ {/each}
96
+ </SidebarMenuSub>
97
+ </Collapsible.Content>
98
+ </SidebarMenuItem>
99
+ {/snippet}
100
+ </Collapsible.Root>
101
+ {:else}
102
+ <SidebarMenuItem>
103
+ <SidebarMenuButton
104
+ isActive={isActive?.(item) ?? false}
105
+ tooltipContent={item.title}
106
+ {size}
107
+ >
108
+ {#snippet child({ props })}
109
+ <!-- A real anchor, not a button: middle-click, cmd-click and "copy
110
+ link" all work, and an item that leaves the studio can open in
111
+ its own tab instead of navigating the admin away. -->
112
+ <a
113
+ {...props}
114
+ href={item.url}
115
+ target={item.newTab ? '_blank' : undefined}
116
+ rel={item.newTab ? 'noopener noreferrer' : undefined}
117
+ >
118
+ {#if item.icon}
119
+ {@const Icon = item.icon}
120
+ <Icon class="h-4 w-4" />
121
+ {/if}
122
+ <span>{item.title}</span>
123
+ </a>
124
+ {/snippet}
125
+ </SidebarMenuButton>
126
+ </SidebarMenuItem>
127
+ {/if}
128
+ {/each}
129
+
130
+ <!-- Plugin tools switch the `?view=plugin:<id>` area rather than navigating a
131
+ path, so they stay buttons — but they sit inside whichever group the
132
+ plugin (or the host app) filed them under. -->
133
+ {#each tools as tool (tool.id)}
134
+ <SidebarMenuItem>
135
+ <SidebarMenuButton
136
+ onclick={() => onSelectTool?.(tool.id)}
137
+ isActive={isToolActive?.(tool.id) ?? false}
138
+ tooltipContent={tool.title}
139
+ class="cursor-pointer"
140
+ {size}
141
+ >
142
+ {#if tool.icon}
143
+ {@const Icon = tool.icon}
144
+ <Icon class="h-4 w-4" />
145
+ {/if}
146
+ <span>{tool.title}</span>
147
+ </SidebarMenuButton>
148
+ </SidebarMenuItem>
149
+ {/each}
150
+ </SidebarMenu>
151
+ </SidebarGroup>
@@ -0,0 +1,31 @@
1
+ import { type IconProps } from '@lucide/svelte';
2
+ import type { Component } from 'svelte';
3
+ import type { AdminToolPart } from '../../../plugins/types.js';
4
+ export type NavGroupItem = {
5
+ title: string;
6
+ url: string;
7
+ icon?: Component<IconProps>;
8
+ isActive?: boolean;
9
+ exact?: boolean;
10
+ /** Leaves the studio — open in a new tab and never light up as active. */
11
+ newTab?: boolean;
12
+ items?: {
13
+ title: string;
14
+ url: string;
15
+ }[];
16
+ };
17
+ type Props = {
18
+ items: NavGroupItem[];
19
+ label?: string;
20
+ /** `'bottom'` is the utility tier: pinned down, one size smaller. */
21
+ placement?: 'top' | 'bottom';
22
+ /** Plugin admin tools filed into this group. Rendered after the nav items. */
23
+ tools?: AdminToolPart[];
24
+ isActive?: (item: NavGroupItem) => boolean;
25
+ isToolActive?: (id: string) => boolean;
26
+ onSelectTool?: (id: string) => void;
27
+ };
28
+ declare const NavGroup: Component<Props, {}, "">;
29
+ type NavGroup = ReturnType<typeof NavGroup>;
30
+ export default NavGroup;
31
+ //# sourceMappingURL=NavGroup.svel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,QAAQ,CAAC"}
@@ -253,6 +253,12 @@ export interface AdminToolPart {
253
253
  * would overflow. Either way the tool opens the same `plugin:<id>` area.
254
254
  */
255
255
  placement?: 'tab' | 'sidebar';
256
+ /**
257
+ * Sidebar placement only: the `id` of a `SidebarNavGroup` to render inside.
258
+ * Unset — or naming a group the app hasn't defined — falls back to the default
259
+ * Tools group, so a plugin never disappears because a host renamed a heading.
260
+ */
261
+ group?: string;
256
262
  }
257
263
  /**
258
264
  * The stable props a field-input widget receives — the same shape the built-in
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/plugins/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,6EAA6E;AAC7E,MAAM,MAAM,QAAQ,GACjB,cAAc,GACd,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,sBAAsB,GACtB,kBAAkB,GAClB,uBAAuB,GACvB,kBAAkB,GAClB,uBAAuB,CAAC;AAI3B,wEAAwE;AACxE,MAAM,W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a,GACb,kBAAkB,CAAC;AAEtB,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACzB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;CACrB;AAED,uFAAuF;AACvF,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAEzD"}
@@ -45,6 +45,7 @@ export declare class LocalStorageAdapter implements StorageAdapter {
45
45
  * caller-influenced path and the rest of the filesystem, and a
46
46
  * per-call-site copy is how one of them ends up missing the check.
47
47
  */
48
+ private isWithin;
48
49
  private assertWithinBase;
49
50
  /**
50
51
  * Where a key lives on disk. Mirrors what `store()` reports, for callers
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage-adapter.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/adapters/local-storage-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,qBAAa,mBAAoB,YAAW,cAAc;IACzD,QAAQ,CAAC,IAAI,WAAW;IACxB,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,EAAE,aAAa;IASjC,iDAAiD;IACjD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;YACW,sBAAsB;IAepC;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;YACW,gBAAgB;IAU9B;;OAEG;IACG,KAAK,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IA0CvD;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAQnB;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIhC;;;OAGG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM9C;;;;;;OAMG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAWlE;;;OAGG;IACG,cAAc,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAUtC;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5C;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW5C;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM5B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAyB/E;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAYnC"}
1
+ {"version":3,"file":"local-storage-adapter.d.ts","sourceRoot":"","sources":["../../../src/lib/storage/adapters/local-storage-adapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,MAAM,uBAAuB,CAAC;AAK/B;;GAEG;AACH,qBAAa,mBAAoB,YAAW,cAAc;IACzD,QAAQ,CAAC,IAAI,WAAW;IACxB,OAAO,CAAC,MAAM,CAA0B;gBAE5B,MAAM,EAAE,aAAa;IASjC,iDAAiD;IACjD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;YACW,sBAAsB;IAepC;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;YACW,gBAAgB;IAU9B;;OAEG;IACG,KAAK,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC;IA0CvD;;;;;;;OAOG;IACH,OAAO,CAAC,WAAW;IAQnB;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,gBAAgB;IAyBxB;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAIhC;;;OAGG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM9C;;;;;;OAMG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAWlE;;;OAGG;IACG,cAAc,CACnB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAUtC;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAU5C;;OAEG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAW5C;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAM5B;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAyB/E;;OAEG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAYnC"}
@@ -1,6 +1,6 @@
1
1
  // Pure local file system storage adapter - no database operations
2
2
  import { writeFile, mkdir, unlink, stat, readdir } from 'fs/promises';
3
- import { join, dirname, resolve, basename } from 'path';
3
+ import { join, dirname, resolve, basename, relative, sep } from 'path';
4
4
  import { cmsLogger } from '../../utils/logger.js';
5
5
  const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
6
6
  /**
@@ -128,13 +128,31 @@ export class LocalStorageAdapter {
128
128
  * caller-influenced path and the rest of the filesystem, and a
129
129
  * per-call-site copy is how one of them ends up missing the check.
130
130
  */
131
+ isWithin(root, candidate) {
132
+ return candidate === root || candidate.startsWith(root + sep);
133
+ }
131
134
  assertWithinBase(path) {
132
135
  const resolved = resolve(path);
133
136
  const base = resolve(this.config.basePath);
134
- if (!resolved.startsWith(base + '/') && resolved !== base) {
135
- throw new Error('Access denied: path outside storage directory');
137
+ if (this.isWithin(base, resolved))
138
+ return resolved;
139
+ // `path` was historically persisted as the complete local filesystem path.
140
+ // When an installation moves its storage root, those rows retain the former
141
+ // prefix even after the files are copied. Rebase paths only from roots the
142
+ // application explicitly trusts; an arbitrary outside path must still fail.
143
+ const configuredLegacyRoots = this.config.options.legacyBasePaths;
144
+ const legacyRoots = Array.isArray(configuredLegacyRoots)
145
+ ? configuredLegacyRoots.filter((root) => typeof root === 'string')
146
+ : [];
147
+ for (const legacyRootPath of legacyRoots) {
148
+ const legacyRoot = resolve(legacyRootPath);
149
+ if (!this.isWithin(legacyRoot, resolved))
150
+ continue;
151
+ const rebased = resolve(base, relative(legacyRoot, resolved));
152
+ if (this.isWithin(base, rebased))
153
+ return rebased;
136
154
  }
137
- return resolved;
155
+ throw new Error('Access denied: path outside storage directory');
138
156
  }
139
157
  /**
140
158
  * Where a key lives on disk. Mirrors what `store()` reports, for callers
@@ -44,6 +44,12 @@ export interface StorageConfig {
44
44
  */
45
45
  maxFileSize?: number;
46
46
  options?: {
47
+ /**
48
+ * Local adapter only: former storage roots whose persisted paths should be
49
+ * rebased beneath the current `basePath`. Files must already have been moved
50
+ * with their relative directory layout intact.
51
+ */
52
+ legacyBasePaths?: string[];
47
53
  [key: string]: any;
48
54
  };
49
55
  }
@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,MAAM,GAAG,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc,CAAC;CACrD"}
@@ -12,6 +12,33 @@ export interface SidebarNavItem {
12
12
  label: string;
13
13
  icon?: Component<IconProps>;
14
14
  badge?: string | number;
15
+ /**
16
+ * Open in a new tab instead of navigating the admin away. Use it for links
17
+ * that leave the studio (the live site), so the editor keeps their place —
18
+ * and never mark such an item active, since it isn't a studio location.
19
+ */
20
+ newTab?: boolean;
21
+ }
22
+ /**
23
+ * One labelled block of sidebar nav. Groups are the unit of hierarchy: an app
24
+ * defines as many as it wants, in the order it wants them.
25
+ */
26
+ export interface SidebarNavGroup {
27
+ /**
28
+ * Stable id, used to target the group. A plugin admin tool with a matching
29
+ * `group` renders inside it instead of the default Tools group — so an app can
30
+ * file plugins under its own headings rather than a bucket labelled "Tools".
31
+ */
32
+ id?: string;
33
+ /** Heading above the group. Omit for an unlabelled block. */
34
+ label?: string;
35
+ items?: SidebarNavItem[];
36
+ /**
37
+ * `'top'` (default) stacks in declared order. `'bottom'` pins the group to the
38
+ * bottom of the sidebar and demotes it a size — the utility tier, for links
39
+ * that leave the studio, help, version.
40
+ */
41
+ placement?: 'top' | 'bottom';
15
42
  }
16
43
  export interface SidebarBranding {
17
44
  title?: string;
@@ -28,7 +55,19 @@ export interface SidebarOrganization {
28
55
  export interface SidebarData {
29
56
  user: SidebarUser;
30
57
  branding?: SidebarBranding;
58
+ /**
59
+ * Full control over the sidebar's hierarchy: any number of groups, labelled and
60
+ * ordered as the app likes. Takes precedence over the three shorthand fields
61
+ * below, which exist because most apps want exactly the default three tiers and
62
+ * shouldn't have to spell out a group to get them.
63
+ */
64
+ navGroups?: SidebarNavGroup[];
65
+ /** Shorthand — the primary tier: the content nav, where an editor works. */
31
66
  navItems?: SidebarNavItem[];
67
+ /** Shorthand — the system tier: operational views (activity, logs). */
68
+ systemNavItems?: SidebarNavItem[];
69
+ /** Shorthand — the utility tier: bottom-pinned, demoted. Links off-site, help. */
70
+ secondaryNavItems?: SidebarNavItem[];
32
71
  organizations?: SidebarOrganization[];
33
72
  activeOrganization?: SidebarOrganization;
34
73
  canCreateOrganization?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/lib/types/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B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AAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,GAAG,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,uEAAuE;IACvE,cAAc,CAAC,EAAE,cAAc,EAAE,CAAC;IAClC,kFAAkF;IAClF,iBAAiB,CAAC,EAAE,cAAc,EAAE,CAAC;IACrC,aAAa,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACtC,kBAAkB,CAAC,EAAE,mBAAmB,CAAC;IACzC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC"}
@@ -7,4 +7,5 @@ export * from './preview.js';
7
7
  export * from './image-url.js';
8
8
  export * from './initial-value-helpers.js';
9
9
  export * from './file-accept.js';
10
+ export * from './random-id.js';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/utils/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAG9E,cAAc,uBAAuB,CAAC;AAGtC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/utils/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAG9E,cAAc,uBAAuB,CAAC;AAGtC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
@@ -12,3 +12,4 @@ export * from './preview.js';
12
12
  export * from './image-url.js';
13
13
  export * from './initial-value-helpers.js';
14
14
  export * from './file-accept.js';
15
+ export * from './random-id.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A v4 UUID that also works outside a secure context.
3
+ *
4
+ * `crypto.randomUUID` is only defined on HTTPS or `localhost`. The dev server
5
+ * runs `vite dev --host`, so opening the Network URL it prints
6
+ * (`http://192.168.x.x:5173`) — from a phone, another machine, or through a
7
+ * plain-HTTP tunnel — leaves it `undefined`, and every call site throws
8
+ * `TypeError: crypto.randomUUID is not a function`.
9
+ *
10
+ * `crypto.getRandomValues` is *not* gated that way, so the fallback is still
11
+ * cryptographically random; only the convenience wrapper is missing. The final
12
+ * `Math.random` branch exists for non-browser contexts with no WebCrypto at all
13
+ * and is **not** suitable for anything security-sensitive — use `node:crypto` on
14
+ * the server, where `randomUUID` is always available.
15
+ */
16
+ export declare function randomId(): string;
17
+ //# sourceMappingURL=random-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random-id.d.ts","sourceRoot":"","sources":["../../src/lib/utils/random-id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAmBjC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A v4 UUID that also works outside a secure context.
3
+ *
4
+ * `crypto.randomUUID` is only defined on HTTPS or `localhost`. The dev server
5
+ * runs `vite dev --host`, so opening the Network URL it prints
6
+ * (`http://192.168.x.x:5173`) — from a phone, another machine, or through a
7
+ * plain-HTTP tunnel — leaves it `undefined`, and every call site throws
8
+ * `TypeError: crypto.randomUUID is not a function`.
9
+ *
10
+ * `crypto.getRandomValues` is *not* gated that way, so the fallback is still
11
+ * cryptographically random; only the convenience wrapper is missing. The final
12
+ * `Math.random` branch exists for non-browser contexts with no WebCrypto at all
13
+ * and is **not** suitable for anything security-sensitive — use `node:crypto` on
14
+ * the server, where `randomUUID` is always available.
15
+ */
16
+ export function randomId() {
17
+ if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
18
+ return crypto.randomUUID();
19
+ }
20
+ if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {
21
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
22
+ // Stamp the version (4) and variant (10xx) nibbles as the spec requires.
23
+ // Mapped rather than assigned by index so the bytes are read once, with no
24
+ // possibly-undefined element access to assert away.
25
+ const hex = Array.from(bytes, (byte, index) => {
26
+ const value = index === 6 ? (byte & 0x0f) | 0x40 : index === 8 ? (byte & 0x3f) | 0x80 : byte;
27
+ return value.toString(16).padStart(2, '0');
28
+ }).join('');
29
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
30
+ }
31
+ return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
32
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aphexcms/cms-core",
3
- "version": "11.0.0",
3
+ "version": "11.1.0",
4
4
  "description": "Aphex CMS Core - A Sanity-style CMS with ports and adapters architecture",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -87,7 +87,7 @@
87
87
  "svelte": "^5.44.0",
88
88
  "tailwind-merge": "^3.4.0",
89
89
  "tailwind-variants": "^3.2.2",
90
- "@aphexcms/ui": "^0.8.6"
90
+ "@aphexcms/ui": "^0.8.7"
91
91
  },
92
92
  "peerDependenciesMeta": {
93
93
  "graphql": {
@@ -1,112 +0,0 @@
1
- <script lang="ts">
2
- import { goto } from '$app/navigation';
3
- import { page } from '$app/state';
4
- import * as Collapsible from '@aphexcms/ui/shadcn/collapsible';
5
- import {
6
- SidebarGroup,
7
- SidebarGroupLabel,
8
- SidebarMenu,
9
- SidebarMenuItem,
10
- SidebarMenuButton,
11
- SidebarMenuSub,
12
- SidebarMenuSubItem,
13
- SidebarMenuSubButton
14
- } from '@aphexcms/ui/shadcn/sidebar';
15
- import { ChevronRight, type IconProps } from '@lucide/svelte';
16
- import type { Component } from 'svelte';
17
-
18
- type NavItem = {
19
- title: string;
20
- url: string;
21
- icon?: Component<IconProps>;
22
- isActive?: boolean;
23
- exact?: boolean;
24
- items?: {
25
- title: string;
26
- url: string;
27
- }[];
28
- };
29
-
30
- type Props = {
31
- items: NavItem[];
32
- label?: string;
33
- isActive?: (path: string, item: NavItem) => boolean;
34
- };
35
-
36
- let { items, label = 'Content', isActive: isActiveProp }: Props = $props();
37
-
38
- function matchActive(item: NavItem): boolean {
39
- if (isActiveProp) return isActiveProp(currentPath, item);
40
- if (item.exact) return currentPath === item.url;
41
- const matches = currentPath === item.url || currentPath.startsWith(item.url + '/');
42
- if (!matches) return false;
43
- return !items.some(
44
- (other) =>
45
- other !== item &&
46
- other.url.length > item.url.length &&
47
- (currentPath === other.url || currentPath.startsWith(other.url + '/'))
48
- );
49
- }
50
-
51
- let currentPath = $derived(page.url.pathname);
52
- </script>
53
-
54
- <SidebarGroup>
55
- <SidebarGroupLabel>{label}</SidebarGroupLabel>
56
- <SidebarMenu>
57
- {#each items as item (item.title)}
58
- {#if item.items && item.items.length > 0}
59
- <Collapsible.Root open={item.isActive} class="group/collapsible">
60
- {#snippet child({ props })}
61
- <SidebarMenuItem {...props}>
62
- <Collapsible.Trigger>
63
- {#snippet child({ props })}
64
- <SidebarMenuButton {...props} tooltipContent={item.title}>
65
- {#if item.icon}
66
- {@const Icon = item.icon}
67
- <Icon class="h-4 w-4" />
68
- {/if}
69
- <span>{item.title}</span>
70
- <ChevronRight
71
- class="ml-auto h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
72
- />
73
- </SidebarMenuButton>
74
- {/snippet}
75
- </Collapsible.Trigger>
76
- <Collapsible.Content>
77
- <SidebarMenuSub>
78
- {#each item.items as subItem (subItem.title)}
79
- <SidebarMenuSubItem>
80
- <SidebarMenuSubButton>
81
- {#snippet child({ props })}
82
- <a href={subItem.url} {...props}>
83
- <span>{subItem.title}</span>
84
- </a>
85
- {/snippet}
86
- </SidebarMenuSubButton>
87
- </SidebarMenuSubItem>
88
- {/each}
89
- </SidebarMenuSub>
90
- </Collapsible.Content>
91
- </SidebarMenuItem>
92
- {/snippet}
93
- </Collapsible.Root>
94
- {:else}
95
- <SidebarMenuItem>
96
- <SidebarMenuButton
97
- onclick={() => goto(item.url)}
98
- isActive={matchActive(item)}
99
- tooltipContent={item.title}
100
- class="cursor-pointer"
101
- >
102
- {#if item.icon}
103
- {@const Icon = item.icon}
104
- <Icon class="h-4 w-4" />
105
- {/if}
106
- <span>{item.title}</span>
107
- </SidebarMenuButton>
108
- </SidebarMenuItem>
109
- {/if}
110
- {/each}
111
- </SidebarMenu>
112
- </SidebarGroup>
@@ -1,22 +0,0 @@
1
- import { type IconProps } from '@lucide/svelte';
2
- import type { Component } from 'svelte';
3
- type NavItem = {
4
- title: string;
5
- url: string;
6
- icon?: Component<IconProps>;
7
- isActive?: boolean;
8
- exact?: boolean;
9
- items?: {
10
- title: string;
11
- url: string;
12
- }[];
13
- };
14
- type Props = {
15
- items: NavItem[];
16
- label?: string;
17
- isActive?: (path: string, item: NavItem) => boolean;
18
- };
19
- declare const NavMain: Component<Props, {}, "">;
20
- type NavMain = ReturnType<typeof NavMain>;
21
- export default NavMain;
22
- //# sourceMappingURL=NavMain.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NavMain.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/sidebar/NavMain.svelte.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAgB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGvC,KAAK,OAAO,GAAG;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACZ,EAAE,CAAC;CACJ,CAAC;AAEF,KAAK,KAAK,GAAG;IACZ,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC;CACpD,CAAC;AAoFH,QAAA,MAAM,OAAO,0BAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
@@ -1,69 +0,0 @@
1
- <script lang="ts">
2
- import {
3
- SidebarGroup,
4
- SidebarGroupContent,
5
- SidebarMenu,
6
- SidebarMenuItem,
7
- SidebarMenuButton
8
- } from '@aphexcms/ui/shadcn/sidebar';
9
- import { Sun, Moon } from '@lucide/svelte';
10
- import { toggleMode } from 'mode-watcher';
11
-
12
- type Props = {
13
- enableGraphiQL?: boolean;
14
- activeTab?: 'structure' | 'vision';
15
- onTabChange?: (tab: 'structure' | 'vision') => void;
16
- };
17
-
18
- let { enableGraphiQL = false, activeTab = $bindable('structure'), onTabChange }: Props = $props();
19
-
20
- function handleTabClick(tab: 'structure' | 'vision') {
21
- activeTab = tab;
22
- if (onTabChange) {
23
- onTabChange(tab);
24
- }
25
- }
26
- </script>
27
-
28
- <SidebarGroup class="mt-auto">
29
- <SidebarGroupContent>
30
- <SidebarMenu>
31
- <!-- Structure Tab -->
32
- <SidebarMenuItem>
33
- <SidebarMenuButton
34
- onclick={() => handleTabClick('structure')}
35
- isActive={activeTab === 'structure'}
36
- tooltipContent="Structure"
37
- size="sm"
38
- >
39
- <span>Structure</span>
40
- </SidebarMenuButton>
41
- </SidebarMenuItem>
42
-
43
- <!-- Vision Tab (if GraphiQL is enabled) -->
44
- {#if enableGraphiQL}
45
- <SidebarMenuItem>
46
- <SidebarMenuButton
47
- onclick={() => handleTabClick('vision')}
48
- isActive={activeTab === 'vision'}
49
- tooltipContent="Vision"
50
- size="sm"
51
- >
52
- <span>Vision</span>
53
- </SidebarMenuButton>
54
- </SidebarMenuItem>
55
- {/if}
56
-
57
- <!-- Theme Toggle -->
58
- <SidebarMenuItem>
59
- <SidebarMenuButton onclick={toggleMode} tooltipContent="Toggle theme" size="sm">
60
- <Sun class="h-4 w-4 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
61
- <Moon
62
- class="absolute h-4 w-4 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"
63
- />
64
- <span>Theme</span>
65
- </SidebarMenuButton>
66
- </SidebarMenuItem>
67
- </SidebarMenu>
68
- </SidebarGroupContent>
69
- </SidebarGroup>
@@ -1,9 +0,0 @@
1
- type Props = {
2
- enableGraphiQL?: boolean;
3
- activeTab?: 'structure' | 'vision';
4
- onTabChange?: (tab: 'structure' | 'vision') => void;
5
- };
6
- declare const NavSecondary: import("svelte").Component<Props, {}, "activeTab">;
7
- type NavSecondary = ReturnType<typeof NavSecondary>;
8
- export default NavSecondary;
9
- //# sourceMappingURL=NavSecondary.svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NavSecondary.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/layout/sidebar/NavSecondary.svelte.ts"],"names":[],"mappings":"AAcC,KAAK,KAAK,GAAG;IACZ,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,GAAG,QAAQ,KAAK,IAAI,CAAC;CACpD,CAAC;AAkDH,QAAA,MAAM,YAAY,oDAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}