@contractspec/bundle.library 3.9.6 → 3.9.8

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 (153) hide show
  1. package/.turbo/turbo-build.log +238 -230
  2. package/CHANGELOG.md +88 -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 +40 -4
  6. package/dist/components/docs/getting-started/index.js +46 -10
  7. package/dist/components/docs/guides/GuideContractDrivenFormsPage.content.d.ts +3 -0
  8. package/dist/components/docs/guides/GuideContractDrivenFormsPage.content.js +95 -0
  9. package/dist/components/docs/guides/GuideContractDrivenFormsPage.d.ts +1 -0
  10. package/dist/components/docs/guides/GuideContractDrivenFormsPage.js +95 -0
  11. package/dist/components/docs/guides/GuideSpecValidationTypingPage.js +1 -1
  12. package/dist/components/docs/guides/GuidesIndexPage.js +2 -2
  13. package/dist/components/docs/guides/guides.docblocks.js +3 -1
  14. package/dist/components/docs/guides/index.d.ts +1 -0
  15. package/dist/components/docs/guides/index.js +139 -44
  16. package/dist/components/docs/index.js +586 -266
  17. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.d.ts +16 -0
  18. package/dist/components/docs/libraries/LibrariesApplicationShellPage.content.js +148 -0
  19. package/dist/components/docs/libraries/LibrariesApplicationShellPage.d.ts +1 -0
  20. package/dist/components/docs/libraries/LibrariesApplicationShellPage.js +148 -0
  21. package/dist/components/docs/libraries/LibrariesDataViewsPage.js +13 -6
  22. package/dist/components/docs/libraries/LibrariesDesignSystemPage.js +3 -3
  23. package/dist/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  24. package/dist/components/docs/libraries/index.d.ts +1 -0
  25. package/dist/components/docs/libraries/index.js +217 -64
  26. package/dist/components/docs/specs/SpecsDataViewsPage.js +37 -1
  27. package/dist/components/docs/specs/index.js +37 -1
  28. package/dist/index.js +597 -277
  29. package/dist/libs/posthog/client.js +1 -1
  30. package/dist/node/components/docs/DocsIndexPage.js +2 -2
  31. package/dist/node/components/docs/docsManifest.js +1 -1
  32. package/dist/node/components/docs/getting-started/DataViewTutorialPage.js +40 -4
  33. package/dist/node/components/docs/getting-started/index.js +46 -10
  34. package/dist/node/components/docs/guides/GuideContractDrivenFormsPage.content.js +94 -0
  35. package/dist/node/components/docs/guides/GuideContractDrivenFormsPage.js +94 -0
  36. package/dist/node/components/docs/guides/GuideSpecValidationTypingPage.js +1 -1
  37. package/dist/node/components/docs/guides/GuidesIndexPage.js +2 -2
  38. package/dist/node/components/docs/guides/guides.docblocks.js +3 -1
  39. package/dist/node/components/docs/guides/index.js +139 -44
  40. package/dist/node/components/docs/index.js +586 -266
  41. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.content.js +147 -0
  42. package/dist/node/components/docs/libraries/LibrariesApplicationShellPage.js +147 -0
  43. package/dist/node/components/docs/libraries/LibrariesDataViewsPage.js +13 -6
  44. package/dist/node/components/docs/libraries/LibrariesDesignSystemPage.js +3 -3
  45. package/dist/node/components/docs/libraries/LibrariesOverviewPage.js +1 -1
  46. package/dist/node/components/docs/libraries/index.js +217 -64
  47. package/dist/node/components/docs/specs/SpecsDataViewsPage.js +37 -1
  48. package/dist/node/components/docs/specs/index.js +37 -1
  49. package/dist/node/index.js +597 -277
  50. package/dist/node/libs/posthog/client.js +1 -1
  51. package/package.json +71 -23
  52. package/src/components/docs/docsManifest.ts +22 -0
  53. package/src/components/docs/generated/docs-index._common.json +2008 -1699
  54. package/src/components/docs/generated/docs-index.agent-console.json +377 -377
  55. package/src/components/docs/generated/docs-index.ai-chat-assistant.json +17 -17
  56. package/src/components/docs/generated/docs-index.ai-chat.json +105 -105
  57. package/src/components/docs/generated/docs-index.ai-support-bot.json +9 -9
  58. package/src/components/docs/generated/docs-index.analytics-dashboard.json +169 -169
  59. package/src/components/docs/generated/docs-index.app-config.json +137 -137
  60. package/src/components/docs/generated/docs-index.artisan-knowledge-product.json +17 -17
  61. package/src/components/docs/generated/docs-index.artisan-payments-stripe.json +33 -33
  62. package/src/components/docs/generated/docs-index.audit-trail.json +49 -49
  63. package/src/components/docs/generated/docs-index.calendar-google.json +9 -9
  64. package/src/components/docs/generated/docs-index.content-generation.json +9 -9
  65. package/src/components/docs/generated/docs-index.control-plane.json +17 -17
  66. package/src/components/docs/generated/docs-index.crm-pipeline.json +161 -161
  67. package/src/components/docs/generated/docs-index.data-grid-showcase.json +25 -25
  68. package/src/components/docs/generated/docs-index.defineExample.json +9 -9
  69. package/src/components/docs/generated/docs-index.email-gmail.json +9 -9
  70. package/src/components/docs/generated/docs-index.feature-flags.json +217 -217
  71. package/src/components/docs/generated/docs-index.files.json +177 -177
  72. package/src/components/docs/generated/docs-index.generated.ts +20 -20
  73. package/src/components/docs/generated/docs-index.harness-lab.json +9 -9
  74. package/src/components/docs/generated/docs-index.health.json +97 -97
  75. package/src/components/docs/generated/docs-index.identity-rbac.json +313 -313
  76. package/src/components/docs/generated/docs-index.in-app-docs.json +9 -9
  77. package/src/components/docs/generated/docs-index.integration-hub.json +265 -265
  78. package/src/components/docs/generated/docs-index.integration-posthog.json +9 -9
  79. package/src/components/docs/generated/docs-index.integration-stripe.json +9 -9
  80. package/src/components/docs/generated/docs-index.integration-supabase.json +9 -9
  81. package/src/components/docs/generated/docs-index.jobs.json +137 -137
  82. package/src/components/docs/generated/docs-index.kb-update-pipeline.json +129 -129
  83. package/src/components/docs/generated/docs-index.knowledge-canon.json +9 -9
  84. package/src/components/docs/generated/docs-index.learning-journey-ambient-coach.json +9 -9
  85. package/src/components/docs/generated/docs-index.learning-journey-crm-onboarding.json +49 -49
  86. package/src/components/docs/generated/docs-index.learning-journey-duo-drills.json +9 -9
  87. package/src/components/docs/generated/docs-index.learning-journey-platform-tour.json +49 -49
  88. package/src/components/docs/generated/docs-index.learning-journey-quest-challenges.json +9 -9
  89. package/src/components/docs/generated/docs-index.learning-journey-registry.json +33 -33
  90. package/src/components/docs/generated/docs-index.learning-journey-studio-onboarding.json +49 -49
  91. package/src/components/docs/generated/docs-index.learning-journey-ui-coaching.json +9 -9
  92. package/src/components/docs/generated/docs-index.learning-journey-ui-gamified.json +9 -9
  93. package/src/components/docs/generated/docs-index.learning-journey-ui-onboarding.json +9 -9
  94. package/src/components/docs/generated/docs-index.learning-journey-ui-shared.json +9 -9
  95. package/src/components/docs/generated/docs-index.learning-journey.json +241 -241
  96. package/src/components/docs/generated/docs-index.learning-patterns.json +9 -9
  97. package/src/components/docs/generated/docs-index.lifecycle-cli.json +9 -9
  98. package/src/components/docs/generated/docs-index.lifecycle-dashboard.json +9 -9
  99. package/src/components/docs/generated/docs-index.locale-jurisdiction-gate.json +65 -65
  100. package/src/components/docs/generated/docs-index.marketplace.json +337 -337
  101. package/src/components/docs/generated/docs-index.meeting-recorder-providers.json +9 -9
  102. package/src/components/docs/generated/docs-index.meeting-recorder.json +49 -49
  103. package/src/components/docs/generated/docs-index.messaging-agent-actions.json +17 -17
  104. package/src/components/docs/generated/docs-index.metrics.json +201 -201
  105. package/src/components/docs/generated/docs-index.minimal.json +17 -17
  106. package/src/components/docs/generated/docs-index.mobile-demo-landing.json +41 -41
  107. package/src/components/docs/generated/docs-index.notifications.json +65 -65
  108. package/src/components/docs/generated/docs-index.openbanking-powens.json +9 -9
  109. package/src/components/docs/generated/docs-index.openbanking.json +65 -65
  110. package/src/components/docs/generated/docs-index.opencode-cli.json +17 -17
  111. package/src/components/docs/generated/docs-index.personalization.json +9 -9
  112. package/src/components/docs/generated/docs-index.platform-acp.json +137 -137
  113. package/src/components/docs/generated/docs-index.platform-agent.json +201 -201
  114. package/src/components/docs/generated/docs-index.platform-context.json +121 -121
  115. package/src/components/docs/generated/docs-index.platform-control-plane.json +321 -321
  116. package/src/components/docs/generated/docs-index.platform-database.json +89 -89
  117. package/src/components/docs/generated/docs-index.platform-docs.json +161 -161
  118. package/src/components/docs/generated/docs-index.platform-harness.json +177 -177
  119. package/src/components/docs/generated/docs-index.platform-integrations.json +329 -329
  120. package/src/components/docs/generated/docs-index.platform-knowledge.json +57 -57
  121. package/src/components/docs/generated/docs-index.platform-provider-ranking.json +217 -217
  122. package/src/components/docs/generated/docs-index.pocket-family-office.json +129 -129
  123. package/src/components/docs/generated/docs-index.policy-safe-knowledge-assistant.json +9 -9
  124. package/src/components/docs/generated/docs-index.product-intent.json +9 -9
  125. package/src/components/docs/generated/docs-index.project-management-sync.json +9 -9
  126. package/src/components/docs/generated/docs-index.saas-boilerplate.json +209 -209
  127. package/src/components/docs/generated/docs-index.service-business-os.json +193 -193
  128. package/src/components/docs/generated/docs-index.team-hub.json +185 -185
  129. package/src/components/docs/generated/docs-index.unknown.json +521 -521
  130. package/src/components/docs/generated/docs-index.versioned-knowledge-base.json +81 -81
  131. package/src/components/docs/generated/docs-index.video-api-showcase.json +33 -33
  132. package/src/components/docs/generated/docs-index.video-docs-terminal.json +9 -9
  133. package/src/components/docs/generated/docs-index.video-marketing-clip.json +9 -9
  134. package/src/components/docs/generated/docs-index.visualization-showcase.json +17 -17
  135. package/src/components/docs/generated/docs-index.voice-providers.json +9 -9
  136. package/src/components/docs/generated/docs-index.wealth-snapshot.json +153 -153
  137. package/src/components/docs/generated/docs-index.workflow-system.json +433 -433
  138. package/src/components/docs/generated/docs-index.workspace-cli.json +9 -9
  139. package/src/components/docs/getting-started/DataViewTutorialPage.tsx +40 -1
  140. package/src/components/docs/guides/GuideContractDrivenFormsPage.content.ts +98 -0
  141. package/src/components/docs/guides/GuideContractDrivenFormsPage.tsx +143 -0
  142. package/src/components/docs/guides/GuideSpecValidationTypingPage.tsx +2 -2
  143. package/src/components/docs/guides/GuidesIndexPage.tsx +7 -0
  144. package/src/components/docs/guides/guides.docblocks.ts +12 -0
  145. package/src/components/docs/guides/index.ts +1 -0
  146. package/src/components/docs/libraries/LibrariesApplicationShellPage.content.ts +170 -0
  147. package/src/components/docs/libraries/LibrariesApplicationShellPage.tsx +112 -0
  148. package/src/components/docs/libraries/LibrariesDataViewsPage.tsx +26 -5
  149. package/src/components/docs/libraries/LibrariesDesignSystemPage.tsx +9 -0
  150. package/src/components/docs/libraries/LibrariesOverviewPage.tsx +6 -0
  151. package/src/components/docs/libraries/index.ts +1 -0
  152. package/src/components/docs/specs/SpecsDataViewsPage.tsx +39 -3
  153. package/src/libs/posthog/client.ts +11 -9
