@kitlangton/knobs 0.4.0-next.7 → 0.4.0-next.9

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.
@@ -222,6 +222,20 @@ export type WalkthroughMedia = string | {
222
222
  } | {
223
223
  readonly kind: "text";
224
224
  readonly text: string;
225
+ } | {
226
+ readonly kind: "facts";
227
+ /** A small faint label over it. */
228
+ readonly title?: string;
229
+ /** One run of term → value pairs… */
230
+ readonly facts?: WalkthroughFacts;
231
+ /** …or several, each under a heading, hairlines between. */
232
+ readonly groups?: readonly WalkthroughFactGroup[];
233
+ } | {
234
+ readonly kind: "decision";
235
+ /** Side by side where there's room, one under another where there isn't. */
236
+ readonly options: readonly WalkthroughDecisionOption[];
237
+ /** The word before each option's number: "Option" by default. */
238
+ readonly noun?: string;
225
239
  } | {
226
240
  readonly kind: "mount";
227
241
  readonly mount: (element: HTMLElement) => (() => void) | void;
@@ -229,6 +243,35 @@ export type WalkthroughMedia = string | {
229
243
  readonly height?: number;
230
244
  };
231
245
  export type CalloutTone = "info" | "good" | "warn" | "bad";
246
+ /** A term and its value. */
247
+ export interface WalkthroughFact {
248
+ readonly term: string;
249
+ /** Markdown, where `code` reads as a small mono chip; several values sit one under another. */
250
+ readonly value: string | readonly string[];
251
+ /** Each value is code or evidence (a string splits at commas): small mono chips. */
252
+ readonly code?: boolean;
253
+ }
254
+ /** Facts as a list, or as `{ term: value }`. */
255
+ export type WalkthroughFacts = readonly WalkthroughFact[] | Readonly<Record<string, string | readonly string[]>>;
256
+ export interface WalkthroughFactGroup {
257
+ readonly title?: string;
258
+ readonly facts: WalkthroughFacts;
259
+ }
260
+ /** One way to go in a decision. */
261
+ export interface WalkthroughDecisionOption {
262
+ readonly id?: string;
263
+ readonly title: string;
264
+ /** A sentence: what it does. Markdown. */
265
+ readonly summary?: string;
266
+ /** What it looks like: a picture, a compare, code. */
267
+ readonly media?: WalkthroughMedia;
268
+ /** What changes, as facts ("What the user sees", "Size"). */
269
+ readonly facts?: WalkthroughFacts;
270
+ readonly pros?: readonly string[];
271
+ readonly cons?: readonly string[];
272
+ /** The one to take: a quiet "Recommended" beside its number. */
273
+ readonly recommended?: boolean;
274
+ }
232
275
  /** One option in a taste test. */
233
276
  export interface WalkthroughOption {
234
277
  /** "a", "b"… by position when left out. */
@@ -236,8 +279,12 @@ export interface WalkthroughOption {
236
279
  readonly label: string;
237
280
  readonly caption?: string;
238
281
  readonly media?: WalkthroughMedia;
239
- /** The agent's own pick, marked "Suggested". */
282
+ /** What changes, as facts, under its caption. */
283
+ readonly facts?: WalkthroughFacts;
284
+ /** The agent's own pick, marked "Recommended". */
240
285
  readonly suggested?: boolean;
286
+ /** Another name for `suggested`. */
287
+ readonly recommended?: boolean;
241
288
  }
242
289
  export interface WalkthroughStep {
243
290
  /** From the title when left out. */
@@ -352,6 +399,10 @@ export interface WalkthroughDoc {
352
399
  }
353
400
  export interface WalkthroughPR {
354
401
  readonly state?: "merged" | "open" | "draft" | "closed";
402
+ /** An issue rather than a pull request (`issue:` refs and `/issues/` links are). */
403
+ readonly kind?: "pr" | "issue";
404
+ /** Its checks pass (a stack item's status saying green, passing or CI). */
405
+ readonly checks?: boolean;
355
406
  readonly title?: string;
356
407
  /** Its URL, when neither `repo` nor a link on the page gives it. */
357
408
  readonly href?: string;
@@ -406,7 +457,7 @@ export interface WalkTableColumn {
406
457
  * nothing.
407
458
  */
408
459
  export type WalkMedia = Exclude<WalkthroughMedia, string | {
409
- readonly kind: "compare" | "video" | "history" | "stack" | "table";
460
+ readonly kind: "compare" | "video" | "history" | "stack" | "table" | "facts" | "decision";
410
461
  }> | (Omit<CompareMedia, "before" | "after" | "chapters"> & {
411
462
  readonly before: WalkthroughSource;
412
463
  readonly after: WalkthroughSource;
@@ -422,6 +473,13 @@ export type WalkMedia = Exclude<WalkthroughMedia, string | {
422
473
  readonly kind: "stack";
423
474
  readonly base?: string;
424
475
  readonly items: readonly WalkStackItem[];
476
+ } | {
477
+ readonly kind: "facts";
478
+ readonly title?: string;
479
+ readonly groups: readonly WalkFactGroup[];
480
+ } | {
481
+ readonly kind: "decision";
482
+ readonly options: readonly WalkDecisionOption[];
425
483
  } | {
426
484
  readonly kind: "table";
427
485
  readonly columns: readonly WalkTableColumn[];
@@ -438,8 +496,30 @@ export interface WalkOption {
438
496
  readonly letter: string;
439
497
  readonly caption?: string;
440
498
  readonly media?: WalkMedia;
499
+ readonly facts?: readonly WalkFact[];
441
500
  readonly suggested: boolean;
442
501
  }
502
+ /** A fact filled in: its values as a list. */
503
+ export interface WalkFact {
504
+ readonly term: string;
505
+ readonly value: readonly string[];
506
+ readonly code: boolean;
507
+ }
508
+ export interface WalkFactGroup {
509
+ readonly title?: string;
510
+ readonly facts: readonly WalkFact[];
511
+ }
512
+ /** A decision's option filled in: its id, its number's words, pros and cons as facts. */
513
+ export interface WalkDecisionOption {
514
+ readonly id: string;
515
+ /** "Option 1". */
516
+ readonly number: string;
517
+ readonly title: string;
518
+ readonly summary?: string;
519
+ readonly media?: WalkMedia;
520
+ readonly facts: readonly WalkFact[];
521
+ readonly recommended: boolean;
522
+ }
443
523
  export interface WalkStep {
444
524
  /** `section/step`: where its feedback is kept. */
445
525
  readonly key: string;
@@ -516,6 +596,15 @@ export declare const mediaOf: (src: string) => WalkMedia;
516
596
  export declare function parseAspect(aspect: number | string | undefined): number | undefined;
517
597
  /** Media filled in: a bare URL as a video or image, sources resolved against `base`. */
518
598
  export declare function fillMedia(m: WalkthroughMedia, base?: string): WalkMedia;
599
+ /** Facts as a list of terms and their values (a code value split at its commas). */
600
+ export declare function fillFacts(facts: WalkthroughFacts | readonly WalkFact[]): readonly WalkFact[];
601
+ /**
602
+ * How many options sit side by side: as many as fit at `min` px each with `gap` between, up to 4,
603
+ * and always a count that fills whole rows (4 → 4, 2 or 1; 3 → 3 or 1; 5 → 1), so no row is short.
604
+ */
605
+ export declare function optionColumns(count: number, width: number, min?: number, gap?: number): number;
606
+ /** A decision's options filled in: ids, "Option 1"…, pros and cons as the last facts. */
607
+ export declare function fillDecision(options: readonly (WalkthroughDecisionOption | WalkDecisionOption)[], noun?: string, base?: string): readonly WalkDecisionOption[];
519
608
  /**
520
609
  * What `history()` draws: the lanes shape as written, or the older groups (`rows` read as
521
610
  * `events`, bare `events` as one group first) for it to lay on the code lane.
@@ -580,8 +669,23 @@ export declare function linkLabel(href: string): string;
580
669
  export declare function normalizeWalkthrough(doc: WalkthroughDoc): WalkPage;
581
670
  /** The number in a pull request's URL (`…/pull/57148`), or null. */
582
671
  export declare const prNumber: (href: string) => string | null;
583
- /** A pull request by number: what the page knows, or (with a repo) its URL. */
584
- export declare function findPR(prs: Readonly<Record<string, WalkthroughPR>>, n: string, repo?: string): WalkthroughPR | null;
672
+ export type PRState = NonNullable<WalkthroughPR["state"]>;
673
+ /**
674
+ * A pull request's state from some status words: the first word when it's merged, draft, open or
675
+ * closed (any case; shipped and done read as merged), and whether they say its checks pass
676
+ * ("green", "passing", "CI"). The state comes from the words, never a tone.
677
+ */
678
+ export declare function prStatus(status: string | undefined): {
679
+ state: PRState | null;
680
+ checks: boolean;
681
+ };
682
+ /**
683
+ * A pull request (or an issue) by number: what the page knows, or (with a repo) its URL; null
684
+ * when it knows nothing. An issue takes only what `prs` says of it as an issue.
685
+ */
686
+ export declare function findPR(prs: Readonly<Record<string, WalkthroughPR>>, n: string, repo?: string, kind?: "pr" | "issue"): WalkthroughPR | null;
687
+ /** The number in an issue's URL (`…/issues/123`), or null. */
688
+ export declare const issueNumber: (href: string) => string | null;
585
689
  /** Whether a link is a pull (or merge) request: GitHub's `/pull/123`, GitLab's merge requests. */
586
690
  export declare const isPullRequest: (href: string) => boolean;
587
691
  /**
@@ -28,7 +28,7 @@ export interface TasteTest {
28
28
  * A vs B (or more): each option's letter, label and media side by side (stacking where it's
29
29
  * narrow). The picked one takes a check and a wash; the others step back.
30
30
  */
31
- export declare function tasteTest(container: HTMLElement, options: TasteTestOptions): TasteTest;
31
+ export declare function tasteTest(container: HTMLElement, given: TasteTestOptions): TasteTest;
32
32
  export interface WalkthroughOptions extends UiLook {
33
33
  readonly doc: WalkthroughDoc;
34
34
  /** Where Kit's answers are kept (localStorage by default; `null` keeps none). */
@@ -82,4 +82,4 @@ export interface Walkthrough {
82
82
  reset(): void;
83
83
  dispose(): void;
84
84
  }
85
- export declare function walkthrough(container: HTMLElement, options: WalkthroughOptions): Walkthrough;
85
+ export declare function walkthrough(container: HTMLElement, given: WalkthroughOptions): Walkthrough;