@forwardimpact/pathway 0.22.0 → 0.23.1

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 (78) hide show
  1. package/bin/fit-pathway.js +8 -4
  2. package/package.json +6 -2
  3. package/src/commands/agent.js +6 -3
  4. package/src/commands/behaviour.js +11 -1
  5. package/src/commands/build.js +11 -2
  6. package/src/commands/command-factory.js +4 -2
  7. package/src/commands/dev.js +9 -2
  8. package/src/commands/discipline.js +25 -10
  9. package/src/commands/driver.js +11 -1
  10. package/src/commands/job.js +127 -28
  11. package/src/commands/level.js +25 -3
  12. package/src/commands/skill.js +11 -1
  13. package/src/commands/stage.js +11 -1
  14. package/src/commands/tool.js +6 -3
  15. package/src/commands/track.js +20 -4
  16. package/src/components/card.js +8 -104
  17. package/src/components/comparison-radar.js +1 -1
  18. package/src/components/detail.js +16 -118
  19. package/src/components/error-page.js +8 -68
  20. package/src/components/grid.js +12 -106
  21. package/src/components/list.js +7 -116
  22. package/src/components/nav.js +7 -60
  23. package/src/css/bundles/app.css +25 -21
  24. package/src/css/bundles/handout.css +33 -33
  25. package/src/css/bundles/slides.css +25 -25
  26. package/src/formatters/discipline/markdown.js +16 -1
  27. package/src/formatters/interview/shared.js +3 -3
  28. package/src/formatters/job/description.js +2 -2
  29. package/src/formatters/progress/shared.js +3 -3
  30. package/src/formatters/skill/shared.js +1 -1
  31. package/src/formatters/track/markdown.js +14 -0
  32. package/src/formatters/track/shared.js +1 -1
  33. package/src/handout.html +32 -13
  34. package/src/index.html +32 -13
  35. package/src/lib/error-boundary.js +3 -66
  36. package/src/lib/errors.js +7 -45
  37. package/src/lib/job-cache.js +1 -1
  38. package/src/lib/markdown.js +2 -109
  39. package/src/lib/reactive.js +7 -73
  40. package/src/lib/render.js +49 -197
  41. package/src/lib/router-core.js +2 -156
  42. package/src/lib/router-pages.js +2 -11
  43. package/src/lib/router-slides.js +2 -197
  44. package/src/lib/state.js +14 -63
  45. package/src/lib/utils.js +3 -10
  46. package/src/lib/yaml-loader.js +13 -71
  47. package/src/pages/agent-builder.js +1 -1
  48. package/src/pages/assessment-results.js +1 -1
  49. package/src/pages/job-builder.js +1 -1
  50. package/src/pages/job.js +1 -1
  51. package/src/pages/skill.js +1 -1
  52. package/src/slide-main.js +1 -1
  53. package/src/slides/index.js +1 -1
  54. package/src/slides/job.js +1 -1
  55. package/src/slides/overview.js +1 -1
  56. package/src/slides.html +32 -13
  57. package/src/css/base.css +0 -56
  58. package/src/css/components/badges.css +0 -232
  59. package/src/css/components/buttons.css +0 -101
  60. package/src/css/components/forms.css +0 -191
  61. package/src/css/components/layout.css +0 -218
  62. package/src/css/components/nav.css +0 -206
  63. package/src/css/components/progress.css +0 -166
  64. package/src/css/components/states.css +0 -82
  65. package/src/css/components/surfaces.css +0 -347
  66. package/src/css/components/tables.css +0 -362
  67. package/src/css/components/top-bar.css +0 -180
  68. package/src/css/components/typography.css +0 -121
  69. package/src/css/components/utilities.css +0 -41
  70. package/src/css/pages/detail.css +0 -119
  71. package/src/css/reset.css +0 -50
  72. package/src/css/tokens.css +0 -162
  73. package/src/css/views/handout.css +0 -30
  74. package/src/css/views/print.css +0 -634
  75. package/src/css/views/slide-animations.css +0 -113
  76. package/src/css/views/slide-base.css +0 -331
  77. package/src/css/views/slide-sections.css +0 -597
  78. package/src/css/views/slide-tables.css +0 -275
