@contractspec/bundle.library 3.9.7 → 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 (71) hide show
  1. package/.turbo/turbo-build.log +186 -174
  2. package/CHANGELOG.md +96 -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 +117 -6
  6. package/dist/components/docs/getting-started/index.js +130 -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 +1195 -276
  15. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +33 -0
  16. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +236 -0
  17. package/dist/components/docs/libraries/LibrariesApplicationShellPage.d.ts +1 -0
  18. package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +236 -0
  19. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +130 -6
  20. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +102 -3
  21. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  22. package/dist/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  23. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.d.ts +10 -0
  24. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +43 -0
  25. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.d.ts +1 -0
  26. package/dist/components/docs/libraries/LibrariesTranslationRuntimePage.js +43 -0
  27. package/dist/components/docs/libraries/index.d.ts +2 -0
  28. package/dist/components/docs/libraries/index.js +616 -64
  29. package/dist/components/docs/specs/SpecsDataViewsPage.js +85 -3
  30. package/dist/components/docs/specs/index.js +96 -14
  31. package/dist/index.js +1206 -287
  32. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  33. package/dist/node/components/docs/docsManifest.js +1 -1
  34. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +117 -6
  35. package/dist/node/components/docs/getting-started/index.js +130 -19
  36. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.js +175 -0
  37. package/dist/node/components/docs/guides/GuideDataExchangeImportTemplatesPage.js +175 -0
  38. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  39. package/dist/node/components/docs/guides/index.js +220 -46
  40. package/dist/node/components/docs/index.js +1195 -276
  41. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +235 -0
  42. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +235 -0
  43. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +130 -6
  44. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +102 -3
  45. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  46. package/dist/node/components/docs/libraries/LibrariesPersonalizationPage.js +58 -4
  47. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.content.js +42 -0
  48. package/dist/node/components/docs/libraries/LibrariesTranslationRuntimePage.js +42 -0
  49. package/dist/node/components/docs/libraries/index.js +616 -64
  50. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +85 -3
  51. package/dist/node/components/docs/specs/index.js +96 -14
  52. package/dist/node/index.js +1206 -287
  53. package/package.json +98 -26
  54. package/src/components/docs/docsManifest.test.ts +87 -0
  55. package/src/components/docs/docsManifest.ts +98 -1
  56. package/src/components/docs/generated/docs-index.notifications.json +7 -7
  57. package/src/components/docs/getting-started/DataViewTutorialPage.tsx +217 -47
  58. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.content.ts +185 -0
  59. package/src/components/docs/guides/GuideDataExchangeImportTemplatesPage.tsx +186 -0
  60. package/src/components/docs/guides/GuidesIndexPage.tsx +49 -42
  61. package/src/components/docs/guides/index.ts +1 -0
  62. package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +283 -0
  63. package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +145 -0
  64. package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +278 -54
  65. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +244 -0
  66. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +13 -1
  67. package/src/components/docs/libraries/LibrariesPersonalizationPage.tsx +141 -31
  68. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.content.ts +78 -0
  69. package/src/components/docs/libraries/LibrariesTranslationRuntimePage.tsx +137 -0
  70. package/src/components/docs/libraries/index.ts +2 -0
  71. package/src/components/docs/specs/SpecsDataViewsPage.tsx +278 -116
