@contractspec/example.in-app-docs 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.turbo/turbo-build.log +34 -33
  2. package/.turbo/turbo-prebuild.log +1 -0
  3. package/CHANGELOG.md +25 -0
  4. package/dist/browser/docs/in-app-docs.docblock.js +50 -0
  5. package/dist/browser/docs/index.js +47 -0
  6. package/dist/browser/example.js +38 -0
  7. package/dist/browser/index.js +136 -0
  8. package/dist/browser/ui/InAppDocsViewer.js +100 -0
  9. package/dist/browser/ui/index.js +100 -0
  10. package/dist/docs/in-app-docs.docblock.d.ts +2 -6
  11. package/dist/docs/in-app-docs.docblock.d.ts.map +1 -1
  12. package/dist/docs/in-app-docs.docblock.js +33 -47
  13. package/dist/docs/index.d.ts +2 -1
  14. package/dist/docs/index.d.ts.map +1 -0
  15. package/dist/docs/index.js +48 -1
  16. package/dist/example.d.ts +2 -6
  17. package/dist/example.d.ts.map +1 -1
  18. package/dist/example.js +37 -50
  19. package/dist/index.d.ts +4 -5
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +136 -5
  22. package/dist/node/docs/in-app-docs.docblock.js +50 -0
  23. package/dist/node/docs/index.js +47 -0
  24. package/dist/node/example.js +38 -0
  25. package/dist/node/index.js +136 -0
  26. package/dist/node/ui/InAppDocsViewer.js +100 -0
  27. package/dist/node/ui/index.js +100 -0
  28. package/dist/ui/InAppDocsViewer.d.ts +2 -5
  29. package/dist/ui/InAppDocsViewer.d.ts.map +1 -1
  30. package/dist/ui/InAppDocsViewer.js +98 -59
  31. package/dist/ui/index.d.ts +2 -2
  32. package/dist/ui/index.d.ts.map +1 -0
  33. package/dist/ui/index.js +100 -2
  34. package/package.json +77 -25
  35. package/tsdown.config.js +1 -2
  36. package/.turbo/turbo-build$colon$bundle.log +0 -33
  37. package/dist/docs/in-app-docs.docblock.js.map +0 -1
  38. package/dist/example.js.map +0 -1
  39. package/dist/ui/InAppDocsViewer.js.map +0 -1
  40. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,136 @@