@@ -1,10 +1,10 @@
1
1
  [
2
- {
3
- "id": "workspace-cli/workspace-cli",
4
- "title": "workspace-cli",
5
- "summary": "Core CLI operations for managing ContractSpec workspaces\n- **Type**: feature\n- **Version**: 1.0.0\n- **Stability**: stable\n- **Owners**: @lssm/core\n- **Tags**: cli, core\n- **File**: `packages/bundles/workspace/src/contracts/features/cli.feature.ts`",
6
- "route": "/docs/reference/workspace-cli/workspace-cli",
7
- "source": "generated",
8
- "contentPath": "workspace-cli/workspace-cli.md"
9
- }
10
- ]
2
+ {
3
+ "id": "workspace-cli/workspace-cli",
4
+ "title": "workspace-cli",
5
+ "summary": "Core CLI operations for managing ContractSpec workspaces\n- **Type**: feature\n- **Version**: 1.0.0\n- **Stability**: stable\n- **Owners**: @lssm/core\n- **Tags**: cli, core\n- **File**: `packages/bundles/workspace/src/contracts/features/cli.feature.ts`",
6
+ "route": "/docs/reference/workspace-cli/workspace-cli",
7
+ "source": "generated",
8
+ "contentPath": "workspace-cli/workspace-cli.md"
9
+ }
10
+ ]
@@ -45,8 +45,44 @@ export const TransactionHistory = defineDataView({
45
45
  { key: 'account', label: 'Account', dataPath: 'account', sortable: true },
46
46
  { key: 'owner', label: 'Owner', dataPath: 'owner', sortable: true },
47
47
  { key: 'status', label: 'Status', dataPath: 'status', sortable: true },
48
+ {
49
+ key: 'amount',
50
+ label: 'Amount',
51
+ dataPath: 'amount',
52
+ sortable: true,
53
+ format: { type: 'currency', currency: 'EUR', rounded: true },
54
+ },
55
+ {
56
+ key: 'renewalDate',
57
+ label: 'Renewal',
58
+ dataPath: 'renewalDate',
59
+ format: { type: 'date', dateStyle: 'medium' },
60
+ },
61
+ {
62
+ key: 'processingTime',
63
+ label: 'Processing time',
64
+ dataPath: 'processingMinutes',
65
+ format: { type: 'duration', unit: 'minute', display: 'digital' },
66
+ },
48
67
  { key: 'notes', label: 'Notes', dataPath: 'notes' },
49
68
  ],
69
+ filters: [
70
+ { key: 'status', label: 'Status', field: 'status', type: 'enum' },
71
+ {
72
+ key: 'amount',
73
+ label: 'Amount',
74
+ field: 'amount',
75
+ type: 'currency',
76
+ valueMode: 'range',
77
+ },
78
+ {
79
+ key: 'renewalDate',
80
+ label: 'Renewal',
81
+ field: 'renewalDate',
82
+ type: 'date',
83
+ valueMode: 'range',
84
+ },
85
+ ],
50
86
  },
