@kitlangton/knobs 0.1.0 → 0.3.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.
Files changed (65) hide show
  1. package/README.md +303 -41
  2. package/dist/dev/{chunk-qtt698hp.js → chunk-7xgkerd2.js} +34 -11
  3. package/dist/dev/{chunk-ktsn42p7.js → chunk-jx1ktap3.js} +13762 -11794
  4. package/dist/dev/{chunk-kdewv0mt.js → chunk-pmkvb9ep.js} +1692 -207
  5. package/dist/dev/{chunk-e13znr7c.js → chunk-v8ssbcbk.js} +18 -7
  6. package/dist/dev/index.js +557 -130
  7. package/dist/index.js +589 -141
  8. package/dist/panel.js +21615 -17048
  9. package/dist/types/core/keys.d.ts +2 -0
  10. package/dist/types/core/random.d.ts +61 -1
  11. package/dist/types/core/remote.d.ts +5 -1
  12. package/dist/types/core/schema.d.ts +35 -6
  13. package/dist/types/core/store.d.ts +97 -8
  14. package/dist/types/core/unlock.d.ts +77 -0
  15. package/dist/types/core/variants.d.ts +10 -2
  16. package/dist/types/index.d.ts +4 -2
  17. package/dist/types/panel/attach.d.ts +2 -0
  18. package/dist/types/panel/crumbs.d.ts +19 -0
  19. package/dist/types/panel/editors.d.ts +20 -0
  20. package/dist/types/panel/feel.d.ts +103 -0
  21. package/dist/types/panel/flash.d.ts +13 -0
  22. package/dist/types/panel/give.d.ts +34 -1
  23. package/dist/types/panel/gpu/color.d.ts +4 -4
  24. package/dist/types/panel/gpu/renderer.d.ts +110 -6
  25. package/dist/types/panel/gpu/shader.wgsl.d.ts +1 -1
  26. package/dist/types/panel/haptics.d.ts +6 -2
  27. package/dist/types/panel/has.d.ts +0 -1
  28. package/dist/types/panel/index.d.ts +3 -1
  29. package/dist/types/panel/inspector.d.ts +33 -3
  30. package/dist/types/panel/lens.d.ts +113 -0
  31. package/dist/types/panel/motion.d.ts +2 -0
  32. package/dist/types/panel/optkeys.d.ts +7 -0
  33. package/dist/types/panel/page-hints.d.ts +2 -1
  34. package/dist/types/panel/prefs.d.ts +2 -2
  35. package/dist/types/panel/presence.d.ts +20 -0
  36. package/dist/types/panel/presets.d.ts +17 -5
  37. package/dist/types/panel/ramp-morph.d.ts +117 -0
  38. package/dist/types/panel/ramps.d.ts +1 -1
  39. package/dist/types/panel/reel.d.ts +43 -0
  40. package/dist/types/panel/scope.d.ts +48 -0
  41. package/dist/types/panel/slider.d.ts +22 -5
  42. package/dist/types/panel/sound.d.ts +137 -0
  43. package/dist/types/panel/styles.d.ts +1 -1
  44. package/dist/types/panel/tab-transition.d.ts +15 -0
  45. package/dist/types/panel/tabs.d.ts +1 -1
  46. package/dist/types/panel/toggle.d.ts +27 -0
  47. package/dist/types/panel/toolbar-grid.d.ts +6 -0
  48. package/dist/types/ui/activity-css.d.ts +1 -0
  49. package/dist/types/ui/activity-model.d.ts +122 -0
  50. package/dist/types/ui/activity.d.ts +67 -0
  51. package/dist/types/ui/follow.d.ts +17 -0
  52. package/dist/types/ui/index.d.ts +5 -1
  53. package/dist/types/ui/look.d.ts +9 -0
  54. package/dist/types/ui/picker-css.d.ts +1 -0
  55. package/dist/types/ui/picker-model.d.ts +53 -0
  56. package/dist/types/ui/picker.d.ts +67 -0
  57. package/dist/types/ui/react.d.ts +27 -0
  58. package/dist/types/ui/scrollbar.d.ts +12 -0
  59. package/dist/types/ui/solid.d.ts +23 -0
  60. package/dist/types/ui/split-model.d.ts +55 -0
  61. package/dist/types/ui/split.d.ts +22 -3
  62. package/dist/ui-react.js +3462 -690
  63. package/dist/ui-solid.js +3440 -689
  64. package/dist/ui.js +2963 -264
  65. package/package.json +1 -1
