@zakkster/lite-ui-fx 1.4.0 → 1.6.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/llms.txt CHANGED
@@ -1,7 +1,7 @@
1
1
  # @zakkster/lite-ui-fx
2
- > Canvas-hijacked UI components with pluggable recipe system. 50 built-in recipes.
2
+ > Canvas-hijacked UI components with pluggable recipe system. 56 built-in recipes.
3
3
 
4
- VERSION 1.4.0
4
+ VERSION 1.6.0
5
5
 
6
6
  ## Install
7
7
  npm i @zakkster/lite-ui-fx
@@ -12,9 +12,9 @@ Canvas overlay (z-index:1) renders visuals via a recipe factory function.
12
12
  Recipe = { tick(), init?(), onHover?(), onClick?(), onToggle?(), onDrag?(), destroy?() }
13
13
 
14
14
  ## Import -- Controller
15
- import { mountUIFX, UIType } from '@zakkster/lite-ui-fx';
15
+ import { mountUIFX, decorateUIFX, UIType } from '@zakkster/lite-ui-fx';
16
16
 
17
- ## Import -- Recipes (one ./recipes subpath, 50 total, tree-shakeable)
17
+ ## Import -- Recipes (one ./recipes subpath, 56 total, tree-shakeable)
18
18
  import { SwarmToggle, MagneticButton, SparkSlider } from '@zakkster/lite-ui-fx/recipes';
19
19
  import { PendulumToggle, HeartbeatButton, AuroraSlider } from '@zakkster/lite-ui-fx/recipes';
20
20
  import { VolumeKnob, WaterLevel, TimerCountdown } from '@zakkster/lite-ui-fx/recipes';
@@ -24,9 +24,23 @@ import { RECIPES, RECIPE_META, RECIPE_NAMES, registerRecipe, mountRecipe } from
24
24
  // RECIPES id->factory (null-proto); RECIPE_META { id, name, type, family, themeable, motionSafe }; RECIPE_NAMES frozen.
25
25
  // mountRecipe(container, id, options?): resolves id fail-closed (did-you-mean), asserts META.type, mounts.
26
26
 
27
- ## Mount
27
+ ## Mount -- two modes
28
+ // HIJACK (mountUIFX): creates a native element (opacity:0) inside `container` and
29
+ // paints a canvas over it. The native element owns events + a11y.
28
30
  const instance = mountUIFX(container, UIType.TOGGLE, SwarmToggle, { label: 'Sound' });
29
- instance.destroy(); // cleanup
31
+ instance.setValue(v); // SLIDER/KNOB/PROGRESS: v in 0..1 (fires onDrag once); CHECKBOX: setValue(null) = indeterminate
32
+ instance.setChecked(b); // TOGGLE/CHECKBOX: set checked (fires onToggle once)
33
+ instance.destroy(); // cleanup
34
+ // DECORATE (decorateUIFX): a canvas AROUND an EXISTING visible element -- no
35
+ // native element created, no opacity:0, host never reparented; the overlay is a
36
+ // sibling placed from the host's offset box, removed on destroy (host byte-
37
+ // identical). State is wired from the host's own events; for a form-control host
38
+ // state.text/state.valid mirror el.value/el.validity (read at event time). This
39
+ // is the home for a decoration over a real input.
40
+ const deco = decorateUIFX(inputEl, PasswordStrength, { theme });
41
+ deco.destroy(); // removes ONLY the overlay + its listeners; host untouched
42
+ // setValue/setChecked are HIJACK-ONLY: they throw in decorate mode (a decoration
43
+ // reflects the host; it does not drive it).
30
44
 
31
45
  ## Options (4th arg; unknown option or recipe-hook keys throw a did-you-mean -- fail closed)
32
46
  width, height, padding=40, label // geometry + accessible label
@@ -38,16 +52,27 @@ colors // string[] palette override; wins over theme (array-palette recipes:
38
52
  theme // { light, mid, dark } -> accent/dim/surface; partial or wrong-shape throws
39
53
  text // visible canvas label; falls back to label, then the recipe default (label-in-name)
40
54
  font // canvas font string; falls back to the recipe's historical font
55
+ knobMode // KNOB only: 'rotate' | 'vertical' pointer mapping (default 'rotate'); wrong type throws
56
+ announce // PROGRESS only: opt-in aria-live announcements at 10% steps; wrong type throws
57
+ // decorateUIFX accepts a SUBSET: padding, seed, colors, theme, text, font. The
58
+ // hijack-only keys (width/height/value/checked/disabled/knobMode/announce/label)
59
+ // throw in decorate mode -- geometry comes from the host, value is read from it.
41
60
 
42
61
  ## Element Types
