@contractspec/lib.example-shared-ui 6.0.6 → 6.0.7

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 (81) hide show
  1. package/.turbo/turbo-build.log +90 -84
  2. package/AGENTS.md +43 -25
  3. package/README.md +63 -35
  4. package/dist/EvolutionDashboard.js +9 -9
  5. package/dist/EvolutionSidebar.js +15 -15
  6. package/dist/LocalDataIndicator.js +3 -3
  7. package/dist/MarkdownView.d.ts +0 -7
  8. package/dist/MarkdownView.js +76 -172
  9. package/dist/PersonalizationInsights.js +12 -12
  10. package/dist/SaveToStudioButton.js +2 -2
  11. package/dist/SpecDrivenTemplateShell.d.ts +1 -1
  12. package/dist/SpecDrivenTemplateShell.js +10 -10
  13. package/dist/SpecEditorPanel.js +3 -3
  14. package/dist/TemplateShell.js +10 -10
  15. package/dist/browser/EvolutionDashboard.js +9 -9
  16. package/dist/browser/EvolutionSidebar.js +15 -15
  17. package/dist/browser/LocalDataIndicator.js +3 -3
  18. package/dist/browser/MarkdownView.js +76 -172
  19. package/dist/browser/PersonalizationInsights.js +12 -12
  20. package/dist/browser/SaveToStudioButton.js +2 -2
  21. package/dist/browser/SpecDrivenTemplateShell.js +10 -10
  22. package/dist/browser/SpecEditorPanel.js +3 -3
  23. package/dist/browser/TemplateShell.js +10 -10
  24. package/dist/browser/hooks/index.js +29 -29
  25. package/dist/browser/index.js +193 -286
  26. package/dist/browser/lib/component-registry.js +1 -1
  27. package/dist/browser/markdown/formatPresentationName.js +9 -0
  28. package/dist/browser/markdown/useMarkdownPresentation.js +65 -0
  29. package/dist/hooks/index.d.ts +3 -3
  30. package/dist/hooks/index.js +29 -29
  31. package/dist/index.d.ts +12 -11
  32. package/dist/index.js +193 -286
  33. package/dist/lib/component-registry.js +1 -1
  34. package/dist/markdown/formatPresentationName.d.ts +1 -0
  35. package/dist/markdown/formatPresentationName.js +10 -0
  36. package/dist/markdown/useMarkdownPresentation.d.ts +21 -0
  37. package/dist/markdown/useMarkdownPresentation.js +66 -0
  38. package/dist/node/EvolutionDashboard.js +9 -9
  39. package/dist/node/EvolutionSidebar.js +15 -15
  40. package/dist/node/LocalDataIndicator.js +3 -3
  41. package/dist/node/MarkdownView.js +76 -172
  42. package/dist/node/PersonalizationInsights.js +12 -12
  43. package/dist/node/SaveToStudioButton.js +2 -2
  44. package/dist/node/SpecDrivenTemplateShell.js +10 -10
  45. package/dist/node/SpecEditorPanel.js +3 -3
  46. package/dist/node/TemplateShell.js +10 -10
  47. package/dist/node/hooks/index.js +29 -29
  48. package/dist/node/index.js +193 -286
  49. package/dist/node/lib/component-registry.js +1 -1
  50. package/dist/node/markdown/formatPresentationName.js +9 -0
  51. package/dist/node/markdown/useMarkdownPresentation.js +65 -0
  52. package/dist/utils/index.d.ts +1 -1
  53. package/package.json +38 -11
  54. package/src/EvolutionDashboard.tsx +415 -415
  55. package/src/EvolutionSidebar.tsx +245 -245
  56. package/src/LocalDataIndicator.tsx +28 -28
  57. package/src/MarkdownView.tsx +119 -372
  58. package/src/OverlayContextProvider.tsx +272 -272
  59. package/src/PersonalizationInsights.tsx +232 -232
  60. package/src/SaveToStudioButton.tsx +51 -51
  61. package/src/SpecDrivenTemplateShell.tsx +59 -59
  62. package/src/SpecEditorPanel.tsx +138 -138
  63. package/src/TemplateShell.tsx +50 -50
  64. package/src/bundles/ExampleTemplateBundle.ts +78 -78
  65. package/src/hooks/index.ts +3 -3
  66. package/src/hooks/useBehaviorTracking.ts +252 -252
  67. package/src/hooks/useEvolution.ts +437 -437
  68. package/src/hooks/useRegistryTemplates.ts +42 -42
  69. package/src/hooks/useSpecContent.ts +214 -214
  70. package/src/hooks/useWorkflowComposer.ts +567 -567
  71. package/src/index.ts +12 -11
  72. package/src/lib/component-registry.tsx +40 -40
  73. package/src/lib/runtime-context.tsx +31 -31
  74. package/src/lib/types.ts +57 -57
  75. package/src/markdown/formatPresentationName.ts +9 -0
  76. package/src/markdown/useMarkdownPresentation.ts +107 -0
  77. package/src/overlay-types.ts +15 -15
  78. package/src/utils/fetchPresentationData.ts +13 -13
  79. package/src/utils/generateSpecFromTemplate.ts +29 -29
  80. package/src/utils/index.ts +1 -1
  81. package/tsconfig.json +8 -8
