@kitlangton/knobs 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +1270 -2
- package/dist/dev/chunk-e13znr7c.js +155 -0
- package/dist/dev/chunk-kdewv0mt.js +1334 -0
- package/dist/dev/chunk-ktsn42p7.js +15668 -0
- package/dist/dev/chunk-qtt698hp.js +1118 -0
- package/dist/dev/index.js +1389 -0
- package/dist/index.js +2367 -0
- package/dist/panel.js +23635 -0
- package/dist/react.js +326 -0
- package/dist/solid.js +336 -0
- package/dist/themes.js +235 -0
- package/dist/types/core/adapter.d.ts +21 -0
- package/dist/types/core/code.d.ts +3 -0
- package/dist/types/core/color.d.ts +27 -0
- package/dist/types/core/easing.d.ts +21 -0
- package/dist/types/core/internal.d.ts +18 -0
- package/dist/types/core/keys.d.ts +21 -0
- package/dist/types/core/mutate.d.ts +21 -0
- package/dist/types/core/ramp.d.ts +150 -0
- package/dist/types/core/random.d.ts +2 -0
- package/dist/types/core/readout.d.ts +73 -0
- package/dist/types/core/remote.d.ts +258 -0
- package/dist/types/core/schema.d.ts +526 -0
- package/dist/types/core/spring.d.ts +38 -0
- package/dist/types/core/storage.d.ts +8 -0
- package/dist/types/core/store.d.ts +474 -0
- package/dist/types/core/theme.d.ts +27 -0
- package/dist/types/core/variants.d.ts +17 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/panel/attach.d.ts +5 -0
- package/dist/types/panel/choice.d.ts +56 -0
- package/dist/types/panel/die.d.ts +121 -0
- package/dist/types/panel/editors.d.ts +159 -0
- package/dist/types/panel/folds.d.ts +14 -0
- package/dist/types/panel/give.d.ts +73 -0
- package/dist/types/panel/gpu/atlas.d.ts +40 -0
- package/dist/types/panel/gpu/color.d.ts +128 -0
- package/dist/types/panel/gpu/die.wgsl.d.ts +1 -0
- package/dist/types/panel/gpu/renderer.d.ts +712 -0
- package/dist/types/panel/gpu/shader.wgsl.d.ts +2 -0
- package/dist/types/panel/haptics.d.ts +8 -0
- package/dist/types/panel/has.d.ts +14 -0
- package/dist/types/panel/hints.d.ts +45 -0
- package/dist/types/panel/icons.d.ts +30 -0
- package/dist/types/panel/index.d.ts +10 -0
- package/dist/types/panel/inspector.d.ts +20 -0
- package/dist/types/panel/measure.d.ts +6 -0
- package/dist/types/panel/menu.d.ts +38 -0
- package/dist/types/panel/morph.d.ts +38 -0
- package/dist/types/panel/motion.d.ts +77 -0
- package/dist/types/panel/page-hints.d.ts +82 -0
- package/dist/types/panel/page.d.ts +423 -0
- package/dist/types/panel/panel.d.ts +43 -0
- package/dist/types/panel/position.d.ts +5 -0
- package/dist/types/panel/prefs.d.ts +28 -0
- package/dist/types/panel/presets.d.ts +48 -0
- package/dist/types/panel/ramps.d.ts +14 -0
- package/dist/types/panel/readout-row.d.ts +21 -0
- package/dist/types/panel/reveal.d.ts +15 -0
- package/dist/types/panel/rolling-css.d.ts +2 -0
- package/dist/types/panel/search.d.ts +36 -0
- package/dist/types/panel/seg.d.ts +15 -0
- package/dist/types/panel/session.d.ts +21 -0
- package/dist/types/panel/slider.d.ts +92 -0
- package/dist/types/panel/smear.d.ts +7 -0
- package/dist/types/panel/spin.d.ts +13 -0
- package/dist/types/panel/styles.d.ts +11 -0
- package/dist/types/panel/swipe.d.ts +114 -0
- package/dist/types/panel/switcher.d.ts +20 -0
- package/dist/types/panel/tabs.d.ts +31 -0
- package/dist/types/panel/thumb.d.ts +36 -0
- package/dist/types/react/Knobs.d.ts +15 -0
- package/dist/types/react/VariantSwitcher.d.ts +10 -0
- package/dist/types/react/index.d.ts +3 -0
- package/dist/types/react/useControls.d.ts +11 -0
- package/dist/types/solid/index.d.ts +50 -0
- package/dist/types/themes/index.d.ts +1 -0
- package/dist/types/ui/bento-css.d.ts +1 -0
- package/dist/types/ui/bento-model.d.ts +96 -0
- package/dist/types/ui/bento.d.ts +77 -0
- package/dist/types/ui/commands.d.ts +11 -0
- package/dist/types/ui/confirm.d.ts +13 -0
- package/dist/types/ui/index.d.ts +20 -0
- package/dist/types/ui/layer.d.ts +70 -0
- package/dist/types/ui/look.d.ts +53 -0
- package/dist/types/ui/menu.d.ts +63 -0
- package/dist/types/ui/overlay-css.d.ts +1 -0
- package/dist/types/ui/overlay-model.d.ts +87 -0
- package/dist/types/ui/palette.d.ts +38 -0
- package/dist/types/ui/popover.d.ts +35 -0
- package/dist/types/ui/react.d.ts +45 -0
- package/dist/types/ui/readout-css.d.ts +1 -0
- package/dist/types/ui/readout-model.d.ts +137 -0
- package/dist/types/ui/readouts.d.ts +85 -0
- package/dist/types/ui/rgba.d.ts +6 -0
- package/dist/types/ui/solid.d.ts +40 -0
- package/dist/types/ui/split-model.d.ts +81 -0
- package/dist/types/ui/split.d.ts +75 -0
- package/dist/types/ui/timeline-model.d.ts +83 -0
- package/dist/types/ui/timeline.d.ts +76 -0
- package/dist/types/ui/toast.d.ts +19 -0
- package/dist/types/ui/tooltip.d.ts +19 -0
- package/dist/types/ui/tree-model.d.ts +125 -0
- package/dist/types/ui/tree.d.ts +95 -0
- package/dist/ui-react.js +6558 -0
- package/dist/ui-solid.js +6511 -0
- package/dist/ui.js +9238 -0
- package/package.json +99 -4
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Spring, type SpringValue } from "../core/spring.js";
|
|
2
|
+
export declare const DIE: {
|
|
3
|
+
readonly half: number;
|
|
4
|
+
readonly round: number;
|
|
5
|
+
readonly pip: 12;
|
|
6
|
+
};
|
|
7
|
+
/** Pip centres per face value, relative to the face centre, in icon units (y down). */
|
|
8
|
+
export declare const PIPS: Record<number, readonly (readonly [number, number])[]>;
|
|
9
|
+
type V3 = readonly [number, number, number];
|
|
10
|
+
/**
|
|
11
|
+
* Faces: value, the cube rotation that brings it to the front, and its outward normal and in-plane
|
|
12
|
+
* axes in cube space (the front face rotated by the inverse turn). Opposites sum to 7.
|
|
13
|
+
*/
|
|
14
|
+
export declare const FACES: {
|
|
15
|
+
value: 3 | 1 | 2 | 4 | 5 | 6;
|
|
16
|
+
front: readonly [0 | 90 | -90, 0 | 180 | 90 | -90];
|
|
17
|
+
n: V3;
|
|
18
|
+
u: V3;
|
|
19
|
+
v: V3;
|
|
20
|
+
}[];
|
|
21
|
+
export interface DieLook {
|
|
22
|
+
/** Eye distance in icon sizes at full spin (the resting die is seen orthographically). */
|
|
23
|
+
readonly perspective: number;
|
|
24
|
+
/** How far a spinning die rises towards the eye, in icon sizes, at full spin. */
|
|
25
|
+
readonly lift: number;
|
|
26
|
+
/** Degrees from a face where the inked bevel begins (atan ½ ≈ 26.6° is Phosphor's outline). */
|
|
27
|
+
readonly bevel: number;
|
|
28
|
+
/** Face fill while spinning: ambient and lit (Lambert) parts. */
|
|
29
|
+
readonly fill: number;
|
|
30
|
+
readonly shade: number;
|
|
31
|
+
}
|
|
32
|
+
export declare const DIE_LOOK: DieLook;
|
|
33
|
+
export interface DieSpin {
|
|
34
|
+
readonly spring: SpringValue;
|
|
35
|
+
/** Extra whole turns per roll. */
|
|
36
|
+
readonly turns: number;
|
|
37
|
+
}
|
|
38
|
+
export declare const DIE_SPIN: DieSpin;
|
|
39
|
+
/**
|
|
40
|
+
* The box around a die of `size` px, in sizes: room for the corners while it tumbles and lifts
|
|
41
|
+
* (they reach 0.6 of a size out at the default look), so it overflows its button's round wash
|
|
42
|
+
* rather than clipping to it. Past `DIE_FEATHER` of the way out it fades, so a die tuned to lift
|
|
43
|
+
* further never meets a hard edge.
|
|
44
|
+
*/
|
|
45
|
+
export declare const DIE_BOX = 2;
|
|
46
|
+
export declare const DIE_FEATHER = 0.75;
|
|
47
|
+
export declare const dieBox: (size: number) => number;
|
|
48
|
+
/** How much of the die shows `r` px from its centre: all of it, fading out at the box's edge. */
|
|
49
|
+
export declare function dieFeather(size: number, r: number): number;
|
|
50
|
+
/** Supersamples per axis: dense at icon sizes, cheaper when large. */
|
|
51
|
+
export declare const dieSamples: (size: number) => 3 | 6;
|
|
52
|
+
export declare class DieMotion {
|
|
53
|
+
readonly rx: Spring;
|
|
54
|
+
readonly ry: Spring;
|
|
55
|
+
value: number;
|
|
56
|
+
turns: number;
|
|
57
|
+
constructor(spin?: DieSpin);
|
|
58
|
+
tune({ spring, turns }: DieSpin): void;
|
|
59
|
+
/** Tumble to a different face (or `to`) from wherever it is now. */
|
|
60
|
+
roll(to?: number, random?: () => number): 3 | 1 | 2 | 4 | 5 | 6;
|
|
61
|
+
/** A quarter turn onto a neighbouring face: a nudge rather than a roll. */
|
|
62
|
+
nudge(random?: () => number): 3 | 1 | 2 | 4 | 5 | 6;
|
|
63
|
+
/** A quarter turn sideways (`dir` +1 rolls it rightwards): a die rolled along under the fingers. */
|
|
64
|
+
turn(dir: -1 | 1): number;
|
|
65
|
+
snapTo(value: number): void;
|
|
66
|
+
/** Advance; returns the orientation (degrees) and spin energy 0…1 for lift and shading. */
|
|
67
|
+
step(dt: number): DieView;
|
|
68
|
+
get resting(): boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface DieView {
|
|
71
|
+
readonly rx: number;
|
|
72
|
+
readonly ry: number;
|
|
73
|
+
readonly energy: number;
|
|
74
|
+
}
|
|
75
|
+
/** The face a cube turned `rx`, `ry` (degrees) shows the viewer. */
|
|
76
|
+
export declare function frontFace(rx: number, ry: number): 3 | 1 | 2 | 4 | 5 | 6;
|
|
77
|
+
/** Light direction for the spin shading (towards the viewer, from the upper left; y down). */
|
|
78
|
+
export declare const DIE_LIGHT: V3;
|
|
79
|
+
/**
|
|
80
|
+
* Traces one ray through the pixel offset (`x`, `y`) px from the die's centre and returns
|
|
81
|
+
* ink + fill coverage (0…1), or `MISS`. Mirrors `die_trace` in die.wgsl.ts step for step.
|
|
82
|
+
*/
|
|
83
|
+
export declare function dieTracer(size: number, view: DieView, look: DieLook): (x: number, y: number) => number;
|
|
84
|
+
/**
|
|
85
|
+
* The DOM die: a canvas traced in JS. Its backing store is whole device pixels and `render` takes
|
|
86
|
+
* the die centre in those pixels, so the caller can land the canvas on the pixel grid (no
|
|
87
|
+
* resampling blur). Each pixel is traced 2×2; only pixels whose samples disagree (an edge, a pip)
|
|
88
|
+
* are refined at `dieSamples` × `dieSamples`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createDieCanvas(doc: Document, size: number): {
|
|
91
|
+
canvas: HTMLCanvasElement;
|
|
92
|
+
/** Backing size (device px) for a given ratio; the CSS size is this over the ratio. */
|
|
93
|
+
pixels: (dpr: number) => number;
|
|
94
|
+
render(view: DieView, look: DieLook, rgba: readonly [number, number, number, number], dpr: number, centre: readonly [number, number]): void;
|
|
95
|
+
};
|
|
96
|
+
/** Icon size of the header die (px), matching the other header icons. */
|
|
97
|
+
export declare const HEADER_DIE = 14;
|
|
98
|
+
/** A group's die, beside its reset icon. */
|
|
99
|
+
export declare const GROUP_DIE = 13;
|
|
100
|
+
/**
|
|
101
|
+
* A die button's icon. It is always the traced die, rolling or at rest, so nothing swaps shape
|
|
102
|
+
* when a roll starts or lands. In the DOM it is a canvas laid on whole device pixels and re-traced
|
|
103
|
+
* when its colour changes (hover, focus, theme) or the zoom does; in GPU mode the canvas is skipped
|
|
104
|
+
* and the renderer traces `view` itself, with `onFrame` waking it.
|
|
105
|
+
*/
|
|
106
|
+
export declare function createHeaderDie(doc: Document, onFrame: () => void, size?: number): {
|
|
107
|
+
node: HTMLSpanElement;
|
|
108
|
+
size: number;
|
|
109
|
+
/** Tumble to another face; `nudge` turns a quarter onto a neighbour instead (Mutate). */
|
|
110
|
+
roll(nudge?: boolean): void;
|
|
111
|
+
/** A quarter turn sideways with a pan (`dir` +1 rightwards). */
|
|
112
|
+
turn(dir: -1 | 1): void;
|
|
113
|
+
/** Re-trace now (e.g. after the panel moved or switched renderer). */
|
|
114
|
+
repaint: () => void;
|
|
115
|
+
readonly view: DieView;
|
|
116
|
+
readonly value: number;
|
|
117
|
+
readonly rolling: boolean;
|
|
118
|
+
dispose(): void;
|
|
119
|
+
};
|
|
120
|
+
export type HeaderDie = ReturnType<typeof createHeaderDie>;
|
|
121
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { type Oklch } from "../core/color.js";
|
|
2
|
+
import { type ColorField, type EasingField, type Knob, type PointField, type SpringField, type Value } from "../core/schema.js";
|
|
3
|
+
import { type SpringValue } from "../core/spring.js";
|
|
4
|
+
import type { GpuExpander, GpuRowBinding, GpuStrip, RowWave } from "./gpu/renderer.js";
|
|
5
|
+
import { type Slider } from "./slider.js";
|
|
6
|
+
/** What a row needs from the panel. */
|
|
7
|
+
export interface RowContext<F> {
|
|
8
|
+
readonly doc: Document;
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly display: string;
|
|
11
|
+
readonly field: F;
|
|
12
|
+
readonly wave: RowWave;
|
|
13
|
+
get(): Value;
|
|
14
|
+
set(value: unknown, options?: {
|
|
15
|
+
coalesce?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
isModified(): boolean;
|
|
18
|
+
wake(): void;
|
|
19
|
+
/** Opens a disclosure row's editor at once, as it was before a reload. */
|
|
20
|
+
readonly expanded?: boolean;
|
|
21
|
+
/** A flat spring's two number fields: their ranges, labels and units replace the defaults. */
|
|
22
|
+
readonly parts?: {
|
|
23
|
+
readonly duration: Knob;
|
|
24
|
+
readonly bounce: Knob;
|
|
25
|
+
};
|
|
26
|
+
onExpand?(open: boolean): void;
|
|
27
|
+
}
|
|
28
|
+
/** A slider inside a compound row, adjusted by the panel's arrow keys like a knob row. */
|
|
29
|
+
export interface SubTrack {
|
|
30
|
+
readonly slider: Slider;
|
|
31
|
+
readonly field: Knob;
|
|
32
|
+
get(): number;
|
|
33
|
+
set(value: number): void;
|
|
34
|
+
}
|
|
35
|
+
export interface EditorRow {
|
|
36
|
+
readonly row: HTMLElement;
|
|
37
|
+
readonly labelEl: HTMLElement;
|
|
38
|
+
/** Where the row's ↑↓ stop lands. */
|
|
39
|
+
readonly input: HTMLElement;
|
|
40
|
+
/** Every ↑↓ stop in the row, in order (an open editor's parts follow its head). */
|
|
41
|
+
stops(): HTMLElement[];
|
|
42
|
+
/**
|
|
43
|
+
* `instant` places the value without motion (a different item arrived); `mixed` shows it as
|
|
44
|
+
* indeterminate (a multi-selection whose items differ).
|
|
45
|
+
*/
|
|
46
|
+
update(value: Value, delay: number, instant?: boolean, mixed?: boolean): void;
|
|
47
|
+
/** Reads what `update` will, ahead of a batch's writes (see `Slider.prime`). */
|
|
48
|
+
prime?(): void;
|
|
49
|
+
/** A flat spring's halves changed range or label (see `RowContext.parts`). */
|
|
50
|
+
retune?(parts: {
|
|
51
|
+
readonly duration: Knob;
|
|
52
|
+
readonly bounce: Knob;
|
|
53
|
+
}): void;
|
|
54
|
+
dispose(): void;
|
|
55
|
+
readonly tracks: readonly SubTrack[];
|
|
56
|
+
readonly gpu: readonly GpuRowBinding[];
|
|
57
|
+
}
|
|
58
|
+
export declare const reducedMotion: (doc: Document) => boolean;
|
|
59
|
+
export declare const rgbCss: (rgb: readonly number[]) => string;
|
|
60
|
+
export declare const pathOf: (pts: readonly number[]) => string;
|
|
61
|
+
export declare const visible: (node: HTMLElement) => boolean;
|
|
62
|
+
/** Applies a placement, skipping the transition when it's the first one or a resize. */
|
|
63
|
+
export declare function place(nodes: readonly (HTMLElement | SVGElement)[], instant: boolean, apply: () => void): void;
|
|
64
|
+
export declare function setPath(path: SVGPathElement, pts: readonly number[]): void;
|
|
65
|
+
/** One undo step per gesture: the first change that lands records history, the rest fold in. */
|
|
66
|
+
export declare function gesture(c: RowContext<unknown>): {
|
|
67
|
+
start(): void;
|
|
68
|
+
set(value: unknown): void;
|
|
69
|
+
};
|
|
70
|
+
export declare function factory(doc: Document): {
|
|
71
|
+
el: <K extends keyof HTMLElementTagNameMap>(tag: K, cls?: string, text?: string) => HTMLElementTagNameMap[K];
|
|
72
|
+
svg: <K extends keyof SVGElementTagNameMap>(tag: K, cls?: string) => SVGElementTagNameMap[K];
|
|
73
|
+
};
|
|
74
|
+
export declare const plainKey: (event: KeyboardEvent) => boolean;
|
|
75
|
+
/** A size kept current by a ResizeObserver, so layout reads stay out of the frame loop. */
|
|
76
|
+
export declare function measure(node: Element, onResize: () => void): {
|
|
77
|
+
w: number;
|
|
78
|
+
h: number;
|
|
79
|
+
disconnect: () => void;
|
|
80
|
+
};
|
|
81
|
+
export declare function expander(c: RowContext<unknown>, summary: Node[], body: Node[]): {
|
|
82
|
+
row: HTMLDivElement;
|
|
83
|
+
head: HTMLDivElement;
|
|
84
|
+
label: HTMLSpanElement;
|
|
85
|
+
body: HTMLDivElement;
|
|
86
|
+
isOpen: () => boolean;
|
|
87
|
+
gpu: GpuExpander;
|
|
88
|
+
};
|
|
89
|
+
interface StripOptions {
|
|
90
|
+
label: string;
|
|
91
|
+
aria: string;
|
|
92
|
+
min: number;
|
|
93
|
+
max: number;
|
|
94
|
+
step: number;
|
|
95
|
+
format(value: number): string;
|
|
96
|
+
set(value: number): void;
|
|
97
|
+
start(): void;
|
|
98
|
+
}
|
|
99
|
+
/** A scrub strip: a capsule track (painted by its row) with a ring thumb and a readout. */
|
|
100
|
+
export declare function strip(c: RowContext<unknown>, o: StripOptions): {
|
|
101
|
+
line: HTMLDivElement;
|
|
102
|
+
track: HTMLDivElement;
|
|
103
|
+
thumb: HTMLElement;
|
|
104
|
+
gpu: GpuStrip;
|
|
105
|
+
update(value: number, text?: string): void;
|
|
106
|
+
paint(key: string, fn: (ratio: number) => string): void;
|
|
107
|
+
dispose: () => void;
|
|
108
|
+
};
|
|
109
|
+
/** The step response over a fixed 1.2 s window in a w×h box, as x,y pairs (px). */
|
|
110
|
+
export declare function springCurve(value: SpringValue, w: number, h: number, pad?: number, padX?: number): number[];
|
|
111
|
+
/** Duration and bounce as two sliders beside the curve they make; a dot runs the curve on change. */
|
|
112
|
+
export declare function springRow(c: RowContext<SpringField>): EditorRow;
|
|
113
|
+
/**
|
|
114
|
+
* Hue, relative chroma (0…maxC) and lightness strips for one colour: a colour row's body, and a
|
|
115
|
+
* gradient's editor for its selected stop. `commit` receives each change as OKLCH.
|
|
116
|
+
*/
|
|
117
|
+
export declare function colorStrips(c: RowContext<unknown>, o: {
|
|
118
|
+
aria: string;
|
|
119
|
+
start(): void;
|
|
120
|
+
commit(color: Oklch): void;
|
|
121
|
+
}): {
|
|
122
|
+
body: HTMLDivElement;
|
|
123
|
+
strips: {
|
|
124
|
+
line: HTMLDivElement;
|
|
125
|
+
track: HTMLDivElement;
|
|
126
|
+
thumb: HTMLElement;
|
|
127
|
+
gpu: GpuStrip;
|
|
128
|
+
update(value: number, text?: string): void;
|
|
129
|
+
paint(key: string, fn: (ratio: number) => string): void;
|
|
130
|
+
dispose: () => void;
|
|
131
|
+
}[];
|
|
132
|
+
send: (patch: {
|
|
133
|
+
l?: number;
|
|
134
|
+
r?: number;
|
|
135
|
+
h?: number;
|
|
136
|
+
}) => void;
|
|
137
|
+
color: () => Oklch;
|
|
138
|
+
dragging: () => boolean;
|
|
139
|
+
/** Shows `color` (a new colour, or the same one after an edit); `mixed` dashes the readouts. */
|
|
140
|
+
show(color: Oklch, mixed?: boolean, fresh?: boolean): string;
|
|
141
|
+
dispose(): void;
|
|
142
|
+
};
|
|
143
|
+
/** OKLCH: a swatch and hex in the head; hue, relative chroma (0…maxC) and lightness strips in the body. */
|
|
144
|
+
export declare function colorRow(c: RowContext<ColorField>): EditorRow;
|
|
145
|
+
/** A 2D pad with crosshair guides, the default marked, and a puck that arrows and drags move. */
|
|
146
|
+
export declare function pointRow(c: RowContext<PointField>): EditorRow;
|
|
147
|
+
/**
|
|
148
|
+
* A sideways pan on a row's head steps through its presets like a menu, a tick each, as one undo
|
|
149
|
+
* step; past either end `nudged` (the head's mini strip or curve) gives a little.
|
|
150
|
+
*/
|
|
151
|
+
export declare function panPresets(c: RowContext<unknown>, head: HTMLElement, nudged: HTMLElement | SVGElement, o: {
|
|
152
|
+
readonly count: number;
|
|
153
|
+
/** The preset showing, or -1. */
|
|
154
|
+
at(): number;
|
|
155
|
+
choose(i: number, coalesce: boolean): void;
|
|
156
|
+
}): void;
|
|
157
|
+
/** A mini curve in the head; an editor with two handles and named chips in the body. */
|
|
158
|
+
export declare function easingRow(c: RowContext<EasingField>): EditorRow;
|
|
159
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type StoragePort } from "../core/storage.js";
|
|
2
|
+
/** What a page remembers folded or open: its sections and its group cards. */
|
|
3
|
+
export type FoldKind = "sections" | "groups";
|
|
4
|
+
export interface FoldMemory {
|
|
5
|
+
/** What the user last chose for it, if anything. */
|
|
6
|
+
get(kind: FoldKind, id: string): boolean | undefined;
|
|
7
|
+
set(kind: FoldKind, id: string, folded: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A page's folds, kept under `knobs:<id>:folds:v1` in `storage` as
|
|
11
|
+
* `{ sections: Record<string, boolean>, groups: Record<string, boolean> }`, and nothing else (no
|
|
12
|
+
* values, locks or variants). `null` storage remembers nothing.
|
|
13
|
+
*/
|
|
14
|
+
export declare function foldMemory(id: string, storage: () => StoragePort | null): FoldMemory;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** The most a control gives past an end (px). */
|
|
2
|
+
export declare const GIVE = 6;
|
|
3
|
+
/** The give `over` px of push past an end makes: 1:1 at first, never reaching `max`. */
|
|
4
|
+
export declare const rubber: (over: number, max?: number) => number;
|
|
5
|
+
/** The push (px) that makes `give` (`rubber`'s inverse). */
|
|
6
|
+
export declare const unrubber: (give: number, max?: number) => number;
|
|
7
|
+
/** A position (px) between two ends, and how far it gives past one of them. */
|
|
8
|
+
export interface Band {
|
|
9
|
+
readonly at: number;
|
|
10
|
+
readonly give: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Moves `from.at` by `d` px within [lo, hi]. Past an end the rest of the push stretches the give;
|
|
14
|
+
* travel back takes the give up first, 1:1, and moves on with what's left.
|
|
15
|
+
*/
|
|
16
|
+
export declare function band(from: Band, d: number, lo: number, hi: number, max?: number): Band;
|
|
17
|
+
/** A pan counted in whole steps: travel (px) toward the next one, and any give past an end. */
|
|
18
|
+
export interface Steps {
|
|
19
|
+
readonly travel: number;
|
|
20
|
+
readonly give: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Adds `d` px of pan to `from`, a step every `size` px. `room` is how many steps there are each
|
|
24
|
+
* way (down, up) before this pan: once a way has none left, travel that way stretches the give.
|
|
25
|
+
* Returns the state and the steps to take (signed).
|
|
26
|
+
*/
|
|
27
|
+
export declare function stepBand(from: Steps, d: number, size: number, room: readonly [number, number], max?: number): {
|
|
28
|
+
readonly next: Steps;
|
|
29
|
+
readonly steps: number;
|
|
30
|
+
};
|
|
31
|
+
/** Px of pan per item when a pan steps through a list (a menu's choices, a ramp's presets). */
|
|
32
|
+
export declare const LIST_STEP = 28;
|
|
33
|
+
/**
|
|
34
|
+
* Where a pan through `count` items lands from `at` (-1: none of them, so the first step picks an
|
|
35
|
+
* end), and the state it leaves; `index` is undefined while it stays put.
|
|
36
|
+
*/
|
|
37
|
+
export declare function stepList(from: Steps, d: number, at: number, count: number, size?: number): {
|
|
38
|
+
next: Steps;
|
|
39
|
+
index: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
/** Whether a move went from no give to some: the moment to tick. */
|
|
42
|
+
export declare const stretched: (before: number, after: number) => boolean;
|
|
43
|
+
/** The fingers' speed (px/ms, signed) over their last `window` ms of moves before a lift. */
|
|
44
|
+
export declare function speedOf(moves: readonly {
|
|
45
|
+
readonly t: number;
|
|
46
|
+
readonly d: number;
|
|
47
|
+
}[], window?: number): number;
|
|
48
|
+
/** How many steps a lift at `speed` (px/ms) carries on for: none from a still hand, three at most. */
|
|
49
|
+
export declare const carrySteps: (speed: number) => number;
|
|
50
|
+
/** When each carried step lands (ms after the lift), slowing as it goes. */
|
|
51
|
+
export declare const carryAt: (i: number) => number;
|
|
52
|
+
/** Keeps a pan's recent moves (for `speedOf`), forgetting the old ones. */
|
|
53
|
+
export declare function moves(): {
|
|
54
|
+
add(d: number, t?: number): void;
|
|
55
|
+
speed: () => number;
|
|
56
|
+
reset(): void;
|
|
57
|
+
};
|
|
58
|
+
/** How far (px) a text readout is giving right now, for the GPU to draw it there too. */
|
|
59
|
+
export declare const giveOf: (el: Element) => number;
|
|
60
|
+
/**
|
|
61
|
+
* A text readout's give (a number that can't go further). While in hand it's held where the
|
|
62
|
+
* pan puts it; let go, it springs home on one loop that both renderers read: the DOM as a
|
|
63
|
+
* `translate`, the GPU through `giveOf`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function textGive(el: HTMLElement | SVGElement, wake: () => void): {
|
|
66
|
+
/** The give as last held (0 once let go). */
|
|
67
|
+
readonly give: number;
|
|
68
|
+
/** Holds the give at `px` (signed), ticking as it starts. */
|
|
69
|
+
hold(px: number): void;
|
|
70
|
+
/** Lets go: the give springs home. */
|
|
71
|
+
release(): void;
|
|
72
|
+
};
|
|
73
|
+
export type TextGive = ReturnType<typeof textGive>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const ATLAS_SIZE = 2048;
|
|
2
|
+
export interface AtlasEntry {
|
|
3
|
+
readonly uv: readonly [number, number, number, number];
|
|
4
|
+
readonly w: number;
|
|
5
|
+
readonly h: number;
|
|
6
|
+
readonly pad: number;
|
|
7
|
+
readonly textW: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class LabelAtlas {
|
|
10
|
+
private readonly doc;
|
|
11
|
+
readonly canvas: HTMLCanvasElement;
|
|
12
|
+
private readonly ctx;
|
|
13
|
+
private readonly map;
|
|
14
|
+
private lx;
|
|
15
|
+
private ly;
|
|
16
|
+
private rowH;
|
|
17
|
+
private dirty;
|
|
18
|
+
private dirtyY0;
|
|
19
|
+
private dirtyY1;
|
|
20
|
+
private currentScale;
|
|
21
|
+
constructor(doc: Document);
|
|
22
|
+
private attach;
|
|
23
|
+
detach(): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
/** Glyphs are rasterized at the canvas's own device-pixel ratio so they blit 1:1. */
|
|
26
|
+
ensureScale(scale: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* Starts a frame: a nearly full atlas is cleared now rather than midway through a frame, which
|
|
29
|
+
* would strand glyphs already placed. Gliding font sizes and weights fill it fastest.
|
|
30
|
+
*/
|
|
31
|
+
beginFrame(): void;
|
|
32
|
+
get(text: string, rawPx: number, rawWeight: number, family: string, scaleFactor?: number, letterSpacingEm?: number): AtlasEntry;
|
|
33
|
+
private readonly widths;
|
|
34
|
+
/** Advance width (CSS px) of `text`, measured with the browser's shaping, without rasterizing. */
|
|
35
|
+
measure(text: string, rawPx: number, rawWeight: number, family: string): number;
|
|
36
|
+
/** Rasterizes a 256×256 SVG path (Phosphor) at `px` CSS pixels into the atlas. */
|
|
37
|
+
icon(path: string, px: number, scaleFactor?: number): AtlasEntry;
|
|
38
|
+
get isDirty(): boolean;
|
|
39
|
+
flush(device: any, texture: any): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
export type Rgba = readonly [number, number, number, number];
|
|
2
|
+
export declare function parseCssColor(raw: string, fallback?: Rgba): Rgba;
|
|
3
|
+
export declare function withAlpha(c: Rgba, alphaFactor: number): Rgba;
|
|
4
|
+
export declare function mixColor(a: Rgba, b: Rgba, t: number): Rgba;
|
|
5
|
+
/** CSS `color-mix(in srgb, a p, b)`, interpolated with premultiplied alpha like the browser. */
|
|
6
|
+
export declare function cssMix(a: Rgba, b: Rgba, p: number): Rgba;
|
|
7
|
+
export interface PanelThemeTokens {
|
|
8
|
+
readonly bg: Rgba;
|
|
9
|
+
readonly surface: Rgba;
|
|
10
|
+
readonly surfaceHi: Rgba;
|
|
11
|
+
readonly line: Rgba;
|
|
12
|
+
readonly lineHi: Rgba;
|
|
13
|
+
readonly text: Rgba;
|
|
14
|
+
readonly label: Rgba;
|
|
15
|
+
readonly dim: Rgba;
|
|
16
|
+
readonly accent: Rgba;
|
|
17
|
+
readonly modified: Rgba;
|
|
18
|
+
readonly segBg: Rgba;
|
|
19
|
+
readonly segActive: Rgba;
|
|
20
|
+
readonly toggleTrack: Rgba;
|
|
21
|
+
readonly toggleThumb: Rgba;
|
|
22
|
+
readonly rim: Rgba;
|
|
23
|
+
/** The panel's hairline edge (--k-edge), drawn --k-rim-width wide like the rim. */
|
|
24
|
+
readonly edge: Rgba;
|
|
25
|
+
/** Width (CSS px) of the edge, the rim and the selected pill's outline (--k-rim-width). */
|
|
26
|
+
readonly rimWidth: number;
|
|
27
|
+
readonly rowHover: Rgba;
|
|
28
|
+
/** Space between rows (px); above 0 each row is its own bar rather than part of one card. */
|
|
29
|
+
readonly rowGap: number;
|
|
30
|
+
/** Hover wash in and out (ms). */
|
|
31
|
+
readonly hoverIn: number;
|
|
32
|
+
readonly hoverOut: number;
|
|
33
|
+
/** A slider handle's opacity at rest (0 shows it only on hover, focus and drag). */
|
|
34
|
+
readonly handleRest: number;
|
|
35
|
+
/** Group headings in small caps (`--k-group-transform: none` keeps their case). */
|
|
36
|
+
readonly groupUpper: boolean;
|
|
37
|
+
/** The slider handle's colour and how far inside the fill's edge it sits (px). */
|
|
38
|
+
readonly handle: Rgba;
|
|
39
|
+
readonly handleInset: number;
|
|
40
|
+
/** Group headings: size (px), colour, letter spacing (em) and the hairline above a group. */
|
|
41
|
+
readonly groupSize: number;
|
|
42
|
+
readonly groupColor: Rgba;
|
|
43
|
+
readonly groupTracking: number;
|
|
44
|
+
readonly groupDivider: Rgba;
|
|
45
|
+
/** Readout units: the space before them (px) and their colour. */
|
|
46
|
+
readonly unitGap: number;
|
|
47
|
+
/** null: the readout's own colour (`currentColor`). */
|
|
48
|
+
readonly unitColor: Rgba | null;
|
|
49
|
+
/** 1: a modified readout takes the modified colour behind a small dot. */
|
|
50
|
+
readonly readoutMark: number;
|
|
51
|
+
/** The readout's face. */
|
|
52
|
+
readonly valueFamily: string;
|
|
53
|
+
/** Spring curve: horizontal inset (px), one dashed guide at rest (vs. two solid), the running dot. */
|
|
54
|
+
readonly curveInset: number;
|
|
55
|
+
readonly curveDashed: boolean;
|
|
56
|
+
readonly curveDot: number;
|
|
57
|
+
readonly pillBg: Rgba;
|
|
58
|
+
readonly pillBorder: Rgba;
|
|
59
|
+
readonly fillRest: Rgba;
|
|
60
|
+
readonly fillActive: Rgba;
|
|
61
|
+
/** The fill under a hovered slider. */
|
|
62
|
+
readonly fillHover: Rgba;
|
|
63
|
+
/** 0 drops an inline panel's card: background, border and rim. */
|
|
64
|
+
readonly chrome: number;
|
|
65
|
+
/** A page's background (--k-page). */
|
|
66
|
+
readonly page: Rgba;
|
|
67
|
+
readonly pad: number;
|
|
68
|
+
readonly inset: number;
|
|
69
|
+
readonly row: number;
|
|
70
|
+
readonly gap: number;
|
|
71
|
+
readonly trayPad: number;
|
|
72
|
+
readonly radius: number;
|
|
73
|
+
readonly panelRadius: number;
|
|
74
|
+
readonly radiusMd: number;
|
|
75
|
+
readonly radiusSm: number;
|
|
76
|
+
readonly fontSize: number;
|
|
77
|
+
readonly textTitle: number;
|
|
78
|
+
readonly textBody: number;
|
|
79
|
+
readonly textControl: number;
|
|
80
|
+
readonly textMeta: number;
|
|
81
|
+
readonly textCap: number;
|
|
82
|
+
/** Readouts' size (--k-value-size, else a half pixel under the body size). */
|
|
83
|
+
readonly valueSize: number;
|
|
84
|
+
/** The button tokens (--k-button-*), where set; each element keeps its own look otherwise. */
|
|
85
|
+
readonly buttonBg: Rgba | null;
|
|
86
|
+
readonly buttonLine: Rgba | null;
|
|
87
|
+
readonly buttonHoverBg: Rgba | null;
|
|
88
|
+
readonly buttonHoverLine: Rgba | null;
|
|
89
|
+
readonly buttonRadius: number | null;
|
|
90
|
+
readonly buttonFontSize: number | null;
|
|
91
|
+
/** Buttons' label colour at rest (--k-button-color). */
|
|
92
|
+
readonly buttonColor: Rgba | null;
|
|
93
|
+
/** A fill or outline is set: action rows and preset chips are buttons (`[data-buttons]`). */
|
|
94
|
+
readonly boxed: boolean;
|
|
95
|
+
readonly iconSize: number;
|
|
96
|
+
readonly iconSm: number;
|
|
97
|
+
readonly labelWeight: number;
|
|
98
|
+
readonly disabledOpacity: number;
|
|
99
|
+
readonly hintTypedOpacity: number;
|
|
100
|
+
readonly blurStrength: number;
|
|
101
|
+
/** Smear on moving fill edges and selection pills, 0 (off) to 1 (--k-motion-blur). */
|
|
102
|
+
readonly motionBlur: number;
|
|
103
|
+
/** Smear on a range band's moving ends, 0 (off) to 1 (--k-range-blur). */
|
|
104
|
+
readonly rangeBlur: number;
|
|
105
|
+
readonly glowStrength: number;
|
|
106
|
+
/** 0 is an opaque panel; up to 1 thins it over a blurred backdrop (--k-glass). */
|
|
107
|
+
readonly glass: number;
|
|
108
|
+
/** Backdrop brightness under full glass (dims what shows through dark panels). */
|
|
109
|
+
readonly glassTone: number;
|
|
110
|
+
/** The spring values settle on (--k-spring: duration bounce), as ω and ζ. */
|
|
111
|
+
readonly fillOmega: number;
|
|
112
|
+
readonly fillZeta: number;
|
|
113
|
+
readonly fontFamily: string;
|
|
114
|
+
readonly monoFamily: string;
|
|
115
|
+
readonly isLight: boolean;
|
|
116
|
+
/** Body and readout weight (--k-font-weight) and titles' and headings' (--k-title-weight). */
|
|
117
|
+
readonly fontWeight: number;
|
|
118
|
+
readonly titleWeight: number;
|
|
119
|
+
/** Round things' radius (--k-round): fully round unless --k-radius is 0, or a px value. */
|
|
120
|
+
readonly round: number;
|
|
121
|
+
/** `flat`: groups draw no card surfaces and rows square off (--k-frame). */
|
|
122
|
+
readonly flat: boolean;
|
|
123
|
+
/** A switch's thumb when off, and colour strips' rings (--k-thumb). */
|
|
124
|
+
readonly thumb: Rgba;
|
|
125
|
+
/** How strongly small drop shadows show under thumbs and pills (--k-lift). */
|
|
126
|
+
readonly lift: number;
|
|
127
|
+
}
|
|
128
|
+
export declare function readPanelTokens(panel: HTMLElement, version?: number): PanelThemeTokens;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DIE_WGSL: string;
|