@kitlangton/knobs 0.4.0-next.3 → 0.4.0-next.5

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.
@@ -1,4 +1,9 @@
1
1
  import { type ContextEvent, type WalkChapter, type WalkMedia } from "./walkthrough-model.js";
2
+ /** The glyphs the blocks draw. */
3
+ export declare const GLYPH: {
4
+ go: string;
5
+ caret: string;
6
+ };
2
7
  /** How media reach the page's steps: `step` on a history event, a stack item or a table cell. */
3
8
  export interface StepLinks {
4
9
  /** The step a ref names (its key, id or number), or null when there's none. */
@@ -17,6 +22,8 @@ export interface Block {
17
22
  kind: string;
18
23
  };
19
24
  }
25
+ /** A small arrow that goes to the step a ref names; null when it names none. */
26
+ export declare function stepButton(doc: Document, ref: string | undefined, steps: StepLinks | undefined): HTMLButtonElement | null;
20
27
  export declare function mountHistory(host: HTMLElement, m: Extract<WalkMedia, {
21
28
  kind: "history";
22
29
  }>, steps: StepLinks | undefined): Block;
@@ -27,7 +34,7 @@ export declare function mountTable(host: HTMLElement, m: Extract<WalkMedia, {
27
34
  kind: "table";
28
35
  }>, steps: StepLinks | undefined): Block;
29
36
  export interface ChapterPills {
30
- /** The chapter the time is in (call as it plays or seeks): the highlight springs to it. */
37
+ /** The chapter the time is in (call as it plays or seeks): the pill slides to it. */
31
38
  sync(): void;
32
39
  /** The chapter playing, or null. */
33
40
  readonly current: WalkChapter | null;
@@ -40,4 +47,34 @@ export declare function chapterPills(host: HTMLElement, chapters: readonly WalkC
40
47
  seek(time: number): void;
41
48
  onEvent: OnEvent;
42
49
  }): ChapterPills;
50
+ export interface Disclosure {
51
+ readonly element: HTMLElement;
52
+ readonly open: boolean;
53
+ toggle(open?: boolean): void;
54
+ dispose(): void;
55
+ }
56
+ export declare function disclosure(host: HTMLElement, options: {
57
+ label: string;
58
+ count?: number;
59
+ open?: boolean;
60
+ content: HTMLElement;
61
+ }): Disclosure;
62
+ declare const PR_STATE: {
63
+ readonly merged: "Merged";
64
+ readonly open: "Open";
65
+ readonly draft: "Draft";
66
+ readonly closed: "Closed";
67
+ };
68
+ export interface PRInfo {
69
+ readonly state?: keyof typeof PR_STATE;
70
+ readonly title?: string;
71
+ readonly href?: string;
72
+ }
73
+ /** A pull request as a small chip: its state's icon and number, the title and state on hover. */
74
+ export declare function prChip(doc: Document, n: string, pr: PRInfo): HTMLElement;
75
+ /**
76
+ * Turns the pull requests in some rendered prose into chips: links to one whose words are its
77
+ * number or URL, and bare `#57148`s the page can resolve. Code, buttons and media stay as they are.
78
+ */
79
+ export declare function linkPRs(root: HTMLElement, find: (n: string) => PRInfo | null): void;
43
80
  export {};