@@ -248,6 +248,17 @@ function comboParts2(combo, apple = isApple()) {
248
248
  function comboLabel2(combo, apple = isApple()) {
249
249
  return comboParts2(combo, apple).join(apple ? "" : "+");
250
250
  }
251
+ function isTypingTarget(target) {
252
+ let el = target;
253
+ if (!el || typeof el.tagName !== "string")
254
+ return !1;
255
+ let tag = el.tagName;
256
+ if (tag === "SELECT" || el.isContentEditable)
257
+ return !0;
258
+ if (tag === "TEXTAREA")
259
+ return !el.readOnly;
260
+ return tag === "INPUT" && !el.readOnly && !["range", "checkbox", "radio", "button", "submit", "reset", "color"].includes(el.type);
261
+ }
251
262
 
252
263
  // src/core/ramp.ts
253
264
  var MAX_STOPS = 32, MAX_POINTS = 64, GRADIENT_SAMPLES = 64, CURVE_SAMPLES = 129, clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v)), finite = (v) => typeof v === "number" && Number.isFinite(v), round4 = (v) => Math.round(v * 1e4) / 1e4 || 0;
@@ -531,11 +542,9 @@ function withMeta(base, meta) {
531
542
  return checkShortcut(meta?.shortcut), Object.freeze({ ...base, ...pickMeta(meta) });
532
543
  }
533
544
  function knob2(value, options) {
534
- let step = options.step ?? ((options.max - options.min) / 100 || 1);
535
- if (![value, options.min, options.max, step].every(Number.isFinite) || options.max < options.min || step <= 0)
545
+ if (!Number.isFinite(value))
536
546
  throw Error("A knob needs finite bounds and a positive step.");
537
- if (options.decimals !== void 0 && !(Number.isInteger(options.decimals) && options.decimals >= 0))
538
- throw Error("A knob's decimals must be a whole number.");
547
+ let step = bounds(options, "A knob");
539
548
  checkShortcut(options.shortcut);
540
549
  let field = { ...options, kind: "knob", value, step };
541
550
  return Object.freeze({ ...field, value: normalizeField(field, value) });
@@ -553,7 +562,15 @@ function choice2(value, options, meta) {
553
562
  }, meta);
554
563
  }
555
564
  function action2(label, meta) {
556
- return withMeta({ kind: "action", ...meta?.run ? { run: meta.run } : {} }, { ...meta, ...label !== void 0 ? { label } : {} });
565
+ let { shortcut, global, rebind, run, ...rest } = meta ?? {}, key = shortcutOf({ ...shortcut ? { shortcut } : {}, ...global ? { global } : {} }), combo = key ? normalizeCombo2(key.key) : "";
566
+ if (key && !combo)
567
+ throw Error("An action's shortcut must name a key.");
568
+ return withMeta({
569
+ kind: "action",
570
+ ...run ? { run } : {},
571
+ ...key ? { shortcut: combo, scope: key.scope } : {},
572
+ ...rebind ? { rebind: !0 } : {}
573
+ }, { ...rest, ...label !== void 0 ? { label } : {} });
557
574
  }
