@kitlangton/knobs 0.4.0-next.8 → 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. */
@@ -410,7 +457,7 @@ export interface WalkTableColumn {
410
457
  * nothing.
411
458
  */
412
459
  export type WalkMedia = Exclude<WalkthroughMedia, string | {
413
- readonly kind: "compare" | "video" | "history" | "stack" | "table";
460
+ readonly kind: "compare" | "video" | "history" | "stack" | "table" | "facts" | "decision";
414
461
  }> | (Omit<CompareMedia, "before" | "after" | "chapters"> & {
415
462
  readonly before: WalkthroughSource;
416
463
  readonly after: WalkthroughSource;
@@ -426,6 +473,13 @@ export type WalkMedia = Exclude<WalkthroughMedia, string | {
426
473
  readonly kind: "stack";
427
474
  readonly base?: string;
428
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[];
429
483
  } | {
430
484
  readonly kind: "table";
431
485
  readonly columns: readonly WalkTableColumn[];
@@ -442,8 +496,30 @@ export interface WalkOption {
442
496
  readonly letter: string;
443
497
  readonly caption?: string;
444
498
  readonly media?: WalkMedia;
499
+ readonly facts?: readonly WalkFact[];
445
500
  readonly suggested: boolean;
446
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
+ }
447
523
  export interface WalkStep {
448
524
  /** `section/step`: where its feedback is kept. */
449
525
  readonly key: string;
@@ -520,6 +596,15 @@ export declare const mediaOf: (src: string) => WalkMedia;
520
596
  export declare function parseAspect(aspect: number | string | undefined): number | undefined;
521
597
  /** Media filled in: a bare URL as a video or image, sources resolved against `base`. */
522
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[];
523
608
  /**
524
609
  * What `history()` draws: the lanes shape as written, or the older groups (`rows` read as
525
610
  * `events`, bare `events` as one group first) for it to lay on the code lane.
@@ -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;