@wix/interact 2.5.1 → 2.5.2
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 +27 -0
- package/docs/api/interact-class.md +1 -1
- package/docs/guides/custom-elements.md +10 -10
- package/docs/integration/react.md +17 -13
- package/package.json +1 -1
- package/rules/full-lean.md +1 -1
- package/rules/validate.md +49 -17
package/README.md
CHANGED
|
@@ -19,6 +19,33 @@ Declarative, configuration-driven interaction library — web-native, AI-ready,
|
|
|
19
19
|
- **Preset ecosystem** — Plug in [`@wix/motion-presets`](https://github.com/wix/interact/tree/master/packages/motion-presets) for 75+ ready-made effects.
|
|
20
20
|
- **Accessible** — Built-in `activate` (click + keyboard) and `interest` (hover + focus) trigger variants
|
|
21
21
|
|
|
22
|
+
## Coding-agent skill: Interactor
|
|
23
|
+
|
|
24
|
+
Working with an AI coding agent (Claude Code, Cursor, and others)? Install the **Interactor** skill so your agent can install, wire up, and configure `@wix/interact` for you — creating beautiful interactions and validating them before shipping.
|
|
25
|
+
|
|
26
|
+
### Install
|
|
27
|
+
|
|
28
|
+
Install it via the [`skills`](https://www.npmjs.com/package/skills) CLI (runs through `npx`, nothing to install globally):
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx skills add wix/interact # add to the current project
|
|
32
|
+
npx skills add wix/interact --global # or install for every project
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Run interactively, the CLI prompts for the agent and scope; pass `-a cursor` (also `claude-code`, `opencode`, or `-a '*'` for all) to pick up-front.
|
|
36
|
+
|
|
37
|
+
### Use it
|
|
38
|
+
|
|
39
|
+
In **Cursor** or **Claude Code**, invoke the skill from chat with `/interactor` and describe what you want:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
/interactor fade the hero in when it scrolls into view
|
|
43
|
+
/interactor stagger these cards in on entrance
|
|
44
|
+
/interactor add a subtle 3D tilt toward the cursor on the product cards
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The agent follows the skill workflow: detects your stack (React, Web Components, or vanilla JS), installs packages if needed, generates an `InteractConfig`, validates it with `@wix/interact-validate`, and injects `generate()` CSS.
|
|
48
|
+
|
|
22
49
|
## Install
|
|
23
50
|
|
|
24
51
|
```bash
|
|
@@ -103,9 +103,9 @@ interact-element.--hover-active .my-element {
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
### State Toggle
|
|
106
|
+
### State Toggle Actions
|
|
107
107
|
|
|
108
|
-
The element provides
|
|
108
|
+
The element provides actions to manage states:
|
|
109
109
|
|
|
110
110
|
1. `add`: adds a state named by `effectId`
|
|
111
111
|
2. `remove`: removes a state named by `effectId`
|
|
@@ -164,16 +164,16 @@ export default {
|
|
|
164
164
|
```javascript
|
|
165
165
|
// Create element programmatically
|
|
166
166
|
function createInteractiveElement(id, content) {
|
|
167
|
-
const
|
|
168
|
-
|
|
167
|
+
const interactElement = document.createElement('interact-element');
|
|
168
|
+
interactElement.dataset.interactKey = id;
|
|
169
169
|
|
|
170
170
|
const childElement = document.createElement('div');
|
|
171
171
|
childElement.id = id;
|
|
172
172
|
childElement.innerHTML = content;
|
|
173
173
|
|
|
174
|
-
|
|
174
|
+
interactElement.appendChild(childElement);
|
|
175
175
|
|
|
176
|
-
return
|
|
176
|
+
return interactElement;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
// Usage
|
|
@@ -218,12 +218,12 @@ You can change the key dynamically:
|
|
|
218
218
|
const element = document.querySelector('interact-element');
|
|
219
219
|
|
|
220
220
|
// Remove old interactions
|
|
221
|
-
if (element.dataset.
|
|
222
|
-
remove(element.dataset.
|
|
221
|
+
if (element.dataset.interactKey) {
|
|
222
|
+
remove(element.dataset.interactKey);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// Update key
|
|
226
|
-
element.dataset.
|
|
226
|
+
element.dataset.interactKey = 'new-target';
|
|
227
227
|
|
|
228
228
|
// Reconnect with new key
|
|
229
229
|
element.connect('new-target');
|
|
@@ -303,7 +303,7 @@ console.log('interact-element registered:', customElements.get('interact-element
|
|
|
303
303
|
```javascript
|
|
304
304
|
const element = document.querySelector('interact-element');
|
|
305
305
|
console.log('Connected:', element.connected);
|
|
306
|
-
console.log('Key:', element.dataset.
|
|
306
|
+
console.log('Key:', element.dataset.interactKey);
|
|
307
307
|
console.log('Has child:', element.firstElementChild !== null);
|
|
308
308
|
```
|
|
309
309
|
|
|
@@ -400,7 +400,7 @@ const config: InteractConfig = {
|
|
|
400
400
|
key: 'accordion',
|
|
401
401
|
trigger: 'click',
|
|
402
402
|
selector: '.accordion-header',
|
|
403
|
-
effects: [{ effectId: 'expanded',
|
|
403
|
+
effects: [{ effectId: 'expanded', stateAction: 'toggle' }],
|
|
404
404
|
},
|
|
405
405
|
],
|
|
406
406
|
};
|
|
@@ -460,20 +460,24 @@ import { Interact, Interaction, InteractConfig } from '@wix/interact/react';
|
|
|
460
460
|
const config: InteractConfig = {
|
|
461
461
|
interactions: [
|
|
462
462
|
{
|
|
463
|
-
key: 'product-list',
|
|
463
|
+
key: 'product-list', // single triggering parent
|
|
464
464
|
trigger: 'viewEnter',
|
|
465
|
-
|
|
466
|
-
effects: [
|
|
465
|
+
sequences: [
|
|
467
466
|
{
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
467
|
+
offset: 100, // Stagger animation for list items
|
|
468
|
+
effects: [
|
|
469
|
+
{
|
|
470
|
+
listContainer: '.products', //multiple target elements
|
|
471
|
+
keyframeEffect: {
|
|
472
|
+
name: 'slide-up',
|
|
473
|
+
keyframes: [
|
|
474
|
+
{ opacity: 0, transform: 'translateY(30px)' },
|
|
475
|
+
{ opacity: 1, transform: 'translateY(0)' },
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
duration: 400,
|
|
479
|
+
},
|
|
480
|
+
],
|
|
477
481
|
},
|
|
478
482
|
],
|
|
479
483
|
},
|
package/package.json
CHANGED
package/rules/full-lean.md
CHANGED
|
@@ -654,7 +654,7 @@ The target element is what the effect animates. Resolved in priority order:
|
|
|
654
654
|
| `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `create`. |
|
|
655
655
|
| `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
|
|
656
656
|
| `Interact.forceReducedMotion` | `boolean` (default: `false`) — force reduced-motion behavior regardless of OS setting. |
|
|
657
|
-
| `Interact.allowA11yTriggers` | `boolean` (default: `
|
|
657
|
+
| `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
|
|
658
658
|
| `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
|
|
659
659
|
|
|
660
660
|
**`Interact.setup(options)`** — optional configuration object:
|
package/rules/validate.md
CHANGED
|
@@ -55,7 +55,7 @@ if (!result.valid) {
|
|
|
55
55
|
- `valid` is `true` when no remaining issue has severity `'error'`. **Warnings alone do not make `valid: false`.**
|
|
56
56
|
- `errors` holds **all** surfaced issues — both `'error'` and `'warning'` severities. Filter on `severity` to separate them.
|
|
57
57
|
- Issues are sorted lexicographically by `path`.
|
|
58
|
-
- Validation runs in two layers: a **structural** zod parse first (produces `SCHEMA_*` and numeric/threshold codes); if that succeeds, **referential + semantic** checks run (dangling references, unused definitions, duplicate keyframe names, media-query syntax). If the structural parse fails, the semantic layer is skipped.
|
|
58
|
+
- Validation runs in two layers: a **structural** zod parse first (produces `SCHEMA_*` and numeric/threshold codes); if that succeeds, **referential + semantic** checks run (dangling references, unused definitions, duplicate keyframe names, media-query syntax, and the rule-derived semantic warnings — same-element re-trigger, hit-area shift, scroll-preset `range`, `animationEnd` graph cycles, element-selection coherence, `fill`/`inset`/keyframe-camelCase nudges). If the structural parse fails, the semantic layer is skipped.
|
|
59
59
|
|
|
60
60
|
### assertValidInteractConfig
|
|
61
61
|
|
|
@@ -124,13 +124,23 @@ try {
|
|
|
124
124
|
Severity is one of `'error' | 'warning'`. There are exactly two levers:
|
|
125
125
|
|
|
126
126
|
1. **`strict: true`** — promotes all remaining issues to `'error'`, so any warning fails the config.
|
|
127
|
-
2. **`severityOverrides`** — keyed by **rule category**, not by individual code. Only the following
|
|
128
|
-
|
|
129
|
-
| Rule category
|
|
130
|
-
|
|
|
131
|
-
| `UNUSED_DEFINITION`
|
|
132
|
-
| `UNIQUE_DEFINITION_IDS`
|
|
133
|
-
| `VALID_MEDIA_QUERIES`
|
|
127
|
+
2. **`severityOverrides`** — keyed by **rule category**, not by individual code. Only the following categories are registered and overridable:
|
|
128
|
+
|
|
129
|
+
| Rule category | Covers codes | Default severity |
|
|
130
|
+
| ------------------------ | --------------------------------------------------------------------------- | ---------------- |
|
|
131
|
+
| `UNUSED_DEFINITION` | `UNUSED_EFFECT`, `UNUSED_SEQUENCE`, `UNUSED_CONDITION` | warning |
|
|
132
|
+
| `UNIQUE_DEFINITION_IDS` | `DUPLICATE_KEYFRAME_NAME` | warning |
|
|
133
|
+
| `VALID_MEDIA_QUERIES` | `INVALID_MEDIA_QUERY` | error |
|
|
134
|
+
| `SAME_ELEMENT_RETRIGGER` | `SAME_ELEMENT_RETRIGGER` | warning |
|
|
135
|
+
| `HIT_AREA_SHIFT` | `HIT_AREA_SHIFT` | warning |
|
|
136
|
+
| `SCROLL_RANGE` | `SCROLL_PRESET_MISSING_RANGE`, `SCROLL_PRESET_BAD_RANGE` | warning |
|
|
137
|
+
| `ANIMATION_END_GRAPH` | `ANIMATION_END_SELF_REFERENCE`, `ANIMATION_END_CYCLE` | warning |
|
|
138
|
+
| `ELEMENT_SELECTION` | `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER`, `REDUNDANT_SELECTOR_WITH_LIST_ITEM` | warning |
|
|
139
|
+
| `STATE_EFFECT` | `EMPTY_STYLE_PROPERTIES`, `STATE_REMOVE_WITHOUT_EFFECT_ID` | warning |
|
|
140
|
+
| `RECOMMENDED_FILL` | `RECOMMENDED_FILL_BOTH` | info |
|
|
141
|
+
| `POINTER_AXIS` | `POINTER_AXIS_IGNORED` | warning |
|
|
142
|
+
| `KEYFRAME_STYLE` | `KEYFRAME_PROP_NOT_CAMEL_CASE` | warning |
|
|
143
|
+
| `VIEW_INSET` | `INVALID_INSET` | warning |
|
|
134
144
|
|
|
135
145
|
For each category, set `'off'` to drop those issues entirely, `'warning'` / `'error'` to set their severity:
|
|
136
146
|
|
|
@@ -184,17 +194,17 @@ This is the authoritative list of every code the validator emits today. Codes no
|
|
|
184
194
|
|
|
185
195
|
| Code | What it flags |
|
|
186
196
|
| -------------------------------- | ------------------------------------------------------------------------------ |
|
|
187
|
-
| `EFFECT_ID_NOT_FOUND` | An effect's `effectId` references a key absent from `config.effects`. |
|
|
188
197
|
| `ANIMATION_END_EFFECT_NOT_FOUND` | An `animationEnd` interaction's `params.effectId` references a missing effect. |
|
|
189
198
|
| `SEQUENCE_ID_NOT_FOUND` | A `sequenceId` references a key absent from `config.sequences`. |
|
|
190
199
|
| `CONDITION_NOT_FOUND` | A `conditions[]` entry references a key absent from `config.conditions`. |
|
|
191
200
|
|
|
192
201
|
### Other structural errors (severity: error)
|
|
193
202
|
|
|
194
|
-
| Code | What it flags
|
|
195
|
-
| --------------------- |
|
|
196
|
-
| `INTERACTION_EMPTY` | An interaction has neither `effects` nor `sequences`. (`viewProgress`/`pointerMove` require a non-empty `effects` array and instead surface `SCHEMA_TOO_SMALL`.)
|
|
197
|
-
| `INVALID_MEDIA_QUERY` | A `media` condition's `predicate` fails static media-query syntax validation (balanced parentheses + allowed characters). Belongs to the `VALID_MEDIA_QUERIES` rule category.
|
|
203
|
+
| Code | What it flags |
|
|
204
|
+
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
205
|
+
| `INTERACTION_EMPTY` | An interaction has neither `effects` nor `sequences`. (`viewProgress`/`pointerMove` require a non-empty `effects` array and instead surface `SCHEMA_TOO_SMALL`.) |
|
|
206
|
+
| `INVALID_MEDIA_QUERY` | A `media` condition's `predicate` fails static media-query syntax validation (balanced parentheses + allowed characters). Belongs to the `VALID_MEDIA_QUERIES` rule category. |
|
|
207
|
+
| `ANIMATION_END_CYCLE` | A cycle of `animationEnd` interactions wait on each other's effects → deadlock; none can start. Belongs to the `ANIMATION_END_GRAPH` rule category (so it can be demoted/silenced). |
|
|
198
208
|
|
|
199
209
|
### Best-practice warnings (severity: warning)
|
|
200
210
|
|
|
@@ -204,6 +214,27 @@ This is the authoritative list of every code the validator emits today. Codes no
|
|
|
204
214
|
| `UNUSED_SEQUENCE` | A `config.sequences` entry is defined but never referenced. | `UNUSED_DEFINITION` |
|
|
205
215
|
| `UNUSED_CONDITION` | A `config.conditions` entry is defined but never referenced. | `UNUSED_DEFINITION` |
|
|
206
216
|
| `DUPLICATE_KEYFRAME_NAME` | A `keyframeEffect.name` is reused across effects in the same config. | `UNIQUE_DEFINITION_IDS` |
|
|
217
|
+
| `EFFECT_ID_NOT_FOUND` | An effect's `effectId` references a key absent from `config.effects`. | `ID_NOT_FOUND` |
|
|
218
|
+
|
|
219
|
+
### Rule-derived semantic warnings (severity: warning)
|
|
220
|
+
|
|
221
|
+
Statically-detectable authoring pitfalls lifted from the trigger rule files. Each belongs to its own rule category, so `severityOverrides` can silence (`'off'`) or escalate (`'error'`) it. `strict: true` promotes all of these to `error`.
|
|
222
|
+
|
|
223
|
+
| Code | What it flags | Rule category |
|
|
224
|
+
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
|
|
225
|
+
| `SAME_ELEMENT_RETRIGGER` | `viewEnter` with `triggerType` `repeat`/`alternate`/`state` on the same source+target element (re-trigger loop). | `SAME_ELEMENT_RETRIGGER` |
|
|
226
|
+
| `HIT_AREA_SHIFT` | `hover`/`click`/`interest`/`activate`/`pointerMove` `keyframeEffect` with a `translate`/`scale`/`matrix` transform on the same source+target element. | `HIT_AREA_SHIFT` |
|
|
227
|
+
| `SCROLL_PRESET_MISSING_RANGE` | A `*Scroll` `namedEffect` on `viewProgress` omits `range`. | `SCROLL_RANGE` |
|
|
228
|
+
| `SCROLL_PRESET_BAD_RANGE` | A scroll preset `range` is not `'in'`/`'out'`/`'continuous'`. | `SCROLL_RANGE` |
|
|
229
|
+
| `ANIMATION_END_SELF_REFERENCE` | An `animationEnd` interaction waits for an effect it also produces → it can never start. | `ANIMATION_END_GRAPH` |
|
|
230
|
+
| `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER` | `listItemSelector` present without `listContainer` (inert) — on an interaction or an effect. | `ELEMENT_SELECTION` |
|
|
231
|
+
| `REDUNDANT_SELECTOR_WITH_LIST_ITEM` | `selector` is ignored when both `listContainer` and `listItemSelector` are present. | `ELEMENT_SELECTION` |
|
|
232
|
+
| `EMPTY_STYLE_PROPERTIES` | A state effect's `transition.styleProperties` / `transitionProperties` is `[]` (toggles nothing). | `STATE_EFFECT` |
|
|
233
|
+
| `STATE_REMOVE_WITHOUT_EFFECT_ID` | `stateAction: 'remove'` with no `effectId` to pair with a matching `'add'`. | `STATE_EFFECT` |
|
|
234
|
+
| `RECOMMENDED_FILL_BOTH` | A scrubbed (`viewProgress`/`pointerMove`) or toggling (`alternate`/`repeat`/`state`) effect omits `fill: 'both'`. | `RECOMMENDED_FILL` |
|
|
235
|
+
| `POINTER_AXIS_IGNORED` | `pointerMove` `params.axis` set on a `namedEffect`/`customEffect` (axis only applies to `keyframeEffect`). | `POINTER_AXIS` |
|
|
236
|
+
| `KEYFRAME_PROP_NOT_CAMEL_CASE` | A `keyframeEffect` property name is kebab-case (not WAAPI camelCase). | `KEYFRAME_STYLE` |
|
|
237
|
+
| `INVALID_INSET` | `viewEnter` `params.inset` is not 1–4 whitespace-separated CSS lengths/percentages. | `VIEW_INSET` |
|
|
207
238
|
|
|
208
239
|
---
|
|
209
240
|
|
|
@@ -263,9 +294,10 @@ The validator is **static**. It cannot see the DOM, the browser, or the preset r
|
|
|
263
294
|
- **DOM-dependent issues** — element existence for a `key`/`selector`, `overflow: hidden` ancestors breaking `viewProgress`, `pointer-events: none` on a source, `:first-child` presence.
|
|
264
295
|
- **Preset correctness** — only the config shape is checked, never whether a `namedEffect.type` is a registered preset or whether its options are valid. See [scroll-presets and other preset rules](https://github.com/wix/interact/blob/master/packages/motion-presets/rules/presets/presets-main.md).
|
|
265
296
|
- **Documented authoring pitfalls with no static signal**, which the trigger rule files cover instead:
|
|
266
|
-
-
|
|
267
|
-
-
|
|
268
|
-
-
|
|
269
|
-
|
|
297
|
+
- `overflow: hidden` ancestors breaking `viewProgress` → [viewprogress.md](https://wix.github.io/interact/rules/viewprogress.md).
|
|
298
|
+
- Whether a `keyframeEffect`/`namedEffect` actually changes size/position when it cannot be introspected (e.g. `namedEffect` options) — only inline `keyframeEffect` transforms are scanned for `HIT_AREA_SHIFT`.
|
|
299
|
+
- Reduced-motion alternatives, perspective usage, and other authoring guidance with no static signal.
|
|
300
|
+
|
|
301
|
+
> **Note:** Several pitfalls that previously had "no static signal" are now flagged as **warnings** (see the rule-derived semantic warnings above): same source+target on `viewEnter` with a non-`once` `triggerType` (`SAME_ELEMENT_RETRIGGER`), hit-area shift from inline `keyframeEffect` transforms on `hover`/`pointerMove` (`HIT_AREA_SHIFT`), scroll presets missing/invalid `range` (`SCROLL_PRESET_*`), and missing `fill: 'both'` (`RECOMMENDED_FILL_BOTH`). These are heuristic and conservative (they skip ambiguous cases to avoid false positives), so the trigger rule files remain the authoritative guidance.
|
|
270
302
|
|
|
271
303
|
For the full API, usage recipes, and the same catalogue in package form, see the [`@wix/interact-validate` README](https://github.com/wix/interact/blob/master/packages/interact-validate/README.md).
|