@@ -1,5 +1,5 @@
1
1
  // src/lib/component-registry.tsx
2
- import { useState, useEffect } from "react";
2
+ import { useEffect, useState } from "react";
3
3
  "use client";
4
4
 
5
5
  class TemplateComponentRegistry {
@@ -0,0 +1,9 @@
1
+ // src/markdown/formatPresentationName.ts
2
+ function formatPresentationName(name) {
3
+ const parts = name.split(".");
4
+ const lastPart = parts[parts.length - 1] ?? name;
5
+ return lastPart.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
6
+ }
7
+ export {
8
+ formatPresentationName
9
+ };
@@ -0,0 +1,65 @@
1
+ // src/markdown/useMarkdownPresentation.ts
2
+ import { useCallback, useEffect, useState } from "react";
3
+ "use client";
4
+ function useMarkdownPresentation({
5
+ engine,
6
+ fetchData,
7
+ presentationId,
8
+ presentations,
9
+ resolvePresentation,
10
+ templateId
11
+ }) {
12
+ const [selectedPresentation, setSelectedPresentation] = useState("");
13
+ const [markdownContent, setMarkdownContent] = useState("");
14
+ const [loading, setLoading] = useState(false);
15
+ const [error, setError] = useState(null);
16
+ useEffect(() => {
17
+ if (presentationId && presentations.includes(presentationId)) {
18
+ setSelectedPresentation(presentationId);
19
+ return;
20
+ }
21
+ if (presentations.length === 0) {
22
+ setSelectedPresentation("");
23
+ return;
24
+ }
25
+ if (!presentations.includes(selectedPresentation)) {
26
+ setSelectedPresentation(presentations[0] ?? "");
27
+ }
28
+ }, [presentationId, presentations, selectedPresentation, templateId]);
29
+ const renderMarkdown = useCallback(async () => {
30
+ if (!selectedPresentation || !engine)
31
+ return;
32
+ setLoading(true);
33
+ setError(null);
34
+ try {
35
+ if (!resolvePresentation) {
36
+ throw new Error("resolvePresentation not available in runtime context");
37
+ }
38
+ const descriptor = resolvePresentation(selectedPresentation);
39
+ if (!descriptor) {
40
+ throw new Error(`Presentation descriptor not found: ${selectedPresentation}`);
41
+ }
42
+ const dataResult = await fetchData(selectedPresentation);
43
+ const result = await engine.render("markdown", descriptor, { data: dataResult.data });
44
+ setMarkdownContent(result.body);
45
+ } catch (err) {
46
+ setError(err instanceof Error ? err : new Error("Failed to render markdown"));
47
+ } finally {
48
+ setLoading(false);
49
+ }
50
+ }, [engine, fetchData, resolvePresentation, selectedPresentation]);
51
+ useEffect(() => {
52
+ renderMarkdown();
53
+ }, [renderMarkdown]);
54
+ return {
55
+ error,
56
+ loading,
57
+ markdownContent,
58
+ renderMarkdown,
59
+ selectedPresentation,
60
+ setSelectedPresentation
61
+ };
62
+ }
63
+ export {
64
+ useMarkdownPresentation
65
+ };
@@ -1,5 +1,5 @@
1
- export * from './useSpecContent';
2
- export * from './useEvolution';
3
1
  export * from './useBehaviorTracking';
4
- export * from './useWorkflowComposer';
2
+ export * from './useEvolution';
5
3
  export * from './useRegistryTemplates';
4
+ export * from './useSpecContent';
5
+ export * from './useWorkflowComposer';
@@ -989,6 +989,35 @@ function useSpecContent(templateId) {
989
989
  };
990
990
  }