51
87
  });`;
52
88
 
@@ -154,7 +190,10 @@ export function TransactionsPage() {
154
190
  Column visibility, pinning, resizing, and row expansion stay
155
191
  contract-driven
156
192
  </li>
157
- <li>Format rules (currency, dates, badges) applied consistently</li>
193
+ <li>
194
+ Typed format rules for numbers, percent values, currency, dates,
195
+ times, datetimes, and durations applied consistently
196
+ </li>
158
197
  <li>Export to CSV/PDF using the same spec</li>
159
198
  <li>A/B test different layouts without touching the backend</li>
160
199
  </ul>
@@ -0,0 +1,98 @@
1
+ export const leadCaptureFormCode = `import {
2
+ defineFormSpec,
3
+ FormRegistry,
4
+ responsiveFormColumns,
5
+ } from "@contractspec/lib.contracts-spec/forms";
6
+ import { fromZod } from "@contractspec/lib.schema";
7
+ import { z } from "zod";
8
+
9
+ const LeadCaptureModel = fromZod(
10
+ z.object({
11
+ fullName: z.string().min(1),
12
+ email: z.string().email(),
13
+ company: z.string().min(1),
14
+ intent: z.enum(["demo", "pricing", "pilot"]),
15
+ notes: z.string().max(1000).optional(),
16
+ newsletter: z.boolean().optional(),
17
+ }),
18
+ { name: "LeadCaptureModel" },
19
+ );
20
+
21
+ export const LeadCaptureForm = defineFormSpec({
22
+ meta: {
23
+ key: "marketing.lead.form",
24
+ version: "1.0.0",
25
+ title: "Lead capture form",
26
+ description: "Collect qualified OSS and Studio leads.",
27
+ domain: "marketing",
28
+ owners: ["@growth"],
29
+ tags: ["forms", "leads"],
30
+ stability: "experimental",
31
+ },
32
+ model: LeadCaptureModel,
33
+ layout: {
34
+ columns: responsiveFormColumns(2),
35
+ gap: "md",
36
+ flow: {
37
+ kind: "sections",
38
+ sections: [
39
+ { key: "identity", titleI18n: "Who you are", fieldNames: ["fullName", "email", "company"] },
40
+ { key: "request", titleI18n: "What you need", fieldNames: ["intent", "notes", "newsletter"] },
41
+ ],
42
+ },
43
+ },
44
+ fields: [
45
+ { kind: "text", name: "fullName", labelI18n: "Full name", required: true, autoComplete: "name" },
46
+ { kind: "email", name: "email", labelI18n: "Work email", required: true, autoComplete: "email" },
47
+ { kind: "text", name: "company", labelI18n: "Company", required: true, autoComplete: "organization" },
48
+ {
49
+ kind: "select",
50
+ name: "intent",
51
+ labelI18n: "Primary goal",
52
+ required: true,
53
+ options: [
54
+ { labelI18n: "Book a demo", value: "demo" },
55
+ { labelI18n: "Understand pricing", value: "pricing" },
56
+ { labelI18n: "Plan a pilot", value: "pilot" },
57
+ ],
58
+ },
59
+ { kind: "textarea", name: "notes", labelI18n: "Context", rows: 4, layout: { colSpan: "full" } },
60
+ { kind: "checkbox", name: "newsletter", labelI18n: "Send product updates" },
61
+ ],
62
+ actions: [{ key: "submit", labelI18n: "Send request", op: { name: "lead.create", version: "1.0.0" } }],
63
+ policy: { flags: ["lead-capture"], pii: ["fullName", "email", "company", "notes"] },
64
+ renderHints: { ui: "shadcn", form: "react-hook-form" },
65
+ });
66
+
67
+ export const formRegistry = new FormRegistry().register(LeadCaptureForm);`;
68
+
69
+ export const leadCapturePanelCode = `"use client";
70
+
71
+ import { formRenderer } from "@contractspec/lib.design-system/renderers/form-contract";
72
+ import { LeadCaptureForm } from "../contracts/forms/lead-capture.form";
73
+
74
+ export function LeadCapturePanel() {
75
+ return formRenderer.render(LeadCaptureForm, {
76
+ defaultValues: { newsletter: true },
77
+ overrides: {
78
+ onSubmitOverride: async (values, actionKey) => {
79
+ await fetch("/api/leads", {
80
+ method: "POST",
81
+ headers: { "content-type": "application/json" },
82
+ body: JSON.stringify({ actionKey, values }),
83
+ });
84
+ },
85
+ },
86
+ });
87
+ }`;
88
+
89
+ export const formShowcaseTemplateCode = `bun add @contractspec/example.form-showcase
90
+
91
+ # Full form-only example docs
92
+ open https://www.contractspec.io/docs/examples/form-showcase
93
+
94
+ # Template catalog filtered to forms
95
+ open https://www.contractspec.io/templates?tag=forms
96
+
97
+ # Sandbox spec preview
98
+ open https://www.contractspec.io/sandbox?template=form-showcase`;
@@ -0,0 +1,143 @@
1
+ import { CodeBlock } from '@contractspec/lib.design-system';
2
+ import { HStack, VStack } from '@contractspec/lib.design-system/layout';
3
+ import { List, ListItem } from '@contractspec/lib.design-system/list';
4
+ import {
5
+ Code,
6
+ H1,
7
+ H2,
8
+ H3,
9
+ P,
10
+ Text,
11
+ } from '@contractspec/lib.design-system/typography';
12
+ import Link from '@contractspec/lib.ui-link';
13
+ import { ChevronRight } from 'lucide-react';
14
+ import { StudioPrompt } from '../shared/StudioPrompt';
15
+ import {
16
+ formShowcaseTemplateCode,
17
+ leadCaptureFormCode,
18
+ leadCapturePanelCode,
19
+ } from './GuideContractDrivenFormsPage.content';
20
+
21
+ export function GuideContractDrivenFormsPage() {
22
+ return (
23
+ <VStack className="space-y-8">
24
+ <VStack className="space-y-3">
25
+ <H1 className="font-bold text-4xl">Build a contract-driven form</H1>
26
+ <P className="text-lg text-muted-foreground">
27
+ Define form data, fields, layout, policy, and submit behavior once,
28
+ then let your app render from the same ContractSpec surface.
29
+ </P>
30
+ </VStack>
31
+
32
+ <VStack className="card-subtle space-y-4 p-6">
33
+ <H2 className="font-bold text-2xl">What you'll build</H2>
34
+ <List className="space-y-2 text-muted-foreground text-sm">
35
+ <ListItem>
36
+ <Text>A schema-backed FormSpec for a lead capture form.</Text>
37
+ </ListItem>
38
+ <ListItem>
39
+ <Text>
40
+ A FormRegistry that exposes the latest version by stable key.
41
+ </Text>
42
+ </ListItem>
43
+ <ListItem>
44
+ <Text>
45
+ A React renderer that keeps UI, validation, and policy aligned.
46
+ </Text>
47
+ </ListItem>
48
+ </List>
49
+ </VStack>
50
+
51
+ <VStack className="space-y-6">
52
+ <VStack className="space-y-3">
53
+ <H2 className="font-bold text-2xl">1) Define the form spec</H2>
54
+ <P className="text-muted-foreground text-sm">
55
+ Create <Code>src/contracts/forms/lead-capture.form.ts</Code>:
56
+ </P>
57
+ <CodeBlock
58
+ language="typescript"
59
+ filename="src/contracts/forms/lead-capture.form.ts"
60
+ code={leadCaptureFormCode}
61
+ />
62
+ </VStack>
63
+
64
+ <VStack className="card-subtle space-y-3 p-6">
65
+ <H3 className="font-semibold text-lg">Need every form field?</H3>
66
+ <P className="text-muted-foreground text-sm">
67
+ Start from the{' '}
68
+ <Link href="/docs/examples/form-showcase">
69
+ Form Showcase example
70
+ </Link>{' '}
71
+ or the{' '}
72
+ <Link href="/templates?tag=forms">form template catalog</Link>. It
73
+ is focused only on forms and covers field kinds, section layouts,
74
+ step layouts, arrays, groups, conditionals, and validation hints.
75
+ </P>
76
+ <CodeBlock
77
+ language="bash"
78
+ filename="form-showcase-template"
79
+ code={formShowcaseTemplateCode}
80
+ />
81
+ </VStack>
82
+
83
+ <VStack className="space-y-3">
84
+ <H2 className="font-bold text-2xl">2) Render from the contract</H2>
85
+ <P className="text-muted-foreground text-sm">
86
+ Use the shared renderer, or provide your own driver if your app uses
87
+ a different component library.
88
+ </P>
89
+ <CodeBlock
90
+ language="tsx"
91
+ filename="src/components/LeadCapturePanel.tsx"
92
+ code={leadCapturePanelCode}
93
+ />
94
+ </VStack>
95
+
96
+ <VStack className="space-y-3">
97
+ <H2 className="font-bold text-2xl">3) Validate and evolve</H2>
98
+ <CodeBlock
99
+ language="bash"
100
+ filename="validate-form"
101
+ code={`contractspec validate src/contracts/forms/lead-capture.form.ts`}
102
+ />
103
+ <P className="text-muted-foreground text-sm">
104
+ Expected output: <Code>Validation passed</Code>. When the form
105
+ becomes public contract surface, version changes deliberately
106
+ instead of editing field meaning in place.
107
+ </P>
108
+ </VStack>
109
+
110
+ <VStack className="card-subtle space-y-3 p-6">
111
+ <H3 className="font-semibold text-lg">Repo tutorial</H3>
112
+ <P className="text-muted-foreground text-sm">
113
+ The repository guide adds the longer implementation checklist,
114
+ custom renderer notes, and rollout rules.
115
+ </P>
116
+ <CodeBlock
117
+ language="bash"
118
+ filename="repo-guide"
119
+ code={`open docs/tutorials/contract-driven-forms.md`}
120
+ />
121
+ </VStack>
122
+
123
+ <StudioPrompt
124
+ title="Need governed form changes?"
125
+ body="Studio can connect form edits to customer evidence, approval packets, and rollout checks before teams regenerate public surfaces."
126
+ />
127
+ </VStack>
128
+
129
+ <HStack className="flex items-center gap-4 pt-4">
130
+ <Link
131
+ href="/docs/guides/generate-docs-clients-schemas"
132
+ className="btn-primary"
133
+ >
134
+ <Text>Next: Generate docs + clients</Text>
135
+ <ChevronRight size={16} />
136
+ </Link>
137
+ <Link href="/docs/guides" className="btn-ghost">
138
+ <Text>Back to guides</Text>
139
+ </Link>
140
+ </HStack>
141
+ </VStack>
142
+ );
143
+ }
@@ -144,10 +144,10 @@ bun run validate`}
144
144
 
145
145
  <div className="flex items-center gap-4 pt-4">
146
146
  <Link
147
- href="/docs/guides/generate-docs-clients-schemas"
147
+ href="/docs/guides/contract-driven-forms"
148
148
  className="btn-primary"
149
149
  >
150
- Next: Generate docs + clients <ChevronRight size={16} />
150
+ Next: Contract-driven forms <ChevronRight size={16} />
151
151
  </Link>
152
152
  <Link href="/docs/guides" className="btn-ghost">
153
153
  Back to guides
@@ -24,6 +24,13 @@ const guides = [
24
24
  href: '/docs/guides/spec-validation-and-typing',
25
25
  time: '20 min',
26
26
  },
27
+ {
28
+ title: 'Build a contract-driven form',
29
+ description:
30
+ 'Use FormSpec to keep data shape, fields, layout, policy, and submit behavior aligned.',
31
+ href: '/docs/guides/contract-driven-forms',
32
+ time: '25 min',
33
+ },
27
34
  {
28
35
  title: 'Generate docs and clients',
29
36
  description:
@@ -37,6 +37,18 @@ Create a single OperationSpec, register it, and expose it through a Next.js App
37
37
  body: `# Spec-driven validation and typing