43
- UIType.TOGGLE -> <input type="checkbox" role="switch"> -> state.toggled, onToggle(checked)
44
- UIType.BUTTON -> <button> -> state.active, onClick(x, y, state)
45
- UIType.SLIDER -> <input type="range"> -> state.val (0-1), onDrag(val, velocity)
62
+ UIType.TOGGLE -> <input type="checkbox" role="switch"> -> state.toggled, onToggle(checked)
63
+ UIType.BUTTON -> <button> -> state.active, onClick(x, y, state)
64
+ UIType.SLIDER -> <input type="range"> -> state.val (0-1), onDrag(val, velocity)
65
+ UIType.CHECKBOX -> <input type="checkbox"> (no role=switch) -> state.toggled + state.indeterminate, onToggle(checked)
66
+ UIType.PROGRESS -> <progress> (non-interactive) -> state.val, driven by instance.setValue
67
+ UIType.KNOB -> <input type="range"> -> state.val, arrows native + knobMode pointer map, onDrag(val, velocity)
68
+ (decorate) -> NO native element created; a canvas AROUND a live host (decorateUIFX). Not a UIType --
69
+ RECIPE_META.type 'decorate' routes mountRecipe to decorateUIFX. State: focused + text + valid.
46
70
 
47
71
  ## State Object (provided to tick every frame)
48
- { hover, active, focused, toggled, disabled, val, w, h, padding, dpr }
72
+ { hover, active, focused, toggled, indeterminate, disabled, val, w, h, padding, dpr }
73
+ // decorate mode adds: text (host value string), valid (host validity boolean).
49
74
 
50
- ## 50 Built-in Recipes
75
+ ## 56 Built-in Recipes
51
76
 
52
77
  ### Vol. 1 -- 10 recipes
53
78
  Toggles: SwarmToggle, LiquidToggle, NeonPulseToggle
@@ -72,6 +97,15 @@ Mood: DayNightToggle, ReactionPicker, NotificationBell
72
97
  Feedback: TypewriterField, SoundWaveBtn, UploadProgress
73
98
  Fun: ScratchReveal, TimerCountdown, PullRefresh
74
99
 
100
+ ### U4a -- 3 recipes (new element types)
101
+ Checkboxes (UIType.CHECKBOX): TickDraw, IndeterminateScan
102
+ Progress (UIType.PROGRESS): LiquidFill
103
+
104
+ ### U4b -- 3 recipes (decorate mode: a canvas AROUND a live element)
105
+ Form feedback (decorateUIFX): FocusHalo, ErrorShake, SuccessBloom
106
+ // Re-homed to decorate mode (type 'decorate'): PasswordStrength (reads the live
107
+ // input's text), TypewriterField (an underline that grows with the typed text).
108
+
75
109
  ## Writing Custom Recipes
76
110
  See UIFX-RECIPE-GUIDE.md (included in package).
77
111
 
@@ -87,8 +121,15 @@ See UIFX-RECIPE-GUIDE.md (included in package).
87
121
  - Zero-GC in all built-in recipes: const colors + globalAlpha, precomputed
88
122
  color/label LUTs, fixed preallocated particle pools, gradients built in init.
89
123
  Gated per recipe by the t3-frame-alloc torture tier (default AND themed mount).
90
- - Themeable: all 50 recipes honour { colors, theme:{light,mid,dark}, text, font },
124
+ - Themeable: all 56 recipes honour { colors, theme:{light,mid,dark}, text, font },
91
125
  resolved once in init (zero per-frame alloc). RECIPE_META.themeable is true for
92
- all 50; motionSafe stays false (reduced motion is a later pass). A bare mount is
126
+ all 56; motionSafe stays false (reduced motion is a later pass). A bare mount is
93
127
  byte-identical to pre-theming. Shipped palettes + APCA contrast are authored with
94
128
  @zakkster/lite-hueforge (a dev-only tool, never a runtime dependency).
129
+ - U4a element types: CHECKBOX (indeterminate), PROGRESS (setValue-driven, aria-live
130
+ opt-in), KNOB (knobMode pointer map); setValue/setChecked sync native+state+hook once.
131
+ - U4b decorate mode (decorateUIFX): a canvas AROUND a live element -- no hijack, no
132
+ opacity:0, host never reparented; the overlay is a sibling placed from the host's
133
+ offset box and removed on destroy (host byte-identical, additive-only). State is
134
+ wired from the host's own events (state.text/state.valid at event time). It is the
135
+ second mount mode + the surface the enrichment decorations build on.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zakkster/lite-ui-fx",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "Canvas-hijacked UI components with a pluggable recipe system. 50 built-in recipes across toggles, buttons, sliders, knobs, loaders, checkboxes, counters, and ratings.",
5
5
  "author": "Zahary Shinikchiev <shinikchiev@yahoo.com>",
6
6
  "license": "MIT",