@kitlangton/knobs 0.4.0-next.1 → 0.4.0-next.11

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 (53) hide show
  1. package/README.md +191 -13
  2. package/dist/dev/{chunk-ayb292zj.js → chunk-75gbzbyd.js} +3 -3
  3. package/dist/dev/{chunk-1qzffbpa.js → chunk-bnhzf1tj.js} +240 -87
  4. package/dist/dev/{chunk-8mabjeyk.js → chunk-j57rhjtm.js} +166 -2
  5. package/dist/dev/{chunk-3ygqgy1x.js → chunk-mjdgzad5.js} +15 -2
  6. package/dist/dev/index.js +37 -14
  7. package/dist/index.js +46 -11
  8. package/dist/panel.js +408 -73
  9. package/dist/review-react.js +18580 -0
  10. package/dist/review-solid.js +18482 -0
  11. package/dist/review.js +18488 -0
  12. package/dist/themes.js +281 -23
  13. package/dist/types/core/remote.d.ts +2 -0
  14. package/dist/types/core/schema.d.ts +13 -1
  15. package/dist/types/core/store.d.ts +8 -0
  16. package/dist/types/panel/gpu/renderer.d.ts +2 -0
  17. package/dist/types/panel/presets.d.ts +7 -1
  18. package/dist/types/review/font.d.ts +13 -0
  19. package/dist/types/review/foundations.d.ts +175 -0
  20. package/dist/types/review/index.d.ts +13 -0
  21. package/dist/types/review/react.d.ts +1 -0
  22. package/dist/types/review/solid.d.ts +1 -0
  23. package/dist/types/themes/index.d.ts +7 -2
  24. package/dist/types/themes/review.d.ts +8 -0
  25. package/dist/types/tokens/schema.d.ts +180 -0
  26. package/dist/types/ui/compare-css.d.ts +1 -1
  27. package/dist/types/ui/compare-gpu.d.ts +6 -6
  28. package/dist/types/ui/compare-model.d.ts +85 -2
  29. package/dist/types/ui/compare.d.ts +18 -4
  30. package/dist/types/ui/diff.d.ts +4 -5
  31. package/dist/types/ui/history-css.d.ts +1 -0
  32. package/dist/types/ui/history-model.d.ts +249 -0
  33. package/dist/types/ui/history.d.ts +38 -0
  34. package/dist/types/ui/icons.d.ts +40 -0
  35. package/dist/types/ui/index.d.ts +8 -4
  36. package/dist/types/ui/player-css.d.ts +1 -0
  37. package/dist/types/ui/player.d.ts +51 -0
  38. package/dist/types/ui/review-look.d.ts +6 -0
  39. package/dist/types/ui/review-options.d.ts +28 -0
  40. package/dist/types/ui/selection-pill-css.d.ts +1 -0
  41. package/dist/types/ui/selection-pill.d.ts +106 -0
  42. package/dist/types/ui/timeline-model.d.ts +27 -0
  43. package/dist/types/ui/timeline.d.ts +16 -1
  44. package/dist/types/ui/tree.d.ts +3 -2
  45. package/dist/types/ui/walkthrough-annotations.d.ts +42 -0
  46. package/dist/types/ui/walkthrough-blocks.d.ts +87 -0
  47. package/dist/types/ui/walkthrough-media.d.ts +30 -1
  48. package/dist/types/ui/walkthrough-model.d.ts +469 -5
  49. package/dist/types/ui/walkthrough.d.ts +27 -5
  50. package/dist/ui-react.js +5124 -1031
  51. package/dist/ui-solid.js +5136 -1043
  52. package/dist/ui.js +6411 -2269
  53. package/package.json +13 -1
