@wix/interact 2.5.4 → 2.5.6

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 (56) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/react.js +1 -1
  4. package/dist/cjs/web.js +1 -1
  5. package/dist/es/index.js +1 -1
  6. package/dist/es/react.js +2 -2
  7. package/dist/es/web.js +2 -2
  8. package/dist/{index-CfagoYAR.mjs → index-CEt49C5d.mjs} +1246 -1112
  9. package/dist/index-CEt49C5d.mjs.map +1 -0
  10. package/dist/index-CxaQDD-U.js +21 -0
  11. package/dist/index-CxaQDD-U.js.map +1 -0
  12. package/dist/tsconfig.build.tsbuildinfo +1 -1
  13. package/dist/types/core/Interact.d.ts +10 -1
  14. package/dist/types/core/Interact.d.ts.map +1 -1
  15. package/dist/types/core/InteractionController.d.ts +3 -1
  16. package/dist/types/core/InteractionController.d.ts.map +1 -1
  17. package/dist/types/core/add.d.ts.map +1 -1
  18. package/dist/types/core/css.d.ts +19 -6
  19. package/dist/types/core/css.d.ts.map +1 -1
  20. package/dist/types/core/cssUtils.d.ts.map +1 -1
  21. package/dist/types/types/config.d.ts +2 -1
  22. package/dist/types/types/config.d.ts.map +1 -1
  23. package/dist/types/types/controller.d.ts +5 -0
  24. package/dist/types/types/controller.d.ts.map +1 -1
  25. package/dist/types/types/css.d.ts +16 -1
  26. package/dist/types/types/css.d.ts.map +1 -1
  27. package/dist/types/types/effects.d.ts +2 -1
  28. package/dist/types/types/effects.d.ts.map +1 -1
  29. package/dist/types/types/external.d.ts +2 -0
  30. package/dist/types/types/external.d.ts.map +1 -1
  31. package/dist/types/types/index.d.ts +1 -0
  32. package/dist/types/types/index.d.ts.map +1 -1
  33. package/dist/types/types/plugins.d.ts +81 -0
  34. package/dist/types/types/plugins.d.ts.map +1 -0
  35. package/dist/types/utils.d.ts +7 -1
  36. package/dist/types/utils.d.ts.map +1 -1
  37. package/docs/api/README.md +1 -1
  38. package/docs/api/functions.md +23 -13
  39. package/docs/api/interact-class.md +35 -0
  40. package/docs/api/types.md +93 -1
  41. package/docs/examples/entrance-animations.md +1 -0
  42. package/docs/guides/README.md +4 -0
  43. package/docs/guides/configuration-structure.md +2 -0
  44. package/docs/guides/plugins.md +192 -0
  45. package/package.json +2 -2
  46. package/rules/click.md +2 -2
  47. package/rules/full-lean.md +58 -12
  48. package/rules/hover.md +2 -2
  49. package/rules/integration.md +11 -11
  50. package/rules/plugins.md +122 -0
  51. package/rules/validate.md +5 -3
  52. package/rules/viewenter.md +5 -2
  53. package/rules/viewprogress.md +1 -1
  54. package/dist/index-CfagoYAR.mjs.map +0 -1
  55. package/dist/index-DdqUOFMC.js +0 -21
  56. package/dist/index-DdqUOFMC.js.map +0 -1