1
+ // src/docs/in-app-docs.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var inAppDocs = [
4
+ {
5
+ id: "docs.examples.in-app-docs",
6
+ title: "In‑App Docs — Overview",
7
+ summary: "Overview of the in‑app documentation example demonstrating how DocBlock can serve end‑user guides.",
8
+ kind: "goal",
9
+ visibility: "public",
10
+ route: "/docs/examples/in-app-docs",
11
+ tags: ["documentation", "overview", "guide"],
12
+ body: `## Purpose
13
+ The in‑app documentation example shows how you can use ContractSpec's DocBlock system to build user‑facing guides directly inside an application's UI.
14
+
15
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non‑technical language. When embedded in your app, these blocks present a self‑contained help centre for users.
16
+
17
+ ## What you'll learn
18
+ * How to define DocBlock objects with public visibility and user‑friendly routes.
19
+ * How to structure an overview page for your in‑app guide using Markdown.
20
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
21
+
22
+ Use this example as a template for documenting your own frontend workflows.`
23
+ },
24
+ {
25
+ id: "docs.examples.in-app-docs.usage",
26
+ title: "In‑App Docs — Using the Application",
27
+ summary: "Step‑by‑step guide for end users to navigate and use the example application.",
28
+ kind: "usage",
29
+ visibility: "public",
30
+ route: "/docs/examples/in-app-docs/usage",
31
+ tags: ["documentation", "usage", "guide"],
32
+ body: `## Getting Started
33
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
34
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
35
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
36
+
37
+ ## Tips
38
+ * Look for information icons (ℹ️) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
39
+ * Use keyboard shortcuts—such as **Ctrl+S** to save or **Ctrl+K** to open the command palette—for quicker navigation.
40
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
41
+
42
+ ## Next Steps
43
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
44
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`
45
+ }
46
+ ];
47
+ registerDocBlocks(inAppDocs);
48
+ // src/example.ts
49
+ import { defineExample } from "@contractspec/lib.contracts";
50
+ var example = defineExample({
51
+ meta: {
52
+ key: "in-app-docs",
53
+ version: "1.0.0",
54
+ title: "In‑App Documentation Example",
55
+ description: "Demonstrates using DocBlock to create user‑facing guides that live inside your application's frontend. It shows how to structure a public, non‑technical user guide using ContractSpec.",
56
+ kind: "ui",
57
+ visibility: "public",
58
+ stability: "experimental",
59
+ owners: ["@docs-team"],
60
+ tags: ["documentation", "guide", "ui"]
61
+ },
62
+ docs: {
63
+ rootDocId: "docs.examples.in-app-docs",
64
+ usageDocId: "docs.examples.in-app-docs.usage",
65
+ goalDocId: "docs.examples.in-app-docs"
66
+ },
67
+ entrypoints: {
68
+ packageName: "@contractspec/example.in-app-docs",
69
+ docs: "./docs",
70
+ ui: "./ui"
71
+ },
72
+ surfaces: {
73
+ templates: false,
74
+ sandbox: {
75
+ enabled: true,
76
+ modes: ["markdown"]
77
+ },
78
+ studio: { enabled: false, installable: false },
79
+ mcp: { enabled: false }
80
+ }
81
+ });
82
+ var example_default = example;
83
+
84
+ // src/ui/InAppDocsViewer.tsx
85
+ import { useState } from "react";
86
+ import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
87
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
88
+ "use client";
89
+ var InAppDocsViewer = () => {
90
+ const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
91
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
92
+ return /* @__PURE__ */ jsxDEV("div", {
93
+ style: { display: "flex", height: "100%", gap: "1rem" },
94
+ children: [
95
+ /* @__PURE__ */ jsxDEV("nav", {
96
+ style: { width: "220px", borderRight: "1px solid #eee" },
97
+ children: /* @__PURE__ */ jsxDEV("ul", {
98
+ style: { listStyle: "none", padding: 0, margin: 0 },
99
+ children: inAppDocs.map((doc) => /* @__PURE__ */ jsxDEV("li", {
100
+ style: { marginBottom: "0.5rem" },
101
+ children: /* @__PURE__ */ jsxDEV("button", {
102
+ onClick: () => setActiveId(doc.id),
103
+ style: {
104
+ background: doc.id === activeId ? "#f0f0f0" : "transparent",
105
+ border: "none",
106
+ padding: "0.5rem 0.75rem",
107
+ cursor: "pointer",
108
+ textAlign: "left",
109
+ width: "100%"
110
+ },
111
+ children: doc.title
112
+ }, undefined, false, undefined, this)
113
+ }, doc.id, false, undefined, this))
114
+ }, undefined, false, undefined, this)
115
+ }, undefined, false, undefined, this),
116
+ /* @__PURE__ */ jsxDEV("main", {
117
+ style: { flexGrow: 1, padding: "1rem", overflowY: "auto" },
118
+ children: activeDoc && /* @__PURE__ */ jsxDEV(Fragment, {
119
+ children: [
120
+ /* @__PURE__ */ jsxDEV("h1", {
121
+ children: activeDoc.title
122
+ }, undefined, false, undefined, this),
123
+ /* @__PURE__ */ jsxDEV(MarkdownRenderer, {
124
+ content: activeDoc.body
125
+ }, undefined, false, undefined, this)
126
+ ]
127
+ }, undefined, true, undefined, this)
128
+ }, undefined, false, undefined, this)
129
+ ]
130
+ }, undefined, true, undefined, this);
131
+ };
132
+ var InAppDocsViewer_default = InAppDocsViewer;
133
+ export {
134
+ example_default as example,
135
+ InAppDocsViewer_default as InAppDocsViewer
136
+ };
@@ -0,0 +1,100 @@
1
+ // src/docs/in-app-docs.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var inAppDocs = [
4
+ {
5
+ id: "docs.examples.in-app-docs",
6
+ title: "In‑App Docs — Overview",
7
+ summary: "Overview of the in‑app documentation example demonstrating how DocBlock can serve end‑user guides.",
8
+ kind: "goal",
9
+ visibility: "public",
10
+ route: "/docs/examples/in-app-docs",
11
+ tags: ["documentation", "overview", "guide"],
12
+ body: `## Purpose
13
+ The in‑app documentation example shows how you can use ContractSpec's DocBlock system to build user‑facing guides directly inside an application's UI.
14
+
15
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non‑technical language. When embedded in your app, these blocks present a self‑contained help centre for users.
16
+
17
+ ## What you'll learn
18
+ * How to define DocBlock objects with public visibility and user‑friendly routes.
19
+ * How to structure an overview page for your in‑app guide using Markdown.
20
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
21
+
22
+ Use this example as a template for documenting your own frontend workflows.`
23
+ },
24
+ {
25
+ id: "docs.examples.in-app-docs.usage",
26
+ title: "In‑App Docs — Using the Application",
27
+ summary: "Step‑by‑step guide for end users to navigate and use the example application.",
28
+ kind: "usage",
29
+ visibility: "public",
30
+ route: "/docs/examples/in-app-docs/usage",
31
+ tags: ["documentation", "usage", "guide"],
32
+ body: `## Getting Started
33
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
34
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
35
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
36
+
37
+ ## Tips
38
+ * Look for information icons (ℹ️) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
39
+ * Use keyboard shortcuts—such as **Ctrl+S** to save or **Ctrl+K** to open the command palette—for quicker navigation.
40
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
41
+
42
+ ## Next Steps
43
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
44
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`
45
+ }
46
+ ];
47
+ registerDocBlocks(inAppDocs);
48
+
49
+ // src/ui/InAppDocsViewer.tsx
50
+ import { useState } from "react";
51
+ import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
52
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
53
+ "use client";
54
+ var InAppDocsViewer = () => {
55
+ const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
56
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
57
+ return /* @__PURE__ */ jsxDEV("div", {
58
+ style: { display: "flex", height: "100%", gap: "1rem" },
59
+ children: [
60
+ /* @__PURE__ */ jsxDEV("nav", {
61
+ style: { width: "220px", borderRight: "1px solid #eee" },
62
+ children: /* @__PURE__ */ jsxDEV("ul", {
63
+ style: { listStyle: "none", padding: 0, margin: 0 },
64
+ children: inAppDocs.map((doc) => /* @__PURE__ */ jsxDEV("li", {
65
+ style: { marginBottom: "0.5rem" },
66
+ children: /* @__PURE__ */ jsxDEV("button", {
67
+ onClick: () => setActiveId(doc.id),
68
+ style: {
69
+ background: doc.id === activeId ? "#f0f0f0" : "transparent",
70
+ border: "none",
71
+ padding: "0.5rem 0.75rem",
72
+ cursor: "pointer",
73
+ textAlign: "left",
74
+ width: "100%"
75
+ },
76
+ children: doc.title
77
+ }, undefined, false, undefined, this)
78
+ }, doc.id, false, undefined, this))
79
+ }, undefined, false, undefined, this)
80
+ }, undefined, false, undefined, this),
81
+ /* @__PURE__ */ jsxDEV("main", {
82
+ style: { flexGrow: 1, padding: "1rem", overflowY: "auto" },
83
+ children: activeDoc && /* @__PURE__ */ jsxDEV(Fragment, {
84
+ children: [
85
+ /* @__PURE__ */ jsxDEV("h1", {
86
+ children: activeDoc.title
87
+ }, undefined, false, undefined, this),
88
+ /* @__PURE__ */ jsxDEV(MarkdownRenderer, {
89
+ content: activeDoc.body
90
+ }, undefined, false, undefined, this)
91
+ ]
92
+ }, undefined, true, undefined, this)
93
+ }, undefined, false, undefined, this)
94
+ ]
95
+ }, undefined, true, undefined, this);
96
+ };
97
+ var InAppDocsViewer_default = InAppDocsViewer;
98
+ export {
99
+ InAppDocsViewer_default as default
100
+ };
@@ -0,0 +1,100 @@
1
+ // src/docs/in-app-docs.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var inAppDocs = [
4
+ {
5
+ id: "docs.examples.in-app-docs",
6
+ title: "In‑App Docs — Overview",
7
+ summary: "Overview of the in‑app documentation example demonstrating how DocBlock can serve end‑user guides.",
8
+ kind: "goal",
9
+ visibility: "public",
10
+ route: "/docs/examples/in-app-docs",
11
+ tags: ["documentation", "overview", "guide"],
12
+ body: `## Purpose
13
+ The in‑app documentation example shows how you can use ContractSpec's DocBlock system to build user‑facing guides directly inside an application's UI.
14
+
15
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non‑technical language. When embedded in your app, these blocks present a self‑contained help centre for users.
16
+
17
+ ## What you'll learn
18
+ * How to define DocBlock objects with public visibility and user‑friendly routes.
19
+ * How to structure an overview page for your in‑app guide using Markdown.
20
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
21
+
22
+ Use this example as a template for documenting your own frontend workflows.`
23
+ },
24
+ {
25
+ id: "docs.examples.in-app-docs.usage",
26
+ title: "In‑App Docs — Using the Application",
27
+ summary: "Step‑by‑step guide for end users to navigate and use the example application.",
28
+ kind: "usage",
29
+ visibility: "public",
30
+ route: "/docs/examples/in-app-docs/usage",
31
+ tags: ["documentation", "usage", "guide"],
32
+ body: `## Getting Started
33
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
34
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
35
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
36
+
37
+ ## Tips
38
+ * Look for information icons (ℹ️) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
39
+ * Use keyboard shortcuts—such as **Ctrl+S** to save or **Ctrl+K** to open the command palette—for quicker navigation.
40
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
41
+
42
+ ## Next Steps
43
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
44
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`
45
+ }
46
+ ];
47
+ registerDocBlocks(inAppDocs);
48
+
49
+ // src/ui/InAppDocsViewer.tsx
50
+ import { useState } from "react";
51
+ import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
52
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
53
+ "use client";
54
+ var InAppDocsViewer = () => {
55
+ const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
56
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
57
+ return /* @__PURE__ */ jsxDEV("div", {
58
+ style: { display: "flex", height: "100%", gap: "1rem" },
59
+ children: [
60
+ /* @__PURE__ */ jsxDEV("nav", {
61
+ style: { width: "220px", borderRight: "1px solid #eee" },
62
+ children: /* @__PURE__ */ jsxDEV("ul", {
63
+ style: { listStyle: "none", padding: 0, margin: 0 },
64
+ children: inAppDocs.map((doc) => /* @__PURE__ */ jsxDEV("li", {
65
+ style: { marginBottom: "0.5rem" },
66
+ children: /* @__PURE__ */ jsxDEV("button", {
67
+ onClick: () => setActiveId(doc.id),
68
+ style: {
69
+ background: doc.id === activeId ? "#f0f0f0" : "transparent",
70
+ border: "none",
71
+ padding: "0.5rem 0.75rem",
72
+ cursor: "pointer",
73
+ textAlign: "left",
74
+ width: "100%"
75
+ },
76
+ children: doc.title
77
+ }, undefined, false, undefined, this)
78
+ }, doc.id, false, undefined, this))
79
+ }, undefined, false, undefined, this)
80
+ }, undefined, false, undefined, this),
81
+ /* @__PURE__ */ jsxDEV("main", {
82
+ style: { flexGrow: 1, padding: "1rem", overflowY: "auto" },
83
+ children: activeDoc && /* @__PURE__ */ jsxDEV(Fragment, {
84
+ children: [
85
+ /* @__PURE__ */ jsxDEV("h1", {
86
+ children: activeDoc.title
87
+ }, undefined, false, undefined, this),
88
+ /* @__PURE__ */ jsxDEV(MarkdownRenderer, {
89
+ content: activeDoc.body
90
+ }, undefined, false, undefined, this)
91
+ ]
92
+ }, undefined, true, undefined, this)
93
+ }, undefined, false, undefined, this)
94
+ ]
95
+ }, undefined, true, undefined, this);
96
+ };
97
+ var InAppDocsViewer_default = InAppDocsViewer;
98
+ export {
99
+ InAppDocsViewer_default as InAppDocsViewer
100
+ };
@@ -1,11 +1,8 @@
1
- import React from "react";
2
-
3
- //#region src/ui/InAppDocsViewer.d.ts
1
+ import React from 'react';
4
2
  /**
5
3
  * InAppDocsViewer renders a simple navigation and content area for the example's DocBlocks.
6
4
  * Users can click titles on the left to switch between documentation pages.
7
5
  */