@@ -0,0 +1,42 @@
1
+ import type { WalkthroughAnnotation } from "./walkthrough-model.js";
2
+ export interface Rect {
3
+ readonly x: number;
4
+ readonly y: number;
5
+ readonly w: number;
6
+ readonly h: number;
7
+ }
8
+ /** The part of the picture in view, 0–1 (`{ u: 0, v: 0, w: 1, h: 1 }` is all of it). */
9
+ export interface View {
10
+ readonly u: number;
11
+ readonly v: number;
12
+ readonly w: number;
13
+ readonly h: number;
14
+ }
15
+ /** Where the picture sits now: its rects in the layer (one, or a compare's two), view and time. */
16
+ export interface Placement {
17
+ readonly rects: readonly Rect[];
18
+ readonly view?: View;
19
+ readonly time?: number;
20
+ }
21
+ export interface AnnotationLayer {
22
+ readonly element: HTMLElement;
23
+ /** Places the marks again: after a resize, a zoom, a seek, a mode change. */
24
+ update(): void;
25
+ dispose(): void;
26
+ }
27
+ /** Whether a mark shows at `time` (always without `at`, or without a time). */
28
+ export declare const showsAt: (a: WalkthroughAnnotation, time: number | undefined) => boolean;
29
+ /**
30
+ * A mark's box in the layer, in px, for a picture at `rect` showing `view` of itself; null when
31
+ * it's out of view.
32
+ */
33
+ export declare function placeMark(a: WalkthroughAnnotation, rect: Rect, view?: View): Rect | null;
34
+ /** Whether a page's annotations show. */
35
+ export declare const annotationsOn: (scope: HTMLElement) => boolean;
36
+ /** Shows or hides every annotation on a page (or a lone slot); its eye buttons follow. */
37
+ export declare function setAnnotations(scope: HTMLElement, on: boolean): void;
38
+ /**
39
+ * Draws `list` over `host` (positioned, the picture's box or a compare's stage), placing it with
40
+ * `place()`; the eye button goes in `corner` (the host by default).
41
+ */
42
+ export declare function annotationLayer(host: HTMLElement, list: readonly WalkthroughAnnotation[], place: () => Placement, corner?: HTMLElement): AnnotationLayer;
@@ -0,0 +1,87 @@
1
+ import { type ContextEvent, type WalkChapter, type WalkMedia, prStatus, type PRState } from "./walkthrough-model.js";
2
+ /** The glyphs the blocks draw. */
3
+ export declare const GLYPH: {
4
+ caret: string;
5
+ };
6
+ /** How media reach the page's steps: `step` on a history event, a stack item or a table cell. */
7
+ export interface StepLinks {
8
+ /** The step a ref names (its key, id or number), or null when there's none. */
9
+ find(ref: string): {
10
+ readonly key: string;
11
+ readonly number: string;
12
+ readonly title: string;
13
+ } | null;
14
+ /** Goes to the step, as j / k do. */
15
+ go(key: string): void;
16
+ }
17
+ type OnEvent = ((event: Omit<ContextEvent, "at" | "step">) => void) | undefined;
18
+ export interface Block {
19
+ dispose(): void;
20
+ context?(): {
21
+ kind: string;
22
+ };
23
+ }
24
+ /**
25
+ * Makes a whole row go to the step a ref names (a click away from its links, Enter or Space when
26
+ * it has focus); nothing trails it, so rows with and without a step line up.
27
+ */
28
+ export declare function rowLink(row: HTMLElement, ref: string | undefined, steps: StepLinks | undefined): void;
29
+ /** A history through `history()`: lanes of spans over a date axis, or the older groups of events. */
30
+ export declare function mountHistory(host: HTMLElement, m: Extract<WalkMedia, {
31
+ kind: "history";
32
+ }>, steps: StepLinks | undefined): Block;
33
+ export declare function mountStack(host: HTMLElement, m: Extract<WalkMedia, {
34
+ kind: "stack";
35
+ }>, steps: StepLinks | undefined, findPR?: (n: string) => PRInfo | null): Block;
36
+ export declare function mountTable(host: HTMLElement, m: Extract<WalkMedia, {
37
+ kind: "table";
38
+ }>, steps: StepLinks | undefined): Block;
39
+ export interface ChapterPills {
40
+ /** The chapter the time is in (call as it plays or seeks): the pill slides to it. */
41
+ sync(): void;
42
+ /** The chapter playing, or null. */
43
+ readonly current: WalkChapter | null;
44
+ dispose(): void;
45
+ }
46
+ export declare function chapterPills(host: HTMLElement, chapters: readonly WalkChapter[], io: {
47
+ /** Seconds. */
48
+ now(): number;
49
+ /** Seeks and plays. */
50
+ seek(time: number): void;
51
+ onEvent: OnEvent;
52
+ }): ChapterPills;
53
+ export interface Disclosure {
54
+ readonly element: HTMLElement;
55
+ readonly open: boolean;
56
+ toggle(open?: boolean): void;
57
+ dispose(): void;
58
+ }
59
+ export declare function disclosure(host: HTMLElement, options: {
60
+ label: string;
61
+ open?: boolean;
62
+ content: HTMLElement;
63
+ }): Disclosure;
64
+ export { prStatus, type PRState };
65
+ /** A pull request's state as GitHub shows it: its glyph and word, quietly tinted; a check after. */
66
+ export declare function prStateLabel(doc: Document, state: PRState, checks: boolean, title?: string): HTMLSpanElement;
67
+ export interface PRInfo {
68
+ readonly state?: PRState;
69
+ readonly kind?: "pr" | "issue";
70
+ readonly checks?: boolean;
71
+ readonly title?: string;
72
+ readonly href?: string;
73
+ }
74
+ /**
75
+ * A pull request (or an issue) as a capsule: its state's glyph and number, tinted quietly by state
76
+ * (neutral where none is known), a faint check where its checks pass, title and state on hover.
77
+ */
78
+ export declare function prChip(doc: Document, n: string, pr: PRInfo): HTMLElement;
79
+ /** What the page knows of a pull request or issue by number (null when nothing). */
80
+ export type FindPR = (n: string, kind: "pr" | "issue") => PRInfo | null;
81
+ /**
82
+ * Turns every pull request and issue ref in some rendered prose into a capsule: links to one
83
+ * whose words are its number or URL, inline code that's just a ref, and bare `#57148`s
84
+ * (`issue:#123` for an issue). One the page knows nothing of is a neutral chip, linked only where
85
+ * the page has a repo.
86
+ */
87
+ export declare function linkPRs(root: HTMLElement, find: FindPR): void;
@@ -1,4 +1,5 @@
1
1
  import { type UiLook } from "./look.js";