991
991
 
992
+ // src/hooks/useRegistryTemplates.ts
993
+ import { useQuery } from "@tanstack/react-query";
994
+ function useRegistryTemplates() {
995
+ return useQuery({
996
+ queryKey: ["registryTemplates"],
997
+ queryFn: async () => {
998
+ const registryUrl = process.env.NEXT_PUBLIC_CONTRACTSPEC_REGISTRY_URL ?? "";
999
+ if (!registryUrl)
1000
+ return [];
1001
+ const res = await fetch(`${registryUrl.replace(/\/$/, "")}/r/contractspec.json`, {
1002
+ method: "GET",
1003
+ headers: { Accept: "application/json" }
1004
+ });
1005
+ if (!res.ok)
1006
+ return [];
1007
+ const json = await res.json();
1008
+ const items = json.items ?? [];
1009
+ return items.filter((i) => i.type === "contractspec:template").map((i) => ({
1010
+ id: i.name,
1011
+ name: i.title ?? i.name,
1012
+ description: i.description,
1013
+ tags: i.meta?.tags ?? [],
1014
+ source: "registry",
1015
+ registryUrl
1016
+ }));
1017
+ }
1018
+ });
1019
+ }
1020
+
992
1021
  // src/hooks/useWorkflowComposer.ts
993
1022
  import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useState as useState4 } from "react";
994
1023
  "use client";
@@ -1479,35 +1508,6 @@ function getTemplateWorkflows(templateId) {
1479
1508
  };
1480
1509
  return templateWorkflows[templateId] ?? [];
1481
1510
  }
1482
-
1483
- // src/hooks/useRegistryTemplates.ts
1484
- import { useQuery } from "@tanstack/react-query";
1485
- function useRegistryTemplates() {
1486
- return useQuery({
1487
- queryKey: ["registryTemplates"],
1488
- queryFn: async () => {
1489
- const registryUrl = process.env.NEXT_PUBLIC_CONTRACTSPEC_REGISTRY_URL ?? "";
1490
- if (!registryUrl)
1491
- return [];
1492
- const res = await fetch(`${registryUrl.replace(/\/$/, "")}/r/contractspec.json`, {
1493
- method: "GET",
1494
- headers: { Accept: "application/json" }
1495
- });
1496
- if (!res.ok)
1497
- return [];
1498
- const json = await res.json();
1499
- const items = json.items ?? [];
1500
- return items.filter((i) => i.type === "contractspec:template").map((i) => ({
1501
- id: i.name,
1502
- name: i.title ?? i.name,
1503
- description: i.description,
1504
- tags: i.meta?.tags ?? [],
1505
- source: "registry",
1506
- registryUrl
1507
- }));
1508
- }
1509
- });
1510
- }
1511
1511
  export {
1512
1512
  useWorkflowComposer,
1513
1513
  useSpecContent,
package/dist/index.d.ts CHANGED
@@ -1,16 +1,17 @@
1
- export * from './TemplateShell';
2
- export * from './SpecDrivenTemplateShell';
3
- export * from './LocalDataIndicator';
4
- export * from './SaveToStudioButton';
5
- export * from './overlay-types';
6
- export * from './MarkdownView';
7
- export * from './SpecEditorPanel';
1
+ export { MarkdownRenderer } from '@contractspec/lib.design-system';
8
2
  export * from './EvolutionDashboard';
9
3
  export * from './EvolutionSidebar';
10
- export * from './OverlayContextProvider';
11
- export * from './PersonalizationInsights';
12
4
  export * from './hooks';
13
- export * from './utils';
14
- export * from './lib/runtime-context';
5
+ export * from './LocalDataIndicator';
15
6
  export * from './lib/component-registry';
7
+ export * from './lib/runtime-context';
16
8
  export * from './lib/types';
9
+ export * from './MarkdownView';
10
+ export * from './OverlayContextProvider';
11
+ export * from './overlay-types';
12
+ export * from './PersonalizationInsights';
13
+ export * from './SaveToStudioButton';
14
+ export * from './SpecDrivenTemplateShell';
15
+ export * from './SpecEditorPanel';
16
+ export * from './TemplateShell';
17
+ export * from './utils';