tweakit 0.4.0 → 0.4.1
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/dist/tweaks/core.js +1 -1
- package/dist/tweaks.css +1 -1
- package/dist/tweaks.js +3 -3
- package/dist/types/tweaks/types.d.ts +26 -4
- package/package.json +1 -1
|
@@ -113,6 +113,10 @@ export interface ControlOptions {
|
|
|
113
113
|
disabled?: boolean | ((get: Get) => boolean);
|
|
114
114
|
/** A tooltip revealed by an ⓘ marker beside the label. */
|
|
115
115
|
hint?: string;
|
|
116
|
+
/** `false` leaves this control out of what `opts.persist` saves, so it opens on its schema
|
|
117
|
+
* value every load (presets, undo and `toJSON()` still carry it). On a control, not a
|
|
118
|
+
* plain folder object, where `persist` is a child. */
|
|
119
|
+
persist?: boolean;
|
|
116
120
|
}
|
|
117
121
|
/** The verbose object forms a schema value can take: `{ type: "…", … }`. */
|
|
118
122
|
export type SchemaObject = {
|
|
@@ -123,6 +127,13 @@ export type SchemaObject = {
|
|
|
123
127
|
step?: number;
|
|
124
128
|
soft?: boolean;
|
|
125
129
|
unit?: string;
|
|
130
|
+
/** Draws the readout from the value ("7:30 AM" for minutes of the day), in place of its
|
|
131
|
+
* digits; `unit` still follows it. Display only, like `unit`: the param stays the number. */
|
|
132
|
+
format?: (value: number) => string;
|
|
133
|
+
/** Reads a typed readout back into a value, so the inline editor shows and takes the
|
|
134
|
+
* formatted text (without one, it edits the digits). Text it can't read (it throws, or
|
|
135
|
+
* returns anything but a finite number) leaves the value where it was. */
|
|
136
|
+
parse?: (text: string) => number;
|
|
126
137
|
} | {
|
|
127
138
|
type: "number";
|
|
128
139
|
value?: number;
|
|
@@ -310,12 +321,22 @@ export interface Theme {
|
|
|
310
321
|
/** Escape hatch — any raw token, e.g. `"--tw-accent": "#6c8cff"`. */
|
|
311
322
|
[token: string]: string | number | undefined;
|
|
312
323
|
}
|
|
324
|
+
/** Options for a programmatic write — `set()`, `setMany()`, `fromJSON()`. */
|
|
325
|
+
export interface SetOptions {
|
|
326
|
+
/** Apply without calling your `on()` listeners: for mirroring a value the host already
|
|
327
|
+
* acted on (another tab, its own state), so the change doesn't echo back. Conditional
|
|
328
|
+
* controls, persistence and undo still follow it: it's an undo step like any other. */
|
|
329
|
+
silent?: boolean;
|
|
330
|
+
}
|
|
313
331
|
/** Panel options (third arg to `tweaks()`). */
|
|
314
332
|
export interface TweaksOptions {
|
|
315
333
|
/** Theme overrides (friendly names or raw `--tw-*`); `null` / omitted = default monochrome. */
|
|
316
334
|
theme?: Theme | null;
|
|
317
335
|
/** Persist values to localStorage + enable presets — a key, or `true` to key by name. */
|
|
318
336
|
persist?: string | boolean;
|
|
337
|
+
/** With `persist`, `false` keeps saving values but leaves the Presets menu out of the
|
|
338
|
+
* toolbar (the presets API still works). On by default. */
|
|
339
|
+
presets?: boolean;
|
|
319
340
|
/** Add a filter/search field to the toolbar. */
|
|
320
341
|
filter?: boolean;
|
|
321
342
|
/** Start the panel already floated (fixed-positioned): `true` → top-left, or an explicit `{x,y}`. */
|
|
@@ -355,7 +376,8 @@ export interface PanelState {
|
|
|
355
376
|
ui?: {
|
|
356
377
|
/** Folder collapse state → `true` when collapsed. Keys are the folder's path with each
|
|
357
378
|
* segment JSON-pointer-escaped (`.`→`~0`, `~`→`~1`) then joined by `.` — injective, so a
|
|
358
|
-
* literal dot in a key can't collide with the nesting separator.
|
|
379
|
+
* literal dot in a key can't collide with the nesting separator. For plain keys that's
|
|
380
|
+
* the dotted path, so `fromJSON({ ui: { folders: { shadow: true } } })` starts one closed. */
|
|
359
381
|
folders?: Record<string, boolean>;
|
|
360
382
|
/** Active tab → the active page's key, under the tabs control's path (escaped as above). */
|
|
361
383
|
tabs?: Record<string, string | null>;
|
|
@@ -374,12 +396,12 @@ export interface Panel {
|
|
|
374
396
|
/** Set a control's value programmatically. Nested controls take a dotted path
|
|
375
397
|
* ("folder.child", "tabs.page.child"); a bare key also reaches a nested control
|
|
376
398
|
* when it's unambiguous. A key matching no control is stored on `params` as-is. */
|
|
377
|
-
set(key: string, value: unknown): void;
|
|
399
|
+
set(key: string, value: unknown, options?: SetOptions): void;
|
|
378
400
|
/** Set several controls at once — a flat map of keys (dotted for nested controls), e.g.
|
|
379
401
|
* `setMany({ "shadow.radius": 28, blur: 48 })`. Resolves each key like `set()`, then fires
|
|
380
402
|
* listeners + persists ONCE for the whole batch, where N separate `set()` calls would fire
|
|
381
403
|
* N times. Unknown / ambiguous / reserved keys warn and are skipped. */
|
|
382
|
-
setMany(values: Record<string, unknown
|
|
404
|
+
setMany(values: Record<string, unknown>, options?: SetOptions): void;
|
|
383
405
|
/** Reset every control to its default (or run `opts.onReset`). */
|
|
384
406
|
reset(): void;
|
|
385
407
|
/** Serialize the whole panel — every control value plus UI state (collapsed folders,
|
|
@@ -398,7 +420,7 @@ export interface Panel {
|
|
|
398
420
|
* `{ ui }` to restore chrome only. The value restore is undoable (one history step); the
|
|
399
421
|
* UI restore is intentionally outside undo, so a Cmd-Z reverts values without thrashing
|
|
400
422
|
* folders/tabs. */
|
|
401
|
-
fromJSON(state: PanelState): void;
|
|
423
|
+
fromJSON(state: PanelState, options?: SetOptions): void;
|
|
402
424
|
/** Re-theme the panel live; `null` reverts to the default. */
|
|
403
425
|
setTheme(theme?: Theme | null): void;
|
|
404
426
|
/** Retitle the panel live — the header and the copy toast follow. The name it was built
|