@@ -24,6 +24,7 @@ Declarative configuration-driven interaction library. Binds animations to trigge
24
24
  - [Conditions](#conditions)
25
25
  - [CSS Generation & FOUC Prevention](#css-generation--fouc-prevention)
26
26
  - [Element Resolution](#element-resolution)
27
+ - [Plugins](#plugins)
27
28
  - [Static API](#static-api)
28
29
 
29
30
  ---
@@ -361,7 +362,7 @@ Each effect applies a visual change to a target element. An effect is either inl
361
362
  **`fill` guidance:**
362
363
 
363
364
  - `'both'` — use for scroll-driven (`viewProgress`), pointer-driven (`pointerMove`), and toggling effects (`hover`/`click` with `alternate`, `repeat`, or `state` type).
364
- - `'backwards'` — use for entrance animations with `type: 'once'` when the element's own CSS already matches the final keyframe (applies the initial keyframe during any `delay`).
365
+ - `'backwards'` — use for entrance animations (`viewEnter` + `once`). Entrance presets default to `'backwards'`; set it explicitly for inline `keyframeEffect` entrances. Use `'both'` when the final keyframe must persist after the animation.
365
366
 
366
367
  **`composite`** — same as CSS's `animation-composition`. Controls how this effect combines with others on the same property (transforms & filters):
367
368
 
@@ -468,7 +469,7 @@ Used with `hover` / `click` triggers. Set `stateAction` on the effect to control
468
469
  }
469
470
  ```
470
471
 
471
- CSS property names use **camelCase** (e.g. `'backgroundColor'`, `'borderRadius'`).
472
+ CSS property names may be written in **kebab-case** (`'background-color'`) or **camelCase** (`'backgroundColor'`) — both are accepted and normalized. Prefer kebab-case here: these properties are written into CSS. CSS custom properties (`--*`) are used verbatim and are case-sensitive.
472
473
 
473
474
  ### Animation Payloads
474
475
 
@@ -504,7 +505,7 @@ Exactly one MUST be provided per time-based or scroll/pointer-driven effect:
504
505
  ```
505
506
 
506
507
  - `[EFFECT_NAME]` — unique string identifier for this effect.
507
- - `[KEYFRAMES]` — array of keyframe objects using standard WAAPI format (e.g. `[{ opacity: '0' }, { opacity: '1' }]`). Property names in camelCase.
508
+ - `[KEYFRAMES]` — array of keyframe objects using standard WAAPI format (e.g. `[{ opacity: '0' }, { opacity: '1' }]`). Property names may be camelCase or kebab-case (both are accepted and normalized); prefer camelCase, which is what WAAPI uses. `offset`, `easing` and `composite` keep their WAAPI meaning, so the CSS `offset` property is written as `cssOffset`.
508
509
 
509
510
  3. **`customEffect`** — imperative update callback. Use only when CSS-based effects cannot express the desired behavior (e.g., animating SVG attributes, canvas, text content).
510
511
 
@@ -705,17 +706,62 @@ The target element is what the effect animates. Resolved in priority order:
705
706
 
706
707
  ---
707
708
 
709
+ ## Plugins
710
+
711
+ Interact can route config to external plugins registered with `Interact.use(name, plugin)`. Interact is only a bridge — it matches a `$<name>` config field to a registered plugin name and passes the value in; it never inspects plugin behavior. Neither Interact nor the plugin package depend on each other. A plugin package MAY ship its own adapter typed structurally against the contract (e.g. `@wix/splittext/plugin`) — use it instead of hand-rolling one; your app supplies only the type glue.
712
+
713
+ - Register before `create()`: `Interact.use('splitText', splitTextPlugin)`.
714
+ - Reference with a `$<name>` field on an **interaction** or **effect**: `$splitText: { container: '.title', type: 'chars' }`.
715
+ - Plugins run at connect time, **before** target resolution — so DOM they create (e.g. `.split-c` spans) is visible to `selector` queries that follow.
716
+ - A plugin may return a cleanup function; Interact runs it on disconnect/teardown.
717
+ - A `$<name>` field with no registered plugin is ignored.
718
+ - Plugin fields MUST be `$`-prefixed — a non-prefixed unknown key on an interaction/effect is rejected by `@wix/interact-validate`.
719
+ - **SSR styling:** for FOUC prevention (e.g. hiding un-split text before an entrance animation), pass a **separate** per-plugin callback in the `plugins` option of `generate()`'s options bag: `generate(config, { useFirstChild: true, plugins: { myPlugin: (value, context) => { declarations, selectorSuffix }[] } })`. `generate()` does not inspect the value; the callback returns CSS rule(s) data and scopes them under the base selector (`[data-interact-key="<key>"]`). It is NOT the `use()` callback. If the plugin package ships a generator (e.g. `splitTextStyle` from `@wix/splittext/plugin`), pass that instead of writing one.
720
+
721
+ **Example — split text, then stagger the generated char spans.** Use the adapter shipped from `@wix/splittext/plugin` (`splitTextPlugin` + its SSR counterpart `splitTextStyle`); do NOT hand-roll it:
722
+
723
+ ```js
724
+ import { Interact, generate } from '@wix/interact';
725
+ import { splitTextPlugin, splitTextStyle } from '@wix/splittext/plugin';
726
+
727
+ const config = {
728
+ effects: { 'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 } },
729
+ interactions: [
730
+ {
731
+ key: 'hero',
732
+ trigger: 'viewEnter',
733
+ // `hideUntilReady` opts into the SSR hide rule emitted by splitTextStyle
734
+ $splitText: { container: '.title', type: 'chars', hideUntilReady: true },
735
+ sequences: [{ offset: 30, effects: [{ effectId: 'char-fade-up', selector: '.split-c' }] }],
736
+ },
737
+ ],
738
+ };
739
+
740
+ const css = generate(config, { useFirstChild: true, plugins: { splitText: splitTextStyle } });
741
+ // Embed css in HTML — see CSS Generation & FOUC Prevention
742
+
743
+ Interact.use('splitText', splitTextPlugin);
744
+
745
+ Interact.create(config);
746
+ ```
747
+
748
+ - `$splitText` takes `{ container, hideUntilReady?, ...SplitTextOptions }`; `container` is resolved within the element and every match is split.
749
+ - Type the field in your app: `declare module '@wix/interact' { interface InteractPluginConfigMap { splitText: SplitTextPluginConfig } }` (type from `@wix/splittext/plugin`).
750
+
751
+ Default split wrapper classes: `.split-c` (chars), `.split-w` (words), `.split-l` (lines), `.split-s` (sentences).
752
+
708
753
  ## Static API
709
754
 
710
- | Method / Property | Description |
711
- | :---------------------------------- | :------------------------------------------------------------------------------------------------------------ |
712
- | `generate(config, useFirstChild?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. |
713
- | `Interact.create(config)` | Initialize with a config. Returns the instance. Store the instance to manage its lifecycle. |
714
- | `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `generate()` and `create`. |
715
- | `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
716
- | `Interact.forceReducedMotion` | `boolean` (default: `false`) — force reduced-motion behavior regardless of OS setting. |
717
- | `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
718
- | `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
755
+ | Method / Property | Description |
756
+ | :---------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
757
+ | `generate(config, options?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. `options` = `{ useFirstChild?, plugins? }`, or a bare boolean for legacy `useFirstChild`. `plugins` = per-plugin SSR style generators (see [Plugins](#plugins)). |
758
+ | `Interact.create(config)` | Initialize with a config. Returns the instance. Store the instance to manage its lifecycle. |
759
+ | `Interact.registerEffects(presets)` | Register named effect presets. MUST be called before `generate()` and `create`. |
760
+ | `Interact.destroy()` | Tear down all instances. Call on unmount or route change to prevent memory leaks. |
761
+ | `Interact.forceReducedMotion` | `boolean` (default: `false`) — force reduced-motion behavior regardless of OS setting. |
762
+ | `Interact.allowA11yTriggers` | `boolean` (default: `true`) — enable accessibility trigger variants (`interest`, `activate`). |
763
+ | `Interact.setup(options)` | Configure global options for scroll, pointer, and viewEnter systems. Call before `create`. See options below. |
764
+ | `Interact.use(name, plugin)` | Register an external plugin by name (see [Plugins](#plugins)). Call before `create`. |
719
765
 
720
766
  **`Interact.setup(options)`** — optional configuration object:
721
767
 
package/rules/hover.md CHANGED
@@ -69,7 +69,7 @@ Use `keyframeEffect` or `namedEffect` when the hover should play an animation (C
69
69
  - `'repeat'` — restarts the animation from the beginning on each enter. On leave, jumps to the beginning and pauses.
70
70
  - `'once'` — plays once on the first enter and never again.
71
71
  - `'state'` — resumes on enter, pauses on leave. Useful for continuous loops (`iterations: Infinity`).
72
- - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
72
+ - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names may be camelCase or kebab-case (both accepted); prefer camelCase, which is what WAAPI uses.
73
73
  - `[EFFECT_NAME]` — unique string identifier for a `keyframeEffect`.
74
74
  - `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built effect from `@wix/motion-presets`. Refer to motion-presets rules for available presets and their options.
75
75
  - `[DURATION_MS]` — animation duration in milliseconds.
@@ -131,7 +131,7 @@ Use `transition` when all properties share timing. Use `transitionProperties` wh
131
131
  - `'add'` — applies the style state on enter. Leave does NOT remove it.
132
132
  - `'remove'` — removes a previously applied style state on enter. Use with provided `effectId` to map to a matching interaction with `add` and effect with same `effectId`.
133
133
  - `'clear'` — clears all previously applied style states on enter. Use to reset multiple stacked `'add'` style changes at once (e.g. a "reset" hover area that undoes several accumulated states).
134
- - `[CSS_PROP]` — CSS property name as a string in camelCase format (e.g. `'backgroundColor'`, `'borderRadius'`, `'opacity'`).
134
+ - `[CSS_PROP]` — CSS property name as a string, in kebab-case (`'background-color'`) or camelCase (`'backgroundColor'`) — both accepted; prefer kebab-case, since these are written into CSS. Custom properties (`--*`) are used verbatim.
135
135
  - `[VALUE]` — target CSS value for the property.
136
136
  - `[DURATION_MS]` — transition duration in milliseconds.
137
137
  - `[DELAY_MS]` — optional transition delay in milliseconds.
@@ -273,7 +273,7 @@ Define reusable sequences in `InteractConfig.sequences` and reference by `sequen
273
273
 
274
274
  ## CSS Generation & FOUC Prevention
275
275
 
276
- `generate(config, useFirstChild)` produces complete CSS for **all** interactions in the config — `@keyframes`, animation/transition custom properties, `view-timeline` declarations, state-selector rules, coordinated-list aggregation, and FOUC-prevention initial rules.
276
+ `generate(config, options?)` produces complete CSS for **all** interactions in the config — `@keyframes`, animation/transition custom properties, `view-timeline` declarations, state-selector rules, coordinated-list aggregation, and FOUC-prevention initial rules.
277
277
 
278
278
  **Static site policy:** For static or pre-rendered HTML (agent-generated pages,
279
279
  SSG, static export), prefer calling `generate()` for the complete config at
@@ -284,7 +284,7 @@ browser before its `Interact.create()` call. If splitting is impractical,
284
284
  generating the complete CSS at runtime is an acceptable fallback. Call
285
285
  `registerEffects()` before each `generate()` when using `namedEffect`.
286
286
 
287
- The `useFirstChild` argument tells Interact whether to render `:first-child` selectors for custom-element (`web`) integration: `true` for **web**, `false` for **react** and **vanilla**.
287
+ The `useFirstChild` option tells Interact whether to render `:first-child` selectors for custom-element (`web`) integration: `true` for **web**, `false` for **react** and **vanilla**. Pass it either as a bare boolean (`generate(config, true)`) or in the options bag (`generate(config, { useFirstChild: true })`) — the bag is also where `plugins` goes.
288
288
 
289
289
  ```javascript
290
290
  import { generate } from '@wix/interact/web';
@@ -344,12 +344,12 @@ See [viewenter.md](./viewenter.md) for full details.
344
344
 
345
345
  Each `Interact.create(config)` call returns an instance. Keep a reference if you need to add/remove elements dynamically (vanilla JS) or to destroy a specific instance. Call `Interact.destroy()` to tear down all instances at once (e.g. on page navigation).
346
346
 
347
- | Method / Property | Description |
348
- | :---------------------------------- | :------------------------------------------------------------------------------------------- |
349
- | `generate(config, useFirstChild?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. |
350
- | `Interact.create(config)` | Initialize with a config. Returns the instance. Multiple configs create separate instances. |
351
- | `Interact.registerEffects(presets)` | Register named effect presets before `generate()` and `create`. Required for `namedEffect`. |
352
- | `Interact.destroy()` | Tear down all instances. |
353
- | `Interact.forceReducedMotion` | `boolean` — force reduced-motion behavior regardless of OS setting. Default: `false`. |
354
- | `Interact.allowA11yTriggers` | `boolean` — enable accessibility triggers (`interest`, `activate`). Default: `false`. |
355
- | `Interact.setup(options)` | Configure global defaults for scroll/pointer/viewEnter trigger params. Call before `create`. |
347
+ | Method / Property | Description |
348
+ | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
349
+ | `generate(config, options?)` | Produce complete CSS for all interactions. Call at build/generation time; embed in HTML. `options` = `{ useFirstChild?, plugins? }`, or a bare boolean for legacy `useFirstChild`. |
350
+ | `Interact.create(config)` | Initialize with a config. Returns the instance. Multiple configs create separate instances. |
351
+ | `Interact.registerEffects(presets)` | Register named effect presets before `generate()` and `create`. Required for `namedEffect`. |
352
+ | `Interact.destroy()` | Tear down all instances. |
353
+ | `Interact.forceReducedMotion` | `boolean` — force reduced-motion behavior regardless of OS setting. Default: `false`. |
354
+ | `Interact.allowA11yTriggers` | `boolean` — enable accessibility triggers (`interest`, `activate`). Default: `false`. |
355
+ | `Interact.setup(options)` | Configure global defaults for scroll/pointer/viewEnter trigger params. Call before `create`. |
@@ -0,0 +1,122 @@
1
+ # @wix/interact Plugin Rules
2
+
3
+ Rules for extending `@wix/interact` with external plugins via `Interact.use()` and `$`-prefixed config fields.
4
+
5
+ ## Model
6
+
7
+ Interact is a **generic bridge**. It knows a plugin only by the name it was registered under. When an interaction or effect carries a field named `$<name>`, Interact passes that field's value to the matching plugin and (optionally) stores a cleanup. Interact never inspects what the plugin does.
8
+
9
+ - `@wix/interact` has **no** plugin-specific code and does **not** depend on any plugin package.
10
+ - A plugin package (e.g. `@wix/splittext`) does **not** depend on `@wix/interact`.
11
+ - A plugin package MAY still ship a ready-made adapter (e.g. `@wix/splittext/plugin`), typed _structurally_ against the contract below so it stays assignable to `InteractPlugin` without importing Interact. Prefer the shipped adapter over hand-rolling one.
12
+ - Only the **typing** glue lives in your app — the declaration merge on `InteractPluginConfigMap` (see [Config placement](#config-placement)).
13
+
14
+ ## Registration
15
+
16
+ Register before `Interact.create()`:
17
+
18
+ ```js
19
+ Interact.use('<plugin-name>', (value, context) => {
20
+ // value: the value of the `$<plugin-name>` field
21
+ // context: { root, key, scope: 'interaction' | 'effect', config }
22
+ // return: optional cleanup () => void, run on disconnect/teardown
23
+ });
24
+ ```
25
+
26
+ - `Interact.getPlugin(name) / Interact.getPluginsNames()` inspect the registry.
27
+
28
+ ## Config placement
29
+
30
+ Add a `$<plugin-name>` field on an **interaction** or an **effect**:
31
+
32
+ ```js
33
+ {
34
+ key: 'hero',
35
+ trigger: 'viewEnter',
36
+ $splitText: { /* any value */ },
37
+ effects: [ /* ... */ ],
38
+ }
39
+ ```
40
+
41
+ ## Rules
42
+
43
+ - **MUST** register the plugin (`Interact.use`) before `Interact.create()`. A `$<name>` field with no registered plugin is ignored.
44
+ - **MUST** prefix plugin fields with `$` (e.g. `$splitText`). A non-prefixed unknown key on an interaction/effect is rejected by `@wix/interact-validate` (via `catchall` + key check). Only `$`-prefixed fields are treated as opaque, un-inspected plugin config.
45
+ - Use a bare, unquoted `$<name>` key — no quotes needed since `$` is a valid identifier start (e.g. `$splitText:`, not `'plugin:splitText':`).
46
+ - Plugins run at **connect time, before target resolution** — DOM a plugin creates is visible to the `selector` / `listContainer` queries that follow.
47
+ - 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.
49
+ - Interaction-level fields use the interaction's element as `root`; effect-level fields use the effect's target element as `root`.
50
+
51
+ ## SSR styling (FOUC prevention)
52
+
53
+ Runtime plugins mutate the DOM only after JS loads. To style the element _before_ that (e.g. hide un-split text so an entrance animation doesn't flash), pass a **separate** per-plugin callback in the `plugins` option of `generate()`'s options bag:
54
+
55
+ ```js
56
+ const css = generate(config, {
57
+ useFirstChild: true,
58
+ plugins: {
59
+ myPlugin: (value, _context) => {
60
+ // value: the opaque `$myPlugin` value;
61
+ // context: { key, scope: 'interaction' | 'effect', config }
62
+ // return: { declarations: { name: string; value: number | string }[]; selectorSuffix?: string }[]
63
+ return [
64
+ {
65
+ declarations: [{ name: 'visibility', value: 'hidden' }],
66
+ selectorSuffix: ` ${value.container ?? ''}:not([data-myplugin-ready])`,
67
+ },
68
+ ];
69
+ },
70
+ },
71
+ });
72
+ ```
73
+
74
+ - If the plugin package ships its own generator, pass that instead of writing one — e.g. `splitTextStyle` from `@wix/splittext/plugin` (see the example below).
75
+ - This is **NOT** the callback registered via `Interact.use()` — it's a build-time styling generator.
76
+ - `generate()` does **not** inspect the `$<name>` value (same as `create()`); it just routes it to the generator, which returns partial CSS rule(s) data.
77
+ - `declarations` is an array of names and values of CSS properties to set; `selectorSuffix` is used to refine the target of the CSS rule - the resulting selector for the rule is `[data-interact-key=${key}]${selectorSuffix}`
78
+ - Context: `{ key, scope: 'interaction' | 'effect', config }`.
79
+ - Typical pattern: the runtime plugin sets a marker attribute after applying (e.g. `data-splittext-ready`), and the SSR rule hides until that marker is present.
80
+
81
+ ## Example: `@wix/splittext`
82
+
83
+ Split text into `<span>`s, then target the generated spans with a normal `selector`. Default classes: `.split-c` (chars), `.split-w` (words), `.split-l` (lines), `.split-s` (sentences).
84
+
85
+ **Do NOT hand-roll this adapter.** `@wix/splittext/plugin` ships both callbacks — `splitTextPlugin` (runtime) and `splitTextStyle` (SSR) — already paired on the `data-splittext-ready` marker:
86
+
87
+ ```js
88
+ import { Interact, generate } from '@wix/interact';
89
+ import { splitTextPlugin, splitTextStyle } from '@wix/splittext/plugin';
90
+
91
+ const config = {
92
+ effects: { 'char-fade-up': { namedEffect: { type: 'FadeIn' }, duration: 400 } },
93
+ interactions: [
94
+ {
95
+ key: 'hero',
96
+ trigger: 'viewEnter',
97
+ // `hideUntilReady` opts into the SSR hide rule emitted by splitTextStyle
98
+ $splitText: { container: '.title', type: 'chars', hideUntilReady: true },
99
+ sequences: [{ offset: 30, effects: [{ effectId: 'char-fade-up', selector: '.split-c' }] }],
100
+ },
101
+ ],
102
+ };
103
+
104
+ Interact.use('splitText', splitTextPlugin);
105
+
106
+ const css = generate(config, { useFirstChild: true, plugins: { splitText: splitTextStyle } });
107
+ // Embed css in HTML — see CSS Generation & FOUC Prevention
108
+
109
+ Interact.create(config);
110
+ ```
111
+
112
+ To type the `$splitText` field, declaration-merge in your app (the only place importing both packages):
113
+
114
+ ```ts
115
+ import type { SplitTextPluginConfig } from '@wix/splittext/plugin';
116
+
117
+ declare module '@wix/interact' {
118
+ interface InteractPluginConfigMap {
119
+ splitText: SplitTextPluginConfig;
120
+ }
121
+ }
122
+ ```
package/rules/validate.md CHANGED
@@ -56,7 +56,7 @@ if (!result.valid) {
56
56
  - `valid` is `true` when no remaining issue has severity `'error'`. **Warnings alone do not make `valid: false`.**
57
57
  - `errors` holds **all** surfaced issues — both `'error'` and `'warning'` severities. Filter on `severity` to separate them.
58
58
  - Issues are sorted lexicographically by `path`.
59
- - 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
+ - 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` nudges, CSS property names that are neither camelCase nor kebab-case). If the structural parse fails, the semantic layer is skipped.
60
60
 
61
61
  ### assertValidInteractConfig
62
62
 
@@ -140,7 +140,7 @@ Severity is one of `'error' | 'warning'`. There are exactly two levers:
140
140
  | `STATE_EFFECT` | `EMPTY_STYLE_PROPERTIES`, `STATE_REMOVE_WITHOUT_EFFECT_ID` | warning |
141
141
  | `RECOMMENDED_FILL` | `RECOMMENDED_FILL_BOTH` | info |
142
142
  | `POINTER_AXIS` | `POINTER_AXIS_IGNORED` | warning |
143
- | `KEYFRAME_STYLE` | `KEYFRAME_PROP_NOT_CAMEL_CASE` | warning |
143
+ | `CSS_PROPERTY_NAME` | `INVALID_CSS_PROPERTY_NAME` | warning |
144
144
  | `VIEW_INSET` | `INVALID_INSET` | warning |
145
145
 
146
146
  For each category, set `'off'` to drop those issues entirely, `'warning'` / `'error'` to set their severity:
@@ -233,8 +233,9 @@ Statically-detectable authoring pitfalls lifted from the trigger rule files. Eac
233
233
  | `EMPTY_STYLE_PROPERTIES` | A state effect's `transition.styleProperties` / `transitionProperties` is `[]` (toggles nothing). | `STATE_EFFECT` |
234
234
  | `STATE_REMOVE_WITHOUT_EFFECT_ID` | `stateAction: 'remove'` with no `effectId` to pair with a matching `'add'`. | `STATE_EFFECT` |
235
235
  | `RECOMMENDED_FILL_BOTH` | A scrubbed (`viewProgress`/`pointerMove`) or toggling (`alternate`/`repeat`/`state`) effect omits `fill: 'both'`. | `RECOMMENDED_FILL` |
236
+ | `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
237
  | `POINTER_AXIS_IGNORED` | `pointerMove` `params.axis` set on a `namedEffect`/`customEffect` (axis only applies to `keyframeEffect`). | `POINTER_AXIS` |
237
- | `KEYFRAME_PROP_NOT_CAMEL_CASE` | A `keyframeEffect` property name is kebab-case (not WAAPI camelCase). | `KEYFRAME_STYLE` |
238
+ | `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
239
  | `INVALID_INSET` | `viewEnter` `params.inset` is not 1–4 whitespace-separated CSS lengths/percentages. | `VIEW_INSET` |
239
240
 
240
241
  ---
@@ -277,6 +278,7 @@ const ExperienceSchema = z.object({
277
278
  - `InteractConfigSchema` is `.strict()` — unrecognized top-level keys produce `SCHEMA_UNRECOGNIZED_KEYS`.
278
279
  - `InteractConfigSchema` carries a `.transform()`, so a successful `.parse()` returns the config augmented with an internal `warnings` array; `validateInteractConfig` consumes that for you.
279
280
  - `customEffect` and function-valued `offsetEasing` are accepted as opaque functions (`z.custom<Function>`) — they are not deep-validated, so JS-authored configs with function fields validate correctly.
281
+ - Interactions and effects accept `$`-prefixed plugin fields (e.g. `$splitText`) — config routed to plugins registered via `Interact.use()`. Interaction/effect schemas use `.catchall(z.unknown())` + a key check instead of `.strict()`: `$`-prefixed fields are accepted with opaque values (validate has no knowledge of any plugin's shape), while any non-prefixed unknown key is still reported as `SCHEMA_UNRECOGNIZED_KEYS` (typo detection preserved). The top-level `InteractConfigSchema` stays `.strict()`.
280
282
 
281
283
  ---
282
284
 
@@ -23,6 +23,8 @@ This document contains rules for generating interactions that respond to element
23
23
 
24
24
  **Solution:** Call `generate(config, useFirstChild)` at build/generation time and embed the resulting CSS before first paint. Among all the CSS it produces, `generate()` includes initial rules that hide entrance-animated elements from the moment the page renders, before JS runs. The rules use `:not([data-interact-enter])` so elements become visible once the animation starts.
25
25
 
26
+ For entrance animations, set `fill: 'backwards'` (or `'both'` when the final keyframe must persist). Entrance presets default to `backwards`; inline `keyframeEffect` entrances should set it explicitly.
27
+
26
28
  ### Generate CSS at build time and embed in HTML
27
29
 
28
30
  Prefer running this for the complete config in a **build/generation script**
@@ -90,6 +92,7 @@ const css = generate(config, useFirstChild); // true for web; false for react/va
90
92
  - Inject runtime-generated CSS before the corresponding `Interact.create()` call
91
93
  and before revealing initially hidden content to minimize FOUC.
92
94
  - FOUC initial rules apply only to `viewEnter` + `triggerType: 'once'` (or no `triggerType`, which defaults to `'once'`) where source and target are the same element.
95
+ - For `viewEnter` + `once` entrance animations, use `fill: 'backwards'` (or `'both'` when the final keyframe must persist after the animation).
93
96
  - For `viewEnter` with `triggerType: 'repeat'`/`'alternate'`/`'state'`, manually apply the starting keyframe as inline styles on the target element and use `fill: 'both'`.
94
97
  - `generate(config)` processes all interactions in the config, not just `viewEnter`.
95
98
 
@@ -149,10 +152,10 @@ Use `keyframeEffect` or `namedEffect` when the viewEnter should play an animatio
149
152
  - `'state'` — resumes on enter, pauses on leave. Useful for continuous loops (`iterations: Infinity`). Use separate source and target.
150
153
  - `[VISIBILITY_THRESHOLD]` — optional. Number between 0–1 indicating how much of the source element must be visible to trigger (e.g. `0.3` = 30%).
151
154
  - `[VIEWPORT_INSETS]` — optional. String adjusting the viewport detection area (e.g. `'-100px'` extends it, `'50px'` shrinks it).
152
- - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
155
+ - `[KEYFRAMES]` — array of keyframe objects (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names may be camelCase or kebab-case (both accepted); prefer camelCase, which is what WAAPI uses.
153
156
  - `[EFFECT_NAME]` — unique string identifier for a `keyframeEffect`.
154
157
  - `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built effect from `@wix/motion-presets`. Refer to motion-presets rules for available presets and their options.
155
- - `[FILL_MODE]` — `'both'` for `triggerType: 'alternate'`, `'repeat'`, or `'state'`. For `triggerType: 'once'`: use `'backwards'` when the animation's final keyframe has no additional effect (over element's base style); use `'both'` otherwise.
158
+ - `[FILL_MODE]` — `'both'` for `triggerType: 'alternate'`, `'repeat'`, or `'state'`. For `triggerType: 'once'`: use `'backwards'` for entrance, so the first keyframe applies during any `delay` (use `'both'` when the final keyframe must persist after the animation).
156
159
  - `[DURATION_MS]` — animation duration in milliseconds.
157
160
  - `[EASING_FUNCTION]` — CSS easing string or named easing from `@wix/motion`.
158
161
  - `[DELAY_MS]` — optional delay before the effect starts, in milliseconds.
@@ -55,7 +55,7 @@ For static sites, pre-render CSS via `generate()` at build time — see
55
55
  - `[TARGET_KEY]` — identifier matching the element's key (`data-interact-key` for web, `interactKey` for React) on the element to animate (can be same as source or different).
56
56
  - `[NAMED_EFFECT_DEFINITION]` — object with properties of pre-built effect from `@wix/motion-presets`. **CRITICAL:** Scroll presets (`*Scroll`) MUST include `range: 'in' | 'out' | 'continuous'` in their options. `'in'` ends at the idle state, `'out'` starts from the idle state, `'continuous'` passes through it.
57
57
  - `[EFFECT_NAME]` — unique name for custom keyframe effect.
58
- - `[EFFECT_KEYFRAMES]` — array of keyframe objects defining CSS property values (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names in camelCase.
58
+ - `[EFFECT_KEYFRAMES]` — array of keyframe objects defining CSS property values (e.g. `[{ opacity: 0 }, { opacity: 1 }]`). Property names may be camelCase or kebab-case (both accepted); prefer camelCase, which is what WAAPI uses.
59
59
  - `[RANGE_NAME]` — scroll range name:
60
60
  - `'cover'` — full visibility span from first pixel entering to last pixel leaving.
61
61
  - `'entry'` — the phase while the element is entering the viewport.