@popcorn245/cornfield 0.24.0 → 0.25.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.
- package/explorer/check.js +3 -0
- package/explorer/cloud-model.js +4 -4
- package/explorer/corn-state.js +34 -0
- package/explorer/flows.js +1 -1
- package/explorer/forge-panel.js +36 -31
- package/explorer/house.js +4 -0
- package/explorer/index.html +103 -103
- package/explorer/layers.js +1 -1
- package/explorer/live-model.js +1 -1
- package/explorer/live.js +1 -1
- package/explorer/mockups-model.js +4 -3
- package/explorer/mockups.js +4 -0
- package/explorer/panels.js +1 -1
- package/explorer/plugins.js +2 -2
- package/explorer/proposal-model.js +1 -1
- package/explorer/proposal.js +4 -4
- package/explorer/renderer.js +1 -0
- package/explorer/review-tokens.js +2 -1
- package/explorer/review.js +2 -1
- package/explorer/runs-map.js +1 -0
- package/explorer/runs-view.js +6 -5
- package/explorer/scenario-ui.js +4 -2
- package/explorer/sheets.js +1 -0
- package/explorer/whatif.js +22 -21
- package/package.json +1 -1
- package/server/server.js +2 -2
|
@@ -172,7 +172,7 @@ export function proposalPanelHtml(item) {
|
|
|
172
172
|
const body = rows.map((r) => (item.mark === 'changed'
|
|
173
173
|
? `<div class="hx-change"><span class="hx-change-field">${escHtml(r.field)}</span><span class="hx-change-before">${escHtml(r.before) || '<em>nothing</em>'}</span><span class="hx-change-arrow" aria-hidden="true">→</span><span class="hx-change-after">${escHtml(r.after) || '<em>nothing</em>'}</span></div>`
|
|
174
174
|
: `<div class="hx-change"><span class="hx-change-field">${escHtml(r.field)}</span><span class="hx-change-after">${escHtml(r.after)}</span></div>`)).join('');
|
|
175
|
-
return `<div class="hx-sec hx-proposal-sec hx-proposal-sec--${escHtml(item.mark)}" data-proposal-mark="${escHtml(item.mark)}">
|
|
175
|
+
return `<div class="hx-sec hx-proposal-sec hx-proposal-sec--${escHtml(item.mark)}" data-proposal-mark="${escHtml(item.mark)}" data-corn="section">
|
|
176
176
|
<strong class="hx-strong"><span class="hx-mark-dot hx-mark-dot--${escHtml(item.mark)}"></span>${escHtml(item.mark === 'edit' ? `${item.editOp === 'removed' ? 'Removed' : 'Added'} by your edit` : `${MARK_WORDS[item.mark] || item.mark} by this proposal`)}</strong>
|
|
177
177
|
${item.why ? `<div class="hx-why">${escHtml(item.why)}</div>` : ''}
|
|
178
178
|
${body}
|
package/explorer/proposal.js
CHANGED
|
@@ -282,10 +282,10 @@ function renderChanges() {
|
|
|
282
282
|
const rows = [];
|
|
283
283
|
for (const mark of [...MARKS, 'edit']) {
|
|
284
284
|
for (const n of state.nodes.filter((x) => x.mark === mark)) {
|
|
285
|
-
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="node" data-key="${escHtml(n.id)}"><span class="hx-mark-dot hx-mark-dot--${mark}"></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(n.label)}</span><span class="hx-faint">${escHtml(n.type)}</span></button>`);
|
|
285
|
+
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="node" data-key="${escHtml(n.id)}" data-corn="row"><span class="hx-mark-dot hx-mark-dot--${mark}"></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(n.label)}</span><span class="hx-faint">${escHtml(n.type)}</span></button>`);
|
|
286
286
|
}
|
|
287
287
|
for (const e of state.edges.filter((x) => x.mark === mark && said.has(edgeKey(x)))) {
|
|
288
|
-
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="edge" data-key="${escHtml(edgeKey(e))}"><span class="hx-mark-dot hx-mark-dot--${mark}"></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(nameOf(e.from))} → ${escHtml(nameOf(e.to))}</span><span class="hx-faint">${escHtml(e.kind || 'ownership')}</span></button>`);
|
|
288
|
+
rows.push(`<button type="button" class="hx-change-row" data-action="proposal-focus" data-kind="edge" data-key="${escHtml(edgeKey(e))}" data-corn="row"><span class="hx-mark-dot hx-mark-dot--${mark}"></span><span class="hx-change-what">${escHtml(MARK_WORDS[mark])}</span><span class="hx-name">${escHtml(nameOf(e.from))} → ${escHtml(nameOf(e.to))}</span><span class="hx-faint">${escHtml(e.kind || 'ownership')}</span></button>`);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
list.innerHTML = rows.join('') || '<p class="hx-faint">This proposal changes nothing on the map.</p>';
|
|
@@ -350,13 +350,13 @@ export function proposalRowHtml(entry, current) {
|
|
|
350
350
|
const meta = [`<span class="hx-proposal-where">${escHtml(where(entry))}</span>`];
|
|
351
351
|
if (entry.spec) meta.push(`<span>spec ${escHtml(entry.spec)}</span>`);
|
|
352
352
|
if (entry.error) {
|
|
353
|
-
return `<div class="hx-proposal-item is-broken">${head}<span class="hx-proposal-sum hx-error-text">${escHtml(entry.error)}</span><span class="hx-proposal-meta">${meta.join('')}</span></div>`;
|
|
353
|
+
return `<div class="hx-proposal-item is-broken" data-corn="row">${head}<span class="hx-proposal-sum hx-error-text">${escHtml(entry.error)}</span><span class="hx-proposal-meta">${meta.join('')}</span></div>`;
|
|
354
354
|
}
|
|
355
355
|
if (entry.counts) meta.push(`<span>${escHtml(chipText(entry.counts))}</span>`);
|
|
356
356
|
const reviewed = reviewWords(entry.review, Date.now()); // "Approved 3 minutes ago", from the listing
|
|
357
357
|
if (reviewed) meta.push(`<span class="hx-proposal-reviewed">${escHtml(reviewed)}</span>`);
|
|
358
358
|
if (entry.errors) meta.push(`<span class="hx-warn">${escHtml(plural(entry.errors, 'problem'))}</span>`);
|
|
359
|
-
return `<button type="button" class="hx-proposal-item${mine ? ' is-current' : ''}" data-action="open-proposal" data-slug="${escHtml(entry.slug)}" data-source="${escHtml(entry.source)}">${head}${entry.summary ? `<span class="hx-proposal-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-proposal-meta">${meta.join('')}</span></button>`;
|
|
359
|
+
return `<button type="button" class="hx-proposal-item${mine ? ' is-current' : ''}" data-action="open-proposal" data-slug="${escHtml(entry.slug)}" data-source="${escHtml(entry.source)}" data-corn="row">${head}${entry.summary ? `<span class="hx-proposal-sum">${escHtml(entry.summary)}</span>` : ''}<span class="hx-proposal-meta">${meta.join('')}</span></button>`;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
function renderMenu(loading = false) {
|
package/explorer/renderer.js
CHANGED
|
@@ -41,6 +41,7 @@ export function rendererPreference(search) {
|
|
|
41
41
|
function addStandIn(canvas) {
|
|
42
42
|
const standIn = canvas.ownerDocument.createElement('canvas');
|
|
43
43
|
standIn.className = 'hx-overlay';
|
|
44
|
+
standIn.setAttribute('data-corn', 'map-overlay');
|
|
44
45
|
standIn.setAttribute('aria-hidden', 'true');
|
|
45
46
|
canvas.after(standIn);
|
|
46
47
|
return standIn;
|
|
@@ -55,7 +55,7 @@ function paint() {
|
|
|
55
55
|
else {
|
|
56
56
|
list.innerHTML = ui.tokens.map((t) => {
|
|
57
57
|
const line = tokenLine(t, now());
|
|
58
|
-
return `<li class="hx-tokens-item" data-state="${line.state}"><span class="hx-tokens-label">${escHtml(line.label)}</span> <span class="hx-tokens-meta hx-faint">${escHtml(line.status)} · ${escHtml(line.used)}</span> ${line.canRevoke ? `<button type="button" class="hx-btn hx-btn--quiet" data-revoke="${escHtml(String(line.id))}" aria-label="Revoke ${escHtml(line.label)}"${ui.busy ? ' disabled' : ''}>Revoke</button>` : ''}</li>`;
|
|
58
|
+
return `<li class="hx-tokens-item" data-state="${line.state}" data-corn="row"><span class="hx-tokens-label">${escHtml(line.label)}</span> <span class="hx-tokens-meta hx-faint">${escHtml(line.status)} · ${escHtml(line.used)}</span> ${line.canRevoke ? `<button type="button" class="hx-btn hx-btn--quiet" data-revoke="${escHtml(String(line.id))}" aria-label="Revoke ${escHtml(line.label)}"${ui.busy ? ' disabled' : ''} data-corn-kind="danger">Revoke</button>` : ''}</li>`;
|
|
59
59
|
}).join('');
|
|
60
60
|
}
|
|
61
61
|
const intro = $('tokens-intro');
|
|
@@ -64,6 +64,7 @@ function paint() {
|
|
|
64
64
|
msg.hidden = !ui.message;
|
|
65
65
|
msg.textContent = ui.message ? ui.message.text : '';
|
|
66
66
|
msg.classList.toggle('hx-forge-msg--bad', !!ui.message && !ui.message.ok);
|
|
67
|
+
if (ui.message && !ui.message.ok) msg.dataset.cornState = 'failure'; else delete msg.dataset.cornState;
|
|
67
68
|
$('tokens-make').disabled = ui.busy;
|
|
68
69
|
}
|
|
69
70
|
|
package/explorer/review.js
CHANGED
|
@@ -60,12 +60,13 @@ function mount() {
|
|
|
60
60
|
root = document.createElement('div');
|
|
61
61
|
root.id = 'review';
|
|
62
62
|
root.className = 'hx-review';
|
|
63
|
+
root.dataset.corn = 'review-bar';
|
|
63
64
|
root.setAttribute('aria-label', 'Approve or send back');
|
|
64
65
|
root.innerHTML = `
|
|
65
66
|
<label class="hx-review-label" for="review-note">Note for the drafting agent</label>
|
|
66
67
|
<textarea id="review-note" class="hx-review-note" rows="2" maxlength="20000" placeholder="What should change? Needed to send it back, optional to approve."></textarea>
|
|
67
68
|
<div class="hx-review-row">
|
|
68
|
-
<button type="button" class="hx-btn hx-btn--approve" data-review="approved" title="Sign this proposal off">Approve</button>
|
|
69
|
+
<button type="button" class="hx-btn hx-btn--approve" data-review="approved" title="Sign this proposal off" data-corn-kind="approve">Approve</button>
|
|
69
70
|
<button type="button" class="hx-btn" data-review="notes" title="Send it back to the drafting agent with the note and your edits">Send back</button>
|
|
70
71
|
<span class="hx-review-status" data-review-status role="status"></span>
|
|
71
72
|
</div>
|
package/explorer/runs-map.js
CHANGED
|
@@ -108,6 +108,7 @@ export function syncRunOverlay(scene, camera) {
|
|
|
108
108
|
el.className = `hx-run-mark hx-run-mark--${kind}`;
|
|
109
109
|
el.dataset.node = node.id;
|
|
110
110
|
el.dataset.kind = kind;
|
|
111
|
+
el.dataset.corn = 'run-mark';
|
|
111
112
|
el.innerHTML = `<span class="hx-run-ring"></span>${kind === 'collision' ? `<span class="hx-run-tag"><span class="hx-run-sign">⚠</span> ${collisionTag(runs.length)}</span>` : ''}`;
|
|
112
113
|
layer.append(el);
|
|
113
114
|
marks.set(key, el);
|
package/explorer/runs-view.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { relativeTime } from './review-model.js';
|
|
12
12
|
import { runTone, canRetry, aboutWords, statusWords, statusWhy, runMeta, canStop, canAnswer, groupRuns, compareTitle, limitRows, checksWords, timelineWords, nodeLabels, collisionWords, answerWords } from './runs-model.js';
|
|
13
|
+
import { cornStateAttr } from './corn-state.js';
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -84,8 +85,8 @@ function answerHtml(ctx, run) {
|
|
|
84
85
|
const reply = ctx.replies && ctx.replies.get(run.runId) || '';
|
|
85
86
|
return `${run.answer ? answeredHtml(ctx, run) : ''}<div class="hx-run-actions" role="group" aria-label="Answer run ${id}">
|
|
86
87
|
<button type="button" class="hx-btn hx-forge-act" data-run-answer="continue" data-run-id="${id}" aria-label="Continue run ${id}"${off}>Continue</button>
|
|
87
|
-
<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="Stop run ${id}"${off}>Stop</button></div>
|
|
88
|
-
<label class="hx-forge-field">Reply to run ${id}<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
88
|
+
<button type="button" class="hx-btn hx-forge-act" data-run-answer="stop" data-run-id="${id}" aria-label="Stop run ${id}"${off} data-corn-kind="danger">Stop</button></div>
|
|
89
|
+
<label class="hx-forge-field" data-corn="field">Reply to run ${id}<input type="text" class="hx-forge-input" data-run-reply="${id}" value="${ctx.esc(reply)}" maxlength="4000" autocomplete="off" /></label>
|
|
89
90
|
<div class="hx-run-actions"><button type="button" class="hx-btn hx-forge-act" data-run-answer="reply" data-run-id="${id}" aria-label="Send reply to run ${id}"${off}>Reply</button></div>`;
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -103,14 +104,14 @@ export function runHtml(ctx, run, all) {
|
|
|
103
104
|
const note = run.report && run.report.note ? `<p class="hx-forge-meta">Runner: ${ctx.esc(run.report.note)}</p>` : '';
|
|
104
105
|
const answering = canAnswer(run);
|
|
105
106
|
const retry = canRetry(run) ? `<button type="button" class="hx-btn hx-forge-act" data-forge-retry="${ctx.esc(run.runId)}" aria-label="Start again on run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''}>Start again</button>` : '';
|
|
106
|
-
const stop = canStop(run) && !answering ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="Stop run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''}>Stop</button>` : '';
|
|
107
|
+
const stop = canStop(run) && !answering ? `<button type="button" class="hx-btn hx-forge-act" data-forge-stop="${ctx.esc(run.runId)}" aria-label="Stop run ${ctx.esc(run.runId)}"${ctx.busy ? ' disabled' : ''} data-corn-kind="danger">Stop</button>` : '';
|
|
107
108
|
const names = nodeLabels(run.nodes, ctx.nodes);
|
|
108
109
|
const collision = collisionWords(run, all, ctx.nodes);
|
|
109
110
|
const limits = limitRows(run);
|
|
110
111
|
const count = (run.timeline || []).length;
|
|
111
112
|
const links = linksHtml(ctx, run);
|
|
112
|
-
return `<li class="hx-run hx-forge-file" data-run="${ctx.esc(run.runId)}" tabindex="-1">
|
|
113
|
-
<div class="hx-run-head"><span class="hx-forge-state hx-forge-state--${tone}">${ctx.esc(statusWords(run))}</span> <span class="hx-name">${ctx.esc(run.kind)} on ${ctx.esc(aboutWords(run.refs))}</span>${run.profile ? ` <span class="hx-faint">profile ${ctx.esc(run.profile)}</span>` : ''}</div>
|
|
113
|
+
return `<li class="hx-run hx-forge-file" data-run="${ctx.esc(run.runId)}" tabindex="-1" data-corn="run"${cornStateAttr(run.status)}>
|
|
114
|
+
<div class="hx-run-head"><span class="hx-forge-state hx-forge-state--${tone}" data-corn="state-pill"${cornStateAttr(run.status)}>${ctx.esc(statusWords(run))}</span> <span class="hx-name">${ctx.esc(run.kind)} on ${ctx.esc(aboutWords(run.refs))}</span>${run.profile ? ` <span class="hx-faint">profile ${ctx.esc(run.profile)}</span>` : ''}</div>
|
|
114
115
|
${collision ? `<p class="hx-run-collide"><span aria-hidden="true">⚠</span> ${ctx.esc(collision)}</p>` : ''}
|
|
115
116
|
<p class="hx-forge-meta">${ctx.esc(runMeta(run, ctx.now))}</p>${why ? `<p class="hx-forge-why hx-faint">${ctx.esc(why)}</p>` : ''}${note}
|
|
116
117
|
<dl class="hx-run-limits" aria-label="Limits and what the runner reported">${limits.length ? limits.map((r) => `<dt>${ctx.esc(r.name)}</dt><dd>limit: ${ctx.esc(r.limit)}; reported: ${ctx.esc(r.reported)}</dd>`).join('') : '<dt>Limits</dt><dd>none asked, nothing reported</dd>'}</dl>
|
package/explorer/scenario-ui.js
CHANGED
|
@@ -180,18 +180,19 @@ function showBar(speed) {
|
|
|
180
180
|
if (!stage) return;
|
|
181
181
|
bar = document.createElement('div');
|
|
182
182
|
bar.className = 'hx-player glass';
|
|
183
|
+
bar.dataset.corn = 'scenario-player';
|
|
183
184
|
bar.setAttribute('role', 'region');
|
|
184
185
|
bar.setAttribute('aria-label', 'Scenario player');
|
|
185
186
|
bar.innerHTML = `
|
|
186
187
|
<div class="hx-player-head">
|
|
187
188
|
<span class="hx-player-title"></span>
|
|
188
189
|
<select class="hx-player-speed" data-action="scenario-speed" aria-label="Time for each step" title="Time for each step">${SPEED_CHOICES.map((c) => `<option value="${c.value}">${c.label}</option>`).join('')}</select>
|
|
189
|
-
<button type="button" class="hx-close" data-action="scenario-close" aria-label="Close the scenario">✕</button>
|
|
190
|
+
<button type="button" class="hx-close" data-action="scenario-close" aria-label="Close the scenario" data-corn-kind="icon">✕</button>
|
|
190
191
|
</div>
|
|
191
192
|
<p class="hx-player-text" aria-live="polite"><span class="hx-player-count"></span> · <span class="hx-player-step"></span></p>
|
|
192
193
|
<div class="hx-player-controls">
|
|
193
194
|
<button type="button" class="hx-btn" data-action="scenario-prev">◀ Previous</button>
|
|
194
|
-
<button type="button" class="hx-btn hx-btn--active" data-action="scenario-toggle"></button>
|
|
195
|
+
<button type="button" class="hx-btn hx-btn--active" data-action="scenario-toggle" data-corn-kind="primary"></button>
|
|
195
196
|
<button type="button" class="hx-btn" data-action="scenario-next">Next ▶</button>
|
|
196
197
|
</div>
|
|
197
198
|
<div class="hx-player-track" aria-hidden="true"><span class="hx-player-fill"></span></div>`;
|
|
@@ -326,6 +327,7 @@ export function refreshList() {
|
|
|
326
327
|
const button = document.createElement('button');
|
|
327
328
|
button.type = 'button';
|
|
328
329
|
button.className = 'hx-scenarios-item';
|
|
330
|
+
button.dataset.corn = 'row';
|
|
329
331
|
button.dataset.scenario = s.id;
|
|
330
332
|
const steps = (s.steps || []).length;
|
|
331
333
|
button.textContent = `${s.title} · ${steps} ${steps === 1 ? 'step' : 'steps'}`;
|
package/explorer/sheets.js
CHANGED
|
@@ -108,6 +108,7 @@ export function registerSheet(id, el) {
|
|
|
108
108
|
handle = document.createElement('button');
|
|
109
109
|
handle.type = 'button';
|
|
110
110
|
handle.className = 'hx-sheet-handle';
|
|
111
|
+
handle.dataset.corn = 'sheet-handle';
|
|
111
112
|
handle.innerHTML = '<span></span>';
|
|
112
113
|
el.prepend(handle);
|
|
113
114
|
}
|
package/explorer/whatif.js
CHANGED
|
@@ -227,6 +227,7 @@ function mount() {
|
|
|
227
227
|
root = document.createElement('div');
|
|
228
228
|
root.id = 'whatif';
|
|
229
229
|
root.className = 'hx-whatif';
|
|
230
|
+
root.dataset.corn = 'whatif';
|
|
230
231
|
root.setAttribute('aria-label', 'Try a change');
|
|
231
232
|
root.innerHTML = `
|
|
232
233
|
<div class="hx-whatif-row" role="toolbar" aria-label="Try a change">
|
|
@@ -238,8 +239,8 @@ function mount() {
|
|
|
238
239
|
<button type="button" class="hx-btn" data-whatif="steps" aria-expanded="false" title="Add, reword, reorder or delete the steps of a scenario">Steps</button>
|
|
239
240
|
</div>
|
|
240
241
|
<p class="hx-whatif-hint" data-hint hidden>Drag from one node to another. Escape cancels.</p>
|
|
241
|
-
<p class="hx-whatif-msg" data-msg="toolbar" role="status" hidden></p>
|
|
242
|
-
<p class="hx-whatif-notice" data-notice role="status" hidden></p>
|
|
242
|
+
<p class="hx-whatif-msg" data-msg="toolbar" role="status" hidden data-corn="message"></p>
|
|
243
|
+
<p class="hx-whatif-notice" data-notice role="status" hidden data-corn="notice"></p>
|
|
243
244
|
<div class="hx-whatif-panel" data-panel="confirm" hidden></div>
|
|
244
245
|
<div class="hx-whatif-panel" data-panel="form" hidden></div>
|
|
245
246
|
<div class="hx-whatif-panel" data-panel="edits" hidden></div>
|
|
@@ -316,7 +317,7 @@ function paintConfirm() {
|
|
|
316
317
|
<div class="hx-whatif-actions">
|
|
317
318
|
<button type="button" class="hx-btn hx-btn--active" data-whatif="close-keep">Close and keep my edits</button>
|
|
318
319
|
<button type="button" class="hx-btn" data-whatif="close-discard">Close and throw them away</button>
|
|
319
|
-
<button type="button" class="hx-btn hx-btn--quiet" data-whatif="close-cancel">Keep editing</button>
|
|
320
|
+
<button type="button" class="hx-btn hx-btn--quiet" data-whatif="close-cancel" data-corn-kind="quiet">Keep editing</button>
|
|
320
321
|
</div>`;
|
|
321
322
|
}
|
|
322
323
|
|
|
@@ -350,16 +351,16 @@ function paintForm() {
|
|
|
350
351
|
box.innerHTML = `
|
|
351
352
|
<form class="hx-whatif-form" data-form="node" autocomplete="off">
|
|
352
353
|
<strong class="hx-strong">Add a node</strong>
|
|
353
|
-
<label class="hx-whatif-field">Type <select name="nodeType">${typeOptions('page')}</select></label>
|
|
354
|
-
<label class="hx-whatif-field">Label <input name="label" class="hx-whatif-input" placeholder="/meals" required></label>
|
|
355
|
-
<label class="hx-whatif-field">Parent <select name="parent">${options.join('')}</select></label>
|
|
354
|
+
<label class="hx-whatif-field" data-corn="field">Type <select name="nodeType">${typeOptions('page')}</select></label>
|
|
355
|
+
<label class="hx-whatif-field" data-corn="field">Label <input name="label" class="hx-whatif-input" placeholder="/meals" required></label>
|
|
356
|
+
<label class="hx-whatif-field" data-corn="field">Parent <select name="parent">${options.join('')}</select></label>
|
|
356
357
|
<p class="hx-faint hx-whatif-help">Click a node on the map to make it the parent. A page label starts with a slash, like /meals.</p>
|
|
357
|
-
<label class="hx-whatif-field">Description <input name="desc" class="hx-whatif-input" placeholder="Optional"></label>
|
|
358
|
+
<label class="hx-whatif-field" data-corn="field">Description <input name="desc" class="hx-whatif-input" placeholder="Optional"></label>
|
|
358
359
|
<div class="hx-whatif-actions">
|
|
359
360
|
<button type="submit" class="hx-btn hx-btn--active">Add node</button>
|
|
360
|
-
<button type="button" class="hx-btn hx-btn--quiet" data-whatif="cancel-form">Cancel</button>
|
|
361
|
+
<button type="button" class="hx-btn hx-btn--quiet" data-whatif="cancel-form" data-corn-kind="quiet">Cancel</button>
|
|
361
362
|
</div>
|
|
362
|
-
<p class="hx-whatif-msg" data-msg="form" role="alert" hidden></p>
|
|
363
|
+
<p class="hx-whatif-msg" data-msg="form" role="alert" hidden data-corn="message"></p>
|
|
363
364
|
</form>`;
|
|
364
365
|
box.querySelector('[name="nodeType"]').value = 'page';
|
|
365
366
|
box.querySelector('[name="parent"]').value = parent;
|
|
@@ -372,14 +373,14 @@ function paintForm() {
|
|
|
372
373
|
<form class="hx-whatif-form" data-form="edge" autocomplete="off">
|
|
373
374
|
<strong class="hx-strong">Draw an edge</strong>
|
|
374
375
|
<p class="hx-whatif-pair"><span class="hx-name">${escHtml(nameOf(form.from))}</span> → <span class="hx-name">${escHtml(nameOf(form.to))}</span></p>
|
|
375
|
-
<label class="hx-whatif-field">Kind <select name="kind">${M.EDGE_CHOICES.map((c) => `<option value="${escHtml(c.value)}"${c.value === suggested ? ' selected' : ''}>${escHtml(c.label)}</option>`).join('')}</select></label>
|
|
376
|
-
<label class="hx-whatif-field" data-flow-field hidden>Flow <select name="flow">${M.FLOW_KINDS.map((f) => `<option value="${escHtml(f)}">${escHtml(f)}</option>`).join('')}</select></label>
|
|
377
|
-
<label class="hx-whatif-field">Label <input name="label" class="hx-whatif-input" placeholder="Optional"></label>
|
|
376
|
+
<label class="hx-whatif-field" data-corn="field">Kind <select name="kind">${M.EDGE_CHOICES.map((c) => `<option value="${escHtml(c.value)}"${c.value === suggested ? ' selected' : ''}>${escHtml(c.label)}</option>`).join('')}</select></label>
|
|
377
|
+
<label class="hx-whatif-field" data-flow-field hidden data-corn="field">Flow <select name="flow">${M.FLOW_KINDS.map((f) => `<option value="${escHtml(f)}">${escHtml(f)}</option>`).join('')}</select></label>
|
|
378
|
+
<label class="hx-whatif-field" data-corn="field">Label <input name="label" class="hx-whatif-input" placeholder="Optional"></label>
|
|
378
379
|
<div class="hx-whatif-actions">
|
|
379
380
|
<button type="submit" class="hx-btn hx-btn--active">Add edge</button>
|
|
380
|
-
<button type="button" class="hx-btn hx-btn--quiet" data-whatif="cancel-form">Cancel</button>
|
|
381
|
+
<button type="button" class="hx-btn hx-btn--quiet" data-whatif="cancel-form" data-corn-kind="quiet">Cancel</button>
|
|
381
382
|
</div>
|
|
382
|
-
<p class="hx-whatif-msg" data-msg="form" role="alert" hidden></p>
|
|
383
|
+
<p class="hx-whatif-msg" data-msg="form" role="alert" hidden data-corn="message"></p>
|
|
383
384
|
</form>`;
|
|
384
385
|
box.querySelector('[name="kind"]').value = suggested;
|
|
385
386
|
syncFlowField();
|
|
@@ -439,7 +440,7 @@ function paintEdits() {
|
|
|
439
440
|
};
|
|
440
441
|
const rows = state.whatIf.edits.map((edit, i) => `<li class="hx-whatif-edit"><span class="hx-mark-dot hx-mark-dot--edit"></span><span class="hx-whatif-edit-text">${escHtml(M.describeEdit(edit, words))}</span><button type="button" class="hx-textbtn" data-whatif="remove-edit" data-index="${i}" aria-label="Remove this edit: ${escHtml(M.describeEdit(edit, words))}">Remove</button></li>`);
|
|
441
442
|
box.innerHTML = rows.length
|
|
442
|
-
? `<ol class="hx-whatif-list">${rows.join('')}</ol><p class="hx-whatif-msg" data-msg="edits" role="status" hidden></p>`
|
|
443
|
+
? `<ol class="hx-whatif-list">${rows.join('')}</ol><p class="hx-whatif-msg" data-msg="edits" role="status" hidden data-corn="message"></p>`
|
|
443
444
|
: '<p class="hx-faint">No edits yet. Add a node, draw an edge or change a step, and it appears here.</p>';
|
|
444
445
|
paintMessages();
|
|
445
446
|
}
|
|
@@ -474,17 +475,17 @@ function paintSteps() {
|
|
|
474
475
|
box.innerHTML = `
|
|
475
476
|
<div class="hx-whatif-form">
|
|
476
477
|
<div class="hx-whatif-actions">
|
|
477
|
-
<label class="hx-whatif-field">Scenario <select data-scenario-select>${scenarios.map((s) => `<option value="${escHtml(s.id)}"${s.id === ui.scenarioId ? ' selected' : ''}>${escHtml(s.title)}</option>`).join('')}<option value="${NEW}"${ui.scenarioId === NEW ? ' selected' : ''}>New scenario…</option></select></label>
|
|
478
|
+
<label class="hx-whatif-field" data-corn="field">Scenario <select data-scenario-select>${scenarios.map((s) => `<option value="${escHtml(s.id)}"${s.id === ui.scenarioId ? ' selected' : ''}>${escHtml(s.title)}</option>`).join('')}<option value="${NEW}"${ui.scenarioId === NEW ? ' selected' : ''}>New scenario…</option></select></label>
|
|
478
479
|
${scenario ? '<button type="button" class="hx-btn" data-whatif="play-scenario">Play</button>' : ''}
|
|
479
480
|
</div>
|
|
480
481
|
${rows.length ? `<ol class="hx-whatif-list hx-whatif-steps">${rows.join('')}</ol>` : '<p class="hx-faint">No steps yet.</p>'}
|
|
481
482
|
<form class="hx-whatif-addstep" data-form="step" autocomplete="off">
|
|
482
|
-
${ui.scenarioId === NEW ? `<label class="hx-whatif-field">Title <input name="title" class="hx-whatif-input" placeholder="Add a meal" value="${escHtml(ui.titleDraft)}"></label>` : ''}
|
|
483
|
-
<label class="hx-whatif-field">New step <input name="text" class="hx-whatif-input" placeholder="What happens here?" value="${escHtml(ui.stepDraft)}"></label>
|
|
483
|
+
${ui.scenarioId === NEW ? `<label class="hx-whatif-field" data-corn="field">Title <input name="title" class="hx-whatif-input" placeholder="Add a meal" value="${escHtml(ui.titleDraft)}"></label>` : ''}
|
|
484
|
+
<label class="hx-whatif-field" data-corn="field">New step <input name="text" class="hx-whatif-input" placeholder="What happens here?" value="${escHtml(ui.stepDraft)}"></label>
|
|
484
485
|
<button type="submit" class="hx-btn hx-btn--active" data-step-add>Add step</button>
|
|
485
486
|
<span class="hx-faint hx-whatif-pointing" data-step-target></span>
|
|
486
487
|
</form>
|
|
487
|
-
<p class="hx-whatif-msg" data-msg="steps" role="alert" hidden></p>
|
|
488
|
+
<p class="hx-whatif-msg" data-msg="steps" role="alert" hidden data-corn="message"></p>
|
|
488
489
|
</div>`;
|
|
489
490
|
paintStepTarget();
|
|
490
491
|
paintMessages();
|
|
@@ -543,7 +544,7 @@ function edgeToHtml(n) {
|
|
|
543
544
|
.slice(0, EDGE_TO_MAX);
|
|
544
545
|
if (!others.length) return '';
|
|
545
546
|
return `<div class="hx-whatif-addstep hx-whatif-edgeto">
|
|
546
|
-
<label class="hx-whatif-field">Edge to <select data-edge-to>${others.map((o) => `<option value="${escHtml(o.id)}">${escHtml(o.label)} (${escHtml(o.type)})</option>`).join('')}</select></label>
|
|
547
|
+
<label class="hx-whatif-field" data-corn="field">Edge to <select data-edge-to>${others.map((o) => `<option value="${escHtml(o.id)}">${escHtml(o.label)} (${escHtml(o.type)})</option>`).join('')}</select></label>
|
|
547
548
|
<button type="button" class="hx-btn" data-whatif="edge-to" data-from="${escHtml(n.id)}" title="Draw an edge from this node to the one picked, without dragging">Draw an edge</button>
|
|
548
549
|
</div>`;
|
|
549
550
|
}
|
|
@@ -555,7 +556,7 @@ function paintDrawer() {
|
|
|
555
556
|
box.hidden = !open;
|
|
556
557
|
if (!open) { box.innerHTML = ''; return; }
|
|
557
558
|
|
|
558
|
-
const message = '<p class="hx-whatif-msg" data-msg="drawer" role="alert" hidden></p>';
|
|
559
|
+
const message = '<p class="hx-whatif-msg" data-msg="drawer" role="alert" hidden data-corn="message"></p>';
|
|
559
560
|
const title = '<h3 class="hx-block-title">Try a change</h3>';
|
|
560
561
|
if (state.selectedEdge) {
|
|
561
562
|
const e = state.selectedEdge;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popcorn245/cornfield",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "popcorn245 (https://github.com/popcorn245)",
|
package/server/server.js
CHANGED
|
@@ -129,9 +129,9 @@ function themeHead(theme) {
|
|
|
129
129
|
const u = fontUrl(f);
|
|
130
130
|
if (u) out.push(`<link rel="stylesheet" href="${escapeHtml(u.href)}" referrerpolicy="no-referrer" />`);
|
|
131
131
|
}
|
|
132
|
-
if (theme.css) out.push('<link rel="stylesheet" href="/cornfield/theme.css" data-
|
|
132
|
+
if (theme.css) out.push('<link rel="stylesheet" href="/cornfield/theme.css" data-corn-theme="css" />');
|
|
133
133
|
const { names, fallback } = themeNamesOf(theme);
|
|
134
|
-
if (names.length) out.push(`<link rel="stylesheet" id="cf-theme-name-css"${fallback ? ` href="/cornfield/theme/${fallback}.css"` : ''} data-
|
|
134
|
+
if (names.length) out.push(`<link rel="stylesheet" id="cf-theme-name-css"${fallback ? ` href="/cornfield/theme/${fallback}.css"` : ''} data-corn-theme="name" />`);
|
|
135
135
|
return out.join('\n ');
|
|
136
136
|
}
|
|
137
137
|
|