8
6
  declare const InAppDocsViewer: React.FC;
9
- //#endregion
10
- export { InAppDocsViewer as default };
7
+ export default InAppDocsViewer;
11
8
  //# sourceMappingURL=InAppDocsViewer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InAppDocsViewer.d.ts","names":[],"sources":["../../src/ui/InAppDocsViewer.tsx"],"mappings":";;;;;AAEwC;;cASlC,eAAA,EAAiB,KAAA,CAAM,EAAA"}
1
+ {"version":3,"file":"InAppDocsViewer.d.ts","sourceRoot":"","sources":["../../src/ui/InAppDocsViewer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAKxC;;;GAGG;AACH,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAsC5B,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,62 +1,101 @@
1
- 'use client';
1
+ // @bun
2
+ // src/docs/in-app-docs.docblock.ts
3
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
4
+ var inAppDocs = [
5
+ {
6
+ id: "docs.examples.in-app-docs",
7
+ title: "In\u2011App Docs \u2014 Overview",
8
+ summary: "Overview of the in\u2011app documentation example demonstrating how DocBlock can serve end\u2011user guides.",
9
+ kind: "goal",
10
+ visibility: "public",
11
+ route: "/docs/examples/in-app-docs",
12
+ tags: ["documentation", "overview", "guide"],
13
+ body: `## Purpose
14
+ The in\u2011app documentation example shows how you can use ContractSpec's DocBlock system to build user\u2011facing guides directly inside an application's UI.
2
15
 
3
- import { inAppDocs } from "../docs/in-app-docs.docblock.js";
4
- import React, { useState } from "react";
5
- import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
6
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non\u2011technical language. When embedded in your app, these blocks present a self\u2011contained help centre for users.
7
17
 
8
- //#region src/ui/InAppDocsViewer.tsx
9
- /**
10
- * InAppDocsViewer renders a simple navigation and content area for the example's DocBlocks.
11
- * Users can click titles on the left to switch between documentation pages.
12
- */
13
- const InAppDocsViewer = () => {
14
- const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
15
- const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
16
- return /* @__PURE__ */ jsxs("div", {
17
- style: {
18
- display: "flex",
19
- height: "100%",
20
- gap: "1rem"
21
- },
22
- children: [/* @__PURE__ */ jsx("nav", {
23
- style: {
24
- width: "220px",
25
- borderRight: "1px solid #eee"
26
- },
27
- children: /* @__PURE__ */ jsx("ul", {
28
- style: {
29
- listStyle: "none",
30
- padding: 0,
31
- margin: 0
32
- },
33
- children: inAppDocs.map((doc) => /* @__PURE__ */ jsx("li", {
34
- style: { marginBottom: "0.5rem" },
35
- children: /* @__PURE__ */ jsx("button", {
36
- onClick: () => setActiveId(doc.id),
37
- style: {
38
- background: doc.id === activeId ? "#f0f0f0" : "transparent",
39
- border: "none",
40
- padding: "0.5rem 0.75rem",
41
- cursor: "pointer",
42
- textAlign: "left",
43
- width: "100%"
44
- },
45
- children: doc.title
46
- })
47
- }, doc.id))
48
- })
49
- }), /* @__PURE__ */ jsx("main", {
50
- style: {
51
- flexGrow: 1,
52
- padding: "1rem",
53
- overflowY: "auto"
54
- },
55
- children: activeDoc && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h1", { children: activeDoc.title }), /* @__PURE__ */ jsx(MarkdownRenderer, { content: activeDoc.body })] })
56
- })]
57
- });
58
- };
18
+ ## What you'll learn
19
+ * How to define DocBlock objects with public visibility and user\u2011friendly routes.
20
+ * How to structure an overview page for your in\u2011app guide using Markdown.
21
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
22
+
23
+ Use this example as a template for documenting your own frontend workflows.`
24
+ },
25
+ {
26
+ id: "docs.examples.in-app-docs.usage",
27
+ title: "In\u2011App Docs \u2014 Using the Application",
28
+ summary: "Step\u2011by\u2011step guide for end users to navigate and use the example application.",
29
+ kind: "usage",
30
+ visibility: "public",
31
+ route: "/docs/examples/in-app-docs/usage",
32
+ tags: ["documentation", "usage", "guide"],
33
+ body: `## Getting Started
34
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
35
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
36
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
37
+
38
+ ## Tips
39
+ * Look for information icons (\u2139\uFE0F) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
40
+ * Use keyboard shortcuts\u2014such as **Ctrl+S** to save or **Ctrl+K** to open the command palette\u2014for quicker navigation.
41
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
59
42
 
60
- //#endregion
61
- export { InAppDocsViewer as default };
62
- //# sourceMappingURL=InAppDocsViewer.js.map
43
+ ## Next Steps
44
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
45
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`
46
+ }
47
+ ];
48
+ registerDocBlocks(inAppDocs);
49
+
50
+ // src/ui/InAppDocsViewer.tsx
51
+ import { useState } from "react";
52
+ import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
53
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
54
+ "use client";
55
+ var InAppDocsViewer = () => {
56
+ const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
57
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
58
+ return /* @__PURE__ */ jsxDEV("div", {
59
+ style: { display: "flex", height: "100%", gap: "1rem" },
60
+ children: [
61
+ /* @__PURE__ */ jsxDEV("nav", {
62
+ style: { width: "220px", borderRight: "1px solid #eee" },
63
+ children: /* @__PURE__ */ jsxDEV("ul", {
64
+ style: { listStyle: "none", padding: 0, margin: 0 },
65
+ children: inAppDocs.map((doc) => /* @__PURE__ */ jsxDEV("li", {
66
+ style: { marginBottom: "0.5rem" },
67
+ children: /* @__PURE__ */ jsxDEV("button", {
68
+ onClick: () => setActiveId(doc.id),
69
+ style: {
70
+ background: doc.id === activeId ? "#f0f0f0" : "transparent",
71
+ border: "none",
72
+ padding: "0.5rem 0.75rem",
73
+ cursor: "pointer",
74
+ textAlign: "left",
75
+ width: "100%"
76
+ },
77
+ children: doc.title
78
+ }, undefined, false, undefined, this)
79
+ }, doc.id, false, undefined, this))
80
+ }, undefined, false, undefined, this)
81
+ }, undefined, false, undefined, this),
82
+ /* @__PURE__ */ jsxDEV("main", {
83
+ style: { flexGrow: 1, padding: "1rem", overflowY: "auto" },
84
+ children: activeDoc && /* @__PURE__ */ jsxDEV(Fragment, {
85
+ children: [
86
+ /* @__PURE__ */ jsxDEV("h1", {
87
+ children: activeDoc.title
88
+ }, undefined, false, undefined, this),
89
+ /* @__PURE__ */ jsxDEV(MarkdownRenderer, {
90
+ content: activeDoc.body
91
+ }, undefined, false, undefined, this)
92
+ ]
93
+ }, undefined, true, undefined, this)
94
+ }, undefined, false, undefined, this)
95
+ ]
96
+ }, undefined, true, undefined, this);
97
+ };
98
+ var InAppDocsViewer_default = InAppDocsViewer;
99
+ export {
100
+ InAppDocsViewer_default as default
101
+ };
@@ -1,2 +1,2 @@
1
- import InAppDocsViewer from "./InAppDocsViewer.js";
2
- export { InAppDocsViewer };
1
+ export { default as InAppDocsViewer } from './InAppDocsViewer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/ui/index.js CHANGED
@@ -1,3 +1,101 @@
1
- import InAppDocsViewer from "./InAppDocsViewer.js";
1
+ // @bun
2
+ // src/docs/in-app-docs.docblock.ts
3
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
4
+ var inAppDocs = [
5
+ {
6
+ id: "docs.examples.in-app-docs",
7
+ title: "In\u2011App Docs \u2014 Overview",
8
+ summary: "Overview of the in\u2011app documentation example demonstrating how DocBlock can serve end\u2011user guides.",
9
+ kind: "goal",
10
+ visibility: "public",
11
+ route: "/docs/examples/in-app-docs",
12
+ tags: ["documentation", "overview", "guide"],
13
+ body: `## Purpose
14
+ The in\u2011app documentation example shows how you can use ContractSpec's DocBlock system to build user\u2011facing guides directly inside an application's UI.
2
15
 
3
- export { InAppDocsViewer };
16
+ Instead of relying solely on developer documentation, you can define **public** DocBlocks that describe your product's features in clear, non\u2011technical language. When embedded in your app, these blocks present a self\u2011contained help centre for users.
17
+
18
+ ## What you'll learn
19
+ * How to define DocBlock objects with public visibility and user\u2011friendly routes.
20
+ * How to structure an overview page for your in\u2011app guide using Markdown.
21
+ * How to register your DocBlocks so they show up in the sandbox and in your application.
22
+
23
+ Use this example as a template for documenting your own frontend workflows.`
24
+ },
25
+ {
26
+ id: "docs.examples.in-app-docs.usage",
27
+ title: "In\u2011App Docs \u2014 Using the Application",
28
+ summary: "Step\u2011by\u2011step guide for end users to navigate and use the example application.",
29
+ kind: "usage",
30
+ visibility: "public",
31
+ route: "/docs/examples/in-app-docs/usage",
32
+ tags: ["documentation", "usage", "guide"],
33
+ body: `## Getting Started
34
+ 1. **Sign in**. Launch the app and enter your credentials. New users can click **Create Account** to register.
35
+ 2. **Explore the dashboard**. Use the sidebar or navigation bar to access sections like Dashboard, Profile, and Settings.
36
+ 3. **Add items**. On the Dashboard, click **Add Item** or a plus icon to create a new record. Fill in the form fields and press **Save**.
37
+
38
+ ## Tips
39
+ * Look for information icons (\u2139\uFE0F) throughout the UI. Hover or click these icons to display contextual help powered by DocBlock.
40
+ * Use keyboard shortcuts\u2014such as **Ctrl+S** to save or **Ctrl+K** to open the command palette\u2014for quicker navigation.
41
+ * Need to find something quickly? Use the search bar or filters at the top of lists.
42
+
43
+ ## Next Steps
44
+ Continue exploring the different screens. Try editing or deleting items, adjusting your profile settings, or experimenting with filters.
45
+ This guide is available via the help menu inside the app, so you can reference it without leaving your workflow.`
46
+ }
47
+ ];
48
+ registerDocBlocks(inAppDocs);
49
+
50
+ // src/ui/InAppDocsViewer.tsx
51
+ import { useState } from "react";
52
+ import { MarkdownRenderer } from "@contractspec/lib.example-shared-ui";
53
+ import { jsxDEV, Fragment } from "react/jsx-dev-runtime";
54
+ "use client";
55
+ var InAppDocsViewer = () => {
56
+ const [activeId, setActiveId] = useState(inAppDocs[0]?.id ?? "");
57
+ const activeDoc = inAppDocs.find((doc) => doc.id === activeId);
58
+ return /* @__PURE__ */ jsxDEV("div", {
59
+ style: { display: "flex", height: "100%", gap: "1rem" },
60
+ children: [
61
+ /* @__PURE__ */ jsxDEV("nav", {
62
+ style: { width: "220px", borderRight: "1px solid #eee" },
63
+ children: /* @__PURE__ */ jsxDEV("ul", {
64
+ style: { listStyle: "none", padding: 0, margin: 0 },
65
+ children: inAppDocs.map((doc) => /* @__PURE__ */ jsxDEV("li", {
66
+ style: { marginBottom: "0.5rem" },
67
+ children: /* @__PURE__ */ jsxDEV("button", {
68
+ onClick: () => setActiveId(doc.id),
69
+ style: {
70
+ background: doc.id === activeId ? "#f0f0f0" : "transparent",
71
+ border: "none",
72
+ padding: "0.5rem 0.75rem",
73
+ cursor: "pointer",
74
+ textAlign: "left",
75
+ width: "100%"
76
+ },
77
+ children: doc.title
78
+ }, undefined, false, undefined, this)
79
+ }, doc.id, false, undefined, this))
80
+ }, undefined, false, undefined, this)
81
+ }, undefined, false, undefined, this),
82
+ /* @__PURE__ */ jsxDEV("main", {
83
+ style: { flexGrow: 1, padding: "1rem", overflowY: "auto" },
84
+ children: activeDoc && /* @__PURE__ */ jsxDEV(Fragment, {
85
+ children: [
86
+ /* @__PURE__ */ jsxDEV("h1", {
87
+ children: activeDoc.title
88
+ }, undefined, false, undefined, this),
89
+ /* @__PURE__ */ jsxDEV(MarkdownRenderer, {
90
+ content: activeDoc.body
91
+ }, undefined, false, undefined, this)
92
+ ]
93
+ }, undefined, true, undefined, this)
94
+ }, undefined, false, undefined, this)
95
+ ]
96
+ }, undefined, true, undefined, this);
97
+ };
98
+ var InAppDocsViewer_default = InAppDocsViewer;
99
+ export {
100
+ InAppDocsViewer_default as InAppDocsViewer
101
+ };