@@ -0,0 +1,235 @@
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
+ AppShell,
3
+ type ShellCommandGroup,
4
+ type ShellNavSection,
5
+ type ShellNotificationCenter,
6
+ type PageOutlineItem,
7
+ } from "@contractspec/lib.design-system/shell";
8
+
9
+ const navigation: ShellNavSection[] = [
10
+ {
11
+ title: "Workspace",
12
+ items: [
13
+ { label: "Dashboard", href: "/dashboard" },
14
+ {
15
+ label: "Contracts",
16
+ href: "/contracts",
17
+ children: [
18
+ { label: "Operations", href: "/contracts/operations" },
19
+ { label: "Events", href: "/contracts/events" },
20
+ ],
21
+ },
22
+ ],
23
+ },
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
+
36
+ const outline: PageOutlineItem[] = [
37
+ {
38
+ id: "architecture",
39
+ label: "Architecture",
40
+ level: 1,
41
+ children: [
42
+ { id: "desktop", label: "Desktop shell", level: 2 },
43
+ { id: "mobile", label: "Mobile adaptation", level: 2 },
44
+ ],
45
+ },
46
+ ];
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
+
68
+ export function WorkspacePage() {
69
+ return (
70
+ <AppShell
71
+ title="ContractSpec"
72
+ homeHref="/dashboard"
73
+ navigation={navigation}
74
+ commands={commands}
75
+ breadcrumbs={[
76
+ { label: "Workspace", href: "/dashboard" },
77
+ { label: "Contracts" },
78
+ ]}
79
+ notifications={notifications}
80
+ pageOutline={outline}
81
+ activeHref="/contracts"
82
+ activeOutlineId="desktop"
83
+ userMenu={<UserMenu onSignOut={() => signOut()} />}
84
+ >
85
+ <main>{/* route content */}</main>
86
+ </AppShell>
87
+ );
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.
143
+
144
+ Goal:
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.
146
+
147
+ Use this architecture:
148
+ - Keep route content independent from navigation chrome.
149
+ - Create a typed navigation model with sections, items, active state, optional children, badges, icons, disabled items, and href/onSelect support.
150
+ - Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
151
+ - Create a breadcrumb model for the topbar.
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.
154
+ - Expose the system from the design system or a dedicated shell module, not from a single app route.
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
+
162
+ Desktop behavior:
163
+ - Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
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.
166
+ - Content area with optional right PageOutline.
167
+ - Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
168
+
169
+ Mobile web behavior:
170
+ - Use bottom navigation for the primary destinations.
171
+ - Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.
172
+ - Keep route content first and make the shell controls reachable without covering important content.
173
+
174
+ Native behavior:
175
+ - Add .native.tsx entrypoints for Expo/React 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.
178
+
179
+ Implementation constraints:
180
+ - Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
181
+ - Do not hardcode app-specific routes in the shell component.
182
+ - Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
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.
184
+ - Update docs and exports so developers can import the shell from a stable public API.
185
+
186
+ Deliverables:
187
+ - Typed shell models.
188
+ - Web shell components.
189
+ - Native shell components or adapters.
190
+ - PageOutline component with three-level support.
191
+ - ShellNotifications or equivalent notification center component for web and native shell placement.
192
+ - Usage example.
193
+ - Focused tests and typecheck/build evidence.`,m=`You are refactoring an existing application to use the shared application shell system.
194
+
195
+ Goal:
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.
197
+
198
+ Start by auditing:
199
+ - Current layout wrappers and route groups.
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.
203
+ - Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
204
+ - Any in-page summary/table-of-contents components that should become PageOutline data.
205
+ - Web-only assumptions that would block Expo/React Native adaptation.
206
+
207
+ Refactor plan:
208
+ 1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
209
+ 2. Map existing command/search behavior into grouped command actions with search text and quick actions.
210
+ 3. Map existing route metadata into breadcrumbs.
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.
217
+
218
+ Preserve behavior:
219
+ - Existing route URLs and access rules.
220
+ - Existing keyboard shortcuts where they are public behavior.
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.
223
+ - Existing auth/logout behavior.
224
+ - Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
225
+
226
+ Quality gates:
227
+ - Add regression tests around current visible navigation before removing old shell code when coverage is missing.
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.
229
+ - Run lint, typecheck, and the app's relevant test/build command.
230
+ - Remove dead app-specific shell components only after the shared shell path is verified.
231
+
232
+ Output:
233
+ - List old shell files removed or simplified.
234
+ - List new shared shell integration points.
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};
@@ -0,0 +1,235 @@
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
+ AppShell,
3
+ type ShellCommandGroup,
4
+ type ShellNavSection,
5
+ type ShellNotificationCenter,
6
+ type PageOutlineItem,
7
+ } from "@contractspec/lib.design-system/shell";
8
+
9
+ const navigation: ShellNavSection[] = [
10
+ {
11
+ title: "Workspace",
12
+ items: [
13
+ { label: "Dashboard", href: "/dashboard" },
14
+ {
15
+ label: "Contracts",
16
+ href: "/contracts",
17
+ children: [
18
+ { label: "Operations", href: "/contracts/operations" },
19
+ { label: "Events", href: "/contracts/events" },
20
+ ],
21
+ },
22
+ ],
23
+ },
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
+
36
+ const outline: PageOutlineItem[] = [
37
+ {
38
+ id: "architecture",
39
+ label: "Architecture",
40
+ level: 1,
41
+ children: [
42
+ { id: "desktop", label: "Desktop shell", level: 2 },
43
+ { id: "mobile", label: "Mobile adaptation", level: 2 },
44
+ ],
45
+ },
46
+ ];
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
+
68
+ export function WorkspacePage() {
69
+ return (
70
+ <AppShell
71
+ title="ContractSpec"
72
+ homeHref="/dashboard"
73
+ navigation={navigation}
74
+ commands={commands}
75
+ breadcrumbs={[
76
+ { label: "Workspace", href: "/dashboard" },
77
+ { label: "Contracts" },
78
+ ]}
79
+ notifications={notifications}
80
+ pageOutline={outline}
81
+ activeHref="/contracts"
82
+ activeOutlineId="desktop"
83
+ userMenu={<UserMenu onSignOut={() => signOut()} />}
84
+ >
85
+ <main>{/* route content */}</main>
86
+ </AppShell>
87
+ );
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.
143
+
144
+ Goal:
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.
146
+
147
+ Use this architecture:
148
+ - Keep route content independent from navigation chrome.
149
+ - Create a typed navigation model with sections, items, active state, optional children, badges, icons, disabled items, and href/onSelect support.
150
+ - Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
151
+ - Create a breadcrumb model for the topbar.
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.
154
+ - Expose the system from the design system or a dedicated shell module, not from a single app route.
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
+
162
+ Desktop behavior:
163
+ - Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
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.
166
+ - Content area with optional right PageOutline.
167
+ - Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
168
+
169
+ Mobile web behavior:
170
+ - Use bottom navigation for the primary destinations.
171
+ - Put deeper navigation, command search, notifications, auth actions, and secondary actions behind a menu or drawer when the topbar cannot safely hold them.
172
+ - Keep route content first and make the shell controls reachable without covering important content.
173
+
174
+ Native behavior:
175
+ - Add .native.tsx entrypoints for Expo/React 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.
178
+
179
+ Implementation constraints:
180
+ - Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
181
+ - Do not hardcode app-specific routes in the shell component.
182
+ - Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
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.
184
+ - Update docs and exports so developers can import the shell from a stable public API.
185
+
186
+ Deliverables:
187
+ - Typed shell models.
188
+ - Web shell components.
189
+ - Native shell components or adapters.
190
+ - PageOutline component with three-level support.
191
+ - ShellNotifications or equivalent notification center component for web and native shell placement.
192
+ - Usage example.
193
+ - Focused tests and typecheck/build evidence.`,h=`You are refactoring an existing application to use the shared application shell system.
194
+
195
+ Goal:
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.
197
+
198
+ Start by auditing:
199
+ - Current layout wrappers and route groups.
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.
203
+ - Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
204
+ - Any in-page summary/table-of-contents components that should become PageOutline data.
205
+ - Web-only assumptions that would block Expo/React Native adaptation.
206
+
207
+ Refactor plan:
208
+ 1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
209
+ 2. Map existing command/search behavior into grouped command actions with search text and quick actions.
210
+ 3. Map existing route metadata into breadcrumbs.
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.
217
+
218
+ Preserve behavior:
219
+ - Existing route URLs and access rules.
220
+ - Existing keyboard shortcuts where they are public behavior.
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.
223
+ - Existing auth/logout behavior.
224
+ - Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
225
+
226
+ Quality gates:
227
+ - Add regression tests around current visible navigation before removing old shell code when coverage is missing.
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.
229
+ - Run lint, typecheck, and the app's relevant test/build command.
230
+ - Remove dead app-specific shell components only after the shared shell path is verified.
231
+
232
+ Output:
233
+ - List old shell files removed or simplified.
234
+ - List new shared shell integration points.
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};
@@ -1,4 +1,121 @@
1
- var n=Object.defineProperty;var l=(t)=>t;function d(t,i){this[t]=l.bind(null,i)}var m=(t,i)=>{for(var o in i)n(t,o,{get:i[o],enumerable:!0,configurable:!0,set:d.bind(i,o)})};var g=(t,i)=>()=>(t&&(i=t(t=0)),i);import{CodeBlock as r,InstallCommand as s}from"@contractspec/lib.design-system";import c from"@contractspec/lib.ui-link";import{ChevronRight as p}from"lucide-react";import{jsx as e,jsxs as a}from"react/jsx-runtime";function b(){return a("div",{className:"space-y-8",children:[a("div",{className:"space-y-4",children:[e("h1",{className:"font-bold text-4xl",children:"DataViews Runtime Library"}),a("p",{className:"text-lg text-muted-foreground",children:["The ",e("code",{children:"@contractspec/lib.contracts-spec/data-views"})," and"," ",e("code",{children:"@contractspec/lib.design-system"})," libraries provide the runtime logic and UI components to render DataViews in your application."]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Installation"}),e(s,{package:["@contractspec/lib.contracts-spec","@contractspec/lib.design-system"]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"DataViewRenderer"}),e("p",{className:"text-muted-foreground",children:"The primary component for rendering any DataView. It automatically selects the correct layout (List, Table, Grid, Detail) based on the spec."}),e(r,{language:"tsx",code:`import { DataViewRenderer } from '@contractspec/lib.design-system';
1
+ var Z=Object.defineProperty;var b=(F)=>F;function W(F,K){this[F]=b.bind(null,K)}var O=(F,K)=>{for(var v in K)Z(F,v,{get:K[v],enumerable:!0,configurable:!0,set:W.bind(K,v)})};var B=(F,K)=>()=>(F&&(K=F(F=0)),K);import{CodeBlock as $,InstallCommand as X}from"@contractspec/lib.design-system";import{HStack as g,VStack as Q}from"@contractspec/lib.design-system/layout";import{List as h,ListItem as J}from"@contractspec/lib.design-system/list";import{Code as q,H1 as u,H2 as U,H3 as y,P as Y,Text as z}from"@contractspec/lib.design-system/typography";import G from"@contractspec/lib.ui-link";import{ChevronRight as M}from"lucide-react";import{jsx as f,jsxs as w}from"react/jsx-runtime";var p=`import { defineDataView } from '@contractspec/lib.contracts-spec/data-views';
2
+
3
+ export const AccountsDataView = defineDataView({
4
+ meta: {
5
+ key: 'crm.accounts',
6
+ version: '1.0.0',
7
+ title: 'Accounts',
8
+ description: 'Customer account workspace',
9
+ domain: 'crm',
10
+ entity: 'account',
11
+ owners: ['@crm'],
12
+ tags: ['crm', 'accounts'],
13
+ stability: 'stable',
14
+ },
15
+ source: {
16
+ primary: { key: 'crm.accounts.list', version: '1.0.0' },
17
+ },
18
+ view: {
19
+ kind: 'table',
20
+ fields: [
21
+ { key: 'name', label: 'Name', dataPath: 'name', sortable: true },
22
+ { key: 'owner', label: 'Owner', dataPath: 'owner' },
23
+ { key: 'arr', label: 'ARR', dataPath: 'arr', format: { type: 'currency', currency: 'EUR' } },
24
+ {
25
+ key: 'internalNotes',
26
+ label: 'Internal notes',
27
+ dataPath: 'internalNotes',
28
+ visibility: { minDataDepth: 'detailed' },
29
+ },
30
+ ],
31
+ columns: [
32
+ { field: 'name' },
33
+ { field: 'owner' },
34
+ { field: 'arr' },
35
+ { field: 'internalNotes' },
36
+ ],
37
+ collection: {
38
+ viewModes: {
39
+ defaultMode: 'table',
40
+ allowedModes: ['list', 'grid', 'table'],
41
+ },
42
+ pagination: {
43
+ pageSize: 25,
44
+ pageSizeOptions: [10, 25, 50],
45
+ },
46
+ toolbar: {
47
+ search: true,
48
+ viewMode: true,
49
+ filters: true,
50
+ density: true,
51
+ dataDepth: true,
52
+ },
53
+ density: 'comfortable',
54
+ dataDepth: 'standard',
55
+ personalization: {
56
+ enabled: true,
57
+ persist: {
58
+ viewMode: true,
59
+ density: true,
60
+ dataDepth: true,
61
+ pageSize: true,
62
+ },
63
+ },
64
+ },
65
+ },
66
+ });`,D=`import { DataViewRenderer } from '@contractspec/lib.design-system';
67
+ import { resolveDataViewPreferences } from '@contractspec/lib.personalization/data-view-preferences';
68
+
69
+ const resolved = resolveDataViewPreferences({
70
+ spec: AccountsDataView,
71
+ preferences: profile.canonical,
72
+ insights,
73
+ record: savedDataViewPreference,
74
+ });
75
+
76
+ <DataViewRenderer
77
+ spec={AccountsDataView}
78
+ items={accounts}
79
+ defaultViewMode={resolved.viewMode}
80
+ defaultDensity={resolved.density}
81
+ defaultDataDepth={resolved.dataDepth}
82
+ pagination={{
83
+ page,
84
+ pageSize: resolved.pageSize ?? 25,
85
+ total,
86
+ }}
87
+ onViewModeChange={(viewMode) => {
88
+ tracker.trackDataViewInteraction({
89
+ dataViewKey: AccountsDataView.meta.key,
90
+ dataViewVersion: AccountsDataView.meta.version,
91
+ action: 'view_mode_changed',
92
+ viewMode,
93
+ });
94
+ }}
95
+ onDensityChange={(density) => {
96
+ tracker.trackDataViewInteraction({
97
+ dataViewKey: AccountsDataView.meta.key,
98
+ action: 'density_changed',
99
+ density,
100
+ });
101
+ }}
102
+ onDataDepthChange={(dataDepth) => {
103
+ tracker.trackDataViewInteraction({
104
+ dataViewKey: AccountsDataView.meta.key,
105
+ action: 'data_depth_changed',
106
+ dataDepth,
107
+ });
108
+ }}
109
+ />;
110
+ `,N=`Implement a production DataView for <entity>.
111
+
112
+ Requirements:
113
+ - Define one canonical DataViewSpec with kind 'table', collection viewModes for list/grid/table, pagination defaults, toolbar search/filter/view mode/density/dataDepth controls, and personalization persist hints.
114
+ - Mark fields that should only appear in richer experiences with visibility.minDataDepth.
115
+ - Render it with DataViewRenderer using plain props from resolveDataViewPreferences.
116
+ - Track user interactions with trackDataViewInteraction for view mode, density, data depth, search, filters, sorting, and pagination.
117
+ - Keep @contractspec/lib.design-system independent from @contractspec/lib.personalization.
118
+ - Add focused tests for default resolution, invalid-mode fallback, data-depth projection, and behavior-derived preferred view mode.`;function l(){return w(Q,{className:"space-y-8",children:[w(Q,{className:"space-y-4",children:[f(u,{className:"font-bold text-4xl",children:"DataViews Runtime Library"}),w(Y,{className:"text-lg text-muted-foreground",children:["The ",f(q,{children:"@contractspec/lib.contracts-spec/data-views"})," and"," ",f(q,{children:"@contractspec/lib.design-system"})," libraries provide the runtime logic and UI components to render DataViews in your application."]})]}),w(Q,{className:"space-y-4",children:[f(U,{className:"font-bold text-2xl",children:"Installation"}),f(X,{package:["@contractspec/lib.contracts-spec","@contractspec/lib.design-system"]})]}),w(Q,{className:"space-y-4",children:[f(U,{className:"font-bold text-2xl",children:"DataViewRenderer"}),f(Y,{className:"text-muted-foreground",children:"The primary component for rendering any DataView. It automatically selects the correct layout (List, Table, Grid, Detail) based on the spec."}),f($,{language:"tsx",code:`import { DataViewRenderer } from '@contractspec/lib.design-system';
2
119
  import { MyUserList } from './specs/users.data-view';
3
120
 
4
121
  export function UserPage() {
@@ -10,12 +127,19 @@ export function UserPage() {
10
127
  onPageChange={(page) => fetchPage(page)}
11
128
  />
12
129
  );
13
- }`}),e("h3",{className:"font-semibold text-xl",children:"Props"}),a("ul",{className:"list-disc space-y-2 pl-6 text-muted-foreground",children:[a("li",{children:[e("code",{children:"spec"}),": The DataViewSpec definition."]}),a("li",{children:[e("code",{children:"items"}),": Array of data items to render."]}),a("li",{children:[e("code",{children:"filters"}),": Current filter state object."]}),a("li",{children:[e("code",{children:"onFilterChange"}),": Callback when filters change."]}),a("li",{children:[e("code",{children:"pagination"}),": Object with ",e("code",{children:"page"}),","," ",e("code",{children:"pageSize"}),", ",e("code",{children:"total"}),"."]}),a("li",{children:[e("code",{children:"onPageChange"}),": Callback when page changes."]})]})]}),a("div",{className:"space-y-4",children:[e("h2",{className:"font-bold text-2xl",children:"Query Generation"}),a("p",{className:"text-muted-foreground",children:["The ",e("code",{children:"DataViewQueryGenerator"})," utility helps translate DataView parameters (filters, sorting, pagination) into query arguments for your backend."]}),e(r,{language:"typescript",code:`import { DataViewQueryGenerator } from '@contractspec/lib.contracts-spec/data-views/query-generator';
130
+ }`}),f(y,{className:"font-semibold text-xl",children:"Props"}),w(h,{className:"list-disc space-y-2 pl-6 text-muted-foreground",children:[f(J,{children:w(z,{children:[f(q,{children:"spec"}),": The DataViewSpec definition."]})}),f(J,{children:w(z,{children:[f(q,{children:"items"}),": Array of data items to render."]})}),f(J,{children:w(z,{children:[f(q,{children:"filters"}),": Current filter state object."]})}),f(J,{children:w(z,{children:[f(q,{children:"onFilterChange"}),": Callback when typed filters change. Renderers emit ",f(q,{children:"DataViewFilterValue"})," objects for numeric, percent, currency, temporal, duration, and boolean filters."]})}),f(J,{children:w(z,{children:[f(q,{children:"pagination"}),": Object with ",f(q,{children:"page"}),","," ",f(q,{children:"pageSize"}),", ",f(q,{children:"total"}),"."]})}),f(J,{children:w(z,{children:[f(q,{children:"onPageChange"}),": Callback when page changes."]})}),f(J,{children:w(z,{children:[f(q,{children:"viewMode"})," / ",f(q,{children:"defaultViewMode"}),": Controlled or initial collection mode for specs that allow ",f(q,{children:"list"}),","," ",f(q,{children:"grid"}),", or ",f(q,{children:"table"})," projections through"," ",f(q,{children:"view.collection.viewModes"}),"."]})}),f(J,{children:w(z,{children:[f(q,{children:"density"})," / ",f(q,{children:"defaultDensity"}),": Controlled or initial density for collection renderers. Host apps can seed this from ",f(q,{children:"@contractspec/lib.personalization"})," while specs can declare ",f(q,{children:"view.collection.density"})," and table"," ",f(q,{children:"view.density"})," defaults."]})}),f(J,{children:w(z,{children:[f(q,{children:"dataDepth"})," / ",f(q,{children:"defaultDataDepth"}),": Controlled or initial summary/standard/detailed/exhaustive projection. Fields can declare ",f(q,{children:"visibility.minDataDepth"}),", and collection specs can opt into ",f(q,{children:"view.collection.personalization"})," ","persistence hints."]})})]})]}),w(Q,{className:"space-y-4",children:[f(U,{className:"font-bold text-2xl",children:"Collection Defaults And Data Depth"}),w(Y,{className:"text-muted-foreground",children:["Use one authored ",f(q,{children:"DataViewSpec"})," for list, grid, and table experiences. ",f(q,{children:"view.collection"})," declares allowed modes, toolbar controls, pagination defaults, density, data depth, and persistence hints. ",f(q,{children:"visibility.minDataDepth"})," lets a field appear only when the renderer is in a detailed or exhaustive mode."]}),f($,{language:"typescript",code:p})]}),w(Q,{className:"space-y-4",children:[f(U,{className:"font-bold text-2xl",children:"Personalization Bridge"}),w(Y,{className:"text-muted-foreground",children:["Resolve user preferences in the host app, then pass ordinary renderer props into ",f(q,{children:"DataViewRenderer"}),". The bridge helper lives in"," ",f(q,{children:"@contractspec/lib.personalization"}),", so the design-system renderer stays portable for apps that do not use personalization. See the"," ",f(G,{href:"/docs/libraries/personalization",className:"text-[color:var(--rust)] underline underline-offset-4",children:f(z,{children:"personalization library guide"})})," ","for the behavior tracker, analyzer, and DataView preference resolver."]}),f($,{language:"tsx",code:D})]}),w(Q,{className:"space-y-4",children:[f(U,{className:"font-bold text-2xl",children:"Agent Prompt"}),f(Y,{className:"text-muted-foreground",children:"Use this prompt when asking an implementation agent to add a preference-aware collection DataView without breaking package boundaries."}),f($,{language:"markdown",code:N})]}),w(Q,{className:"space-y-4",children:[f(U,{className:"font-bold text-2xl",children:"Query Generation"}),w(Y,{className:"text-muted-foreground",children:["The ",f(q,{children:"DataViewQueryGenerator"})," utility helps translate DataView parameters (filters, sorting, pagination) into query arguments for your backend."]}),f($,{language:"typescript",code:`import { DataViewQueryGenerator } from '@contractspec/lib.contracts-spec/data-views/query-generator';
14
131
 
15
132
  const generator = new DataViewQueryGenerator(MyUserList);
16
- const query = generator.generate({
133
+ const params = {
17
134
  pagination: { page: 1, pageSize: 20 },
18
- filters: { role: 'admin' }
19
- });
135
+ filters: {
136
+ role: { kind: 'single', value: 'admin' },
137
+ revenue: { kind: 'range', from: 1000, to: 5000 },
138
+ lastSeenAt: { kind: 'single', value: '2026-04-28T08:30:00Z' }
139
+ }
140
+ };
141
+
142
+ const errors = generator.validateParams(params);
143
+ const query = generator.generate(params);
20
144
 
21
- // query.input contains { skip: 0, take: 20, role: 'admin' }`})]}),a("div",{className:"flex items-center gap-4 pt-4",children:[e(c,{href:"/docs/libraries",className:"btn-ghost",children:"Back to Libraries"}),a(c,{href:"/docs/libraries/data-backend",className:"btn-primary",children:["Next: Data & Backend ",e(p,{size:16})]})]})]})}export{b as LibrariesDataViewsPage};
145
+ // query.input contains skip/take plus the typed filter payloads.`})]}),w(g,{className:"items-center gap-4 pt-4",children:[f(G,{href:"/docs/libraries",className:"btn-ghost",children:f(z,{children:"Back to Libraries"})}),w(G,{href:"/docs/libraries/data-backend",className:"btn-primary",children:[f(z,{children:"Next: Data & Backend"})," ",f(M,{size:16})]})]})]})}export{l as LibrariesDataViewsPage};