@kitlangton/knobs 0.4.0-next.11 → 0.4.0-next.13
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 +117 -21
- package/dist/dev/{chunk-75gbzbyd.js → chunk-44r02asc.js} +2 -5
- package/dist/dev/{chunk-mjdgzad5.js → chunk-7kns3qe6.js} +29 -25
- package/dist/dev/{chunk-bnhzf1tj.js → chunk-mbhy4jg5.js} +1453 -1097
- package/dist/dev/{chunk-j57rhjtm.js → chunk-pdf3zy95.js} +95 -42
- package/dist/dev/index.js +188 -63
- package/dist/index.js +211 -60
- package/dist/panel.js +2699 -2149
- package/dist/review-react.js +8 -4
- package/dist/review-solid.js +10 -5
- package/dist/review.js +8 -4
- package/dist/types/core/remote.d.ts +10 -2
- package/dist/types/core/schema.d.ts +52 -4
- package/dist/types/core/store.d.ts +45 -8
- package/dist/types/core/variants.d.ts +3 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/panel/dock.d.ts +9 -0
- package/dist/types/panel/gpu/renderer.d.ts +11 -1
- package/dist/types/panel/inspector.d.ts +11 -3
- package/dist/types/panel/presets.d.ts +26 -4
- package/dist/types/panel/scope.d.ts +15 -4
- package/dist/types/ui/canvas-css.d.ts +1 -0
- package/dist/types/ui/canvas-model.d.ts +116 -0
- package/dist/types/ui/canvas.d.ts +66 -0
- package/dist/types/ui/index.d.ts +2 -0
- package/dist/types/ui/react.d.ts +12 -0
- package/dist/types/ui/solid.d.ts +9 -0
- package/dist/ui-react.js +1020 -17
- package/dist/ui-solid.js +1032 -25
- package/dist/ui.js +986 -4
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** The camera: a world point `p` is drawn at `p * scale + (x, y)` in the canvas's own px. */
|
|
2
|
+
export interface CanvasView {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
readonly scale: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CanvasRect {
|
|
8
|
+
readonly x: number;
|
|
9
|
+
readonly y: number;
|
|
10
|
+
readonly w: number;
|
|
11
|
+
readonly h: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CanvasPoint {
|
|
14
|
+
readonly x: number;
|
|
15
|
+
readonly y: number;
|
|
16
|
+
}
|
|
17
|
+
export declare const clamp: (v: number, lo: number, hi: number) => number;
|
|
18
|
+
/**
|
|
19
|
+
* Tiles in rows, in order: each row takes tiles until the next would pass `width`, rows sit `gap`
|
|
20
|
+
* apart and tiles top-align in them. Rects land on whole px, so at 100% they're on the pixel grid.
|
|
21
|
+
*/
|
|
22
|
+
export declare function packRows(sizes: readonly {
|
|
23
|
+
readonly w: number;
|
|
24
|
+
readonly h: number;
|
|
25
|
+
}[], opts: {
|
|
26
|
+
readonly gap: number;
|
|
27
|
+
readonly width: number;
|
|
28
|
+
readonly x?: number;
|
|
29
|
+
readonly y?: number;
|
|
30
|
+
}): CanvasRect[];
|
|
31
|
+
/**
|
|
32
|
+
* How wide rows run so the packed set comes out about `aspect` (width / height): a bisection
|
|
33
|
+
* between the widest tile and one long row, on how the packing actually comes out.
|
|
34
|
+
*/
|
|
35
|
+
export declare function rowWidth(sizes: readonly {
|
|
36
|
+
readonly w: number;
|
|
37
|
+
readonly h: number;
|
|
38
|
+
}[], gap: number, aspect: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Where every item goes: one with an `x` and `y` stays there; the rest pack in rows (`packRows`),
|
|
41
|
+
* under the placed ones if there are any.
|
|
42
|
+
*/
|
|
43
|
+
export declare function layoutCanvas(items: readonly {
|
|
44
|
+
readonly x?: number;
|
|
45
|
+
readonly y?: number;
|
|
46
|
+
readonly w: number;
|
|
47
|
+
readonly h: number;
|
|
48
|
+
}[], opts: {
|
|
49
|
+
readonly gap: number;
|
|
50
|
+
readonly width?: number;
|
|
51
|
+
readonly aspect?: number;
|
|
52
|
+
}): {
|
|
53
|
+
rects: CanvasRect[];
|
|
54
|
+
width: number;
|
|
55
|
+
};
|
|
56
|
+
/** The rect around `rects`, or null for none. */
|
|
57
|
+
export declare function boundsOf(rects: readonly CanvasRect[]): CanvasRect | null;
|
|
58
|
+
/** Screen (canvas px) to world, and back. */
|
|
59
|
+
export declare const toWorld: (v: CanvasView, p: CanvasPoint) => CanvasPoint;
|
|
60
|
+
export declare const toScreen: (v: CanvasView, p: CanvasPoint) => CanvasPoint;
|
|
61
|
+
/** The view at `scale` (clamped to `min`…`max`), with the world point under `at` still under it. */
|
|
62
|
+
export declare function zoomAround(v: CanvasView, scale: number, at: CanvasPoint, min?: number, max?: number): CanvasView;
|
|
63
|
+
/**
|
|
64
|
+
* Two fingers moved: the world point under their old midpoint `from` lands under the new one
|
|
65
|
+
* `to`, with the zoom times `ratio` (zoom around `from`, then follow the midpoint).
|
|
66
|
+
*/
|
|
67
|
+
export declare function pinchView(v: CanvasView, from: CanvasPoint, to: CanvasPoint, ratio: number, min?: number, max?: number): CanvasView;
|
|
68
|
+
/** The most one wheel event zooms (a mouse wheel's notch under ⌘ or ctrl). */
|
|
69
|
+
export declare const WHEEL_ZOOM_MAX = 1.25;
|
|
70
|
+
/**
|
|
71
|
+
* One ⌘/ctrl-wheel event's zoom factor, applied directly: a trackpad pinch (ctrl) at 1% per px,
|
|
72
|
+
* ⌘-scroll at .25%, and never more than `WHEEL_ZOOM_MAX` either way per event, so a mouse
|
|
73
|
+
* wheel's big notches step evenly without springing.
|
|
74
|
+
*/
|
|
75
|
+
export declare function wheelZoom(deltaY: number, pinch: boolean): number;
|
|
76
|
+
/** The view that shows `r` whole and centred in a `w` × `h` canvas, `pad` px in from its edges. */
|
|
77
|
+
export declare function fitView(r: CanvasRect, w: number, h: number, opts?: {
|
|
78
|
+
readonly pad?: number;
|
|
79
|
+
readonly min?: number;
|
|
80
|
+
readonly max?: number;
|
|
81
|
+
}): CanvasView;
|
|
82
|
+
/**
|
|
83
|
+
* A path between two views, `t` 0 → 1. It zooms around the one canvas point both views agree on,
|
|
84
|
+
* at an even rate in log scale, so every point on screen travels one straight line in one
|
|
85
|
+
* direction (no curve from springing x, y and scale apart). Views at the same scale pan straight.
|
|
86
|
+
*/
|
|
87
|
+
export declare function viewPath(from: CanvasView, to: CanvasView): (t: number) => CanvasView;
|
|
88
|
+
/** The translate on the device-pixel grid, so a resting view draws crisp. */
|
|
89
|
+
export declare const snapView: (v: CanvasView, dpr: number) => CanvasView;
|
|
90
|
+
/**
|
|
91
|
+
* The background's dots: `step` world px apart, drawn `size` canvas px apart, and how strongly
|
|
92
|
+
* (0…1): they fade out as they crowd together zooming out and as they spread apart zooming in.
|
|
93
|
+
*/
|
|
94
|
+
export declare function dotGrid(scale: number, step?: number): {
|
|
95
|
+
size: number;
|
|
96
|
+
alpha: number;
|
|
97
|
+
};
|
|
98
|
+
/** What a key does to the view: 0 fits, 1 is 100%, = and - zoom in and out. */
|
|
99
|
+
export type CanvasKey = "fit" | "actual" | "in" | "out";
|
|
100
|
+
export declare function keyAction(e: {
|
|
101
|
+
readonly key: string;
|
|
102
|
+
readonly altKey?: boolean;
|
|
103
|
+
}): CanvasKey | null;
|
|
104
|
+
/** How far each zoom key steps. */
|
|
105
|
+
export declare const KEY_ZOOM = 1.5;
|
|
106
|
+
/**
|
|
107
|
+
* The hand's velocity at release (px/s) from recent samples `{ x, y, t (ms) }`: the travel over
|
|
108
|
+
* the last `window` ms. Zero if the hand had already stopped.
|
|
109
|
+
*/
|
|
110
|
+
export declare function releaseVelocity(samples: readonly {
|
|
111
|
+
readonly x: number;
|
|
112
|
+
readonly y: number;
|
|
113
|
+
readonly t: number;
|
|
114
|
+
}[], now: number, window?: number): CanvasPoint;
|
|
115
|
+
/** Momentum's time constant (s): the coast slows as iOS's scroll does (0.998 per ms). */
|
|
116
|
+
export declare const COAST_TAU: number;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type CanvasPoint, type CanvasRect, type CanvasView } from "./canvas-model.js";
|
|
2
|
+
import { type UiLook } from "./look.js";
|
|
3
|
+
export interface CanvasItem {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
/** Where it sits on the canvas (world px). Without both, it packs into the grid. */
|
|
6
|
+
readonly x?: number;
|
|
7
|
+
readonly y?: number;
|
|
8
|
+
/** The card's size (px). Without them, the card takes its content's size. */
|
|
9
|
+
readonly w?: number;
|
|
10
|
+
readonly h?: number;
|
|
11
|
+
/** Shown above the card. */
|
|
12
|
+
readonly title?: string;
|
|
13
|
+
/** Draws the item into its card; return a cleanup for when it goes. */
|
|
14
|
+
readonly render: (el: HTMLElement) => void | (() => void);
|
|
15
|
+
}
|
|
16
|
+
export interface CanvasOptions extends UiLook {
|
|
17
|
+
readonly items: readonly CanvasItem[];
|
|
18
|
+
/** Between packed items, world px (48). */
|
|
19
|
+
readonly gap?: number;
|
|
20
|
+
/** Around what `fit` and `focus` show, px on screen (48). */
|
|
21
|
+
readonly padding?: number;
|
|
22
|
+
/** How wide packed rows run, world px (as wide as makes the set about the canvas's shape). */
|
|
23
|
+
readonly width?: number;
|
|
24
|
+
/** The zoom's range (.05 … 8). */
|
|
25
|
+
readonly minZoom?: number;
|
|
26
|
+
readonly maxZoom?: number;
|
|
27
|
+
/** The zoom readout, with fit and 100% (true). */
|
|
28
|
+
readonly readout?: boolean;
|
|
29
|
+
/** The view moved: a gesture, a key, a fit or a focus. */
|
|
30
|
+
readonly onView?: (view: CanvasView) => void;
|
|
31
|
+
/** The canvas's accessible name. */
|
|
32
|
+
readonly label?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface Canvas {
|
|
35
|
+
readonly element: HTMLElement;
|
|
36
|
+
readonly view: CanvasView;
|
|
37
|
+
/** Each item's place (world px, its title included). */
|
|
38
|
+
readonly rects: ReadonlyMap<string, CanvasRect>;
|
|
39
|
+
/** Shows every item. */
|
|
40
|
+
fit(): void;
|
|
41
|
+
/** Brings an item to the middle and zooms to fit it (at most 200%). */
|
|
42
|
+
focus(id: string): void;
|
|
43
|
+
/** Zooms to `scale` around a point on the canvas (its middle by default). */
|
|
44
|
+
zoomTo(scale: number, at?: CanvasPoint): void;
|
|
45
|
+
/** New items: those that stay keep their content and glide to new places; new ones fade in, gone ones out. */
|
|
46
|
+
update(items: readonly CanvasItem[]): void;
|
|
47
|
+
/** Whether anything is moving (the frame loop runs only then). */
|
|
48
|
+
readonly moving: boolean;
|
|
49
|
+
/** Frames stepped, and the script time each took (ms), for perf checks. */
|
|
50
|
+
stats(): {
|
|
51
|
+
frames: number;
|
|
52
|
+
p50: number;
|
|
53
|
+
p95: number;
|
|
54
|
+
max: number;
|
|
55
|
+
};
|
|
56
|
+
dispose(): void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An infinite canvas: items as cards on a dotted page that pans and zooms freely. Drag the page
|
|
60
|
+
* (or hold Space, or the middle button, and drag anywhere) or scroll with two fingers to pan;
|
|
61
|
+
* pinch or ⌘/ctrl-scroll to zoom around the pointer. Both follow the hand 1:1 and coast on
|
|
62
|
+
* release. 0 fits everything, 1 is 100%, = and - zoom, and a double-click focuses an item (again,
|
|
63
|
+
* or on the page, fits). Items stay live: clicks and keys reach them. Items without a place pack
|
|
64
|
+
* into rows sized to their content. Nothing moves on load: the first fit is instant.
|
|
65
|
+
*/
|
|
66
|
+
export declare function canvas(container: HTMLElement, options: CanvasOptions): Canvas;
|
package/dist/types/ui/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { codeDiff, diffCounts, diffReview, diffStatus, type CodeDiff, type CodeD
|
|
|
27
27
|
export { compareText, comparePaths, countChanges, diffBar, diffFiles, diffFolders, diffStats, diffTree, fileKey, filesUnder, keepFile, matchPath, parsePatch, splitPath, stepFile, type DiffChange, type DiffFile, type DiffInput, type DiffRows, type DiffSource, type DiffTreeItem, } from "./diff-model.js";
|
|
28
28
|
export { bento, type Bento, type BentoItem, type BentoOptions } from "./bento.js";
|
|
29
29
|
export { fitRect, FIT_MAX, motionBlur, neighbour as bentoNeighbour, planBento, rowTarget, windowOf as bentoWindow, type BentoDirection, type BentoLayout, type BentoMode, type BentoPlan, type BentoRect, } from "./bento-model.js";
|
|
30
|
+
export { canvas, type Canvas, type CanvasItem, type CanvasOptions } from "./canvas.js";
|
|
31
|
+
export { boundsOf as canvasBounds, dotGrid, fitView, layoutCanvas, packRows, viewPath, zoomAround, type CanvasPoint, type CanvasRect, type CanvasView, } from "./canvas-model.js";
|
|
30
32
|
export { activity, type Activity, type ActivityOptions, } from "./activity.js";
|
|
31
33
|
export { diffActivity, flattenActivity, formatDuration, indexActivity, keepSelection as keepActivitySelection, navigateActivity, railSegments, showsSelection, stackRows, type ActivityEvent, type ActivityInput, type ActivityKey, type ActivityKind, type ActivityRow, type RailNode, } from "./activity-model.js";
|
|
32
34
|
export { optionPicker, type OptionPicker, type OptionPickerOptions, type PickerOption, } from "./picker.js";
|
package/dist/types/ui/react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
2
|
import { type Activity as ActivityHandle, type ActivityOptions } from "./activity.js";
|
|
3
3
|
import { type Bento as BentoHandle, type BentoOptions } from "./bento.js";
|
|
4
|
+
import { type Canvas as CanvasHandle, type CanvasOptions } from "./canvas.js";
|
|
4
5
|
import { type CodeDiff as CodeDiffHandle, type CodeDiffOptions, type DiffReview as DiffReviewHandle, type DiffReviewOptions } from "./diff.js";
|
|
5
6
|
import { type OptionPicker as OptionPickerHandle, type OptionPickerOptions, type PickerOption } from "./picker.js";
|
|
6
7
|
import { type Split as SplitHandle, type SplitOptions } from "./split.js";
|
|
@@ -86,6 +87,17 @@ export type BentoProps = BentoOptions & {
|
|
|
86
87
|
* prop; callbacks always call the latest props.
|
|
87
88
|
*/
|
|
88
89
|
export declare function Bento(props: BentoProps): import("react").JSX.Element;
|
|
90
|
+
export type CanvasProps = CanvasOptions & {
|
|
91
|
+
className?: string;
|
|
92
|
+
style?: CSSProperties;
|
|
93
|
+
onReady?: (canvas: CanvasHandle) => void;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* `canvas()` as a component. New `items` update it in place (items that stay keep their content
|
|
97
|
+
* and glide); `onView` always calls the latest prop. Keep `items` (and their `render`s) stable
|
|
98
|
+
* across renders, or each render redraws the cards.
|
|
99
|
+
*/
|
|
100
|
+
export declare function Canvas(props: CanvasProps): import("react").JSX.Element;
|
|
89
101
|
export type ActivityProps = ActivityOptions & {
|
|
90
102
|
className?: string;
|
|
91
103
|
style?: CSSProperties;
|
package/dist/types/ui/solid.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type JSX } from "solid-js";
|
|
2
2
|
import { type Activity as ActivityHandle, type ActivityOptions } from "./activity.js";
|
|
3
3
|
import { type Bento as BentoHandle, type BentoOptions } from "./bento.js";
|
|
4
|
+
import { type Canvas as CanvasHandle, type CanvasOptions } from "./canvas.js";
|
|
4
5
|
import { type CodeDiff as CodeDiffHandle, type CodeDiffOptions, type DiffReview as DiffReviewHandle, type DiffReviewOptions } from "./diff.js";
|
|
5
6
|
import { type OptionPicker as OptionPickerHandle, type OptionPickerOptions, type PickerOption } from "./picker.js";
|
|
6
7
|
import { type Split as SplitHandle, type SplitOptions } from "./split.js";
|
|
@@ -73,6 +74,14 @@ export type BentoProps = BentoOptions & {
|
|
|
73
74
|
* prop; callbacks always call the latest props.
|
|
74
75
|
*/
|
|
75
76
|
export declare function Bento(props: BentoProps): JSX.Element;
|
|
77
|
+
export type CanvasProps = CanvasOptions & {
|
|
78
|
+
onReady?: (canvas: CanvasHandle) => void;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* `canvas()` as a component. New `items` update it in place (items that stay keep their content
|
|
82
|
+
* and glide); `onView` always calls the latest prop.
|
|
83
|
+
*/
|
|
84
|
+
export declare function Canvas(props: CanvasProps): JSX.Element;
|
|
76
85
|
export type ActivityProps = ActivityOptions & {
|
|
77
86
|
onReady?: (activity: ActivityHandle) => void;
|
|
78
87
|
};
|