@wix/interact 1.66.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/README.md +258 -0
- package/dist/cjs/WixInteractElement.js +103 -0
- package/dist/cjs/WixInteractElement.js.map +1 -0
- package/dist/cjs/__tests__/interact.spec.js +944 -0
- package/dist/cjs/__tests__/interact.spec.js.map +1 -0
- package/dist/cjs/external-types.d.js +2 -0
- package/dist/cjs/external-types.d.js.map +1 -0
- package/dist/cjs/handlers/animationEnd.js +33 -0
- package/dist/cjs/handlers/animationEnd.js.map +1 -0
- package/dist/cjs/handlers/click.js +82 -0
- package/dist/cjs/handlers/click.js.map +1 -0
- package/dist/cjs/handlers/hover.js +103 -0
- package/dist/cjs/handlers/hover.js.map +1 -0
- package/dist/cjs/handlers/index.js +21 -0
- package/dist/cjs/handlers/index.js.map +1 -0
- package/dist/cjs/handlers/pointerMove.js +40 -0
- package/dist/cjs/handlers/pointerMove.js.map +1 -0
- package/dist/cjs/handlers/utilities.js +51 -0
- package/dist/cjs/handlers/utilities.js.map +1 -0
- package/dist/cjs/handlers/viewEnter.js +69 -0
- package/dist/cjs/handlers/viewEnter.js.map +1 -0
- package/dist/cjs/handlers/viewProgress.js +56 -0
- package/dist/cjs/handlers/viewProgress.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interact.js +310 -0
- package/dist/cjs/interact.js.map +1 -0
- package/dist/cjs/test-types.d.js +2 -0
- package/dist/cjs/test-types.d.js.map +1 -0
- package/dist/cjs/types.js +2 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.js +66 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/WixInteractElement.js +97 -0
- package/dist/esm/WixInteractElement.js.map +1 -0
- package/dist/esm/__tests__/interact.spec.js +952 -0
- package/dist/esm/__tests__/interact.spec.js.map +1 -0
- package/dist/esm/external-types.d.js +2 -0
- package/dist/esm/external-types.d.js.map +1 -0
- package/dist/esm/handlers/animationEnd.js +29 -0
- package/dist/esm/handlers/animationEnd.js.map +1 -0
- package/dist/esm/handlers/click.js +82 -0
- package/dist/esm/handlers/click.js.map +1 -0
- package/dist/esm/handlers/hover.js +103 -0
- package/dist/esm/handlers/hover.js.map +1 -0
- package/dist/esm/handlers/index.js +16 -0
- package/dist/esm/handlers/index.js.map +1 -0
- package/dist/esm/handlers/pointerMove.js +39 -0
- package/dist/esm/handlers/pointerMove.js.map +1 -0
- package/dist/esm/handlers/utilities.js +45 -0
- package/dist/esm/handlers/utilities.js.map +1 -0
- package/dist/esm/handlers/viewEnter.js +69 -0
- package/dist/esm/handlers/viewEnter.js.map +1 -0
- package/dist/esm/handlers/viewProgress.js +52 -0
- package/dist/esm/handlers/viewProgress.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interact.js +303 -0
- package/dist/esm/interact.js.map +1 -0
- package/dist/esm/test-types.d.js +2 -0
- package/dist/esm/test-types.d.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.js +61 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/types/WixInteractElement.d.ts +324 -0
- package/dist/types/__tests__/interact.spec.d.ts +1 -0
- package/dist/types/handlers/animationEnd.d.ts +8 -0
- package/dist/types/handlers/click.d.ts +8 -0
- package/dist/types/handlers/hover.d.ts +8 -0
- package/dist/types/handlers/index.d.ts +3 -0
- package/dist/types/handlers/pointerMove.d.ts +8 -0
- package/dist/types/handlers/utilities.d.ts +4 -0
- package/dist/types/handlers/viewEnter.d.ts +8 -0
- package/dist/types/handlers/viewProgress.d.ts +8 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interact.d.ts +25 -0
- package/dist/types/types.d.ts +173 -0
- package/dist/types/utils.d.ts +4 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# @wix/interact
|
|
2
|
+
|
|
3
|
+
A powerful, declarative interaction library for creating engaging web animations and effects. Built on top of `@wix/motion`, it provides a configuration-driven approach to adding triggers, animations, and state transitions to web applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎯 **Declarative Configuration** - Define complex interactions through simple JSON configuration
|
|
8
|
+
- 🎨 **Rich Animation Support** - Integration with `@wix/motion` for high-performance animations
|
|
9
|
+
- 🖱️ **Multiple Trigger Types** - Support for hover, click, scroll, viewport, and custom triggers
|
|
10
|
+
- 📱 **Responsive Conditions** - Media query and container-based conditional interactions
|
|
11
|
+
- 🔧 **Custom Elements** - Web Components API for easy framework integration
|
|
12
|
+
- ⚡ **Performance Optimized** - Efficient event handling and animation management
|
|
13
|
+
- 🧩 **Framework Agnostic** - Works with React, vanilla JS, and other frameworks
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @wix/interact
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### 1. Basic Setup
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Interact } from '@wix/interact';
|
|
27
|
+
|
|
28
|
+
// Define your interaction configuration
|
|
29
|
+
const config = {
|
|
30
|
+
interactions: [
|
|
31
|
+
{
|
|
32
|
+
trigger: 'viewEnter',
|
|
33
|
+
source: '#my-element',
|
|
34
|
+
effects: [
|
|
35
|
+
{
|
|
36
|
+
effectId: 'fade-in',
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
effects: {
|
|
42
|
+
'fade-in': {
|
|
43
|
+
duration: 1000,
|
|
44
|
+
keyframeEffect: {
|
|
45
|
+
opacity: [0, 1]
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Initialize the interact instance
|
|
52
|
+
const interact = Interact.create(config);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 2. HTML Setup
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<!-- Wrap your target element with wix-interact-element -->
|
|
59
|
+
<wix-interact-element data-wix-path="#my-element">
|
|
60
|
+
<div>This will fade in when it enters the viewport!</div>
|
|
61
|
+
</wix-interact-element>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Framework Integration
|
|
65
|
+
|
|
66
|
+
#### React
|
|
67
|
+
```tsx
|
|
68
|
+
import React from 'react';
|
|
69
|
+
|
|
70
|
+
function MyComponent() {
|
|
71
|
+
return (
|
|
72
|
+
<wix-interact-element data-wix-path="#my-element">
|
|
73
|
+
<div className="animated-content">
|
|
74
|
+
Hello, animated world!
|
|
75
|
+
</div>
|
|
76
|
+
</wix-interact-element>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Core Concepts
|
|
82
|
+
|
|
83
|
+
### Triggers
|
|
84
|
+
Define when interactions should occur:
|
|
85
|
+
- `viewEnter` - When element enters viewport
|
|
86
|
+
- `click` - On element click
|
|
87
|
+
- `hover` - On element hover
|
|
88
|
+
- `viewProgress` - Based on scroll progress
|
|
89
|
+
- `pointerMove` - On pointer/mouse movement
|
|
90
|
+
- `pageVisible` - When page becomes visible
|
|
91
|
+
- `animationEnd` - When another animation completes
|
|
92
|
+
|
|
93
|
+
### Effects
|
|
94
|
+
Define what should happen:
|
|
95
|
+
- **Time-based animations** - Duration-based effects with easing
|
|
96
|
+
- **Scroll-driven animations** - Progress-based effects tied to scroll
|
|
97
|
+
- **Pointer-driven animations** - Progress-based effects linked to pointer possition
|
|
98
|
+
- **CSS transitions** - Style property transitions
|
|
99
|
+
- **Custom effects** - Integration with `@wix/motion`
|
|
100
|
+
|
|
101
|
+
### Configuration Structure
|
|
102
|
+
```typescript
|
|
103
|
+
{
|
|
104
|
+
interactions: [ // Define trigger → effect relationships
|
|
105
|
+
{
|
|
106
|
+
trigger: 'viewEnter',
|
|
107
|
+
source: '#source-element',
|
|
108
|
+
effects: [{ effectId: 'my-effect' }]
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
effects: { // Define reusable effect definitions
|
|
112
|
+
'my-effect': {
|
|
113
|
+
duration: 1000,
|
|
114
|
+
keyframeEffect: { opacity: [0, 1] }
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
conditions: { // Define conditional logic
|
|
118
|
+
'mobile-only': {
|
|
119
|
+
type: 'media',
|
|
120
|
+
predicate: '(max-width: 768px)'
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## API Reference
|
|
127
|
+
|
|
128
|
+
### Interact Class
|
|
129
|
+
|
|
130
|
+
#### Static Methods
|
|
131
|
+
```typescript
|
|
132
|
+
// Create a new instance with configuration
|
|
133
|
+
Interact.create(config: InteractConfig): Interact
|
|
134
|
+
|
|
135
|
+
// Get instance that handles a specific path
|
|
136
|
+
Interact.getInstance(path: string): Interact | undefined
|
|
137
|
+
|
|
138
|
+
// Get cached element by path
|
|
139
|
+
Interact.getElement(path: string): IWixInteractElement | undefined
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Standalone Functions
|
|
143
|
+
```typescript
|
|
144
|
+
// Add interactions to an element
|
|
145
|
+
add(element: IWixInteractElement, path: string): boolean
|
|
146
|
+
|
|
147
|
+
// Remove all interactions from an element
|
|
148
|
+
remove(path: string): void
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Examples
|
|
152
|
+
|
|
153
|
+
### Entrance Animation
|
|
154
|
+
```typescript
|
|
155
|
+
{
|
|
156
|
+
interactions: [{
|
|
157
|
+
trigger: 'viewEnter',
|
|
158
|
+
source: '#hero',
|
|
159
|
+
effects: [{ effectId: 'slide-up' }]
|
|
160
|
+
}],
|
|
161
|
+
effects: {
|
|
162
|
+
'slide-up': {
|
|
163
|
+
duration: 800,
|
|
164
|
+
easing: 'ease-out',
|
|
165
|
+
keyframeEffect: {
|
|
166
|
+
transform: ['translateY(50px)', 'translateY(0)'],
|
|
167
|
+
opacity: [0, 1]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Click Interaction
|
|
175
|
+
```typescript
|
|
176
|
+
{
|
|
177
|
+
interactions: [{
|
|
178
|
+
trigger: 'click',
|
|
179
|
+
source: '#button',
|
|
180
|
+
effects: [{ effectId: 'bounce' }]
|
|
181
|
+
}],
|
|
182
|
+
effects: {
|
|
183
|
+
'bounce': {
|
|
184
|
+
duration: 600,
|
|
185
|
+
namedEffect: 'bounce'
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Responsive Interactions
|
|
192
|
+
```typescript
|
|
193
|
+
{
|
|
194
|
+
interactions: [{
|
|
195
|
+
trigger: 'hover',
|
|
196
|
+
source: '#card',
|
|
197
|
+
conditions: ['desktop-only'],
|
|
198
|
+
effects: [{ effectId: 'lift' }]
|
|
199
|
+
}],
|
|
200
|
+
conditions: {
|
|
201
|
+
'desktop-only': {
|
|
202
|
+
type: 'media',
|
|
203
|
+
predicate: '(min-width: 1024px)'
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
effects: {
|
|
207
|
+
'lift': {
|
|
208
|
+
duration: 200,
|
|
209
|
+
keyframeEffect: {
|
|
210
|
+
transform: ['translateY(0)', 'translateY(-8px)'],
|
|
211
|
+
boxShadow: ['0 2px 4px rgba(0,0,0,0.1)', '0 8px 16px rgba(0,0,0,0.15)']
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Documentation
|
|
219
|
+
|
|
220
|
+
- [Full API Documentation](docs/api/README.md)
|
|
221
|
+
- [Guides and Tutorials](docs/guides/README.md)
|
|
222
|
+
- [Examples and Patterns](docs/examples/README.md)
|
|
223
|
+
- [Integration Guides](docs/integration/README.md)
|
|
224
|
+
|
|
225
|
+
## Development
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Install dependencies
|
|
229
|
+
yarn install
|
|
230
|
+
|
|
231
|
+
# Run tests
|
|
232
|
+
yarn test
|
|
233
|
+
|
|
234
|
+
# Run playground
|
|
235
|
+
yarn playground
|
|
236
|
+
|
|
237
|
+
# Build package
|
|
238
|
+
yarn build
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Browser Support
|
|
242
|
+
|
|
243
|
+
- ✅ Modern browsers with Web Components support
|
|
244
|
+
- ⚠️ If using setting styles via JS in `transition` or `transitionProerties` - which use `adoptedStyleSheets`, browser support is: Chrome 73+, Firefox 101+, Safari 16.4+, Edge 79+
|
|
245
|
+
|
|
246
|
+
## Related Packages
|
|
247
|
+
|
|
248
|
+
- [`@wix/motion`](../motion/README.md) - Core animation engine
|
|
249
|
+
- [`fizban`](https://github.com/wix-incubator/fizban) - For polyfilling scroll-driven animations
|
|
250
|
+
- [`kuliso`](https://github.com/wix-incubator/kuliso) - For polyfilling pointer-driven animations
|
|
251
|
+
|
|
252
|
+
## Contributing
|
|
253
|
+
|
|
254
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this package.
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
UNLICENSED - Internal Wix package
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.WIX_INTERACT_EFFECT_DATA_ATTR = void 0;
|
|
6
|
+
exports.getWixInteractElement = getWixInteractElement;
|
|
7
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
+
var _interact = require("./interact");
|
|
9
|
+
const WIX_INTERACT_EFFECT_DATA_ATTR = exports.WIX_INTERACT_EFFECT_DATA_ATTR = 'wixInteractEffect';
|
|
10
|
+
function getWixInteractElement() {
|
|
11
|
+
let checkedForLegacyStateSyntax = false;
|
|
12
|
+
let isLegacyStateSyntax = false;
|
|
13
|
+
return class WixInteractElement extends HTMLElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
(0, _defineProperty2.default)(this, "_internals", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "connected", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "sheet", void 0);
|
|
19
|
+
this.connected = false;
|
|
20
|
+
this.sheet = null;
|
|
21
|
+
if (this.attachInternals) {
|
|
22
|
+
this._internals = this.attachInternals();
|
|
23
|
+
if (!checkedForLegacyStateSyntax) {
|
|
24
|
+
checkedForLegacyStateSyntax = true;
|
|
25
|
+
try {
|
|
26
|
+
this._internals.states.add('test');
|
|
27
|
+
this._internals.states.delete('test');
|
|
28
|
+
} catch (e) {
|
|
29
|
+
isLegacyStateSyntax = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
checkedForLegacyStateSyntax = true; // custom states not supported - skip syntax check
|
|
34
|
+
this._internals = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
this.connect();
|
|
39
|
+
}
|
|
40
|
+
disconnectedCallback() {
|
|
41
|
+
const path = this.dataset.wixPath;
|
|
42
|
+
if (path) {
|
|
43
|
+
(0, _interact.remove)(path);
|
|
44
|
+
}
|
|
45
|
+
if (this.sheet) {
|
|
46
|
+
const index = document.adoptedStyleSheets.indexOf(this.sheet);
|
|
47
|
+
document.adoptedStyleSheets.splice(index, 1);
|
|
48
|
+
}
|
|
49
|
+
this.connected = false;
|
|
50
|
+
}
|
|
51
|
+
connect(path) {
|
|
52
|
+
if (this.connected) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
path = path || this.dataset.wixPath;
|
|
56
|
+
if (!path) {
|
|
57
|
+
console.warn('WixInteractElement: No path provided');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (this.firstElementChild) {
|
|
61
|
+
this.connected = (0, _interact.add)(this, path);
|
|
62
|
+
} else {
|
|
63
|
+
console.warn('WixInteractElement: No child element found');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
renderStyle(cssText) {
|
|
67
|
+
const sheet = new CSSStyleSheet();
|
|
68
|
+
this.sheet = sheet;
|
|
69
|
+
sheet.replace(cssText);
|
|
70
|
+
document.adoptedStyleSheets.push(sheet);
|
|
71
|
+
}
|
|
72
|
+
toggleEffect(effectId, method) {
|
|
73
|
+
if (isLegacyStateSyntax) {
|
|
74
|
+
effectId = `--${effectId}`;
|
|
75
|
+
}
|
|
76
|
+
if (this._internals) {
|
|
77
|
+
if (method === 'toggle') {
|
|
78
|
+
this._internals.states.has(effectId) ? this._internals.states.delete(effectId) : this._internals.states.add(effectId);
|
|
79
|
+
} else if (method === 'add') {
|
|
80
|
+
this._internals.states.add(effectId);
|
|
81
|
+
} else if (method === 'remove') {
|
|
82
|
+
this._internals.states.delete(effectId);
|
|
83
|
+
} else if (method === 'clear') {
|
|
84
|
+
this._internals.states.clear();
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
var _this$dataset$WIX_INT;
|
|
88
|
+
const currentEffects = new Set(((_this$dataset$WIX_INT = this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR]) == null ? void 0 : _this$dataset$WIX_INT.split(' ')) || []);
|
|
89
|
+
if (method === 'toggle') {
|
|
90
|
+
currentEffects.has(effectId) ? currentEffects.delete(effectId) : currentEffects.add(effectId);
|
|
91
|
+
} else if (method === 'add') {
|
|
92
|
+
currentEffects.add(effectId);
|
|
93
|
+
} else if (method === 'remove') {
|
|
94
|
+
currentEffects.delete(effectId);
|
|
95
|
+
} else if (method === 'clear') {
|
|
96
|
+
currentEffects.clear();
|
|
97
|
+
}
|
|
98
|
+
this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] = Array.from(currentEffects).join(' ');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=WixInteractElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_interact","require","WIX_INTERACT_EFFECT_DATA_ATTR","exports","getWixInteractElement","checkedForLegacyStateSyntax","isLegacyStateSyntax","WixInteractElement","HTMLElement","constructor","_defineProperty2","default","connected","sheet","attachInternals","_internals","states","add","delete","e","connectedCallback","connect","disconnectedCallback","path","dataset","wixPath","remove","index","document","adoptedStyleSheets","indexOf","splice","console","warn","firstElementChild","renderStyle","cssText","CSSStyleSheet","replace","push","toggleEffect","effectId","method","has","clear","_this$dataset$WIX_INT","currentEffects","Set","split","Array","from","join"],"sources":["../../src/WixInteractElement.ts"],"sourcesContent":["import type { StateParams } from './types';\nimport { add, remove } from './interact';\n\nexport const WIX_INTERACT_EFFECT_DATA_ATTR = 'wixInteractEffect';\n\nexport function getWixInteractElement() {\n let checkedForLegacyStateSyntax = false;\n let isLegacyStateSyntax = false;\n\n return class WixInteractElement extends HTMLElement {\n _internals: (ElementInternals & { states: Set<string> }) | null;\n connected: boolean;\n sheet: CSSStyleSheet | null;\n\n constructor() {\n super();\n\n this.connected = false;\n this.sheet = null;\n\n if (this.attachInternals) {\n this._internals = this.attachInternals() as ElementInternals & {\n states: Set<string>;\n };\n\n if (!checkedForLegacyStateSyntax) {\n checkedForLegacyStateSyntax = true;\n\n try {\n this._internals.states.add('test');\n this._internals.states.delete('test');\n } catch (e) {\n isLegacyStateSyntax = true;\n }\n }\n } else {\n checkedForLegacyStateSyntax = true; // custom states not supported - skip syntax check\n this._internals = null;\n }\n }\n connectedCallback() {\n this.connect();\n }\n\n disconnectedCallback() {\n const path = this.dataset.wixPath;\n\n if (path) {\n remove(path);\n }\n\n if (this.sheet) {\n const index = document.adoptedStyleSheets.indexOf(this.sheet);\n document.adoptedStyleSheets.splice(index, 1);\n }\n\n this.connected = false;\n }\n\n connect(path?: string) {\n if (this.connected) {\n return;\n }\n\n path = path || this.dataset.wixPath;\n\n if (!path) {\n console.warn('WixInteractElement: No path provided');\n return;\n }\n\n if (this.firstElementChild) {\n this.connected = add(this, path);\n } else {\n console.warn('WixInteractElement: No child element found');\n }\n }\n\n renderStyle(cssText: string) {\n const sheet = new CSSStyleSheet();\n this.sheet = sheet;\n\n sheet.replace(cssText);\n\n document.adoptedStyleSheets.push(sheet);\n }\n\n toggleEffect(effectId: string, method: StateParams['method']) {\n if (isLegacyStateSyntax) {\n effectId = `--${effectId}`;\n }\n\n if (this._internals) {\n if (method === 'toggle') {\n this._internals.states.has(effectId)\n ? this._internals.states.delete(effectId)\n : this._internals.states.add(effectId);\n } else if (method === 'add') {\n this._internals.states.add(effectId);\n } else if (method === 'remove') {\n this._internals.states.delete(effectId);\n } else if (method === 'clear') {\n this._internals.states.clear();\n }\n } else {\n const currentEffects = new Set(\n this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR]?.split(' ') || [],\n );\n\n if (method === 'toggle') {\n currentEffects.has(effectId)\n ? currentEffects.delete(effectId)\n : currentEffects.add(effectId);\n } else if (method === 'add') {\n currentEffects.add(effectId);\n } else if (method === 'remove') {\n currentEffects.delete(effectId);\n } else if (method === 'clear') {\n currentEffects.clear();\n }\n\n this.dataset[WIX_INTERACT_EFFECT_DATA_ATTR] =\n Array.from(currentEffects).join(' ');\n }\n }\n };\n}\n"],"mappings":";;;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AAEO,MAAMC,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,mBAAmB;AAEzD,SAASE,qBAAqBA,CAAA,EAAG;EACtC,IAAIC,2BAA2B,GAAG,KAAK;EACvC,IAAIC,mBAAmB,GAAG,KAAK;EAE/B,OAAO,MAAMC,kBAAkB,SAASC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