@@ -1,70 +1,7 @@
1
1
  /**
2
2
  * Error boundary wrapper for page rendering
3
+ *
4
+ * Re-exports from @forwardimpact/libui/error-boundary.
3
5
  */
4
6
 
5
- import { renderNotFound, renderError } from "../components/error-page.js";
6
- import { NotFoundError, InvalidCombinationError } from "./errors.js";
7
-
8
- /**
9
- * @typedef {Object} ErrorBoundaryOptions
10
- * @property {(error: Error) => void} [onError] - Error callback for logging
11
- * @property {string} [backPath] - Default back path
12
- * @property {string} [backText] - Default back text
13
- * @property {(title: string, message: string) => void} [renderErrorFn] - Custom error renderer
14
- */
15
-
16
- /**
17
- * Wrap a render function with error handling
18
- * @param {Function} renderFn - Page render function
19
- * @param {ErrorBoundaryOptions} [options]
20
- * @returns {Function}
21
- */
22
- export function withErrorBoundary(renderFn, options = {}) {
23
- const errorRenderer =
24
- options.renderErrorFn ||
25
- ((title, message) => {
26
- renderError({
27
- title,
28
- message,
29
- backPath: options.backPath || "/",
30
- backText: options.backText || "← Back to Home",
31
- });
32
- });
33
-
34
- return (...args) => {
35
- try {
36
- return renderFn(...args);
37
- } catch (error) {
38
- console.error("Page render error:", error);
39
-
40
- options.onError?.(error);
41
-
42
- if (error instanceof NotFoundError) {
43
- if (options.renderErrorFn) {
44
- errorRenderer(
45
- `${error.entityType} Not Found`,
46
- `No ${error.entityType.toLowerCase()} found with ID: ${error.entityId}`,
47
- );
48
- } else {
49
- renderNotFound({
50
- entityType: error.entityType,
51
- entityId: error.entityId,
52
- backPath: error.backPath,
53
- backText: `← Back to ${error.entityType}s`,
54
- });
55
- }
56
- return;
57
- }
58
-
59
- if (error instanceof InvalidCombinationError) {
60
- errorRenderer("Invalid Combination", error.message);
61
- return;
62
- }
63
-
64
- errorRenderer(
65
- "Something Went Wrong",
66
- error.message || "An unexpected error occurred.",
67
- );
68
- }
69
- };
70
- }
7
+ export { withErrorBoundary } from "@forwardimpact/libui/error-boundary";
package/src/lib/errors.js CHANGED
@@ -1,49 +1,11 @@
1
1
  /**
2
2
  * Custom error types for the application
3
+ *
4
+ * Re-exports from @forwardimpact/libui/errors.
3
5
  */
4
6
 
5
- /**
6
- * Entity not found error
7
- */
8
- export class NotFoundError extends Error {
9
- /**
10
- * @param {string} entityType - Type of entity (e.g., 'Skill', 'Behaviour')
11
- * @param {string} entityId - ID that was not found
12
- * @param {string} backPath - Path to navigate back to
13
- */
14
- constructor(entityType, entityId, backPath) {
15
- super(`${entityType} not found: ${entityId}`);
16
- this.name = "NotFoundError";
17
- this.entityType = entityType;
18
- this.entityId = entityId;
19
- this.backPath = backPath;
20
- }
21
- }
22
-
23
- /**
24
- * Invalid combination error (e.g., invalid job configuration)
25
- */
26
- export class InvalidCombinationError extends Error {
27
- /**
28
- * @param {string} message - Error message
29
- * @param {string} backPath - Path to navigate back to
30
- */
31
- constructor(message, backPath) {
32
- super(message);
33
- this.name = "InvalidCombinationError";
34
- this.backPath = backPath;
35
- }
36
- }
37
-
38
- /**
39
- * Data loading error
40
- */
41
- export class DataLoadError extends Error {
42
- /**
43
- * @param {string} message - Error message
44
- */
45
- constructor(message) {
46
- super(message);
47
- this.name = "DataLoadError";
48
- }
49
- }
7
+ export {
8
+ NotFoundError,
9
+ InvalidCombinationError,
10
+ DataLoadError,
11
+ } from "@forwardimpact/libui/errors";
@@ -5,7 +5,7 @@
5
5
  * Provides consistent key generation and get-or-create pattern.
