@contractspec/bundle.library 3.9.8 → 3.9.9

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 (70) hide show
  1. package/.turbo/turbo-build.log +222 -214
  2. package/CHANGELOG.md +52 -0
  3. package/dist/components/docs/DocsIndexPage.js +2 -2
  4. package/dist/components/docs/docsManifest.js +1 -1
  5. package/dist/components/docs/getting-started/DataViewTutorialPage.js +81 -6
  6. package/dist/components/docs/getting-started/index.js +94 -19
  7. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.d.ts +6 -0
  8. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +176 -0
  9. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.d.ts +1 -0
  10. package/dist/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +176 -0
  11. package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
  12. package/dist/components/docs/guides/index.d.ts +1 -0
  13. package/dist/components/docs/guides/index.js +220 -46
  14. package/dist/components/docs/index.js +1003 -309
  15. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +22 -5
  16. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
  17. package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
  18. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
  19. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
  20. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  21. package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  22. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.d.ts +10 -0
  23. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +43 -0
  24. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.d.ts +1 -0
  25. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.js +43 -0
  26. package/dist/components/docs/libraries/index.d.ts +1 -0
  27. package/dist/components/docs/libraries/index.js +496 -97
  28. package/dist/components/docs/specs/SpecsDataViewsPage.js +49 -3
  29. package/dist/components/docs/specs/index.js +60 -14
  30. package/dist/index.js +1014 -320
  31. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  32. package/dist/node/components/docs/docsManifest.js +1 -1
  33. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +81 -6
  34. package/dist/node/components/docs/getting-started/index.js +94 -19
  35. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +175 -0
  36. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +175 -0
  37. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  38. package/dist/node/components/docs/guides/index.js +220 -46
  39. package/dist/node/components/docs/index.js +1003 -309
  40. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +125 -37
  41. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +125 -37
  42. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +120 -3
  43. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +101 -2
  44. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  45. package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  46. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +42 -0
  47. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.js +42 -0
  48. package/dist/node/components/docs/libraries/index.js +496 -97
  49. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +49 -3
  50. package/dist/node/components/docs/specs/index.js +60 -14
  51. package/dist/node/index.js +1014 -320
  52. package/package.json +74 -26
  53. package/src/components/docs/docsManifest.test.ts +87 -0
  54. package/src/components/docs/docsManifest.ts +90 -3
  55. package/src/components/docs/generated/docs-index.notifications.json +7 -7
  56. package/src/components/docs/getting-started/DataViewTutorialPage.tsx +181 -50
  57. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.ts +185 -0
  58. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.tsx +186 -0
  59. package/src/components/docs/guides/GuidesIndexPage.tsx +49 -42
  60. package/src/components/docs/guides/index.ts +1 -0
  61. package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +148 -35
  62. package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +38 -5
  63. package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +267 -64
  64. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +235 -0
  65. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +8 -2
  66. package/src/components/docs/libraries/LibrariesPersonalizationPage.tsx +141 -31
  67. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.content.ts +78 -0
  68. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.tsx +137 -0
  69. package/src/components/docs/libraries/index.ts +1 -0
  70. package/src/components/docs/specs/SpecsDataViewsPage.tsx +239 -113
@@ -1,11 +1,12 @@
1
- var n=Object.defineProperty;var o=(e)=>e;function i(e,t){this[e]=o.bind(null,t)}var s=(e,t)=>{for(var a in t)n(e,a,{get:t[a],enumerable:!0,configurable:!0,set:i.bind(t,a)})};var r=(e,t)=>()=>(e&&(t=e(e=0)),t);var c=`import {
1
+ var i=Object.defineProperty;var n=(e)=>e;function o(e,t){this[e]=n.bind(null,t)}var s=(e,t)=>{for(var a in t)i(e,a,{get:t[a],enumerable:!0,configurable:!0,set:o.bind(t,a)})};var r=(e,t)=>()=>(e&&(t=e(e=0)),t);var l=`import {
2
2
  AppShell,
3
- PageOutline,
4
- type AppShellNavigationSection,
3
+ type ShellCommandGroup,
4
+ type ShellNavSection,
5
+ type ShellNotificationCenter,
5
6
  type PageOutlineItem,
6
7
  } from "@contractspec/lib.design-system/shell";
7
8
 