2
+ import { type PRInfo, type StepLinks } from "./walkthrough-blocks.js";
2
3
  import { type ContextEvent, type MediaContext, type WalkthroughMedia } from "./walkthrough-model.js";
3
4
  export interface MediaSlotOptions extends UiLook {
4
5
  readonly media: WalkthroughMedia;
@@ -6,7 +7,12 @@ export interface MediaSlotOptions extends UiLook {
6
7
  readonly lazy?: boolean;
7
8
  /** Kit played, paused or sought a video, or showed another diff file (for a note's log). */
8
9
  readonly onEvent?: (event: Omit<ContextEvent, "at" | "step">) => void;
10
+ /** The page's steps, for `step` on a history event, a stack item or a table cell. */
11
+ readonly steps?: StepLinks;
12
+ /** What the page knows of a pull request by its number (a stack row's state and link). */
13
+ readonly findPR?: (n: string) => PRInfo | null;
9
14
  }
15
+ export type { StepLinks };
10
16
  export interface MediaSlot {
11
17
  readonly element: HTMLElement;
12
18
  /** Whether its content is mounted (heavy kinds wait until they're near the view). */
@@ -25,5 +31,28 @@ export interface MediaSlot {
25
31
  }
26
32
  /** Adds the walkthrough's stylesheet once per document. */
27
33
  export declare function injectWalkthroughStyles(doc: Document): void;
28
- export declare function mediaSlot(container: HTMLElement, options: MediaSlotOptions): MediaSlot;
34
+ export declare function mediaSlot(container: HTMLElement, given: MediaSlotOptions): MediaSlot;
29
35
  export declare const CHECK: string;
36
+ type FactsMedia = Extract<WalkthroughMedia, {
37
+ kind: "facts";
38
+ }>;
39
+ type DecisionMedia = Extract<WalkthroughMedia, {
40
+ kind: "decision";
41
+ }>;
42
+ export interface FactsOptions extends UiLook, Omit<FactsMedia, "kind"> {
43
+ }
44
+ export interface DecisionOptions extends UiLook, Omit<DecisionMedia, "kind">, Pick<MediaSlotOptions, "lazy" | "steps" | "onEvent"> {
45
+ }
46
+ /**
47
+ * Term → value pairs in an aligned grid: terms small and faint in a fixed gutter, values beside
48
+ * them, code and evidence as small mono chips; groups under a heading, hairlines between. Each
49
+ * term sits over its value where it's narrow. Also a walkthrough's `{ kind: "facts" }`.
50
+ */
51
+ export declare function facts(container: HTMLElement, options: FactsOptions): MediaSlot;
52
+ /**
53
+ * N ways to go, one recommended: each a title, a sentence, optional media and what changes as
54
+ * facts, side by side where there's room (whole rows only), hairlines between, the recommended one
55
+ * marked by a quiet word. Also a walkthrough's `{ kind: "decision" }`; a step's `options` (Kit
56
+ * picks) look the same.
57
+ */
58
+ export declare function decision(container: HTMLElement, options: DecisionOptions): MediaSlot;