@wix/interact 2.6.0 → 2.8.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 (64) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/cjs/react.js +1 -1
  3. package/dist/cjs/web.js +1 -1
  4. package/dist/es/index.js +1 -1
  5. package/dist/es/react.js +2 -2
  6. package/dist/es/web.js +2 -2
  7. package/dist/{index-BcRbaJX2.mjs → index-CHEx5VT7.mjs} +1643 -1411
  8. package/dist/index-CHEx5VT7.mjs.map +1 -0
  9. package/dist/index-DDOkQ8gk.js +29 -0
  10. package/dist/index-DDOkQ8gk.js.map +1 -0
  11. package/dist/tsconfig.build.tsbuildinfo +1 -1
  12. package/dist/types/core/Interact.d.ts +28 -16
  13. package/dist/types/core/Interact.d.ts.map +1 -1
  14. package/dist/types/core/InteractionController.d.ts +1 -0
  15. package/dist/types/core/InteractionController.d.ts.map +1 -1
  16. package/dist/types/core/add.d.ts.map +1 -1
  17. package/dist/types/core/css.d.ts +1 -1
  18. package/dist/types/core/css.d.ts.map +1 -1
  19. package/dist/types/core/reducedMotion.d.ts +21 -0
  20. package/dist/types/core/reducedMotion.d.ts.map +1 -0
  21. package/dist/types/core/resolvers.d.ts +3 -3
  22. package/dist/types/core/resolvers.d.ts.map +1 -1
  23. package/dist/types/handlers/animationEnd.d.ts +1 -1
  24. package/dist/types/handlers/animationEnd.d.ts.map +1 -1
  25. package/dist/types/handlers/effectHandlers.d.ts +1 -1
  26. package/dist/types/handlers/effectHandlers.d.ts.map +1 -1
  27. package/dist/types/handlers/eventTrigger.d.ts +1 -1
  28. package/dist/types/handlers/eventTrigger.d.ts.map +1 -1
  29. package/dist/types/handlers/pointerMove.d.ts +1 -1
  30. package/dist/types/handlers/pointerMove.d.ts.map +1 -1
  31. package/dist/types/handlers/viewEnter.d.ts +1 -1
  32. package/dist/types/handlers/viewEnter.d.ts.map +1 -1
  33. package/dist/types/handlers/viewProgress.d.ts +1 -1
  34. package/dist/types/handlers/viewProgress.d.ts.map +1 -1
  35. package/dist/types/types/config.d.ts +6 -1
  36. package/dist/types/types/config.d.ts.map +1 -1
  37. package/dist/types/types/controller.d.ts +5 -0
  38. package/dist/types/types/controller.d.ts.map +1 -1
  39. package/dist/types/types/css.d.ts +26 -0
  40. package/dist/types/types/css.d.ts.map +1 -1
  41. package/dist/types/types/effects.d.ts +2 -0
  42. package/dist/types/types/effects.d.ts.map +1 -1
  43. package/dist/types/types/external.d.ts +1 -1
  44. package/dist/types/types/external.d.ts.map +1 -1
  45. package/dist/types/types/handlers.d.ts +0 -1
  46. package/dist/types/types/handlers.d.ts.map +1 -1
  47. package/dist/types/types/internal.d.ts +3 -1
  48. package/dist/types/types/internal.d.ts.map +1 -1
  49. package/dist/types/types/plugins.d.ts +10 -0
  50. package/dist/types/types/plugins.d.ts.map +1 -1
  51. package/dist/types/utils.d.ts +1 -0
  52. package/dist/types/utils.d.ts.map +1 -1
  53. package/docs/api/interact-class.md +44 -4
  54. package/docs/api/types.md +33 -3
  55. package/docs/guides/conditions-and-media-queries.md +53 -0
  56. package/docs/guides/plugins.md +36 -1
  57. package/package.json +1 -1
  58. package/rules/full-lean.md +33 -4
  59. package/rules/integration.md +2 -2
  60. package/rules/plugins.md +19 -1
  61. package/rules/validate.md +47 -38
  62. package/dist/index-BcRbaJX2.mjs.map +0 -1
  63. package/dist/index-sqvrGHLA.js +0 -29
  64. package/dist/index-sqvrGHLA.js.map +0 -1
