@kitlangton/knobs 0.4.0-next.3 → 0.4.0-next.4
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/README.md +47 -4
- package/dist/dev/{chunk-8mabjeyk.js → chunk-0w1xk9jc.js} +162 -1
- package/dist/dev/{chunk-zwj6yngd.js → chunk-76frnh2j.js} +13 -2
- package/dist/dev/{chunk-j6zmtens.js → chunk-rem3qrhz.js} +2 -2
- package/dist/dev/index.js +3 -3
- package/dist/panel.js +175 -2
- package/dist/themes.js +160 -0
- package/dist/types/tokens/schema.d.ts +180 -0
- package/dist/types/ui/compare-css.d.ts +1 -1
- package/dist/types/ui/history-css.d.ts +1 -0
- package/dist/types/ui/history-model.d.ts +236 -0
- package/dist/types/ui/history.d.ts +33 -0
- package/dist/types/ui/walkthrough-blocks.d.ts +20 -1
- package/dist/types/ui/walkthrough-model.d.ts +59 -1
- package/dist/types/ui/walkthrough.d.ts +10 -2
- package/dist/ui-react.js +1276 -627
- package/dist/ui-solid.js +1276 -627
- package/dist/ui.js +1276 -627
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type HistoryData, type HistoryModel } from "./history-model.js";
|
|
2
|
+
import { type UiLook } from "./look.js";
|
|
3
|
+
export type { HistoryBand, HistoryData, HistoryEvent, HistoryEvidence, HistoryGroup, HistoryLane, HistoryProvenance, HistorySpan, HistoryState, HistoryTone, } from "./history-model.js";
|
|
4
|
+
export interface HistoryOptions extends UiLook {
|
|
5
|
+
/** Lanes of spans and events (or the walkthrough's `groups` of events): plain JSON. */
|
|
6
|
+
readonly data: HistoryData;
|
|
7
|
+
/** The selected event or span's id. */
|
|
8
|
+
readonly selected?: string | null;
|
|
9
|
+
/** Clicks and keys moved the selection (a host's `select()` doesn't call it). */
|
|
10
|
+
readonly onSelect?: (id: string | null) => void;
|
|
11
|
+
/** Draws "Go to step" in the detail of anything with a `step`, and Enter on it. */
|
|
12
|
+
readonly onJump?: (step: string) => void;
|
|
13
|
+
/** Its accessible name. */
|
|
14
|
+
readonly label?: string;
|
|
15
|
+
/** Under this width (px) lane labels sit above their lanes instead of beside them (560). */
|
|
16
|
+
readonly narrow?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface History {
|
|
19
|
+
readonly element: HTMLElement;
|
|
20
|
+
/** The data filled in: whole days, lanes, the axis and the order ←/→ walk. */
|
|
21
|
+
readonly model: HistoryModel;
|
|
22
|
+
readonly selected: string | null;
|
|
23
|
+
/** Selects an event or span (`null` clears); doesn't call `onSelect`. */
|
|
24
|
+
select(id: string | null): void;
|
|
25
|
+
set(data: HistoryData): void;
|
|
26
|
+
focus(): void;
|
|
27
|
+
dispose(): void;
|
|
28
|
+
/** The same as `dispose`. */
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
/** Adds the history's stylesheet once per document. */
|
|
32
|
+
export declare function injectHistoryStyles(doc: Document): void;
|
|
33
|
+
export declare function history(container: HTMLElement, options: HistoryOptions): History;
|
|
@@ -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
|
|
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,16 @@ 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;
|
|
43
62
|
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,12 @@ 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
|
|
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
|
+
/** The media after the first fold away under a quiet toggle with these words ("More clips"). */
|
|
221
|
+
readonly more?: string;
|
|
210
222
|
/** A taste test: Kit picks one. */
|
|
211
223
|
readonly options?: readonly WalkthroughOption[];
|
|
212
224
|
/**
|
|
@@ -225,6 +237,11 @@ export interface WalkthroughSection {
|
|
|
225
237
|
readonly href: string;
|
|
226
238
|
readonly label?: string;
|
|
227
239
|
};
|
|
240
|
+
/**
|
|
241
|
+
* The words that lead its meta line, in text colour: its count by default (`"PR 2 of 5"` where
|
|
242
|
+
* `link` is a pull request, or the doc's `kickers` noun), your own words, or `false` for none.
|
|
243
|
+
*/
|
|
244
|
+
readonly kicker?: string | false;
|
|
228
245
|
readonly status?: WalkthroughStatus;
|
|
229
246
|
readonly summary?: string;
|
|
230
247
|
readonly steps: readonly WalkthroughStep[];
|
|
@@ -241,6 +258,10 @@ export interface WalkthroughUpdate {
|
|
|
241
258
|
readonly text: string;
|
|
242
259
|
/** The step it's about: its key, id or number ("1.2"). */
|
|
243
260
|
readonly step?: string;
|
|
261
|
+
/** Its state in a word or two (`"shipped"`, `"changes"`), last on its meta line. */
|
|
262
|
+
readonly status?: string;
|
|
263
|
+
/** Context, folded away under the item: one line each, `"0:04 · Played the compare"`. */
|
|
264
|
+
readonly trail?: readonly string[];
|
|
244
265
|
}
|
|
245
266
|
/** A question Kit asked and the agent's answer. */
|
|
246
267
|
export interface WalkthroughQA {
|
|
@@ -249,6 +270,10 @@ export interface WalkthroughQA {
|
|
|
249
270
|
readonly q: string;
|
|
250
271
|
readonly a: string;
|
|
251
272
|
readonly step?: string;
|
|
273
|
+
/** `"shipped"` or `"changes"` (shown as "Changes queued"), or your own words. */
|
|
274
|
+
readonly status?: string;
|
|
275
|
+
/** What Kit did before asking, folded away under the answer: `"0:04 · Played the compare"`. */
|
|
276
|
+
readonly trail?: readonly string[];
|
|
252
277
|
}
|
|
253
278
|
/** The document an agent writes: plain data, JSON but for `mount` media. */
|
|
254
279
|
export interface WalkthroughDoc {
|
|
@@ -266,6 +291,15 @@ export interface WalkthroughDoc {
|
|
|
266
291
|
readonly updates?: readonly WalkthroughUpdate[];
|
|
267
292
|
/** Kit's questions and the agent's answers. */
|
|
268
293
|
readonly qa?: readonly WalkthroughQA[];
|
|
294
|
+
/**
|
|
295
|
+
* How sections are counted on their meta line: `"pr"` (the default) gives "PR i of N" to the
|
|
296
|
+
* sections that link a pull request, `{ noun: "Part" }` "Part i of N" to every section, and
|
|
297
|
+
* `false` none. A section's own `kicker` wins over its count, and `false` hides it, without
|
|
298
|
+
* renumbering the rest.
|
|
299
|
+
*/
|
|
300
|
+
readonly kickers?: "pr" | {
|
|
301
|
+
readonly noun: string;
|
|
302
|
+
} | false;
|
|
269
303
|
readonly sections: readonly WalkthroughSection[];
|
|
270
304
|
}
|
|
271
305
|
type CompareMedia = Extract<WalkthroughMedia, {
|
|
@@ -342,6 +376,9 @@ export type WalkMedia = Exclude<WalkthroughMedia, string | {
|
|
|
342
376
|
readonly columns: readonly WalkTableColumn[];
|
|
343
377
|
readonly rows: readonly Readonly<Record<string, WalkTableCell>>[];
|
|
344
378
|
readonly caption?: string;
|
|
379
|
+
readonly stack: "auto" | "always" | "never";
|
|
380
|
+
/** The key of the column that titles a stacked row. */
|
|
381
|
+
readonly primary: string;
|
|
345
382
|
};
|
|
346
383
|
export interface WalkOption {
|
|
347
384
|
readonly id: string;
|
|
@@ -363,6 +400,9 @@ export interface WalkStep {
|
|
|
363
400
|
readonly caption?: string;
|
|
364
401
|
readonly question?: string;
|
|
365
402
|
readonly media: readonly WalkMedia[];
|
|
403
|
+
/** Media to a row: 1 (one under another) unless the step asked for more. */
|
|
404
|
+
readonly columns: number;
|
|
405
|
+
readonly more?: string;
|
|
366
406
|
readonly options: readonly WalkOption[];
|
|
367
407
|
readonly ask: "note" | "pick" | "none";
|
|
368
408
|
}
|
|
@@ -373,6 +413,8 @@ export interface WalkSection {
|
|
|
373
413
|
readonly href: string;
|
|
374
414
|
readonly label: string;
|
|
375
415
|
};
|
|
416
|
+
/** What leads its meta line ("PR 2 of 5"), when anything does. */
|
|
417
|
+
readonly kicker?: string;
|
|
376
418
|
readonly status?: WalkthroughStatus;
|
|
377
419
|
readonly summary?: string;
|
|
378
420
|
readonly steps: readonly WalkStep[];
|
|
@@ -391,6 +433,8 @@ export interface FeedItem {
|
|
|
391
433
|
readonly q?: string;
|
|
392
434
|
/** The step's key, when it names one that's there. */
|
|
393
435
|
readonly step: string | null;
|
|
436
|
+
readonly status?: string;
|
|
437
|
+
readonly trail: readonly string[];
|
|
394
438
|
}
|
|
395
439
|
export interface WalkPage {
|
|
396
440
|
readonly id: string;
|
|
@@ -470,6 +514,18 @@ export declare function linkLabel(href: string): string;
|
|
|
470
514
|
* ask, options lettered, media URLs resolved against `base`, and the verdicts labelled.
|
|
471
515
|
*/
|
|
472
516
|
export declare function normalizeWalkthrough(doc: WalkthroughDoc): WalkPage;
|
|
517
|
+
/** Whether a link is a pull (or merge) request: GitHub's `/pull/123`, GitLab's merge requests. */
|
|
518
|
+
export declare const isPullRequest: (href: string) => boolean;
|
|
519
|
+
/**
|
|
520
|
+
* Whether a table stacks its rows into blocks: always, never, or (auto) when the room it has is
|
|
521
|
+
* less than its columns' natural width.
|
|
522
|
+
*/
|
|
523
|
+
export declare function tableStacks(stack: "auto" | "always" | "never", room: number, natural: number): boolean;
|
|
524
|
+
/**
|
|
525
|
+
* The page's bottom reserve for the docked note bar: its height, the gap it floats above the
|
|
526
|
+
* page's edge, and a gap above it, so the last step and a step gone to never sit under it.
|
|
527
|
+
*/
|
|
528
|
+
export declare function noteBarReserve(bar: number, inset: number, gap: number): number;
|
|
473
529
|
/** An ISO time as epoch ms; null when it isn't one. */
|
|
474
530
|
export declare function parseAt(at: string | undefined): number | null;
|
|
475
531
|
/** Newest first; items without a time after those with one, later-written first. */
|
|
@@ -677,5 +733,7 @@ export declare function feedbackMarkdown(fb: WalkthroughFeedback, verdicts?: rea
|
|
|
677
733
|
* Inline Markdown as safe HTML: `code`, **bold**, *italic* and [links](https://…), the rest
|
|
678
734
|
* escaped. Links take http(s), relative and # URLs only; blank lines make paragraphs' breaks.
|
|
679
735
|
*/
|
|
736
|
+
/** Inline Markdown as plain words, for a contents row, a label or a title attribute. */
|
|
737
|
+
export declare function plainMarkdown(text: string): string;
|
|
680
738
|
export declare function inlineMarkdown(text: string): string;
|
|
681
739
|
export {};
|
|
@@ -35,8 +35,16 @@ export interface WalkthroughOptions extends UiLook {
|
|
|
35
35
|
readonly onFeedback?: (feedback: WalkthroughFeedback) => void;
|
|
36
36
|
/** The page's keys (on by default). */
|
|
37
37
|
readonly keys?: boolean;
|
|
38
|
-
/** The contents and progress rail (on by default). */
|
|
39
|
-
readonly rail?: boolean;
|
|
38
|
+
/** The contents and progress rail (on by default), beside the column on the right or left. */
|
|
39
|
+
readonly rail?: boolean | "right" | "left";
|
|
40
|
+
/** Each step on a card of its own (off by default: steps sit on the page, hairlines between). */
|
|
41
|
+
readonly cards?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The note bar: a small launcher in the column's corner that opens into the bar on a click, n,
|
|
44
|
+
* a recording or ink, and folds back when it's empty (`"collapsed"`, the default); the bar
|
|
45
|
+
* always there (`"docked"`); or none (`"hidden"`; `send()` still works).
|
|
46
|
+
*/
|
|
47
|
+
readonly noteBar?: "collapsed" | "docked" | "hidden";
|
|
40
48
|
/** Sending a note moves on to the next step (on by default). */
|
|
41
49
|
readonly advance?: boolean;
|
|
42
50
|
}
|