@contractspec/example.learning-journey-ui-shared 0.0.0-canary-20260113170453

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 (60) hide show
  1. package/.turbo/turbo-build$colon$bundle.log +48 -0
  2. package/.turbo/turbo-build.log +49 -0
  3. package/CHANGELOG.md +379 -0
  4. package/LICENSE +21 -0
  5. package/README.md +42 -0
  6. package/dist/components/BadgeDisplay.d.ts +12 -0
  7. package/dist/components/BadgeDisplay.d.ts.map +1 -0
  8. package/dist/components/BadgeDisplay.js +45 -0
  9. package/dist/components/BadgeDisplay.js.map +1 -0
  10. package/dist/components/StreakCounter.d.ts +12 -0
  11. package/dist/components/StreakCounter.d.ts.map +1 -0
  12. package/dist/components/StreakCounter.js +46 -0
  13. package/dist/components/StreakCounter.js.map +1 -0
  14. package/dist/components/ViewTabs.d.ts +12 -0
  15. package/dist/components/ViewTabs.d.ts.map +1 -0
  16. package/dist/components/ViewTabs.js +49 -0
  17. package/dist/components/ViewTabs.js.map +1 -0
  18. package/dist/components/XpBar.d.ts +14 -0
  19. package/dist/components/XpBar.d.ts.map +1 -0
  20. package/dist/components/XpBar.js +47 -0
  21. package/dist/components/XpBar.js.map +1 -0
  22. package/dist/components/index.d.ts +5 -0
  23. package/dist/components/index.js +6 -0
  24. package/dist/docs/index.d.ts +1 -0
  25. package/dist/docs/index.js +1 -0
  26. package/dist/docs/learning-journey-ui-shared.docblock.d.ts +1 -0
  27. package/dist/docs/learning-journey-ui-shared.docblock.js +20 -0
  28. package/dist/docs/learning-journey-ui-shared.docblock.js.map +1 -0
  29. package/dist/example.d.ts +7 -0
  30. package/dist/example.d.ts.map +1 -0
  31. package/dist/example.js +42 -0
  32. package/dist/example.js.map +1 -0
  33. package/dist/hooks/index.d.ts +2 -0
  34. package/dist/hooks/index.js +3 -0
  35. package/dist/hooks/useLearningProgress.d.ts +22 -0
  36. package/dist/hooks/useLearningProgress.d.ts.map +1 -0
  37. package/dist/hooks/useLearningProgress.js +74 -0
  38. package/dist/hooks/useLearningProgress.js.map +1 -0
  39. package/dist/index.d.ts +9 -0
  40. package/dist/index.js +11 -0
  41. package/dist/types.d.ts +58 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +0 -0
  44. package/example.ts +1 -0
  45. package/package.json +72 -0
  46. package/src/components/BadgeDisplay.tsx +65 -0
  47. package/src/components/StreakCounter.tsx +49 -0
  48. package/src/components/ViewTabs.tsx +46 -0
  49. package/src/components/XpBar.tsx +54 -0
  50. package/src/components/index.ts +4 -0
  51. package/src/docs/index.ts +1 -0
  52. package/src/docs/learning-journey-ui-shared.docblock.ts +17 -0
  53. package/src/example.ts +31 -0
  54. package/src/hooks/index.ts +1 -0
  55. package/src/hooks/useLearningProgress.ts +101 -0
  56. package/src/index.ts +20 -0
  57. package/src/types.ts +61 -0
  58. package/tsconfig.json +9 -0
  59. package/tsconfig.tsbuildinfo +1 -0
  60. package/tsdown.config.js +17 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreakCounter.js","names":[],"sources":["../../src/components/StreakCounter.tsx"],"sourcesContent":["'use client';\n\nimport { cn } from '@contractspec/lib.ui-kit-web/ui/utils';\nimport type { StreakCounterProps } from '../types';\n\nconst sizeStyles = {\n sm: {\n container: 'gap-1 px-2 py-1',\n icon: 'text-base',\n text: 'text-xs',\n },\n md: {\n container: 'gap-1.5 px-3 py-1.5',\n icon: 'text-lg',\n text: 'text-sm',\n },\n lg: {\n container: 'gap-2 px-4 py-2',\n icon: 'text-xl',\n text: 'text-base',\n },\n};\n\nexport function StreakCounter({\n days,\n isActive = true,\n size = 'md',\n}: StreakCounterProps) {\n const styles = sizeStyles[size];\n\n return (\n <div\n className={cn(\n 'inline-flex items-center rounded-full font-semibold',\n styles.container,\n isActive\n ? 'bg-orange-500/10 text-orange-500'\n : 'bg-muted text-muted-foreground'\n )}\n >\n <span className={styles.icon} role=\"img\" aria-label=\"streak\">\n πŸ”₯\n </span>\n <span className={styles.text}>\n {days} {days === 1 ? 'day' : 'days'}\n </span>\n </div>\n );\n}\n"],"mappings":";;;;;;AAKA,MAAM,aAAa;CACjB,IAAI;EACF,WAAW;EACX,MAAM;EACN,MAAM;EACP;CACD,IAAI;EACF,WAAW;EACX,MAAM;EACN,MAAM;EACP;CACD,IAAI;EACF,WAAW;EACX,MAAM;EACN,MAAM;EACP;CACF;AAED,SAAgB,cAAc,EAC5B,MACA,WAAW,MACX,OAAO,QACc;CACrB,MAAM,SAAS,WAAW;AAE1B,QACE,qBAAC;EACC,WAAW,GACT,uDACA,OAAO,WACP,WACI,qCACA,iCACL;aAED,oBAAC;GAAK,WAAW,OAAO;GAAM,MAAK;GAAM,cAAW;aAAS;IAEtD,EACP,qBAAC;GAAK,WAAW,OAAO;;IACrB;IAAK;IAAE,SAAS,IAAI,QAAQ;;IACxB;GACH"}