package/rules/plugins.md CHANGED
@@ -25,6 +25,23 @@ Interact.use('<plugin-name>', (value, context) => {
25
25
 
26
26
  - `Interact.getPlugin(name) / Interact.getPluginsNames()` inspect the registry.
27
27
 
28
+ ### Deferring (hydration)
29
+
30
+ When a framework hydrates or owns the DOM (e.g. React), defer DOM-changing plugins until the framework is done, then release:
31
+
32
+ ```js
33
+ Interact.use('splitText', splitTextPlugin, { defer: 'hydrated' });
34
+ Interact.create(config);
35
+
36
+ // React client root — effects run after the hydration commit
37
+ useEffect(() => Interact.ready('hydrated'), []);
38
+ ```
39
+
40
+ - While deferred, the plugin does not run, and neither does what carries its `$<name>` field: the whole interaction (interaction-level field), only that effect (effect-level field), or the whole sequence (field on any sequence effect). Everything else applies immediately.
41
+ - `Interact.ready(name, key)` releases a name for one element only; `Interact.ready(name)` releases it for all.
42
+ - `defer` may list several names (e.g. `['hydrated', 'fonts']`); all must be released. Release `'fonts'` with `document.fonts.ready.then(() => Interact.ready('fonts'))`.
43
+ - Released names persist until `Interact.destroy()`.
44
+
28
45
  ## Config placement
29
46
 
30
47
  Add a `$<plugin-name>` field on an **interaction** or an **effect**:
@@ -45,7 +62,8 @@ Add a `$<plugin-name>` field on an **interaction** or an **effect**:
45
62
  - Use a bare, unquoted `$<name>` key — no quotes needed since `$` is a valid identifier start (e.g. `$splitText:`, not `'plugin:splitText':`).
46
63
  - Plugins run at **connect time, before target resolution** — DOM a plugin creates is visible to the `selector` / `listContainer` queries that follow.
47
64
  - A returned cleanup runs on disconnect, on `Interact.destroy()`, and on media-query reconnect. Use it to fully undo the plugin's work.
48
- - Each distinct plugin value is applied **once per connect**, even across multiple triggers on the same element.
65
+ - Each distinct plugin value is applied **once per connect**, even across multiple triggers on the same element. Use object values — the dedup is by identity.
66
+ - **SHOULD** pass `{ defer: 'hydrated' }` to `Interact.use()` for DOM-changing plugins (e.g. `splitTextPlugin`) in apps that hydrate server-rendered markup, and call `Interact.ready('hydrated')` after hydration.
49
67
  - Interaction-level fields use the interaction's element as `root`; effect-level fields use the effect's target element as `root`.
50
68
 
51
69
  ## SSR styling (FOUC prevention)
package/rules/validate.md CHANGED
@@ -127,22 +127,23 @@ Severity is one of `'error' | 'warning'`. There are exactly two levers:
127
127
  1. **`strict: true`** — promotes all remaining issues to `'error'`, so any warning fails the config.
128
128
  2. **`severityOverrides`** — keyed by **rule category**, not by individual code. Only the following categories are registered and overridable:
129
129
 
130
- | Rule category | Covers codes | Default severity |
131
- | ------------------------ | --------------------------------------------------------------------------- | ---------------- |
132
- | `UNUSED_DEFINITION` | `UNUSED_EFFECT`, `UNUSED_SEQUENCE`, `UNUSED_CONDITION` | warning |
133
- | `UNIQUE_DEFINITION_IDS` | `DUPLICATE_KEYFRAME_NAME` | warning |
134
- | `VALID_MEDIA_QUERIES` | `INVALID_MEDIA_QUERY` | error |
135
- | `SAME_ELEMENT_RETRIGGER` | `SAME_ELEMENT_RETRIGGER` | warning |
136
- | `HIT_AREA_SHIFT` | `HIT_AREA_SHIFT` | 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
- | `CSS_PROPERTY_NAME` | `INVALID_CSS_PROPERTY_NAME` | warning |
143
- | `VIEW_INSET` | `INVALID_INSET` | warning |
144
- | `OFFSET_EASING` | `FUNCTION_OFFSET_EASING` | warning |
145
- | `NAMED_EFFECT_PARAMS` | `NAMED_EFFECT_INVALID_PARAM` (error), `NAMED_EFFECT_UNKNOWN_PARAM` | warning |
130
+ | Rule category | Covers codes | Default severity |
131
+ | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
132
+ | `UNUSED_DEFINITION` | `UNUSED_EFFECT`, `UNUSED_SEQUENCE`, `UNUSED_CONDITION` | warning |
133
+ | `UNIQUE_DEFINITION_IDS` | `DUPLICATE_KEYFRAME_NAME` | warning |
134
+ | `VALID_MEDIA_QUERIES` | `INVALID_MEDIA_QUERY` | error |
135
+ | `SAME_ELEMENT_RETRIGGER` | `SAME_ELEMENT_RETRIGGER` | warning |
136
+ | `HIT_AREA_SHIFT` | `HIT_AREA_SHIFT` | 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
+ | `CSS_PROPERTY_NAME` | `INVALID_CSS_PROPERTY_NAME` | warning |
143
+ | `VIEW_INSET` | `INVALID_INSET` | warning |
144
+ | `OFFSET_EASING` | `FUNCTION_OFFSET_EASING` | warning |
145
+ | `NAMED_EFFECT_PARAMS` | `NAMED_EFFECT_INVALID_PARAM` (error), `NAMED_EFFECT_UNKNOWN_PARAM` | warning |
146
+ | `REDUCED_MOTION` | `REDUCED_MOTION_SELF_REFERENCE`, `REDUCED_MOTION_SHADOWED_EFFECT_ID`, `REDUCED_MOTION_ANIMATION_END_SOURCE_MISMATCH`, `REDUCED_MOTION_COLLAPSE_CANCELS` (info) | warning |
146
147
 
147
148
  For each category, set `'off'` to drop those issues entirely, `'warning'` / `'error'` to set their severity:
148
149
 
@@ -194,11 +195,13 @@ This is the authoritative list of every code the validator emits today. Codes no
194
195
 
195
196
  ### Referential errors (severity: error)
196
197
 
197
- | Code | What it flags |
198
- | -------------------------------- | ------------------------------------------------------------------------------ |
199
- | `ANIMATION_END_EFFECT_NOT_FOUND` | An `animationEnd` interaction's `params.effectId` references a missing effect. |
200
- | `SEQUENCE_ID_NOT_FOUND` | A `sequenceId` references a key absent from `config.sequences`. |
201
- | `CONDITION_NOT_FOUND` | A `conditions[]` entry references a key absent from `config.conditions`. |
198
+ | Code | What it flags |
199
+ | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
200
+ | `ANIMATION_END_EFFECT_NOT_FOUND` | An `animationEnd` interaction's `params.effectId` references a missing effect. |
201
+ | `SEQUENCE_ID_NOT_FOUND` | A `sequenceId` references a key absent from `config.sequences`. |
202
+ | `CONDITION_NOT_FOUND` | A `conditions[]` entry references a key absent from `config.conditions`. |
203
+ | `REDUCED_MOTION_EFFECT_NOT_FOUND` | An effect's `reducedMotionPolicy` names an effectId absent from `config.effects`. On an interaction or sequence it is a **warning** instead — the effects inheriting it collapse. |
204
+ | `REDUCED_MOTION_INCOMPATIBLE_EFFECT` | An effect's `reducedMotionPolicy` names an effect of another kind (time / scroll-or-pointer-driven / state). When inherited from an interaction or sequence it is a **warning** instead — the effect collapses. An effect of a `config.sequences` entry is reported on each sequence reference it inherits from. |
202
205
 
203
206
  ### Other structural errors (severity: error)
204
207
 
@@ -222,23 +225,29 @@ This is the authoritative list of every code the validator emits today. Codes no
222
225
 
223
226
  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`.
224
227
 
225
- | Code | What it flags | Rule category |
226
- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
227
- | `SAME_ELEMENT_RETRIGGER` | `viewEnter` with `triggerType` `repeat`/`alternate`/`state` on the same source+target element (re-trigger loop). | `SAME_ELEMENT_RETRIGGER` |
228
- | `HIT_AREA_SHIFT` | `hover`/`click`/`interest`/`activate`/`pointerMove` `keyframeEffect` with a `translate`/`scale`/`matrix` transform on the same source+target element. | `HIT_AREA_SHIFT` |
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
- | `RECOMMENDED_FILL_BACKWARDS` | A `viewEnter` + `once` named/keyframe effect targeting another element or using a same-element delay omits `fill: 'backwards'` or `'both'`. | `RECOMMENDED_FILL` |
236
- | `POINTER_AXIS_IGNORED` | `pointerMove` `params.axis` set on a `namedEffect`/`customEffect` (axis only applies to `keyframeEffect`). | `POINTER_AXIS` |
237
- | `INVALID_CSS_PROPERTY_NAME` | A keyframe or state-effect property name is neither camelCase nor kebab-case (both casings are accepted; this one cannot be normalized). | `CSS_PROPERTY_NAME` |
238
- | `INVALID_INSET` | `viewEnter` `params.inset` is not 1–4 whitespace-separated CSS lengths/percentages. | `VIEW_INSET` |
239
- | `FUNCTION_OFFSET_EASING` | A sequence's `offsetEasing` is a function, so `generate()` omits that sequence from the generated CSS. | `OFFSET_EASING` |
240
- | `NAMED_EFFECT_INVALID_PARAM` | A `namedEffect` param does not match its effect's registered `schema` (type, enum values, min/max, length/angle format). | `NAMED_EFFECT_PARAMS` |
241
- | `NAMED_EFFECT_UNKNOWN_PARAM` | A `namedEffect` param is not declared in its effect's registered `schema` (e.g. a renamed param). | `NAMED_EFFECT_PARAMS` |
228
+ | Code | What it flags | Rule category |
229
+ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------ |
230
+ | `SAME_ELEMENT_RETRIGGER` | `viewEnter` with `triggerType` `repeat`/`alternate`/`state` on the same source+target element (re-trigger loop). | `SAME_ELEMENT_RETRIGGER` |
231
+ | `HIT_AREA_SHIFT` | `hover`/`click`/`interest`/`activate`/`pointerMove` `keyframeEffect` with a `translate`/`scale`/`matrix` transform on the same source+target element. | `HIT_AREA_SHIFT` |
232
+ | `ANIMATION_END_SELF_REFERENCE` | An `animationEnd` interaction waits for an effect it also produces → it can never start. | `ANIMATION_END_GRAPH` |
233
+ | `LIST_ITEM_SELECTOR_WITHOUT_CONTAINER` | `listItemSelector` present without `listContainer` (inert) — on an interaction or an effect. | `ELEMENT_SELECTION` |
234
+ | `REDUNDANT_SELECTOR_WITH_LIST_ITEM` | `selector` is ignored when both `listContainer` and `listItemSelector` are present. | `ELEMENT_SELECTION` |
235
+ | `EMPTY_STYLE_PROPERTIES` | A state effect's `transition.styleProperties` / `transitionProperties` is `[]` (toggles nothing). | `STATE_EFFECT` |
236
+ | `STATE_REMOVE_WITHOUT_EFFECT_ID` | `stateAction: 'remove'` with no `effectId` to pair with a matching `'add'`. | `STATE_EFFECT` |
237
+ | `RECOMMENDED_FILL_BOTH` | A scrubbed (`viewProgress`/`pointerMove`) or toggling (`alternate`/`repeat`/`state`) effect omits `fill: 'both'`. | `RECOMMENDED_FILL` |
238
+ | `RECOMMENDED_FILL_BACKWARDS` | A `viewEnter` + `once` named/keyframe effect targeting another element or using a same-element delay omits `fill: 'backwards'` or `'both'`. | `RECOMMENDED_FILL` |
239
+ | `POINTER_AXIS_IGNORED` | `pointerMove` `params.axis` set on a `namedEffect`/`customEffect` (axis only applies to `keyframeEffect`). | `POINTER_AXIS` |
240
+ | `INVALID_CSS_PROPERTY_NAME` | A keyframe or state-effect property name is neither camelCase nor kebab-case (both casings are accepted; this one cannot be normalized). | `CSS_PROPERTY_NAME` |
241
+ | `INVALID_INSET` | `viewEnter` `params.inset` is not 1–4 whitespace-separated CSS lengths/percentages. | `VIEW_INSET` |
242
+ | `FUNCTION_OFFSET_EASING` | A sequence's `offsetEasing` is a function, so `generate()` omits that sequence from the generated CSS. | `OFFSET_EASING` |
243
+ | `NAMED_EFFECT_INVALID_PARAM` | A `namedEffect` param does not match its effect's registered `schema` (type, enum values, min/max, length/angle format). | `NAMED_EFFECT_PARAMS` |
244
+ | `NAMED_EFFECT_UNKNOWN_PARAM` | A `namedEffect` param is not declared in its effect's registered `schema` (e.g. a renamed param). | `NAMED_EFFECT_PARAMS` |
245
+ | `REDUCED_MOTION_SELF_REFERENCE` | An effect's `reducedMotionPolicy` names the effect itself, which is the same as `'ignore'`. | `REDUCED_MOTION` |
246
+ | `REDUCED_MOTION_SHADOWED_EFFECT_ID` | A `config.effects` key is `ignore` / `cancel` / `collapse`, so `reducedMotionPolicy` can't name it. | `REDUCED_MOTION` |
247
+ | `REDUCED_MOTION_ANIMATION_END_SOURCE_MISMATCH` | An `animationEnd` source effect gets a different `reducedMotionPolicy` where it plays than from its registry entry, which is all the `animationEnd` trigger sees. | `REDUCED_MOTION` |
248
+ | `REDUCED_MOTION_COLLAPSE_CANCELS` (info) | A collapsed effect has no end state (infinite iterations, or `viewProgress` / `pointerMove`), so reduced motion cancels it. Not reported when no `reducedMotionPolicy` is set. | `REDUCED_MOTION` |
249
+
250
+ The instance's `reducedMotionPolicy` (an `Interact.setup()` / `Interact.create()` option) isn't part of the config, so the `REDUCED_MOTION_*` checks take it to be the default `'collapse'`.
242
251
 
243
252
  ---
244
253