6
6
  */
7
7
 
8
- import { deriveJob } from "@forwardimpact/libpathway/derivation";
8
+ import { deriveJob } from "@forwardimpact/libskill/derivation";
9
9
 
10
10
  /** @type {Map<string, Object>} */
11
11
  const cache = new Map();
@@ -1,114 +1,7 @@
1
1
  /**
2
2
  * Simple Markdown to HTML converter
3
3
  *
4
- * Converts common markdown syntax to HTML. Designed for job descriptions
5
- * with headings, lists, bold text, and paragraphs.
4
+ * Re-exports from @forwardimpact/libui/markdown.
6
5
  */
7
6
 
8
- /**
9
- * Convert markdown text to HTML
10
- * @param {string} markdown - The markdown text to convert
11
- * @returns {string} HTML string
12
- */
13
- export function markdownToHtml(markdown) {
14
- const lines = markdown.split("\n");
15
- const htmlLines = [];
16
- let inList = false;
17
-
18
- for (let i = 0; i < lines.length; i++) {
19
- let line = lines[i];
20
-
21
- // Skip empty lines but close list if open
22
- if (line.trim() === "") {
23
- if (inList) {
24
- htmlLines.push("</ul>");
25
- inList = false;
26
- }
27
- continue;
28
- }
29
-
30
- // H1 heading
31
- if (line.startsWith("# ")) {
32
- if (inList) {
33
- htmlLines.push("</ul>");
34
- inList = false;
35
- }
36
- htmlLines.push(`<h1>${escapeHtml(line.slice(2))}</h1>`);
37
- continue;
38
- }
39
-
40
- // H2 heading
41
- if (line.startsWith("## ")) {
42
- if (inList) {
43
- htmlLines.push("</ul>");
44
- inList = false;
45
- }
46
- htmlLines.push(`<h2>${escapeHtml(line.slice(3))}</h2>`);
47
- continue;
48
- }
49
-
50
- // H3 heading
51
- if (line.startsWith("### ")) {
52
- if (inList) {
53
- htmlLines.push("</ul>");
54
- inList = false;
55
- }
56
- htmlLines.push(`<h3>${escapeHtml(line.slice(4))}</h3>`);
57
- continue;
58
- }
59
-
60
- // List item
61
- if (line.startsWith("- ")) {
62
- if (!inList) {
63
- htmlLines.push("<ul>");
64
- inList = true;
65
- }
66
- const content = formatInlineMarkdown(line.slice(2));
67
- htmlLines.push(`<li>${content}</li>`);
68
- continue;
69
- }
70
-
71
- // Regular paragraph
72
- if (inList) {
73
- htmlLines.push("</ul>");
74
- inList = false;
75
- }
76
- htmlLines.push(`<p>${formatInlineMarkdown(line)}</p>`);
77
- }
78
-
79
- // Close any open list
80
- if (inList) {
81
- htmlLines.push("</ul>");
82
- }
83
-
84
- return htmlLines.join("\n");
85
- }
86
-
87
- /**
88
- * Escape HTML special characters
89
- * @param {string} text - Text to escape
90
- * @returns {string} Escaped text
91
- */
92
- function escapeHtml(text) {
93
- return text
94
- .replace(/&/g, "&amp;")
95
- .replace(/</g, "&lt;")
96
- .replace(/>/g, "&gt;")
97
- .replace(/"/g, "&quot;")
98
- .replace(/'/g, "&#039;");
99
- }
100
-
101
- /**
102
- * Format inline markdown (bold text)
103
- * @param {string} text - Text to format
104
- * @returns {string} HTML formatted text
105
- */
106
- function formatInlineMarkdown(text) {
107
- // First escape HTML
108
- let result = escapeHtml(text);
109
-
110
- // Convert **bold** to <strong>bold</strong>
111
- result = result.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
112
-
113
- return result;
114
- }
7
+ export { markdownToHtml } from "@forwardimpact/libui/markdown";
@@ -1,77 +1,11 @@
1
1
  /**
2
2
  * Reactive state utilities for local component state
3
+ *
4
+ * Re-exports from @forwardimpact/libui/reactive.
3
5
  */
4
6
 
5
- /**
6
- * @template T
7
- * @typedef {Object} Reactive
8
- * @property {() => T} get - Get current value
9
- * @property {(value: T) => void} set - Set new value
10
- * @property {(fn: (prev: T) => T) => void} update - Update value with function
11
- * @property {(fn: (value: T) => void) => () => void} subscribe - Subscribe to changes
12
- */
13
-
14
- /**
15
- * Create a reactive state container
16
- * @template T
17
- * @param {T} initial - Initial value
18
- * @returns {Reactive<T>}
19
- */
20
- export function createReactive(initial) {
21
- let state = initial;
22
- const subscribers = new Set();
23
-
24
- return {
25
- get: () => state,
26
-
27
- set: (next) => {
28
- state = next;
29
- subscribers.forEach((fn) => fn(state));
30
- },
31
-
32
- update: (fn) => {
33
- state = fn(state);
34
- subscribers.forEach((sub) => sub(state));
35
- },
36
-
37
- subscribe: (fn) => {
38
- subscribers.add(fn);
39
- return () => subscribers.delete(fn);
40
- },
41
- };
42
- }
43
-
44
- /**
45
- * Create a computed value that updates when dependencies change
46
- * @template T
47
- * @param {() => T} compute - Computation function
48
- * @param {Reactive<*>[]} deps - Dependencies
49
- * @returns {Reactive<T>}
50
- */
51
- export function createComputed(compute, deps) {
52
- const computed = createReactive(compute());
53
-
54
- deps.forEach((dep) => {
55
- dep.subscribe(() => {
56
- computed.set(compute());
57
- });
58
- });
59
-
60
- return computed;
61
- }
62
-
63
- /**
64
- * Bind a reactive value to an element attribute
65
- * @template T
66
- * @param {Reactive<T>} reactive - Reactive state
67
- * @param {HTMLElement} element - Element to bind
68
- * @param {string} attribute - Attribute name
69
- * @param {(value: T) => *} [transform] - Transform function
70
- */
71
- export function bind(reactive, element, attribute, transform = (v) => v) {
72
- const update = (value) => {
73
- element[attribute] = transform(value);
74
- };
75
- update(reactive.get());
76
- reactive.subscribe(update);
77
- }
7
+ export {
8
+ createReactive,
9
+ createComputed,
10
+ bind,
11
+ } from "@forwardimpact/libui/reactive";
package/src/lib/render.js CHANGED
@@ -1,209 +1,61 @@
1
1
  /**
2
2
  * DOM rendering utilities
3
+ *
4
+ * Re-exports generic utilities from @forwardimpact/libui/render
5
+ * and adds domain-specific display helpers.
3
6
  */
4
7
 
8
+ export {
9
+ getContainer,
10
+ render,
11
+ createElement,
12
+ div,
13
+ span,
14
+ h1,
15
+ h2,
16
+ h3,
17
+ h4,
18
+ p,
19
+ a,
20
+ ul,
21
+ li,
22
+ table,
23
+ thead,
24
+ tbody,
25
+ tr,
26
+ th,
27
+ td,
28
+ pre,
29
+ code,
30
+ button,
31
+ input,
32
+ select,
33
+ option,
34
+ optgroup,
35
+ label,
36
+ form,
37
+ section,
38
+ article,
39
+ header,
40
+ footer,
41
+ nav,
42
+ main,
43
+ details,
44
+ summary,
45
+ heading1,
46
+ heading2,
47
+ heading3,
48
+ fragment,
49
+ showLoading,
50
+ showError,
51
+ formatLevel,
52
+ } from "@forwardimpact/libui/render";
53
+
5
54
  import {
6
55
  SKILL_PROFICIENCY_ORDER,
7
56
  BEHAVIOUR_MATURITY_ORDER,
8
57
  } from "@forwardimpact/map/levels";
9
58
 
10
- /**
11
- * Get the main content container
12
- * @returns {HTMLElement}
13
- */
14
- export function getContainer() {
15
- return document.getElementById("app-content");
16
- }
17
-
18
- /**
19
- * Clear and render content to the main container
20
- * @param {HTMLElement|string} content
21
- */
22
- export function render(content) {
23
- const container = getContainer();
24
- container.innerHTML = "";
25
-
26
- if (typeof content === "string") {
27
- container.innerHTML = content;
28
- } else if (content instanceof HTMLElement) {
29
- container.appendChild(content);
30
- }
31
- }
32
-
33
- /**
34
- * Create an element with attributes and children
35
- * @param {string} tag - HTML tag name
36
- * @param {Object} [attrs] - Attributes and properties
37
- * @param {...(HTMLElement|string)} children - Child elements or text
38
- * @returns {HTMLElement}
39
- */
40
- export function createElement(tag, attrs = {}, ...children) {
41
- const element = document.createElement(tag);
42
-
43
- for (const [key, value] of Object.entries(attrs)) {
44
- if (key === "className") {
45
- element.className = value;
46
- } else if (key === "style" && typeof value === "object") {
47
- Object.assign(element.style, value);
48
- } else if (key.startsWith("on") && typeof value === "function") {
49
- element.addEventListener(key.slice(2).toLowerCase(), value);
50
- } else if (key === "dataset" && typeof value === "object") {
51
- Object.assign(element.dataset, value);
52
- } else if (typeof value === "boolean") {
53
- // Handle boolean attributes - only set if true, skip if false
54
- if (value) {
55
- element.setAttribute(key, "");
56
- }
57
- } else {
58
- element.setAttribute(key, value);
59
- }
60
- }
61
-
62
- for (const child of children) {
63
- if (child == null || child === false) continue;
64
- if (typeof child === "string" || typeof child === "number") {
65
- element.appendChild(document.createTextNode(String(child)));
66
- } else if (child instanceof HTMLElement) {
67
- element.appendChild(child);
68
- } else if (Array.isArray(child)) {
69
- child.forEach((c) => {
70
- if (c == null || c === false) return;
71
- if (c instanceof HTMLElement) {
72
- element.appendChild(c);
73
- } else if (typeof c === "string" || typeof c === "number") {
74
- element.appendChild(document.createTextNode(String(c)));
75
- }
76
- });
77
- }
78
- }
79
-
80
- return element;
81
- }
82
-
83
- // Shorthand element creators
84
- export const div = (attrs, ...children) =>
85
- createElement("div", attrs, ...children);
86
- export const span = (attrs, ...children) =>
87
- createElement("span", attrs, ...children);
88
- export const h1 = (attrs, ...children) =>
89
- createElement("h1", attrs, ...children);
90
- export const h2 = (attrs, ...children) =>
91
- createElement("h2", attrs, ...children);
92
- export const h3 = (attrs, ...children) =>
93
- createElement("h3", attrs, ...children);
94
- export const h4 = (attrs, ...children) =>
95
- createElement("h4", attrs, ...children);
96
- export const p = (attrs, ...children) => createElement("p", attrs, ...children);
97
- export const a = (attrs, ...children) => createElement("a", attrs, ...children);
98
- export const ul = (attrs, ...children) =>
99
- createElement("ul", attrs, ...children);
100
- export const li = (attrs, ...children) =>
101
- createElement("li", attrs, ...children);
102
- export const table = (attrs, ...children) =>
103
- createElement("table", attrs, ...children);
104
- export const thead = (attrs, ...children) =>
105
- createElement("thead", attrs, ...children);
106
- export const tbody = (attrs, ...children) =>
107
- createElement("tbody", attrs, ...children);
108
- export const tr = (attrs, ...children) =>
109
- createElement("tr", attrs, ...children);
110
- export const th = (attrs, ...children) =>
111
- createElement("th", attrs, ...children);
112
- export const td = (attrs, ...children) =>
113
- createElement("td", attrs, ...children);
114
- export const pre = (attrs, ...children) =>
115
- createElement("pre", attrs, ...children);
116
- export const code = (attrs, ...children) =>
117
- createElement("code", attrs, ...children);
118
- export const button = (attrs, ...children) =>
119
- createElement("button", attrs, ...children);
120
- export const input = (attrs) => createElement("input", attrs);
121
- export const select = (attrs, ...children) =>
122
- createElement("select", attrs, ...children);
123
- export const option = (attrs, ...children) =>
124
- createElement("option", attrs, ...children);
125
- export const optgroup = (attrs, ...children) =>
126
- createElement("optgroup", attrs, ...children);
127
- export const label = (attrs, ...children) =>
128
- createElement("label", attrs, ...children);
129
- export const form = (attrs, ...children) =>
130
- createElement("form", attrs, ...children);
131
- export const section = (attrs, ...children) =>
132
- createElement("section", attrs, ...children);
133
- export const article = (attrs, ...children) =>
134
- createElement("article", attrs, ...children);
135
- export const header = (attrs, ...children) =>
136
- createElement("header", attrs, ...children);
137
- export const footer = (attrs, ...children) =>
138
- createElement("footer", attrs, ...children);
139
- export const nav = (attrs, ...children) =>
140
- createElement("nav", attrs, ...children);
141
- export const main = (attrs, ...children) =>
142
- createElement("main", attrs, ...children);
143
- export const details = (attrs, ...children) =>
144
- createElement("details", attrs, ...children);
145
- export const summary = (attrs, ...children) =>
146
- createElement("summary", attrs, ...children);
147
-
148
- /**
149
- * Semantic heading aliases that match heading levels
150
- * Use these instead of h1/h2/h3 for clarity in slides and formatters
151
- */
152
- export const heading1 = h1;
153
- export const heading2 = h2;
154
- export const heading3 = h3;
155
-
156
- /**
157
- * Create a fragment from multiple elements
158
- * @param {...HTMLElement} children
159
- * @returns {DocumentFragment}
160
- */
161
- export function fragment(...children) {
162
- const frag = document.createDocumentFragment();
163
- children.forEach((child) => {
164
- if (child instanceof HTMLElement) {
165
- frag.appendChild(child);
166
- }
167
- });
168
- return frag;
169
- }
170
-
171
- /**
172
- * Show a loading state
173
- */
174
- export function showLoading() {
175
- render(
176
- div(
177
- { className: "loading" },
178
- div({ className: "loading-spinner" }),
179
- p({}, "Loading..."),
180
- ),
181
- );
182
- }
183
-
184
- /**
185
- * Show an error message
186
- * @param {string} message
187
- */
188
- export function showError(message) {
189
- render(div({ className: "error-message" }, h2({}, "Error"), p({}, message)));
190
- }
191
-
192
- /**
193
- * Format a skill proficiency or behaviour maturity for display
194
- * Handles both snake_case and camelCase
195
- * @param {string} value - The level/maturity value
196
- * @returns {string}
197
- */
198
- export function formatLevel(value) {
199
- if (!value) return "";
200
- // Insert space before uppercase letters (for camelCase), then handle snake_case
201
- return value
202
- .replace(/([a-z])([A-Z])/g, "$1 $2")
203
- .replace(/_/g, " ")
204
- .replace(/\b\w/g, (c) => c.toUpperCase());
205
- }
206
-
207
59
  /**
208
60
  * Get the index for a skill proficiency (1-5)
209
61
  * @param {string} level