@@ -0,0 +1,12 @@
1
+ import { ViewTabsProps } from "../types.js";
2
+ import * as react_jsx_runtime1 from "react/jsx-runtime";
3
+
4
+ //#region src/components/ViewTabs.d.ts
5
+ declare function ViewTabs({
6
+ currentView,
7
+ onViewChange,
8
+ availableViews
9
+ }: ViewTabsProps): react_jsx_runtime1.JSX.Element;
10
+ //#endregion
11
+ export { ViewTabs };
12
+ //# sourceMappingURL=ViewTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewTabs.d.ts","names":[],"sources":["../../src/components/ViewTabs.tsx"],"sourcesContent":[],"mappings":";;;;iBAmBgB,QAAA;;;;GAIb,gBAAa,kBAAA,CAAA,GAAA,CAAA"}
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ import { Button } from "@contractspec/lib.design-system";
5
+
6
+ //#region src/components/ViewTabs.tsx
7
+ const VIEW_LABELS = {
8
+ overview: {
9
+ label: "Overview",
10
+ icon: "πŸ“Š"
11
+ },
12
+ steps: {
13
+ label: "Steps",
14
+ icon: "πŸ“"
15
+ },
16
+ progress: {
17
+ label: "Progress",
18
+ icon: "πŸ“ˆ"
19
+ },
20
+ timeline: {
21
+ label: "Timeline",
22
+ icon: "πŸ“…"
23
+ }
24
+ };
25
+ const DEFAULT_VIEWS = [
26
+ "overview",
27
+ "steps",
28
+ "progress",
29
+ "timeline"
30
+ ];
31
+ function ViewTabs({ currentView, onViewChange, availableViews = DEFAULT_VIEWS }) {
32
+ return /* @__PURE__ */ jsx("div", {
33
+ className: "flex flex-wrap gap-2",
34
+ children: availableViews.map((view) => {
35
+ const { label, icon } = VIEW_LABELS[view];
36
+ return /* @__PURE__ */ jsxs(Button, {
37
+ variant: currentView === view ? "default" : "outline",
38
+ size: "sm",
39
+ onClick: () => onViewChange(view),
40
+ className: "gap-1.5",
41
+ children: [/* @__PURE__ */ jsx("span", { children: icon }), /* @__PURE__ */ jsx("span", { children: label })]
42
+ }, view);
43
+ })
44
+ });
45
+ }
46
+
47
+ //#endregion
48
+ export { ViewTabs };
49
+ //# sourceMappingURL=ViewTabs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewTabs.js","names":[],"sources":["../../src/components/ViewTabs.tsx"],"sourcesContent":["'use client';\n\nimport { Button } from '@contractspec/lib.design-system';\nimport type { ViewTabsProps, LearningView } from '../types';\n\nconst VIEW_LABELS: Record<LearningView, { label: string; icon: string }> = {\n overview: { label: 'Overview', icon: 'πŸ“Š' },\n steps: { label: 'Steps', icon: 'πŸ“' },\n progress: { label: 'Progress', icon: 'πŸ“ˆ' },\n timeline: { label: 'Timeline', icon: 'πŸ“…' },\n};\n\nconst DEFAULT_VIEWS: LearningView[] = [\n 'overview',\n 'steps',\n 'progress',\n 'timeline',\n];\n\nexport function ViewTabs({\n currentView,\n onViewChange,\n availableViews = DEFAULT_VIEWS,\n}: ViewTabsProps) {\n return (\n <div className=\"flex flex-wrap gap-2\">\n {availableViews.map((view) => {\n const { label, icon } = VIEW_LABELS[view];\n const isActive = currentView === view;\n\n return (\n <Button\n key={view}\n variant={isActive ? 'default' : 'outline'}\n size=\"sm\"\n onClick={() => onViewChange(view)}\n className=\"gap-1.5\"\n >\n <span>{icon}</span>\n <span>{label}</span>\n </Button>\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAqE;CACzE,UAAU;EAAE,OAAO;EAAY,MAAM;EAAM;CAC3C,OAAO;EAAE,OAAO;EAAS,MAAM;EAAM;CACrC,UAAU;EAAE,OAAO;EAAY,MAAM;EAAM;CAC3C,UAAU;EAAE,OAAO;EAAY,MAAM;EAAM;CAC5C;AAED,MAAM,gBAAgC;CACpC;CACA;CACA;CACA;CACD;AAED,SAAgB,SAAS,EACvB,aACA,cACA,iBAAiB,iBACD;AAChB,QACE,oBAAC;EAAI,WAAU;YACZ,eAAe,KAAK,SAAS;GAC5B,MAAM,EAAE,OAAO,SAAS,YAAY;AAGpC,UACE,qBAAC;IAEC,SALa,gBAAgB,OAKT,YAAY;IAChC,MAAK;IACL,eAAe,aAAa,KAAK;IACjC,WAAU;eAEV,oBAAC,oBAAM,OAAY,EACnB,oBAAC,oBAAM,QAAa;MAPf,KAQE;IAEX;GACE"}
@@ -0,0 +1,14 @@
1
+ import { XpBarProps } from "../types.js";
2
+ import * as react_jsx_runtime2 from "react/jsx-runtime";
3
+
4
+ //#region src/components/XpBar.d.ts
5
+ declare function XpBar({
6
+ current,
7
+ max,
8
+ level,
9
+ showLabel,
10
+ size
11
+ }: XpBarProps): react_jsx_runtime2.JSX.Element;
12
+ //#endregion
13
+ export { XpBar };
14
+ //# sourceMappingURL=XpBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XpBar.d.ts","names":[],"sources":["../../src/components/XpBar.tsx"],"sourcesContent":[],"mappings":";;;;iBAkBgB,KAAA;;;;;;GAMb,aAAU,kBAAA,CAAA,GAAA,CAAA"}
@@ -0,0 +1,47 @@
1
+ 'use client';
2
+
3
+ import { Progress } from "@contractspec/lib.ui-kit-web/ui/progress";
4
+ import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+
7
+ //#region src/components/XpBar.tsx
8
+ const sizeStyles = {
9
+ sm: "h-2",
10
+ md: "h-3",
11
+ lg: "h-4"
12
+ };
13
+ const labelSizeStyles = {
14
+ sm: "text-xs",
15
+ md: "text-sm",
16
+ lg: "text-base"
17
+ };
18
+ function XpBar({ current, max, level, showLabel = true, size = "md" }) {
19
+ const percentage = max > 0 ? Math.min(current / max * 100, 100) : 0;
20
+ return /* @__PURE__ */ jsxs("div", {
21
+ className: "w-full space-y-1",
22
+ children: [showLabel && /* @__PURE__ */ jsxs("div", {
23
+ className: cn("flex items-center justify-between", labelSizeStyles[size]),
24
+ children: [/* @__PURE__ */ jsxs("span", {
25
+ className: "text-muted-foreground font-medium",
26
+ children: [level !== void 0 && /* @__PURE__ */ jsxs("span", {
27
+ className: "text-primary mr-1",
28
+ children: ["Lvl ", level]
29
+ }), "XP"]
30
+ }), /* @__PURE__ */ jsxs("span", {
31
+ className: "font-semibold",
32
+ children: [
33
+ current.toLocaleString(),
34
+ " / ",
35
+ max.toLocaleString()
36
+ ]
37
+ })]
38
+ }), /* @__PURE__ */ jsx(Progress, {
39
+ value: percentage,
40
+ className: cn("bg-muted", sizeStyles[size])
41
+ })]
42
+ });
43
+ }
44
+
45
+ //#endregion
46
+ export { XpBar };
47
+ //# sourceMappingURL=XpBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XpBar.js","names":[],"sources":["../../src/components/XpBar.tsx"],"sourcesContent":["'use client';\n\nimport { Progress } from '@contractspec/lib.ui-kit-web/ui/progress';\nimport { cn } from '@contractspec/lib.ui-kit-web/ui/utils';\nimport type { XpBarProps } from '../types';\n\nconst sizeStyles = {\n sm: 'h-2',\n md: 'h-3',\n lg: 'h-4',\n};\n\nconst labelSizeStyles = {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-base',\n};\n\nexport function XpBar({\n current,\n max,\n level,\n showLabel = true,\n size = 'md',\n}: XpBarProps) {\n const percentage = max > 0 ? Math.min((current / max) * 100, 100) : 0;\n\n return (\n <div className=\"w-full space-y-1\">\n {showLabel && (\n <div\n className={cn(\n 'flex items-center justify-between',\n labelSizeStyles[size]\n )}\n >\n <span className=\"text-muted-foreground font-medium\">\n {level !== undefined && (\n <span className=\"text-primary mr-1\">Lvl {level}</span>\n )}\n XP\n </span>\n <span className=\"font-semibold\">\n {current.toLocaleString()} / {max.toLocaleString()}\n </span>\n </div>\n )}\n <Progress\n value={percentage}\n className={cn('bg-muted', sizeStyles[size])}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;AAMA,MAAM,aAAa;CACjB,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAED,MAAM,kBAAkB;CACtB,IAAI;CACJ,IAAI;CACJ,IAAI;CACL;AAED,SAAgB,MAAM,EACpB,SACA,KACA,OACA,YAAY,MACZ,OAAO,QACM;CACb,MAAM,aAAa,MAAM,IAAI,KAAK,IAAK,UAAU,MAAO,KAAK,IAAI,GAAG;AAEpE,QACE,qBAAC;EAAI,WAAU;aACZ,aACC,qBAAC;GACC,WAAW,GACT,qCACA,gBAAgB,MACjB;cAED,qBAAC;IAAK,WAAU;eACb,UAAU,UACT,qBAAC;KAAK,WAAU;gBAAoB,QAAK;MAAa,EACtD;KAEG,EACP,qBAAC;IAAK,WAAU;;KACb,QAAQ,gBAAgB;KAAC;KAAI,IAAI,gBAAgB;;KAC7C;IACH,EAER,oBAAC;GACC,OAAO;GACP,WAAW,GAAG,YAAY,WAAW,MAAM;IAC3C;GACE"}
@@ -0,0 +1,5 @@
1
+ import { BadgeDisplay } from "./BadgeDisplay.js";
2
+ import { StreakCounter } from "./StreakCounter.js";
3
+ import { ViewTabs } from "./ViewTabs.js";
4
+ import { XpBar } from "./XpBar.js";
5
+ export { BadgeDisplay, StreakCounter, ViewTabs, XpBar };
@@ -0,0 +1,6 @@
1
+ import { XpBar } from "./XpBar.js";
2
+ import { StreakCounter } from "./StreakCounter.js";
3
+ import { BadgeDisplay } from "./BadgeDisplay.js";
4
+ import { ViewTabs } from "./ViewTabs.js";
5
+
6
+ export { BadgeDisplay, StreakCounter, ViewTabs, XpBar };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ import "./learning-journey-ui-shared.docblock.js";
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,20 @@
1
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
2
+
3
+ //#region src/docs/learning-journey-ui-shared.docblock.ts
4
+ registerDocBlocks([{
5
+ id: "docs.examples.learning-journey-ui-shared",
6
+ title: "Learning Journey UI β€” Shared",
7
+ summary: "Shared UI components and hooks for learning journey mini-apps.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/learning-journey-ui-shared",
11
+ tags: [
12
+ "learning",
13
+ "ui",
14
+ "shared"
15
+ ],
16
+ body: `## Includes\n- Hooks: useLearningProgress\n- Components: XpBar, StreakCounter, BadgeDisplay, ViewTabs\n\n## Notes\n- Keep components accessible (labels, focus, contrast).\n- Prefer design-system tokens and components.`
17
+ }]);
18
+
19
+ //#endregion
20
+ //# sourceMappingURL=learning-journey-ui-shared.docblock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"learning-journey-ui-shared.docblock.js","names":[],"sources":["../../src/docs/learning-journey-ui-shared.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\nconst blocks: DocBlock[] = [\n {\n id: 'docs.examples.learning-journey-ui-shared',\n title: 'Learning Journey UI β€” Shared',\n summary: 'Shared UI components and hooks for learning journey mini-apps.',\n kind: 'reference',\n visibility: 'public',\n route: '/docs/examples/learning-journey-ui-shared',\n tags: ['learning', 'ui', 'shared'],\n body: `## Includes\\n- Hooks: useLearningProgress\\n- Components: XpBar, StreakCounter, BadgeDisplay, ViewTabs\\n\\n## Notes\\n- Keep components accessible (labels, focus, contrast).\\n- Prefer design-system tokens and components.`,\n },\n];\n\nregisterDocBlocks(blocks);\n"],"mappings":";;;AAgBA,kBAb2B,CACzB;CACE,IAAI;CACJ,OAAO;CACP,SAAS;CACT,MAAM;CACN,YAAY;CACZ,OAAO;CACP,MAAM;EAAC;EAAY;EAAM;EAAS;CAClC,MAAM;CACP,CACF,CAEwB"}
@@ -0,0 +1,7 @@
1
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
+
3
+ //#region src/example.d.ts
4
+ declare const example: _contractspec_lib_contracts0.ExampleSpec;
5
+ //#endregion
6
+ export { example as default };
7
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","names":[],"sources":["../src/example.ts"],"sourcesContent":[],"mappings":";;;cAEM,SA0BJ,4BAAA,CA1BW"}
@@ -0,0 +1,42 @@
1
+ import { defineExample } from "@contractspec/lib.contracts";
2
+
3
+ //#region src/example.ts
4
+ const example = defineExample({
5
+ meta: {
6
+ key: "learning-journey-ui-shared",
7
+ version: "1.0.0",
8
+ title: "Learning Journey UI β€” Shared",
9
+ description: "Shared UI components and hooks for learning journey mini-apps.",
10
+ kind: "ui",
11
+ visibility: "public",
12
+ stability: "experimental",
13
+ owners: ["@platform.core"],
14
+ tags: [
15
+ "learning",
16
+ "ui",
17
+ "shared"
18
+ ]
19
+ },
20
+ docs: { rootDocId: "docs.examples.learning-journey-ui-shared" },
21
+ entrypoints: {
22
+ packageName: "@contractspec/example.learning-journey-ui-shared",
23
+ docs: "./docs"
24
+ },
25
+ surfaces: {
26
+ templates: true,
27
+ sandbox: {
28
+ enabled: true,
29
+ modes: ["playground", "markdown"]
30
+ },
31
+ studio: {
32
+ enabled: true,
33
+ installable: true
34
+ },
35
+ mcp: { enabled: true }
36
+ }
37
+ });
38
+ var example_default = example;
39
+
40
+ //#endregion
41
+ export { example_default as default };
42
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\nconst example = defineExample({\n meta: {\n key: 'learning-journey-ui-shared',\n version: '1.0.0',\n title: 'Learning Journey UI β€” Shared',\n description:\n 'Shared UI components and hooks for learning journey mini-apps.',\n kind: 'ui',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@platform.core'],\n tags: ['learning', 'ui', 'shared'],\n },\n docs: {\n rootDocId: 'docs.examples.learning-journey-ui-shared',\n },\n entrypoints: {\n packageName: '@contractspec/example.learning-journey-ui-shared',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: { enabled: true, modes: ['playground', 'markdown'] },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n});\n\nexport default example;\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAY;GAAM;GAAS;EACnC;CACD,MAAM,EACJ,WAAW,4CACZ;CACD,aAAa;EACX,aAAa;EACb,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GAAE,SAAS;GAAM,OAAO,CAAC,cAAc,WAAW;GAAE;EAC7D,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF,CAAC;AAEF,sBAAe"}
@@ -0,0 +1,2 @@
1
+ import { useLearningProgress } from "./useLearningProgress.js";
2
+ export { useLearningProgress };
@@ -0,0 +1,3 @@
1
+ import { useLearningProgress } from "./useLearningProgress.js";
2
+
3
+ export { useLearningProgress };
@@ -0,0 +1,22 @@
1
+ import { LearningProgressState } from "../types.js";
2
+ import { LearningJourneyTrackSpec } from "@contractspec/module.learning-journey/track-spec";
3
+
4
+ //#region src/hooks/useLearningProgress.d.ts
5
+ /** Hook for managing learning progress state */
6
+ declare function useLearningProgress(track: LearningJourneyTrackSpec): {
7
+ progress: LearningProgressState;
8
+ stats: {
9
+ totalSteps: number;
10
+ completedSteps: number;
11
+ remainingSteps: number;
12
+ percentComplete: number;
13
+ totalXp: number;
14
+ isComplete: boolean;
15
+ };
16
+ completeStep: (stepId: string) => void;
17
+ resetProgress: () => void;
18
+ incrementStreak: () => void;
19
+ };
20
+ //#endregion
21
+ export { useLearningProgress };
22
+ //# sourceMappingURL=useLearningProgress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLearningProgress.d.ts","names":[],"sources":["../../src/hooks/useLearningProgress.ts"],"sourcesContent":[],"mappings":";;;;;iBAoBgB,mBAAA,QAA2B;EAA3B,QAAA,EAA2B,qBAAR"}
@@ -0,0 +1,74 @@
1
+ 'use client';
2
+
3
+ import { useCallback, useMemo, useState } from "react";
4
+
5
+ //#region src/hooks/useLearningProgress.ts
6
+ /** Default progress state for a new track */
7
+ function createDefaultProgress(trackId) {
8
+ return {
9
+ trackId,
10
+ completedStepIds: [],
11
+ currentStepId: null,
12
+ xpEarned: 0,
13
+ streakDays: 0,
14
+ lastActivityDate: null,
15
+ badges: []
16
+ };
17
+ }
18
+ /** Hook for managing learning progress state */
19
+ function useLearningProgress(track) {
20
+ const [progress, setProgress] = useState(() => createDefaultProgress(track.id));
21
+ const completeStep = useCallback((stepId) => {
22
+ const step = track.steps.find((s) => s.id === stepId);
23
+ if (!step || progress.completedStepIds.includes(stepId)) return;
24
+ setProgress((prev) => {
25
+ const newCompletedIds = [...prev.completedStepIds, stepId];
26
+ const xpReward = step.xpReward ?? 0;
27
+ const nextStep = track.steps.find((s) => !newCompletedIds.includes(s.id));
28
+ const isTrackComplete = newCompletedIds.length === track.steps.length;
29
+ const completionBonus = isTrackComplete ? track.completionRewards?.xpBonus ?? 0 : 0;
30
+ return {
31
+ ...prev,
32
+ completedStepIds: newCompletedIds,
33
+ currentStepId: nextStep?.id ?? null,
34
+ xpEarned: prev.xpEarned + xpReward + completionBonus,
35
+ lastActivityDate: (/* @__PURE__ */ new Date()).toISOString(),
36
+ badges: isTrackComplete && track.completionRewards?.badgeKey ? [...prev.badges, track.completionRewards.badgeKey] : prev.badges
37
+ };
38
+ });
39
+ }, [track, progress.completedStepIds]);
40
+ const resetProgress = useCallback(() => {
41
+ setProgress(createDefaultProgress(track.id));
42
+ }, [track.id]);
43
+ const incrementStreak = useCallback(() => {
44
+ setProgress((prev) => ({
45
+ ...prev,
46
+ streakDays: prev.streakDays + 1,
47
+ lastActivityDate: (/* @__PURE__ */ new Date()).toISOString()
48
+ }));
49
+ }, []);
50
+ return {
51
+ progress,
52
+ stats: useMemo(() => {
53
+ const totalSteps = track.steps.length;
54
+ const completedSteps = progress.completedStepIds.length;
55
+ const percentComplete = totalSteps > 0 ? Math.round(completedSteps / totalSteps * 100) : 0;
56
+ const totalXp = track.totalXp ?? track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) + (track.completionRewards?.xpBonus ?? 0);
57
+ return {
58
+ totalSteps,
59
+ completedSteps,
60
+ remainingSteps: totalSteps - completedSteps,
61
+ percentComplete,
62
+ totalXp,
63
+ isComplete: completedSteps === totalSteps
64
+ };
65
+ }, [track, progress.completedStepIds]),
66
+ completeStep,
67
+ resetProgress,
68
+ incrementStreak
69
+ };
70
+ }
71
+
72
+ //#endregion
73
+ export { useLearningProgress };
74
+ //# sourceMappingURL=useLearningProgress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLearningProgress.js","names":[],"sources":["../../src/hooks/useLearningProgress.ts"],"sourcesContent":["'use client';\n\nimport { useState, useCallback, useMemo } from 'react';\nimport type { LearningJourneyTrackSpec } from '@contractspec/module.learning-journey/track-spec';\nimport type { LearningProgressState } from '../types';\n\n/** Default progress state for a new track */\nfunction createDefaultProgress(trackId: string): LearningProgressState {\n return {\n trackId,\n completedStepIds: [],\n currentStepId: null,\n xpEarned: 0,\n streakDays: 0,\n lastActivityDate: null,\n badges: [],\n };\n}\n\n/** Hook for managing learning progress state */\nexport function useLearningProgress(track: LearningJourneyTrackSpec) {\n const [progress, setProgress] = useState<LearningProgressState>(() =>\n createDefaultProgress(track.id)\n );\n\n const completeStep = useCallback(\n (stepId: string) => {\n const step = track.steps.find((s) => s.id === stepId);\n if (!step || progress.completedStepIds.includes(stepId)) return;\n\n setProgress((prev) => {\n const newCompletedIds = [...prev.completedStepIds, stepId];\n const xpReward = step.xpReward ?? 0;\n\n // Find next incomplete step\n const nextStep = track.steps.find(\n (s) => !newCompletedIds.includes(s.id)\n );\n\n // Check if track is complete\n const isTrackComplete = newCompletedIds.length === track.steps.length;\n const completionBonus = isTrackComplete\n ? (track.completionRewards?.xpBonus ?? 0)\n : 0;\n\n return {\n ...prev,\n completedStepIds: newCompletedIds,\n currentStepId: nextStep?.id ?? null,\n xpEarned: prev.xpEarned + xpReward + completionBonus,\n lastActivityDate: new Date().toISOString(),\n badges:\n isTrackComplete && track.completionRewards?.badgeKey\n ? [...prev.badges, track.completionRewards.badgeKey]\n : prev.badges,\n };\n });\n },\n [track, progress.completedStepIds]\n );\n\n const resetProgress = useCallback(() => {\n setProgress(createDefaultProgress(track.id));\n }, [track.id]);\n\n const incrementStreak = useCallback(() => {\n setProgress((prev) => ({\n ...prev,\n streakDays: prev.streakDays + 1,\n lastActivityDate: new Date().toISOString(),\n }));\n }, []);\n\n const stats = useMemo(() => {\n const totalSteps = track.steps.length;\n const completedSteps = progress.completedStepIds.length;\n const percentComplete =\n totalSteps > 0 ? Math.round((completedSteps / totalSteps) * 100) : 0;\n const totalXp =\n track.totalXp ??\n track.steps.reduce((sum, s) => sum + (s.xpReward ?? 0), 0) +\n (track.completionRewards?.xpBonus ?? 0);\n\n return {\n totalSteps,\n completedSteps,\n remainingSteps: totalSteps - completedSteps,\n percentComplete,\n totalXp,\n isComplete: completedSteps === totalSteps,\n };\n }, [track, progress.completedStepIds]);\n\n return {\n progress,\n stats,\n completeStep,\n resetProgress,\n incrementStreak,\n };\n}\n"],"mappings":";;;;;;AAOA,SAAS,sBAAsB,SAAwC;AACrE,QAAO;EACL;EACA,kBAAkB,EAAE;EACpB,eAAe;EACf,UAAU;EACV,YAAY;EACZ,kBAAkB;EAClB,QAAQ,EAAE;EACX;;;AAIH,SAAgB,oBAAoB,OAAiC;CACnE,MAAM,CAAC,UAAU,eAAe,eAC9B,sBAAsB,MAAM,GAAG,CAChC;CAED,MAAM,eAAe,aAClB,WAAmB;EAClB,MAAM,OAAO,MAAM,MAAM,MAAM,MAAM,EAAE,OAAO,OAAO;AACrD,MAAI,CAAC,QAAQ,SAAS,iBAAiB,SAAS,OAAO,CAAE;AAEzD,eAAa,SAAS;GACpB,MAAM,kBAAkB,CAAC,GAAG,KAAK,kBAAkB,OAAO;GAC1D,MAAM,WAAW,KAAK,YAAY;GAGlC,MAAM,WAAW,MAAM,MAAM,MAC1B,MAAM,CAAC,gBAAgB,SAAS,EAAE,GAAG,CACvC;GAGD,MAAM,kBAAkB,gBAAgB,WAAW,MAAM,MAAM;GAC/D,MAAM,kBAAkB,kBACnB,MAAM,mBAAmB,WAAW,IACrC;AAEJ,UAAO;IACL,GAAG;IACH,kBAAkB;IAClB,eAAe,UAAU,MAAM;IAC/B,UAAU,KAAK,WAAW,WAAW;IACrC,mCAAkB,IAAI,MAAM,EAAC,aAAa;IAC1C,QACE,mBAAmB,MAAM,mBAAmB,WACxC,CAAC,GAAG,KAAK,QAAQ,MAAM,kBAAkB,SAAS,GAClD,KAAK;IACZ;IACD;IAEJ,CAAC,OAAO,SAAS,iBAAiB,CACnC;CAED,MAAM,gBAAgB,kBAAkB;AACtC,cAAY,sBAAsB,MAAM,GAAG,CAAC;IAC3C,CAAC,MAAM,GAAG,CAAC;CAEd,MAAM,kBAAkB,kBAAkB;AACxC,eAAa,UAAU;GACrB,GAAG;GACH,YAAY,KAAK,aAAa;GAC9B,mCAAkB,IAAI,MAAM,EAAC,aAAa;GAC3C,EAAE;IACF,EAAE,CAAC;AAsBN,QAAO;EACL;EACA,OAtBY,cAAc;GAC1B,MAAM,aAAa,MAAM,MAAM;GAC/B,MAAM,iBAAiB,SAAS,iBAAiB;GACjD,MAAM,kBACJ,aAAa,IAAI,KAAK,MAAO,iBAAiB,aAAc,IAAI,GAAG;GACrE,MAAM,UACJ,MAAM,WACN,MAAM,MAAM,QAAQ,KAAK,MAAM,OAAO,EAAE,YAAY,IAAI,EAAE,IACvD,MAAM,mBAAmB,WAAW;AAEzC,UAAO;IACL;IACA;IACA,gBAAgB,aAAa;IAC7B;IACA;IACA,YAAY,mBAAmB;IAChC;KACA,CAAC,OAAO,SAAS,iBAAiB,CAAC;EAKpC;EACA;EACA;EACD"}
@@ -0,0 +1,9 @@
1
+ import { BadgeDisplayProps, LearningMiniAppProps, LearningProgressState, LearningView, LearningViewProps, StreakCounterProps, ViewTabsProps, XpBarProps } from "./types.js";
2
+ import { BadgeDisplay } from "./components/BadgeDisplay.js";
3
+ import { StreakCounter } from "./components/StreakCounter.js";
4
+ import { ViewTabs } from "./components/ViewTabs.js";
5
+ import { XpBar } from "./components/XpBar.js";
6
+ import "./components/index.js";
7
+ import example from "./example.js";
8
+ import { useLearningProgress } from "./hooks/useLearningProgress.js";
9
+ export { BadgeDisplay, type BadgeDisplayProps, type LearningMiniAppProps, type LearningProgressState, type LearningView, type LearningViewProps, StreakCounter, type StreakCounterProps, ViewTabs, type ViewTabsProps, XpBar, type XpBarProps, example, useLearningProgress };
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import example_default from "./example.js";
2
+ import { useLearningProgress } from "./hooks/useLearningProgress.js";
3
+ import "./hooks/index.js";
4
+ import { XpBar } from "./components/XpBar.js";
5
+ import { StreakCounter } from "./components/StreakCounter.js";
6
+ import { BadgeDisplay } from "./components/BadgeDisplay.js";
7
+ import { ViewTabs } from "./components/ViewTabs.js";
8
+ import "./components/index.js";
9
+ import "./docs/index.js";
10
+
11
+ export { BadgeDisplay, StreakCounter, ViewTabs, XpBar, example_default as example, useLearningProgress };
@@ -0,0 +1,58 @@
1
+ import { LearningJourneyTrackSpec } from "@contractspec/module.learning-journey/track-spec";
2
+
3
+ //#region src/types.d.ts
4
+ /** View types for learning mini-apps */
5
+ type LearningView = 'overview' | 'steps' | 'progress' | 'timeline';
6
+ /** Progress state for a learning track */
7
+ interface LearningProgressState {
8
+ trackId: string;
9
+ completedStepIds: string[];
10
+ currentStepId: string | null;
11
+ xpEarned: number;
12
+ streakDays: number;
13
+ lastActivityDate: string | null;
14
+ badges: string[];
15
+ }
16
+ /** Props for mini-app components */
17
+ interface LearningMiniAppProps {
18
+ track: LearningJourneyTrackSpec;
19
+ progress: LearningProgressState;
20
+ onStepComplete?: (stepId: string) => void;
21
+ onViewChange?: (view: LearningView) => void;
22
+ initialView?: LearningView;
23
+ }
24
+ /** Props for view components */
25
+ interface LearningViewProps {
26
+ track: LearningJourneyTrackSpec;
27
+ progress: LearningProgressState;
28
+ onStepComplete?: (stepId: string) => void;
29
+ }
30
+ /** XP bar props */
31
+ interface XpBarProps {
32
+ current: number;
33
+ max: number;
34
+ level?: number;
35
+ showLabel?: boolean;
36
+ size?: 'sm' | 'md' | 'lg';
37
+ }
38
+ /** Streak counter props */
39
+ interface StreakCounterProps {
40
+ days: number;
41
+ isActive?: boolean;
42
+ size?: 'sm' | 'md' | 'lg';
43
+ }
44
+ /** Badge display props */
45
+ interface BadgeDisplayProps {
46
+ badges: string[];
47
+ maxVisible?: number;
48
+ size?: 'sm' | 'md' | 'lg';
49
+ }
50
+ /** View tabs props */
51
+ interface ViewTabsProps {
52
+ currentView: LearningView;
53
+ onViewChange: (view: LearningView) => void;
54
+ availableViews?: LearningView[];
55
+ }
56
+ //#endregion
57
+ export { BadgeDisplayProps, LearningMiniAppProps, LearningProgressState, LearningView, LearningViewProps, StreakCounterProps, ViewTabsProps, XpBarProps };
58
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;KAGY,YAAA;AAAZ;AAGiB,UAAA,qBAAA,CAAqB;EAWrB,OAAA,EAAA,MAAA;EACR,gBAAA,EAAA,MAAA,EAAA;EACG,aAAA,EAAA,MAAA,GAAA,IAAA;EAEY,QAAA,EAAA,MAAA;EACR,UAAA,EAAA,MAAA;EAAY,gBAAA,EAAA,MAAA,GAAA,IAAA;EAIX,MAAA,EAAA,MAAA,EAAA;AAOjB;AASA;AAOiB,UAhCA,oBAAA,CAgCiB;EAOjB,KAAA,EAtCR,wBAsCqB;EACf,QAAA,EAtCH,qBAsCG;EACQ,cAAA,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EACJ,YAAA,CAAA,EAAA,CAAA,IAAA,EAtCK,YAsCL,EAAA,GAAA,IAAA;EAAY,WAAA,CAAA,EArCf,YAqCe;;;UAjCd,iBAAA;SACR;YACG;;;;UAKK,UAAA;;;;;;;;UASA,kBAAA;;;;;;UAOA,iBAAA;;;;;;UAOA,aAAA;eACF;uBACQ;mBACJ"}
package/dist/types.js ADDED
File without changes
package/example.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './src/example';
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@contractspec/example.learning-journey-ui-shared",
3
+ "version": "0.0.0-canary-20260113170453",
4
+ "description": "Shared UI components and hooks for learning journey mini-apps.",
5
+ "type": "module",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.js",
9
+ "./components": "./dist/components/index.js",
10
+ "./components/BadgeDisplay": "./dist/components/BadgeDisplay.js",
11
+ "./components/StreakCounter": "./dist/components/StreakCounter.js",
12
+ "./components/ViewTabs": "./dist/components/ViewTabs.js",
13
+ "./components/XpBar": "./dist/components/XpBar.js",
14
+ "./docs": "./dist/docs/index.js",
15
+ "./docs/learning-journey-ui-shared.docblock": "./dist/docs/learning-journey-ui-shared.docblock.js",
16
+ "./example": "./dist/example.js",
17
+ "./hooks": "./dist/hooks/index.js",
18
+ "./hooks/useLearningProgress": "./dist/hooks/useLearningProgress.js",
19
+ "./types": "./dist/types.js",
20
+ "./*": "./*"
21
+ },
22
+ "scripts": {
23
+ "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
24
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
25
+ "build": "bun build:types && bun build:bundle",
26
+ "build:bundle": "tsdown",
27
+ "build:types": "tsc --noEmit",
28
+ "dev": "bun build:bundle --watch",
29
+ "clean": "rimraf dist .turbo",
30
+ "lint": "bun lint:fix",
31
+ "lint:fix": "eslint src --fix",
32
+ "lint:check": "eslint src",
33
+ "test": "bun test"
34
+ },
35
+ "dependencies": {
36
+ "@contractspec/lib.contracts": "0.0.0-canary-20260113170453",
37
+ "@contractspec/module.learning-journey": "0.0.0-canary-20260113170453",
38
+ "@contractspec/lib.design-system": "0.0.0-canary-20260113170453",
39
+ "@contractspec/lib.ui-kit-web": "0.0.0-canary-20260113170453",
40
+ "react": "19.2.3"
41
+ },
42
+ "devDependencies": {
43
+ "@contractspec/tool.tsdown": "0.0.0-canary-20260113170453",
44
+ "@contractspec/tool.typescript": "0.0.0-canary-20260113170453",
45
+ "@types/react": "^19.2.8",
46
+ "tsdown": "^0.19.0",
47
+ "typescript": "^5.9.3"
48
+ },
49
+ "peerDependencies": {
50
+ "react": "^19.2.3"
51
+ },
52
+ "publishConfig": {
53
+ "exports": {
54
+ ".": "./dist/index.js",
55
+ "./example": "./dist/example.js",
56
+ "./docs": "./dist/docs/index.js",
57
+ "./hooks": "./dist/hooks/index.js",
58
+ "./components": "./dist/components/index.js",
59
+ "./types": "./dist/types.js",
60
+ "./*": "./*"
61
+ },
62
+ "registry": "https://registry.npmjs.org/",
63
+ "access": "public"
64
+ },
65
+ "license": "MIT",
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "https://github.com/lssm-tech/contractspec.git",
69
+ "directory": "packages/examples/learning-journey-ui-shared"
70
+ },
71
+ "homepage": "https://contractspec.io"
72
+ }
@@ -0,0 +1,65 @@
1
+ 'use client';
2
+
3
+ import { cn } from '@contractspec/lib.ui-kit-web/ui/utils';
4
+ import type { BadgeDisplayProps } from '../types';
5
+
6
+ const BADGE_ICONS: Record<string, string> = {
7
+ studio_first_30m: '🎯',
8
+ platform_tour: 'πŸ—ΊοΈ',
9
+ crm_first_win: 'πŸ†',
10
+ drill_master: '🧠',
11
+ coach_listener: 'πŸ‘‚',
12
+ quest_complete: '⭐',
13
+ streak_7: 'πŸ”₯',
14
+ streak_30: 'πŸ’Ž',
15
+ default: 'πŸ…',
16
+ };
17
+
18
+ const sizeStyles = {
19
+ sm: 'h-6 w-6 text-sm',
20
+ md: 'h-8 w-8 text-base',
21
+ lg: 'h-10 w-10 text-lg',
22
+ };
23
+
24
+ export function BadgeDisplay({
25
+ badges,
26
+ maxVisible = 5,
27
+ size = 'md',
28
+ }: BadgeDisplayProps) {
29
+ const visibleBadges = badges.slice(0, maxVisible);
30
+ const hiddenCount = badges.length - maxVisible;
31
+
32
+ if (badges.length === 0) {
33
+ return (
34
+ <div className="text-muted-foreground text-sm">No badges earned yet</div>
35
+ );
36
+ }
37
+
38
+ return (
39
+ <div className="flex items-center gap-1">
40
+ {visibleBadges.map((badge) => (
41
+ <div
42
+ key={badge}
43
+ className={cn(
44
+ 'flex items-center justify-center rounded-full bg-gradient-to-br from-amber-400/20 to-amber-600/20',
45
+ sizeStyles[size]
46
+ )}
47
+ title={badge.replace(/_/g, ' ')}
48
+ >
49
+ {BADGE_ICONS[badge] ?? BADGE_ICONS.default}
50
+ </div>
51
+ ))}
52
+ {hiddenCount > 0 && (
53
+ <div
54
+ className={cn(
55
+ 'text-muted-foreground bg-muted flex items-center justify-center rounded-full',
56
+ sizeStyles[size],
57
+ 'text-xs font-medium'
58
+ )}
59
+ >
60
+ +{hiddenCount}
61
+ </div>
62
+ )}
63
+ </div>
64
+ );
65
+ }