@@ -144,6 +144,14 @@ export type WalkthroughMedia = string | {
144
144
  readonly columns: readonly WalkthroughTableColumn[];
145
145
  readonly rows: readonly WalkthroughTableRow[];
146
146
  readonly caption?: string;
147
+ /**
148
+ * Where the step is too narrow for its columns, each row becomes a block: its primary cell
149
+ * as a title over the rest as term and value (`"auto"`, the default); always; or never
150
+ * (the table scrolls sideways instead).
151
+ */
152
+ readonly stack?: "auto" | "always" | "never";
153
+ /** The column that titles a stacked row (its key); the first by default. */
154
+ readonly primary?: string;
147
155
  } | {
148
156
  readonly kind: "image";
149
157
  readonly src: string;
@@ -205,8 +213,15 @@ export interface WalkthroughStep {
205
213
  readonly title: string;
206
214
  /** A line or two: what it shows and how it was made. `code`, **bold** and [links](…) work. */
207
215
  readonly caption?: string;
208
- /** One slot; two or more sit side by side, stacking where it's narrow. */
216
+ /** One slot, or several one under another (`columns` sets them side by side). */
209
217
  readonly media?: WalkthroughMedia | readonly WalkthroughMedia[];
218
+ /** Media side by side, this many to a row where there's room; one under another by default. */
219
+ readonly columns?: 1 | 2 | 3;
220
+ /**
221
+ * The rest, folded away under the caption behind "More" (Markdown; blank lines start new
222
+ * paragraphs). Keep the title the claim and the caption one sentence; everything else goes here.
223
+ */
224
+ readonly more?: string;
210
225
  /** A taste test: Kit picks one. */
211
226
  readonly options?: readonly WalkthroughOption[];
212
227
  /**
@@ -225,8 +240,15 @@ export interface WalkthroughSection {
225
240
  readonly href: string;
226
241
  readonly label?: string;
227
242
  };
243
+ /**
244
+ * The words that lead its meta line, in text colour: its count by default (`"PR 2 of 5"` where
245
+ * `link` is a pull request, or the doc's `kickers` noun), your own words, or `false` for none.
246
+ */
247
+ readonly kicker?: string | false;
228
248
  readonly status?: WalkthroughStatus;
229
249
  readonly summary?: string;
250
+ /** The rest, folded away under the summary behind "More" (Markdown). */
251
+ readonly more?: string;
230
252
  readonly steps: readonly WalkthroughStep[];
231
253
  }
232
254
  export interface WalkthroughMeta {
@@ -241,6 +263,10 @@ export interface WalkthroughUpdate {
241
263
  readonly text: string;
242
264
  /** The step it's about: its key, id or number ("1.2"). */
243
265
  readonly step?: string;
266
+ /** Its state in a word or two (`"shipped"`, `"changes"`), last on its meta line. */
267
+ readonly status?: string;
268
+ /** Context, folded away under the item: one line each, `"0:04 · Played the compare"`. */
269
+ readonly trail?: readonly string[];
244
270
  }
245
271
  /** A question Kit asked and the agent's answer. */
246
272
  export interface WalkthroughQA {
@@ -249,6 +275,10 @@ export interface WalkthroughQA {
249
275
  readonly q: string;
250
276
  readonly a: string;
251
277
  readonly step?: string;
278
+ /** `"shipped"` or `"changes"` (shown as "Changes queued"), or your own words. */
279
+ readonly status?: string;
280
+ /** What Kit did before asking, folded away under the answer: `"0:04 · Played the compare"`. */
281
+ readonly trail?: readonly string[];
252
282
  }
253
283
  /** The document an agent writes: plain data, JSON but for `mount` media. */
254
284
  export interface WalkthroughDoc {
@@ -256,6 +286,8 @@ export interface WalkthroughDoc {
256
286
  readonly id: string;
257
287
  readonly title: string;
258
288
  readonly summary?: string;
289
+ /** The rest, folded away under the summary behind "More" (Markdown). */
290
+ readonly more?: string;
259
291
  /** Facts beside the title: branch, commit, date… */
260
292
  readonly meta?: Readonly<Record<string, string>> | readonly WalkthroughMeta[];
261
293
  /** Relative media URLs resolve against this. */
@@ -266,8 +298,31 @@ export interface WalkthroughDoc {
266
298
  readonly updates?: readonly WalkthroughUpdate[];
267
299
  /** Kit's questions and the agent's answers. */
268
300
  readonly qa?: readonly WalkthroughQA[];
301
+ /**
302
+ * How sections are counted on their meta line: `"pr"` (the default) gives "PR i of N" to the
303
+ * sections that link a pull request, `{ noun: "Part" }` "Part i of N" to every section, and
304
+ * `false` none. A section's own `kicker` wins over its count, and `false` hides it, without
305
+ * renumbering the rest.
306
+ */
307
+ readonly kickers?: "pr" | {
308
+ readonly noun: string;
309
+ } | false;
310
+ /**
311
+ * The pull requests the page mentions, by number: their state and title. A `#57148` in a title,
312
+ * caption or summary, a link to a pull request, and a section's PR `link` read as a small chip
313
+ * (its state's icon and number; the title on hover).
314
+ */
315
+ readonly prs?: Readonly<Record<string, WalkthroughPR>>;
316
+ /** `owner/name` on GitHub, so a bare `#57148` links to its pull request. */
317
+ readonly repo?: string;
269
318
  readonly sections: readonly WalkthroughSection[];
270
319
  }
320
+ export interface WalkthroughPR {
321
+ readonly state?: "merged" | "open" | "draft" | "closed";
322
+ readonly title?: string;
323
+ /** Its URL, when neither `repo` nor a link on the page gives it. */
324
+ readonly href?: string;
325
+ }
271
326
  type CompareMedia = Extract<WalkthroughMedia, {
272
327
  kind: "compare";
273
328
  }>;
@@ -342,6 +397,9 @@ export type WalkMedia = Exclude<WalkthroughMedia, string | {
342
397
  readonly columns: readonly WalkTableColumn[];
343
398
  readonly rows: readonly Readonly<Record<string, WalkTableCell>>[];
344
399
  readonly caption?: string;
400
+ readonly stack: "auto" | "always" | "never";
401
+ /** The key of the column that titles a stacked row. */
402
+ readonly primary: string;
345
403
  };
346
404
  export interface WalkOption {
347
405
  readonly id: string;
@@ -363,6 +421,9 @@ export interface WalkStep {
363
421
  readonly caption?: string;
364
422
  readonly question?: string;
365
423
  readonly media: readonly WalkMedia[];
424
+ /** Media to a row: 1 (one under another) unless the step asked for more. */
425
+ readonly columns: number;
426
+ readonly more?: string;
366
427
  readonly options: readonly WalkOption[];
367
428
  readonly ask: "note" | "pick" | "none";
368
429
  }
@@ -373,8 +434,11 @@ export interface WalkSection {
373
434
  readonly href: string;
374
435
  readonly label: string;
375
436
  };
437
+ /** What leads its meta line ("PR 2 of 5"), when anything does. */
438
+ readonly kicker?: string;
376
439
  readonly status?: WalkthroughStatus;
377
440
  readonly summary?: string;
441
+ readonly more?: string;
378
442
  readonly steps: readonly WalkStep[];
379
443
  }
380
444
  export interface WalkVerdict {
@@ -391,11 +455,14 @@ export interface FeedItem {
391
455
  readonly q?: string;
392
456
  /** The step's key, when it names one that's there. */
393
457
  readonly step: string | null;
458
+ readonly status?: string;
459
+ readonly trail: readonly string[];
394
460
  }
395
461
  export interface WalkPage {
396
462
  readonly id: string;
397
463
  readonly title: string;
398
464
  readonly summary?: string;
465
+ readonly more?: string;
399
466
  readonly meta: readonly WalkthroughMeta[];
400
467
  readonly verdicts: readonly WalkVerdict[];
401
468
  readonly sections: readonly WalkSection[];
@@ -403,6 +470,10 @@ export interface WalkPage {
403
470
  readonly steps: readonly WalkStep[];
404
471
  /** Updates and answers, newest first. */
405
472
  readonly feed: readonly FeedItem[];
473
+ /** The pull requests the page knows, by number, each with its URL when one is known. */
474
+ readonly prs: Readonly<Record<string, WalkthroughPR>>;
475
+ /** `owner/name`, when the doc gave one. */
476
+ readonly repo?: string;
406
477
  }
407
478
  export declare const DEFAULT_VERDICTS: readonly ["ship", "change", "unsure"];
408
479
  /** A URL-safe id from a title: "Retired model (HTTP 410)" → "retired-model-http-410". */
@@ -470,6 +541,22 @@ export declare function linkLabel(href: string): string;
470
541
  * ask, options lettered, media URLs resolved against `base`, and the verdicts labelled.
471
542
  */
472
543
  export declare function normalizeWalkthrough(doc: WalkthroughDoc): WalkPage;
544
+ /** The number in a pull request's URL (`…/pull/57148`), or null. */
545
+ export declare const prNumber: (href: string) => string | null;
546
+ /** A pull request by number: what the page knows, or (with a repo) its URL. */
547
+ export declare function findPR(prs: Readonly<Record<string, WalkthroughPR>>, n: string, repo?: string): WalkthroughPR | null;
548
+ /** Whether a link is a pull (or merge) request: GitHub's `/pull/123`, GitLab's merge requests. */
549
+ export declare const isPullRequest: (href: string) => boolean;
550
+ /**
551
+ * Whether a table stacks its rows into blocks: always, never, or (auto) when the room it has is
552
+ * less than its columns' natural width.
553
+ */
554
+ export declare function tableStacks(stack: "auto" | "always" | "never", room: number, natural: number): boolean;
555
+ /**
556
+ * The page's bottom reserve for the docked note bar: its height, the gap it floats above the
557
+ * page's edge, and a gap above it, so the last step and a step gone to never sit under it.
558
+ */
559
+ export declare function noteBarReserve(bar: number, inset: number, gap: number): number;
473
560
  /** An ISO time as epoch ms; null when it isn't one. */
474
561
  export declare function parseAt(at: string | undefined): number | null;
475
562
  /** Newest first; items without a time after those with one, later-written first. */
@@ -677,5 +764,7 @@ export declare function feedbackMarkdown(fb: WalkthroughFeedback, verdicts?: rea
677
764
  * Inline Markdown as safe HTML: `code`, **bold**, *italic* and [links](https://…), the rest
678
765
  * escaped. Links take http(s), relative and # URLs only; blank lines make paragraphs' breaks.
679
766
  */
767
+ /** Inline Markdown as plain words, for a contents row, a label or a title attribute. */
768
+ export declare function plainMarkdown(text: string): string;
680
769
  export declare function inlineMarkdown(text: string): string;
681
770
  export {};
@@ -11,6 +11,8 @@ export interface TasteTestOptions extends UiLook {
11
11
  readonly lazy?: boolean;
12
12
  /** The page's steps, for media that name one. */
13
13
  readonly steps?: StepLinks;
14
+ /** Options can be picked (on by default); off, they sit side by side under their labels. */
15
+ readonly pickable?: boolean;
14
16
  }
15
17
  export interface TasteTest {
16
18
  readonly element: HTMLElement;
@@ -35,8 +37,26 @@ export interface WalkthroughOptions extends UiLook {
35
37
  readonly onFeedback?: (feedback: WalkthroughFeedback) => void;
36
38
  /** The page's keys (on by default). */
37
39
  readonly keys?: boolean;
38
- /** The contents and progress rail (on by default). */
39
- readonly rail?: boolean;
40
+ /**
41
+ * Kit's review tools (off by default): progress, notes (typed, voice, ink) and their bar,
42
+ * Copy feedback, the key hints, and picking between options. Off, the page only shows: options
43
+ * sit side by side, and j / k, f and the arrows still work.
44
+ */
45
+ readonly review?: boolean;
46
+ /**
47
+ * The contents and progress rail (on by default): sticky at the page's left edge, the column
48
+ * centred in the room beside it; `"right"` mirrors it. Under 960 px it hides (with review
49
+ * on, a bar on top keeps the progress and the export).
50
+ */
51
+ readonly rail?: boolean | "left" | "right";
52
+ /** Each step on a card of its own (off by default: steps sit on the page, hairlines between). */
53
+ readonly cards?: boolean;
54
+ /**
55
+ * The note bar: a small launcher in the column's corner that opens into the bar on a click, n,
56
+ * a recording or ink, and folds back when it's empty (`"collapsed"`, the default); the bar
57
+ * always there (`"docked"`); or none (`"hidden"`; `send()` still works).
58
+ */
59
+ readonly noteBar?: "collapsed" | "docked" | "hidden";
40
60
  /** Sending a note moves on to the next step (on by default). */
41
61
  readonly advance?: boolean;
42
62
  }