@kitlangton/knobs 0.4.0-next.14 → 0.4.0-next.15

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 CHANGED
@@ -838,8 +838,13 @@ panel.tab("emitter") // shows a tab; panel.tab() answers the one showing
838
838
  - **Keys presets leave alone, in place.** `inPresets: false` on a field, or `inPresets: { Motion:
839
839
  false }` on the store for a whole group, keeps presets, scoped presets and saved variants off
840
840
  those keys exactly as they stay off pinned ones (and a preset's chip stays lit when they move),
841
- but the rows stay where they are. A pinned key is one of these, moved to the top.
842
- `controls.inPresets(key)` says whether presets move a key.
841
+ but the rows stay where they are. A pinned key is one of these, moved to the top. The rule, for
842
+ `inPresets: false` and `pinned` groups alike: presets and variants from *other* scopes (the
843
+ panel-wide presets, tab scopes, other groups') leave the group alone, but a scope keyed by the
844
+ group's own name still moves it. So `inPresets: { Motion: false }` with
845
+ `scopedPresets: { Motion: { Snappy } }` gives Motion its own strip that state presets never
846
+ touch; its chips apply, save, match and mark only Motion. A field's own `inPresets: false` stays
847
+ out of every scope. `controls.inPresets(key)` says whether presets from other scopes move a key.
843
848
  - **Presets of a tab's own.** `scopedPresets` gives a tab (or a group) presets that belong to it:
844
849
  `{ Sidebars: { snappy, smooth, calm } }`. Its strip shows only on that tab, and a tab without any
845
850
  shows none. A scoped preset moves only its tab's (or group's) keys, never pinned ones or another
@@ -854,7 +859,8 @@ panel.tab("emitter") // shows a tab; panel.tab() answers the one showing
854
859
  group keeps Shipped, Snappy and Calm beside its knobs. Every strip's default chip reads `defaultLabel`; by scope,
855
860
  `defaultLabel: { "": "Empty", Motion: "Shipped" }` names each on its own. In code, `controls.preset(id, { scope })`, `activePreset(scope)` and
856
861
  `matchingPreset(scope)` take the tab or group, and `controls.scopeOf(key)` says whose presets
857
- move a key (`""` for plain `presets`, undefined when pinned). An active preset saved while the
862
+ move a key (`""` for plain `presets`, the group's id for a pinned or `inPresets: false`
863
+ group with a scope of its own, else undefined when pinned). An active preset saved while the
858
864
  presets were panel-wide comes back on the scope that now has one by that id, and variants saved
859
865
  then start out in each scope they move.
860
866
 
@@ -16107,7 +16107,7 @@ function buildPanel(controls, host, options) {
16107
16107
  }
16108
16108
  under = name, nodes.push(r.row);
16109
16109
  }
16110
- let strip = run.group !== void 0 && !run.pinned && !stripped.has(run.group) ? groupStripFor(run.group) : void 0;
16110
+ let strip = run.group !== void 0 && !stripped.has(run.group) ? groupStripFor(run.group) : void 0;
16111
16111
  if (strip)
16112
16112
  stripped.add(run.group);