8
- const navigation: AppShellNavigationSection[] = [
9
+ const navigation: ShellNavSection[] = [
9
10
  {
10
11
  title: "Workspace",
11
12
  items: [
@@ -22,6 +23,16 @@ const navigation: AppShellNavigationSection[] = [
22
23
  },
23
24
  ];
24
25
 
26
+ const commands: ShellCommandGroup[] = [
27
+ {
28
+ heading: "Quick actions",
29
+ items: [
30
+ { id: "new-contract", label: "New contract", shortcut: "N" },
31
+ { id: "import", label: "Import existing app" },
32
+ ],
33
+ },
34
+ ];
35
+
25
36
  const outline: PageOutlineItem[] = [
26
37
  {
27
38
  id: "architecture",
@@ -34,41 +45,104 @@ const outline: PageOutlineItem[] = [
34
45
  },
35
46
  ];
36
47
 
48
+ const notifications: ShellNotificationCenter = {
49
+ label: "Notifications",
50
+ loading: false,
51
+ unreadCount: 2,
52
+ items: [
53
+ {
54
+ id: "contract-approved",
55
+ title: "Contract approved",
56
+ body: "Billing.create is ready to publish.",
57
+ status: "unread",
58
+ createdAt: "2026-04-29T09:30:00Z",
59
+ actionUrl: "/contracts/billing.create",
60
+ category: "Review",
61
+ },
62
+ ],
63
+ onSelect: (item) => openNotificationTarget(item),
64
+ onMarkRead: (item) => markNotificationRead(item.id),
65
+ onMarkAllRead: () => markAllNotificationsRead(),
66
+ };
67
+
37
68
  export function WorkspacePage() {
38
69
  return (
39
70
  <AppShell
40
- brand={{ label: "ContractSpec", href: "/dashboard" }}
71
+ title="ContractSpec"
72
+ homeHref="/dashboard"
41
73
  navigation={navigation}
74
+ commands={commands}
42
75
  breadcrumbs={[
43
76
  { label: "Workspace", href: "/dashboard" },
44
77
  { label: "Contracts" },
45
78
  ]}
46
- command={{
47
- placeholder: "Search contracts or run an action",
48
- groups: [
49
- {
50
- title: "Quick actions",
51
- actions: [
52
- { id: "new-contract", label: "New contract" },
53
- { id: "import", label: "Import existing app" },
54
- ],
55
- },
56
- ],
57
- }}
58
- user={{
59
- name: "Ada Lovelace",
60
- email: "ada@example.com",
61
- actions: [{ label: "Sign out", onSelect: () => signOut() }],
62
- }}
63
- pageOutline={<PageOutline items={outline} activeId="desktop" />}
79
+ notifications={notifications}
80
+ pageOutline={outline}
81
+ activeHref="/contracts"
82
+ activeOutlineId="desktop"
83
+ userMenu={<UserMenu onSignOut={() => signOut()} />}
64
84
  >
65
85
  <main>{/* route content */}</main>
66
86
  </AppShell>
67
87
  );
68
- }`,d=`You are implementing a modern application shell from scratch.
88
+ }`,d=`import {
89
+ ListNotificationsOutputModel,
90
+ MarkNotificationReadInputModel,
91
+ } from "@contractspec/lib.contracts-spec/notifications";
92
+ import {
93
+ notificationsSchemaContribution,
94
+ renderNotificationTemplate,
95
+ } from "@contractspec/lib.notification";
96
+ import type { ShellNotificationCenter } from "@contractspec/lib.design-system/shell";
97
+
98
+ type NotificationListResult = {
99
+ unreadCount: number;
100
+ notifications: Array<{
101
+ id: string;
102
+ title: string;
103
+ body: string;
104
+ type: string;
105
+ status: string;
106
+ readAt?: string | Date | null;
107
+ createdAt: string | Date;
108
+ actionUrl?: string;
109
+ metadata?: Record<string, unknown>;
110
+ }>;
111
+ };
112
+
113
+ export function toShellNotifications(
114
+ data: NotificationListResult,
115
+ actions: {
116
+ open: (id: string) => void;
117
+ markRead: (input: { notificationId: string }) => void;
118
+ markAllRead: () => void;
119
+ }
120
+ ): ShellNotificationCenter {
121
+ return {
122
+ unreadCount: data.unreadCount,
123
+ items: data.notifications.map((notification) => ({
124
+ id: notification.id,
125
+ title: notification.title,
126
+ body: notification.body,
127
+ status: notification.status,
128
+ createdAt: notification.createdAt,
129
+ actionUrl: notification.actionUrl,
130
+ category: notification.type,
131
+ metadata: notification.metadata,
132
+ })),
133
+ onSelect: (item) => actions.open(item.id),
134
+ onMarkRead: (item) => actions.markRead({ notificationId: item.id }),
135
+ onMarkAllRead: actions.markAllRead,
136
+ };
137
+ }
138
+
139
+ void ListNotificationsOutputModel;
140
+ void MarkNotificationReadInputModel;
141
+ void notificationsSchemaContribution;
142
+ void renderNotificationTemplate;`,p=`You are implementing a modern application shell from scratch.
69
143
 
70
144
  Goal:
71
- Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, and an in-page section navigator called PageOutline.
145
+ Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, in-app notifications, and an in-page section navigator called PageOutline.
72
146
 
73
147
  Use this architecture:
74
148
  - Keep route content independent from navigation chrome.
@@ -76,29 +150,37 @@ Use this architecture:
76
150
  - Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
77
151
  - Create a breadcrumb model for the topbar.
78
152
  - Create a PageOutline model for right-side in-page navigation with exactly three supported levels. It should render anchors, support active section state, and degrade gracefully when no sections exist.
153
+ - Create a ShellNotificationCenter model with render-ready items, unread count, loading and empty states, onSelect, onMarkRead, onMarkAllRead, and optional custom item rendering.
79
154
  - Expose the system from the design system or a dedicated shell module, not from a single app route.
80
155
 
156
+ Notification boundary:
157
+ - Use @contractspec/lib.contracts-spec/notifications as the canonical source for notification contracts, operation models, and feature metadata.
158
+ - Use @contractspec/lib.notification for reusable notification entities, schema contribution, channels, templates, and i18n helpers.
159
+ - Keep persistence, polling/subscriptions, delivery providers, and optimistic mutations in the host application or notification runtime layer.
160
+ - Pass only render-ready ShellNotificationCenter state into AppShell so the design system does not import or own notification runtime behavior.
161
+
81
162
  Desktop behavior:
82
163
  - Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
83
164
  - Topbar with breadcrumbs and an optional command trigger.
165
+ - Topbar notification trigger with unread badge, loading/empty states, mark-read actions, and item selection.
84
166
  - Content area with optional right PageOutline.
85
167
  - Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
86
168
 
87
169
  Mobile web behavior:
88
170
  - Use bottom navigation for the primary destinations.
89
- - Put deeper navigation, command search, auth actions, and secondary actions behind a menu or drawer.
171
+ - Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.
90
172
  - Keep route content first and make the shell controls reachable without covering important content.
91
173
 
92
174
  Native behavior:
93
175
  - Add .native.tsx entrypoints for Expo/React Native.
94
- - Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation and account actions.
95
- - Keep the same typed navigation, command, breadcrumb, and PageOutline data contracts across web and native.
176
+ - Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation, notifications, and account actions.
177
+ - Keep the same typed navigation, command, breadcrumb, notification, and PageOutline data contracts across web and native.
96
178
 
97
179
  Implementation constraints:
98
180
  - Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
99
181
  - Do not hardcode app-specific routes in the shell component.
100
182
  - Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
101
- - Include tests for navigation rendering, nested items, command filtering, breadcrumbs, PageOutline level handling, active section state, and mobile/native adaptation contracts.
183
+ - Include tests for navigation rendering, nested items, command filtering, breadcrumbs, notification unread badge/loading/empty/callback behavior, PageOutline level handling, active section state, and mobile/native adaptation contracts.
102
184
  - Update docs and exports so developers can import the shell from a stable public API.
103
185
 
104
186
  Deliverables:
@@ -106,15 +188,18 @@ Deliverables:
106
188
  - Web shell components.
107
189
  - Native shell components or adapters.
108
190
  - PageOutline component with three-level support.
191
+ - ShellNotifications or equivalent notification center component for web and native shell placement.
109
192
  - Usage example.
110
- - Focused tests and typecheck/build evidence.`,p=`You are refactoring an existing application to use the shared application shell system.
193
+ - Focused tests and typecheck/build evidence.`,m=`You are refactoring an existing application to use the shared application shell system.
111
194
 
112
195
  Goal:
113
- Replace app-specific sidebar, topbar, breadcrumb, command palette, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell and PageOutline system.
196
+ Replace app-specific sidebar, topbar, breadcrumb, command palette, notification badge/inbox, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell, ShellNotifications, and PageOutline system.
114
197
 
115
198
  Start by auditing:
116
199
  - Current layout wrappers and route groups.
117
200
  - Sidebar, topbar, breadcrumb, command/search, auth menu, and mobile navigation implementations.
201
+ - Existing notification badges, inbox panels, toasts that represent durable in-app items, unread count queries, mark-read actions, and delivery modules.
202
+ - Imports from @contractspec/module.notifications that should migrate to @contractspec/lib.contracts-spec/notifications or @contractspec/lib.notification.
118
203
  - Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
119
204
  - Any in-page summary/table-of-contents components that should become PageOutline data.
120
205
  - Web-only assumptions that would block Expo/React Native adaptation.
@@ -123,25 +208,28 @@ Refactor plan:
123
208
  1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
124
209
  2. Map existing command/search behavior into grouped command actions with search text and quick actions.
125
210
  3. Map existing route metadata into breadcrumbs.
126
- 4. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
127
- 5. Wrap app routes in AppShell while keeping page content components route-local.
128
- 6. Move primary mobile destinations into bottom navigation and deeper/account actions into a menu or drawer.
129
- 7. Add or preserve .native.tsx adapters when the app targets Expo.
211
+ 4. Move canonical notification contracts to @contractspec/lib.contracts-spec/notifications and reusable helpers to @contractspec/lib.notification; keep the old module shim only for compatibility imports that still need the legacy module id.
212
+ 5. Convert notification query results into ShellNotificationCenter items with unreadCount, loading, empty state, onSelect, onMarkRead, and onMarkAllRead callbacks.
213
+ 6. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
214
+ 7. Wrap app routes in AppShell while keeping page content components route-local.
215
+ 8. Move primary mobile destinations into bottom navigation and deeper/account/notification actions into a menu or drawer.
216
+ 9. Add or preserve .native.tsx adapters when the app targets Expo.
130
217
 
131
218
  Preserve behavior:
132
219
  - Existing route URLs and access rules.
133
220
  - Existing keyboard shortcuts where they are public behavior.
134
221
  - Existing analytics or telemetry events on navigation and command actions.
222
+ - Existing notification delivery semantics, unread count semantics, deep links, and mark-read behavior.
135
223
  - Existing auth/logout behavior.
136
224
  - Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
137
225
 
138
226
  Quality gates:
139
227
  - Add regression tests around current visible navigation before removing old shell code when coverage is missing.
140
- - Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
228
+ - Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, notification unread badge/loading/empty/callback behavior, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
141
229
  - Run lint, typecheck, and the app's relevant test/build command.
142
230
  - Remove dead app-specific shell components only after the shared shell path is verified.
143
231
 
144
232
  Output:
145
233
  - List old shell files removed or simplified.
146
234
  - List new shared shell integration points.
147
- - Include before/after route coverage and verification commands.`,m=[{title:"Sidebar",body:"Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area."},{title:"Topbar",body:"Breadcrumbs stay visible while the current route changes. The command trigger can live here when the sidebar is collapsed or hidden."},{title:"PageOutline",body:"The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state."},{title:"Mobile adapters",body:"Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation and account actions."}];export{c as shellUsageExample,m as shellParts,d as scratchPrompt,p as refactorPrompt};
235
+ - Include before/after route coverage and verification commands.`,u=[{title:"Contracts stay canonical",body:"Use @contractspec/lib.contracts-spec/notifications for operation models, feature metadata, and contract-level compatibility."},{title:"Runtime helpers stay reusable",body:"Use @contractspec/lib.notification for schema contribution, channel adapters, templates, and i18n without importing the deprecated module shim in new code."},{title:"Apps own live state",body:"Fetch, subscribe, persist, mutate, and reconcile notification state in the host app or runtime layer where auth and tenancy are known."},{title:"Shell receives view state",body:"Pass AppShell a ShellNotificationCenter with render-ready items, counts, loading state, and callbacks; the design system only renders affordances."}],h=[{title:"Sidebar",body:"Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area."},{title:"Topbar",body:"Breadcrumbs stay visible while the current route changes. Command search and notification affordances can live here when the sidebar is collapsed or hidden."},{title:"PageOutline",body:"The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state."},{title:"Notifications",body:"The shell renders unread badges, item lists, loading/empty states, mark-read actions, and deep-link selection from host-owned notification state."},{title:"Mobile adapters",body:"Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation, notifications, and account actions."}];export{l as shellUsageExample,h as shellParts,p as scratchPrompt,m as refactorPrompt,u as notificationGuide,d as notificationCenterExample};
@@ -1,11 +1,12 @@
1
- var v=Object.defineProperty;var f=(t)=>t;function y(t,n){this[t]=f.bind(null,n)}var k=(t,n)=>{for(var s in n)v(t,s,{get:n[s],enumerable:!0,configurable:!0,set:y.bind(n,s)})};var N=(t,n)=>()=>(t&&(n=t(t=0)),n);var d=`import {
1
+ var w=Object.defineProperty;var k=(t)=>t;function N(t,n){this[t]=k.bind(null,n)}var O=(t,n)=>{for(var d in n)w(t,d,{get:n[d],enumerable:!0,configurable:!0,set:N.bind(n,d)})};var C=(t,n)=>()=>(t&&(n=t(t=0)),n);var p=`import {
2
2
  AppShell,
3
- PageOutline,
4
- type AppShellNavigationSection,
3
+ type ShellCommandGroup,
4
+ type ShellNavSection,
5
+ type ShellNotificationCenter,
5
6
  type PageOutlineItem,
6
7
  } from "@contractspec/lib.design-system/shell";
7
8
 
8
- const navigation: AppShellNavigationSection[] = [
9
+ const navigation: ShellNavSection[] = [
9
10
  {
10
11
  title: "Workspace",
11
12
  items: [
@@ -22,6 +23,16 @@ const navigation: AppShellNavigationSection[] = [
22
23
  },
23
24
  ];
24
25
 
26
+ const commands: ShellCommandGroup[] = [
27
+ {
28
+ heading: "Quick actions",
29
+ items: [
30
+ { id: "new-contract", label: "New contract", shortcut: "N" },
31
+ { id: "import", label: "Import existing app" },
32
+ ],
33
+ },
34
+ ];
35
+
25
36
  const outline: PageOutlineItem[] = [
26
37
  {
27
38
  id: "architecture",
@@ -34,41 +45,104 @@ const outline: PageOutlineItem[] = [
34
45
  },
35
46
  ];
36
47
 
48
+ const notifications: ShellNotificationCenter = {
49
+ label: "Notifications",
50
+ loading: false,
51
+ unreadCount: 2,
52
+ items: [
53
+ {
54
+ id: "contract-approved",
55
+ title: "Contract approved",
56
+ body: "Billing.create is ready to publish.",
57
+ status: "unread",
58
+ createdAt: "2026-04-29T09:30:00Z",
59
+ actionUrl: "/contracts/billing.create",
60
+ category: "Review",
61
+ },
62
+ ],
63
+ onSelect: (item) => openNotificationTarget(item),
64
+ onMarkRead: (item) => markNotificationRead(item.id),
65
+ onMarkAllRead: () => markAllNotificationsRead(),
66
+ };
67
+
37
68
  export function WorkspacePage() {
38
69
  return (
39
70
  <AppShell
40
- brand={{ label: "ContractSpec", href: "/dashboard" }}
71
+ title="ContractSpec"
72
+ homeHref="/dashboard"
41
73
  navigation={navigation}
74
+ commands={commands}
42
75
  breadcrumbs={[
43
76
  { label: "Workspace", href: "/dashboard" },
44
77
  { label: "Contracts" },
45
78
  ]}
46
- command={{
47
- placeholder: "Search contracts or run an action",
48
- groups: [
49
- {
50
- title: "Quick actions",
51
- actions: [
52
- { id: "new-contract", label: "New contract" },
53
- { id: "import", label: "Import existing app" },
54
- ],
55
- },
56
- ],
57
- }}
58
- user={{
59
- name: "Ada Lovelace",
60
- email: "ada@example.com",
61
- actions: [{ label: "Sign out", onSelect: () => signOut() }],
62
- }}
63
- pageOutline={<PageOutline items={outline} activeId="desktop" />}
79
+ notifications={notifications}
80
+ pageOutline={outline}
81
+ activeHref="/contracts"
82
+ activeOutlineId="desktop"
83
+ userMenu={<UserMenu onSignOut={() => signOut()} />}
64
84
  >
65
85
  <main>{/* route content */}</main>
66
86
  </AppShell>
67
87
  );
68
- }`,p=`You are implementing a modern application shell from scratch.
88
+ }`,m=`import {
89
+ ListNotificationsOutputModel,
90
+ MarkNotificationReadInputModel,
91
+ } from "@contractspec/lib.contracts-spec/notifications";
92
+ import {
93
+ notificationsSchemaContribution,
94
+ renderNotificationTemplate,
95
+ } from "@contractspec/lib.notification";
96
+ import type { ShellNotificationCenter } from "@contractspec/lib.design-system/shell";
97
+
98
+ type NotificationListResult = {
99
+ unreadCount: number;
100
+ notifications: Array<{
101
+ id: string;
102
+ title: string;
103
+ body: string;
104
+ type: string;
105
+ status: string;
106
+ readAt?: string | Date | null;
107
+ createdAt: string | Date;
108
+ actionUrl?: string;
109
+ metadata?: Record<string, unknown>;
110
+ }>;
111
+ };
112
+
113
+ export function toShellNotifications(
114
+ data: NotificationListResult,
115
+ actions: {
116
+ open: (id: string) => void;
117
+ markRead: (input: { notificationId: string }) => void;
118
+ markAllRead: () => void;
119
+ }
120
+ ): ShellNotificationCenter {
121
+ return {
122
+ unreadCount: data.unreadCount,
123
+ items: data.notifications.map((notification) => ({
124
+ id: notification.id,
125
+ title: notification.title,
126
+ body: notification.body,
127
+ status: notification.status,
128
+ createdAt: notification.createdAt,
129
+ actionUrl: notification.actionUrl,
130
+ category: notification.type,
131
+ metadata: notification.metadata,
132
+ })),
133
+ onSelect: (item) => actions.open(item.id),
134
+ onMarkRead: (item) => actions.markRead({ notificationId: item.id }),
135
+ onMarkAllRead: actions.markAllRead,
136
+ };
137
+ }
138
+
139
+ void ListNotificationsOutputModel;
140
+ void MarkNotificationReadInputModel;
141
+ void notificationsSchemaContribution;
142
+ void renderNotificationTemplate;`,u=`You are implementing a modern application shell from scratch.
69
143
 
70
144
  Goal:
71
- Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, and an in-page section navigator called PageOutline.
145
+ Build a reusable application shell for a React/Next.js web app and an Expo React Native app. The shell must provide a desktop sidebar, desktop topbar, command search, breadcrumbs, nested navigation, user/auth actions, in-app notifications, and an in-page section navigator called PageOutline.
72
146
 
73
147
  Use this architecture:
74
148
  - Keep route content independent from navigation chrome.
@@ -76,29 +150,37 @@ Use this architecture:
76
150
  - Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
77
151
  - Create a breadcrumb model for the topbar.
78
152
  - Create a PageOutline model for right-side in-page navigation with exactly three supported levels. It should render anchors, support active section state, and degrade gracefully when no sections exist.
153
+ - Create a ShellNotificationCenter model with render-ready items, unread count, loading and empty states, onSelect, onMarkRead, onMarkAllRead, and optional custom item rendering.
79
154
  - Expose the system from the design system or a dedicated shell module, not from a single app route.
80
155
 
156
+ Notification boundary:
157
+ - Use @contractspec/lib.contracts-spec/notifications as the canonical source for notification contracts, operation models, and feature metadata.
158
+ - Use @contractspec/lib.notification for reusable notification entities, schema contribution, channels, templates, and i18n helpers.
159
+ - Keep persistence, polling/subscriptions, delivery providers, and optimistic mutations in the host application or notification runtime layer.
160
+ - Pass only render-ready ShellNotificationCenter state into AppShell so the design system does not import or own notification runtime behavior.
161
+
81
162
  Desktop behavior:
82
163
  - Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
83
164
  - Topbar with breadcrumbs and an optional command trigger.
165
+ - Topbar notification trigger with unread badge, loading/empty states, mark-read actions, and item selection.
84
166
  - Content area with optional right PageOutline.
85
167
  - Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
86
168
 
87
169
  Mobile web behavior:
88
170
  - Use bottom navigation for the primary destinations.
89
- - Put deeper navigation, command search, auth actions, and secondary actions behind a menu or drawer.
171
+ - Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.
90
172
  - Keep route content first and make the shell controls reachable without covering important content.
91
173
 
92
174
  Native behavior:
93
175
  - Add .native.tsx entrypoints for Expo/React Native.
94
- - Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation and account actions.
95
- - Keep the same typed navigation, command, breadcrumb, and PageOutline data contracts across web and native.
176
+ - Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation, notifications, and account actions.
177
+ - Keep the same typed navigation, command, breadcrumb, notification, and PageOutline data contracts across web and native.
96
178
 
97
179
  Implementation constraints:
98
180
  - Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
99
181
  - Do not hardcode app-specific routes in the shell component.
100
182
  - Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
101
- - Include tests for navigation rendering, nested items, command filtering, breadcrumbs, PageOutline level handling, active section state, and mobile/native adaptation contracts.
183
+ - Include tests for navigation rendering, nested items, command filtering, breadcrumbs, notification unread badge/loading/empty/callback behavior, PageOutline level handling, active section state, and mobile/native adaptation contracts.
102
184
  - Update docs and exports so developers can import the shell from a stable public API.
103
185
 
104
186
  Deliverables:
@@ -106,15 +188,18 @@ Deliverables:
106
188
  - Web shell components.
107
189
  - Native shell components or adapters.
108
190
  - PageOutline component with three-level support.
191
+ - ShellNotifications or equivalent notification center component for web and native shell placement.
109
192
  - Usage example.
110
- - Focused tests and typecheck/build evidence.`,m=`You are refactoring an existing application to use the shared application shell system.
193
+ - Focused tests and typecheck/build evidence.`,h=`You are refactoring an existing application to use the shared application shell system.
111
194
 
112
195
  Goal:
113
- Replace app-specific sidebar, topbar, breadcrumb, command palette, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell and PageOutline system.
196
+ Replace app-specific sidebar, topbar, breadcrumb, command palette, notification badge/inbox, account menu, mobile navigation, and in-page table-of-contents code with the shared AppShell, ShellNotifications, and PageOutline system.
114
197
 
115
198
  Start by auditing:
116
199
  - Current layout wrappers and route groups.
117
200
  - Sidebar, topbar, breadcrumb, command/search, auth menu, and mobile navigation implementations.
201
+ - Existing notification badges, inbox panels, toasts that represent durable in-app items, unread count queries, mark-read actions, and delivery modules.
202
+ - Imports from @contractspec/module.notifications that should migrate to @contractspec/lib.contracts-spec/notifications or @contractspec/lib.notification.
118
203
  - Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
119
204
  - Any in-page summary/table-of-contents components that should become PageOutline data.
120
205
  - Web-only assumptions that would block Expo/React Native adaptation.
@@ -123,25 +208,28 @@ Refactor plan:
123
208
  1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
124
209
  2. Map existing command/search behavior into grouped command actions with search text and quick actions.
125
210
  3. Map existing route metadata into breadcrumbs.
126
- 4. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
127
- 5. Wrap app routes in AppShell while keeping page content components route-local.
128
- 6. Move primary mobile destinations into bottom navigation and deeper/account actions into a menu or drawer.
129
- 7. Add or preserve .native.tsx adapters when the app targets Expo.
211
+ 4. Move canonical notification contracts to @contractspec/lib.contracts-spec/notifications and reusable helpers to @contractspec/lib.notification; keep the old module shim only for compatibility imports that still need the legacy module id.
212
+ 5. Convert notification query results into ShellNotificationCenter items with unreadCount, loading, empty state, onSelect, onMarkRead, and onMarkAllRead callbacks.
213
+ 6. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
214
+ 7. Wrap app routes in AppShell while keeping page content components route-local.
215
+ 8. Move primary mobile destinations into bottom navigation and deeper/account/notification actions into a menu or drawer.
216
+ 9. Add or preserve .native.tsx adapters when the app targets Expo.
130
217
 
131
218
  Preserve behavior:
132
219
  - Existing route URLs and access rules.
133
220
  - Existing keyboard shortcuts where they are public behavior.
134
221
  - Existing analytics or telemetry events on navigation and command actions.
222
+ - Existing notification delivery semantics, unread count semantics, deep links, and mark-read behavior.
135
223
  - Existing auth/logout behavior.
136
224
  - Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
137
225
 
138
226
  Quality gates:
139
227
  - Add regression tests around current visible navigation before removing old shell code when coverage is missing.
140
- - Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
228
+ - Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, notification unread badge/loading/empty/callback behavior, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
141
229
  - Run lint, typecheck, and the app's relevant test/build command.
142
230
  - Remove dead app-specific shell components only after the shared shell path is verified.
143
231
 
144
232
  Output:
145
233
  - List old shell files removed or simplified.
146
234
  - List new shared shell integration points.
147
- - Include before/after route coverage and verification commands.`,u=[{title:"Sidebar",body:"Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area."},{title:"Topbar",body:"Breadcrumbs stay visible while the current route changes. The command trigger can live here when the sidebar is collapsed or hidden."},{title:"PageOutline",body:"The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state."},{title:"Mobile adapters",body:"Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation and account actions."}];import{CodeBlock as l,InstallCommand as w}from"@contractspec/lib.design-system";import{Box as h,HStack as O,VStack as o}from"@contractspec/lib.design-system/layout";import{Code as c,H1 as A,H2 as i,H3 as P,P as r,Text as b}from"@contractspec/lib.design-system/typography";import g from"@contractspec/lib.ui-link";import{ChevronRight as E}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function K(){return a(o,{className:"space-y-8",children:[a(o,{className:"space-y-4",children:[e(A,{className:"font-bold text-4xl",children:"Application shell"}),a(r,{className:"text-lg text-muted-foreground",children:["A reusable navigation system for product apps: desktop sidebar, topbar breadcrumbs, command search, account actions, mobile adapters, and a Notion-style ",e(c,{children:"PageOutline"})," for page sections."]})]}),a(o,{className:"space-y-4",children:[e(i,{className:"font-bold text-2xl",children:"Installation"}),e(w,{package:"@contractspec/lib.design-system"})]}),a(o,{className:"space-y-4",children:[e(i,{className:"font-bold text-2xl",children:"What It Standardizes"}),e(h,{className:"grid gap-4 md:grid-cols-2",children:u.map((t)=>a(h,{className:"card-subtle p-4",children:[e(P,{className:"font-semibold",children:t.title}),e(r,{className:"mt-2 text-muted-foreground text-sm leading-7",children:t.body})]},t.title))})]}),a(o,{className:"space-y-4",children:[e(i,{className:"font-bold text-2xl",children:"Import Surface"}),e(r,{className:"text-muted-foreground",children:"The shell is exposed as a focused design-system subpath so apps can adopt navigation chrome without pulling unrelated documentation or marketing helpers."}),e(l,{language:"tsx",filename:"app-shell-example.tsx",code:d})]}),a(o,{className:"space-y-4",children:[e(i,{className:"font-bold text-2xl",children:"AI Prompt: Build From Scratch"}),e(r,{className:"text-muted-foreground",children:"Use this prompt when the app does not already have a shell or when the design-system package needs the reusable primitive first."}),e(l,{language:"markdown",filename:"implement-application-shell.md",code:p})]}),a(o,{className:"space-y-4",children:[e(i,{className:"font-bold text-2xl",children:"AI Prompt: Refactor An App"}),e(r,{className:"text-muted-foreground",children:"Use this prompt when an app already has custom navigation chrome and needs to migrate without breaking route behavior."}),e(l,{language:"markdown",filename:"refactor-to-application-shell.md",code:m})]}),a(o,{className:"card-subtle space-y-3 p-6",children:[e(i,{className:"font-bold text-2xl",children:"Naming"}),a(r,{className:"text-muted-foreground",children:["Use ",e(c,{children:"AppShell"})," for the whole navigation frame and"," ",e(c,{children:"PageOutline"})," for the in-page navigation helper. The latter is the product-app equivalent of a table of contents, but it is intentionally named for live page sections rather than static documentation."]})]}),a(O,{className:"flex flex-wrap items-center gap-3 pt-2",children:[e(g,{href:"/docs/libraries/cross-platform-ui",className:"btn-ghost",children:e(b,{children:"Cross-platform UI"})}),a(g,{href:"/docs/libraries/design-system",className:"btn-primary",children:[e(b,{children:"Design System"})," ",e(E,{size:16})]})]})]})}export{K as LibrariesApplicationShellPage};
235
+ - Include before/after route coverage and verification commands.`,b=[{title:"Contracts stay canonical",body:"Use @contractspec/lib.contracts-spec/notifications for operation models, feature metadata, and contract-level compatibility."},{title:"Runtime helpers stay reusable",body:"Use @contractspec/lib.notification for schema contribution, channel adapters, templates, and i18n without importing the deprecated module shim in new code."},{title:"Apps own live state",body:"Fetch, subscribe, persist, mutate, and reconcile notification state in the host app or runtime layer where auth and tenancy are known."},{title:"Shell receives view state",body:"Pass AppShell a ShellNotificationCenter with render-ready items, counts, loading state, and callbacks; the design system only renders affordances."}],g=[{title:"Sidebar",body:"Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area."},{title:"Topbar",body:"Breadcrumbs stay visible while the current route changes. Command search and notification affordances can live here when the sidebar is collapsed or hidden."},{title:"PageOutline",body:"The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state."},{title:"Notifications",body:"The shell renders unread badges, item lists, loading/empty states, mark-read actions, and deep-link selection from host-owned notification state."},{title:"Mobile adapters",body:"Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation, notifications, and account actions."}];import{CodeBlock as c,InstallCommand as R}from"@contractspec/lib.design-system";import{Box as l,HStack as A,VStack as i}from"@contractspec/lib.design-system/layout";import{Code as o,H1 as S,H2 as s,H3 as f,P as r,Text as v}from"@contractspec/lib.design-system/typography";import y from"@contractspec/lib.ui-link";import{ChevronRight as M}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function K(){return a(i,{className:"space-y-8",children:[a(i,{className:"space-y-4",children:[e(S,{className:"font-bold text-4xl",children:"Application shell"}),a(r,{className:"text-lg text-muted-foreground",children:["A reusable navigation system for product apps: desktop sidebar, topbar breadcrumbs, command search, account actions, mobile adapters, and a Notion-style ",e(o,{children:"PageOutline"})," for page sections, with prop-driven in-app notifications for web and native shells."]})]}),a(i,{className:"space-y-4",children:[e(s,{className:"font-bold text-2xl",children:"Installation"}),e(R,{package:"@contractspec/lib.design-system"})]}),a(i,{className:"space-y-4",children:[e(s,{className:"font-bold text-2xl",children:"What It Standardizes"}),e(l,{className:"grid gap-4 md:grid-cols-2",children:g.map((t)=>a(l,{className:"card-subtle p-4",children:[e(f,{className:"font-semibold",children:t.title}),e(r,{className:"mt-2 text-muted-foreground text-sm leading-7",children:t.body})]},t.title))})]}),a(i,{className:"space-y-4",children:[e(s,{className:"font-bold text-2xl",children:"Import Surface"}),e(r,{className:"text-muted-foreground",children:"The shell is exposed as a focused design-system subpath so apps can adopt navigation chrome without pulling unrelated documentation or marketing helpers."}),e(c,{language:"tsx",filename:"app-shell-example.tsx",code:p})]}),a(i,{className:"space-y-4",children:[e(s,{className:"font-bold text-2xl",children:"Notification Center Boundary"}),a(r,{className:"text-muted-foreground",children:["Notifications are part of the shell experience, but the design system only renders the affordance. Contracts, runtime helpers, persistence, delivery, auth, and subscriptions stay outside the shell and feed a render-ready ",e(o,{children:"ShellNotificationCenter"})," into"," ",e(o,{children:"AppShell"}),"."]}),e(l,{className:"grid gap-4 md:grid-cols-2",children:b.map((t)=>a(l,{className:"card-subtle p-4",children:[e(f,{className:"font-semibold",children:t.title}),e(r,{className:"mt-2 text-muted-foreground text-sm leading-7",children:t.body})]},t.title))}),e(c,{language:"tsx",filename:"notification-center-boundary.ts",code:m})]}),a(i,{className:"space-y-4",children:[e(s,{className:"font-bold text-2xl",children:"AI Prompt: Build From Scratch"}),e(r,{className:"text-muted-foreground",children:"Use this prompt when the app does not already have a shell, command surface, page outline, or in-app notification center."}),e(c,{language:"markdown",filename:"implement-application-shell.md",code:u})]}),a(i,{className:"space-y-4",children:[e(s,{className:"font-bold text-2xl",children:"AI Prompt: Refactor An App"}),e(r,{className:"text-muted-foreground",children:"Use this prompt when an app already has custom navigation chrome and notification UI that need to migrate without breaking route behavior, unread counts, or delivery semantics."}),e(c,{language:"markdown",filename:"refactor-to-application-shell.md",code:h})]}),a(i,{className:"card-subtle space-y-3 p-6",children:[e(s,{className:"font-bold text-2xl",children:"Naming"}),a(r,{className:"text-muted-foreground",children:["Use ",e(o,{children:"AppShell"})," for the whole navigation frame and"," ",e(o,{children:"PageOutline"})," for the in-page navigation helper. The latter is the product-app equivalent of a table of contents, but it is intentionally named for live page sections rather than static documentation. Use ",e(o,{children:"ShellNotifications"})," for the notification affordance when it is rendered directly, or pass the same data contract through ",e(o,{children:"AppShell"})," with the"," ",e(o,{children:"notifications"})," prop."]})]}),a(A,{className:"flex flex-wrap items-center gap-3 pt-2",children:[e(y,{href:"/docs/libraries/cross-platform-ui",className:"btn-ghost",children:e(v,{children:"Cross-platform UI"})}),a(y,{href:"/docs/libraries/design-system",className:"btn-primary",children:[e(v,{children:"Design System"})," ",e(M,{size:16})]})]})]})}export{K as LibrariesApplicationShellPage};