558
575
  function flatSpring2(parts = {}, meta = {}) {
559
576
  let id = meta.id ?? meta.label ?? `spring-${++springIds}`, half = (part, input, fallback) => {
@@ -579,7 +596,7 @@ function flatSpring2(parts = {}, meta = {}) {
579
596
  }
580
597
  var springIds = 0;
581
598
  function toggle2(value, meta) {
582
- return withMeta({ kind: "toggle", value }, meta);
599
+ return withMeta({ kind: "toggle", value }, { ...meta, random: meta?.random ?? !1 });
583
600
  }
584
601
  function spring2(value = {}, meta) {
585
602
  let field = { kind: "spring", value: { duration: 0.5, bounce: 0 } };
@@ -722,13 +739,19 @@ function curve2(points, options = {}) {
722
739
  ...presets && Object.keys(presets).length ? { presets } : {}
723
740
  }, options);
724
741
  }
725
- function toolbarShortcut2(item) {
726
- let s = item.shortcut;
742
+ function shortcutOf(o) {
743
+ let s = o.shortcut;
727
744
  if (!s)
728
745
  return;
729
746
  if (typeof s === "string")
730
- return { key: s, scope: item.global ? "page" : "panel" };
731
- return s.key ? { key: s.key, scope: s.scope ?? (item.global ? "page" : "panel") } : void 0;
747
+ return { key: s, scope: o.global ? "page" : "panel" };
748
+ return s.key ? { key: s.key, scope: s.scope ?? (o.global ? "page" : "panel") } : void 0;
749
+ }
750
+ function toolbarShortcut2(item) {
751
+ return shortcutOf(item);
752
+ }
753
+ function actionShortcut2(field) {
754
+ return field.shortcut ? { key: field.shortcut, scope: field.scope ?? "panel" } : void 0;
732
755
  }
733
756
  function toolbar2(items, meta) {
734
757
  if (!items.length)
@@ -1115,4 +1138,4 @@ function urlFlag2(name) {
1115
1138
  }
1116
1139
  var storageKey = (id, part) => `knobs:${encodeURIComponent(id)}:${part}:v1`;
1117
1140
 
1118
- export { __preload, __chunks, maxChroma, oklchToRgb, parseColor2, fitColor, formatColor, colorHex2, EASINGS2, EASING_Y, easingName, bezierPoint2, bezierCss2, normalizeCombo2, letterOf2, comboFromEvent2, heldMods, matchesCombo2, comboParts2, comboLabel2, GRADIENT_SAMPLES, sampleGradient2, gradientSamples, gradientCss2, stopColorAt, sampleCurve2, curveSamples, CURVE_SHAPES2, inRange, sameRamp, randomStops, mutateStops, randomPoints, mutatePoints, pickMeta, isReadout2, hasValue2, SPRING2, valueKeys, knob2, choice2, action2, flatSpring2, toggle2, spring2, color2, point2, easing2, vec22, vec32, range2, angle2, seed2, keybind2, gradient2, curve2, toolbarShortcut2, toolbar2, watch2, sparkline2, graph2, meter2, table2, log2, wrapAngle2, normalizeField, normalize, isRecord, same, equal, Spring, springMotion2, springResponse, springEasing, springCss2, RESHAPE, RESET_KEYS, REFRESHES, readoutState, pushReadout, READOUT, memoryStorage2, browserStorage, urlFlag2, storageKey };
1141
+ export { __preload, __chunks, maxChroma, oklchToRgb, parseColor2, fitColor, formatColor, colorHex2, EASINGS2, EASING_Y, easingName, bezierPoint2, bezierCss2, normalizeCombo2, letterOf2, comboFromEvent2, heldMods, matchesCombo2, comboParts2, comboLabel2, isTypingTarget, GRADIENT_SAMPLES, sampleGradient2, gradientSamples, gradientCss2, stopColorAt, sampleCurve2, curveSamples, CURVE_SHAPES2, inRange, sameRamp, randomStops, mutateStops, randomPoints, mutatePoints, pickMeta, isReadout2, hasValue2, SPRING2, valueKeys, knob2, choice2, action2, flatSpring2, toggle2, spring2, color2, point2, easing2, vec22, vec32, range2, angle2, seed2, keybind2, gradient2, curve2, toolbarShortcut2, actionShortcut2, toolbar2, watch2, sparkline2, graph2, meter2, table2, log2, wrapAngle2, normalizeField, normalize, isRecord, same, equal, Spring, springMotion2, springResponse, springEasing, springCss2, RESHAPE, RESET_KEYS, REFRESHES, readoutState, pushReadout, READOUT, memoryStorage2, browserStorage, urlFlag2, storageKey };