16113
16113
  if (arrange(block.card, strip ? [strip.element, ...nodes] : nodes), animate && at >= 0) {
@@ -82,7 +82,7 @@ function attach(controls, element, options = {}) {
82
82
  return;
83
83
  loading = !0;
84
84
  try {
85
- let { createPanel } = await import("./chunk-s7d5a8vb.js");
85
+ let { createPanel } = await import("./chunk-49hkdggk.js");
86
86
  if (disposed || !controls.enabled || panel)
87
87
  return;
88
88
  if (panel = createPanel(controls, element, close, { restored, chip }), remember)
package/dist/dev/index.js CHANGED
@@ -625,9 +625,13 @@ function defineControls(id, input, options = {}) {
625
625
  named.add(variants);
626
626
  let of = /* @__PURE__ */ new Map;
627
627
  for (let k of valueKeys(schema)) {
628
- if (presetFree().has(k))
628
+ let f = fields[k];
629
+ if (presetFree().has(k)) {
630
+ if (f.inPresets !== !1 && f.group !== void 0 && named.has(f.group))
631
+ of.set(k, f.group);
629
632
  continue;
630
- let f = fields[k], tab = tabOf(f);
633
+ }
634
+ let tab = tabOf(f);
631
635
  of.set(k, tab !== void 0 && named.has(tab) ? tab : f.group !== void 0 && named.has(f.group) ? f.group : "");
632
636
  }
633
637
  return scopingOf = { schema, of, named: [...named], variants }, scopingOf;
@@ -1522,11 +1526,11 @@ function defineControls(id, input, options = {}) {
1522
1526
  code: (format, values) => formatCode(values ?? get(), format),
1523
1527
  variants,
1524
1528
  attach(element, chip) {
1525
- let load = options.ship ? () => options.ship().then((m) => m.attach) : () => import("./chunk-f0e5tkqg.js").then((m) => m.attach);
1529
+ let load = options.ship ? () => options.ship().then((m) => m.attach) : () => import("./chunk-902v1jgd.js").then((m) => m.attach);
1526
1530
  return live(load, (attach) => attach(controls, element, chip), (detach) => detach());
1527
1531
  },
1528
1532
  mount(container, mountOptions) {
1529
- let load = options.ship ? () => options.ship().then((m) => m.mountPanel) : () => import("./chunk-s7d5a8vb.js").then((m) => m.mountPanel);
1533
+ let load = options.ship ? () => options.ship().then((m) => m.mountPanel) : () => import("./chunk-49hkdggk.js").then((m) => m.mountPanel);
1530
1534
  return live(load, (mountPanel) => {
1531
1535
  let panel = mountPanel(controls, container, mountOptions);
1532
1536
  return mountOptions?.onReady?.(panel), panel;
package/dist/index.js CHANGED
@@ -1688,9 +1688,13 @@ function defineControls(id, input, options = {}) {
1688
1688
  named.add(variants);
1689
1689
  let of = /* @__PURE__ */ new Map;
1690
1690
  for (let k of valueKeys(schema)) {
1691
- if (presetFree().has(k))
1691
+ let f = fields[k];
1692
+ if (presetFree().has(k)) {
1693
+ if (f.inPresets !== !1 && f.group !== void 0 && named.has(f.group))
1694
+ of.set(k, f.group);
1692
1695
  continue;
1693
- let f = fields[k], tab = tabOf(f);
1696
+ }
1697
+ let tab = tabOf(f);
1694
1698
  of.set(k, tab !== void 0 && named.has(tab) ? tab : f.group !== void 0 && named.has(f.group) ? f.group : "");
1695
1699
  }
1696
1700
  return scopingOf = { schema, of, named: [...named], variants }, scopingOf;
package/dist/panel.js CHANGED
@@ -27530,7 +27530,7 @@ function buildPanel(controls, host, options) {
27530
27530
  under = name;
27531
27531
  nodes.push(r.row);
27532
27532
  }
27533
- const strip = run.group !== undefined && !run.pinned && !stripped.has(run.group) ? groupStripFor(run.group) : undefined;
27533
+ const strip = run.group !== undefined && !stripped.has(run.group) ? groupStripFor(run.group) : undefined;
27534
27534
  if (strip)
27535
27535
  stripped.add(run.group);
27536
27536
  arrange(block.card, strip ? [strip.element, ...nodes] : nodes);
@@ -389,13 +389,15 @@ export interface ControlsOptions<S extends Schema> extends LabelOptions {
389
389
  * Groups pinned to the top of a panel, under the header and above the tab strip, on every tab
390
390
  * (as fields' `pinned: true` pins theirs). Presets and saved variants leave them alone: applying
391
391
  * one keeps their values, saving one keeps them out, and they're modified against their defaults.
392
+ * A scope keyed by the group's own name (`scopedPresets`) still moves it.
392
393
  */
393
394
  pinned?: readonly string[];
394
395
  /**
395
396
  * Groups presets leave alone, where they are: `{ Motion: false }`. As with pinned groups,
396
397
  * applying a preset or variant keeps their values, saving one leaves them out, and a preset's chip
397
- * doesn't drift when they change; but their rows stay in place. A field says it alone with
398
- * `inPresets: false`.
398
+ * doesn't drift when they change; but their rows stay in place. A scope keyed by the group's own
399
+ * name (`scopedPresets: { Motion: … }`) still moves it: only other scopes' presets leave it
400
+ * alone. A field says it alone with `inPresets: false`, and then no scope moves it.
399
401
  */
400
402
  inPresets?: Readonly<Record<string, boolean>>;
401
403
  /**
@@ -449,7 +451,7 @@ export interface Controls<S extends Schema = Schema> {
449
451
  readonly scopes: Readonly<Record<string, PresetScope<Values<S>>>>;
450
452
  /**
451
453
  * The scope `key`'s presets come from: a tab or group's id, `""` for `presets`, or undefined
452
- * when presets leave it alone (pinned, `inPresets: false`).
454
+ * when presets leave it alone (pinned, `inPresets: false`, without a scope of its group's own).
453
455
  */
454
456
  scopeOf(key: string): string | undefined;
455
457
  readonly actions: readonly ControlAction<Values<S>>[];
@@ -485,7 +487,10 @@ export interface Controls<S extends Schema = Schema> {
485
487
  presetLabel(id: string, scope?: string): string;
486
488
  /** Whether `key` is pinned (its group is, see `ControlsOptions.pinned`), outside the presets. */
487
489
  isPinned(key: string): boolean;
488
- /** Whether presets move `key`: false when it's pinned or says `inPresets: false` (or its group does). */
490
+ /**
491
+ * Whether presets move `key`: false when it's pinned or says `inPresets: false` (or its group
492
+ * does). Its group's own scope may still move it (see `scopeOf`).
493
+ */
489
494
  inPresets(key: string): boolean;
490
495
  readonly error: string | null;
491
496
  get(): Values<S>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitlangton/knobs",
3
- "version": "0.4.0-next.14",
3
+ "version": "0.4.0-next.15",
4
4
  "description": "Per-component tuning controls. Explore in development, ship constants.",
5
5
  "type": "module",
6
6
  "license": "MIT",