38
38
 
39
39
  Define command/query specs that enforce validation and generate types without rewriting your app.`,
40
+ },
41
+ {
42
+ id: 'docs.guides.contract-driven-forms',
43
+ title: 'Contract-driven forms',
44
+ summary: 'Define schema-backed FormSpec surfaces and render them safely.',
45
+ kind: 'usage',
46
+ visibility: 'public',
47
+ route: '/docs/guides/contract-driven-forms',
48
+ tags: ['guides', 'forms', 'ui'],
49
+ body: `# Build a contract-driven form
50
+
51
+ Define a FormSpec with model, fields, layout, policy, and actions, then render it through a shared or app-specific renderer.`,
40
52
  },
41
53
  {
42
54
  id: 'docs.guides.docs-clients-schemas',
@@ -2,6 +2,7 @@ import './guides.docblocks';
2
2
 
3
3
  export { GuideCIDiffGatingPage } from './GuideCIDiffGatingPage';
4
4
  export { GuideConnectInRepoPage } from './GuideConnectInRepoPage';
5
+ export { GuideContractDrivenFormsPage } from './GuideContractDrivenFormsPage';
5
6
  export { GuideContractTypesPage } from './GuideContractTypesPage';
6
7
  export { GuideDocsPipelinePage } from './GuideDocsPipelinePage';
7
8
  export { GuideFirstModuleBundlePage } from './GuideFirstModuleBundlePage';
@@ -0,0 +1,170 @@
1
+ export const shellUsageExample = `import {
2
+ AppShell,
3
+ PageOutline,
4
+ type AppShellNavigationSection,
5
+ type PageOutlineItem,
6
+ } from "@contractspec/lib.design-system/shell";
7
+
8
+ const navigation: AppShellNavigationSection[] = [
9
+ {
10
+ title: "Workspace",
11
+ items: [
12
+ { label: "Dashboard", href: "/dashboard" },
13
+ {
14
+ label: "Contracts",
15
+ href: "/contracts",
16
+ children: [
17
+ { label: "Operations", href: "/contracts/operations" },
18
+ { label: "Events", href: "/contracts/events" },
19
+ ],
20
+ },
21
+ ],
22
+ },
23
+ ];
24
+
25
+ const outline: PageOutlineItem[] = [
26
+ {
27
+ id: "architecture",
28
+ label: "Architecture",
29
+ level: 1,
30
+ children: [
31
+ { id: "desktop", label: "Desktop shell", level: 2 },
32
+ { id: "mobile", label: "Mobile adaptation", level: 2 },
33
+ ],
34
+ },
35
+ ];
36
+
37
+ export function WorkspacePage() {
38
+ return (
39
+ <AppShell
40
+ brand={{ label: "ContractSpec", href: "/dashboard" }}
41
+ navigation={navigation}
42
+ breadcrumbs={[
43
+ { label: "Workspace", href: "/dashboard" },
44
+ { label: "Contracts" },
45
+ ]}
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" />}
64
+ >
65
+ <main>{/* route content */}</main>
66
+ </AppShell>
67
+ );
68
+ }`;
69
+
70
+ export const scratchPrompt = `You are implementing a modern application shell from scratch.
71
+
72
+ Goal:
73
+ 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.
74
+
75
+ Use this architecture:
76
+ - Keep route content independent from navigation chrome.
77
+ - Create a typed navigation model with sections, items, active state, optional children, badges, icons, disabled items, and href/onSelect support.
78
+ - Create a command model with search input, grouped suggestions, quick actions, keyboard shortcut labels, empty state, and loading state.
79
+ - Create a breadcrumb model for the topbar.
80
+ - 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.
81
+ - Expose the system from the design system or a dedicated shell module, not from a single app route.
82
+
83
+ Desktop behavior:
84
+ - Persistent left sidebar with app logo/title, command trigger, grouped navigation, nested submenus, and current user/auth/logout area.
85
+ - Topbar with breadcrumbs and an optional command trigger.
86
+ - Content area with optional right PageOutline.
87
+ - Keep dimensions stable. Navigation labels must not resize layout on hover or active state.
88
+
89
+ Mobile web behavior:
90
+ - Use bottom navigation for the primary destinations.
91
+ - Put deeper navigation, command search, auth actions, and secondary actions behind a menu or drawer.
92
+ - Keep route content first and make the shell controls reachable without covering important content.
93
+
94
+ Native behavior:
95
+ - Add .native.tsx entrypoints for Expo/React Native.
96
+ - Prefer bottom tabs for primary destinations and a menu/sheet for deeper navigation and account actions.
97
+ - Keep the same typed navigation, command, breadcrumb, and PageOutline data contracts across web and native.
98
+
99
+ Implementation constraints:
100
+ - Reuse the existing design-system primitives, tokens, icons, and accessibility patterns.
101
+ - Do not hardcode app-specific routes in the shell component.
102
+ - Do not introduce a new dependency unless the repo already uses it for dialogs, menus, icons, or navigation.
103
+ - Include tests for navigation rendering, nested items, command filtering, breadcrumbs, PageOutline level handling, active section state, and mobile/native adaptation contracts.
104
+ - Update docs and exports so developers can import the shell from a stable public API.
105
+
106
+ Deliverables:
107
+ - Typed shell models.
108
+ - Web shell components.
109
+ - Native shell components or adapters.
110
+ - PageOutline component with three-level support.
111
+ - Usage example.
112
+ - Focused tests and typecheck/build evidence.`;
113
+
114
+ export const refactorPrompt = `You are refactoring an existing application to use the shared application shell system.
115
+
116
+ Goal:
117
+ 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.
118
+
119
+ Start by auditing:
120
+ - Current layout wrappers and route groups.
121
+ - Sidebar, topbar, breadcrumb, command/search, auth menu, and mobile navigation implementations.
122
+ - Any duplicated navigation arrays, route labels, icon maps, access-control checks, and active-state logic.
123
+ - Any in-page summary/table-of-contents components that should become PageOutline data.
124
+ - Web-only assumptions that would block Expo/React Native adaptation.
125
+
126
+ Refactor plan:
127
+ 1. Define a single typed navigation source for primary nav, grouped sidebar nav, nested children, labels, icons, badges, disabled states, and permissions.
128
+ 2. Map existing command/search behavior into grouped command actions with search text and quick actions.
129
+ 3. Map existing route metadata into breadcrumbs.
130
+ 4. Convert page table-of-contents or section summary data into PageOutline items with a maximum of three levels.
131
+ 5. Wrap app routes in AppShell while keeping page content components route-local.
132
+ 6. Move primary mobile destinations into bottom navigation and deeper/account actions into a menu or drawer.
133
+ 7. Add or preserve .native.tsx adapters when the app targets Expo.
134
+
135
+ Preserve behavior:
136
+ - Existing route URLs and access rules.
137
+ - Existing keyboard shortcuts where they are public behavior.
138
+ - Existing analytics or telemetry events on navigation and command actions.
139
+ - Existing auth/logout behavior.
140
+ - Existing responsive breakpoints unless there is a documented design-system breakpoint to adopt.
141
+
142
+ Quality gates:
143
+ - Add regression tests around current visible navigation before removing old shell code when coverage is missing.
144
+ - Test active nav state, nested nav expansion, command search/action invocation, breadcrumbs, auth menu, mobile bottom navigation, and PageOutline anchor behavior.
145
+ - Run lint, typecheck, and the app's relevant test/build command.
146
+ - Remove dead app-specific shell components only after the shared shell path is verified.
147
+
148
+ Output:
149
+ - List old shell files removed or simplified.
150
+ - List new shared shell integration points.
151
+ - Include before/after route coverage and verification commands.`;
152
+
153
+ export const shellParts = [
154
+ {
155
+ title: 'Sidebar',
156
+ body: 'Desktop owns brand, command entry, grouped navigation, nested items, and account actions in one persistent scanning area.',
157
+ },
158
+ {
159
+ title: 'Topbar',
160
+ body: 'Breadcrumbs stay visible while the current route changes. The command trigger can live here when the sidebar is collapsed or hidden.',
161
+ },
162
+ {
163
+ title: 'PageOutline',
164
+ body: 'The right-side in-page navigator replaces ad hoc tables of contents. It supports three levels of section anchors and active state.',
165
+ },
166
+ {
167
+ title: 'Mobile adapters',
168
+ body: 'Small web and native surfaces move primary destinations to bottom navigation and reserve drawers or menus for deep navigation and account actions.',
169
+ },
170
+ ] as const;
@@ -0,0 +1,112 @@
1
+ import { CodeBlock, InstallCommand } from '@contractspec/lib.design-system';
2
+ import { Box, HStack, VStack } from '@contractspec/lib.design-system/layout';
3
+ import {
4
+ Code,
5
+ H1,
6
+ H2,
7
+ H3,
8
+ P,
9
+ Text,
10
+ } from '@contractspec/lib.design-system/typography';
11
+ import Link from '@contractspec/lib.ui-link';
12
+ import { ChevronRight } from 'lucide-react';
13
+ import {
14
+ refactorPrompt,
15
+ scratchPrompt,
16
+ shellParts,
17
+ shellUsageExample,
18
+ } from './LibrariesApplicationShellPage.content';
19
+
20
+ export function LibrariesApplicationShellPage() {
21
+ return (
22
+ <VStack className="space-y-8">
23
+ <VStack className="space-y-4">
24
+ <H1 className="font-bold text-4xl">Application shell</H1>
25
+ <P className="text-lg text-muted-foreground">
26
+ A reusable navigation system for product apps: desktop sidebar, topbar
27
+ breadcrumbs, command search, account actions, mobile adapters, and a
28
+ Notion-style <Code>PageOutline</Code> for page sections.
29
+ </P>
30
+ </VStack>
31
+
32
+ <VStack className="space-y-4">
33
+ <H2 className="font-bold text-2xl">Installation</H2>
34
+ <InstallCommand package="@contractspec/lib.design-system" />
35
+ </VStack>
36
+
37
+ <VStack className="space-y-4">
38
+ <H2 className="font-bold text-2xl">What It Standardizes</H2>
39
+ <Box className="grid gap-4 md:grid-cols-2">
40
+ {shellParts.map((part) => (
41
+ <Box key={part.title} className="card-subtle p-4">
42
+ <H3 className="font-semibold">{part.title}</H3>
43
+ <P className="mt-2 text-muted-foreground text-sm leading-7">
44
+ {part.body}
45
+ </P>
46
+ </Box>
47
+ ))}
48
+ </Box>
49
+ </VStack>
50
+
51
+ <VStack className="space-y-4">
52
+ <H2 className="font-bold text-2xl">Import Surface</H2>
53
+ <P className="text-muted-foreground">
54
+ The shell is exposed as a focused design-system subpath so apps can
55
+ adopt navigation chrome without pulling unrelated documentation or
56
+ marketing helpers.
57
+ </P>
58
+ <CodeBlock
59
+ language="tsx"
60
+ filename="app-shell-example.tsx"
61
+ code={shellUsageExample}
62
+ />
63
+ </VStack>
64
+
65
+ <VStack className="space-y-4">
66
+ <H2 className="font-bold text-2xl">AI Prompt: Build From Scratch</H2>
67
+ <P className="text-muted-foreground">
68
+ Use this prompt when the app does not already have a shell or when the
69
+ design-system package needs the reusable primitive first.
70
+ </P>
71
+ <CodeBlock
72
+ language="markdown"
73
+ filename="implement-application-shell.md"
74
+ code={scratchPrompt}
75
+ />
76
+ </VStack>
77
+
78
+ <VStack className="space-y-4">
79
+ <H2 className="font-bold text-2xl">AI Prompt: Refactor An App</H2>
80
+ <P className="text-muted-foreground">
81
+ Use this prompt when an app already has custom navigation chrome and
82
+ needs to migrate without breaking route behavior.
83
+ </P>
84
+ <CodeBlock
85
+ language="markdown"
86
+ filename="refactor-to-application-shell.md"
87
+ code={refactorPrompt}
88
+ />
89
+ </VStack>
90
+
91
+ <VStack className="card-subtle space-y-3 p-6">
92
+ <H2 className="font-bold text-2xl">Naming</H2>
93
+ <P className="text-muted-foreground">
94
+ Use <Code>AppShell</Code> for the whole navigation frame and{' '}
95
+ <Code>PageOutline</Code> for the in-page navigation helper. The latter
96
+ is the product-app equivalent of a table of contents, but it is
97
+ intentionally named for live page sections rather than static
98
+ documentation.
99
+ </P>
100
+ </VStack>
101
+
102
+ <HStack className="flex flex-wrap items-center gap-3 pt-2">
103
+ <Link href="/docs/libraries/cross-platform-ui" className="btn-ghost">
104
+ <Text>Cross-platform UI</Text>
105
+ </Link>
106
+ <Link href="/docs/libraries/design-system" className="btn-primary">
107
+ <Text>Design System</Text> <ChevronRight size={16} />
108
+ </Link>
109
+ </HStack>
110
+ </VStack>
111
+ );
112
+ }