@prosdevlab/experience-sdk-plugins 0.2.0 → 0.3.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/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +120 -0
- package/README.md +141 -79
- package/dist/index.d.ts +206 -35
- package/dist/index.js +1229 -75
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/banner/banner.ts +63 -62
- package/src/exit-intent/exit-intent.ts +2 -3
- package/src/index.ts +2 -0
- package/src/inline/index.ts +3 -0
- package/src/inline/inline.test.ts +620 -0
- package/src/inline/inline.ts +269 -0
- package/src/inline/insertion.ts +66 -0
- package/src/inline/types.ts +52 -0
- package/src/integration.test.ts +356 -297
- package/src/modal/form-rendering.ts +262 -0
- package/src/modal/form-styles.ts +212 -0
- package/src/modal/form-validation.test.ts +413 -0
- package/src/modal/form-validation.ts +126 -0
- package/src/modal/index.ts +3 -0
- package/src/modal/modal-styles.ts +204 -0
- package/src/modal/modal.browser.test.ts +164 -0
- package/src/modal/modal.test.ts +1294 -0
- package/src/modal/modal.ts +685 -0
- package/src/modal/types.ts +114 -0
- package/src/scroll-depth/scroll-depth.test.ts +35 -0
- package/src/scroll-depth/scroll-depth.ts +2 -4
- package/src/time-delay/time-delay.test.ts +2 -2
- package/src/time-delay/time-delay.ts +2 -3
- package/src/types.ts +20 -36
- package/src/utils/sanitize.ts +4 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @prosdevlab/experience-sdk-plugins@0.
|
|
2
|
+
> @prosdevlab/experience-sdk-plugins@0.3.0 build /home/runner/work/experience-sdk/experience-sdk/packages/plugins
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
[34mCLI[39m Target: es2024
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
13
|
-
[32mESM[39m [1mdist/index.js.map [22m[
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m79.10 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m191.96 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 304ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1228ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m28.79 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
1
|
# @prosdevlab/experience-sdk-plugins
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2fc279c: **Phase 2: Presentation Layer - Modal & Inline Plugins**
|
|
8
|
+
|
|
9
|
+
This release introduces two powerful new rendering plugins with built-in form support, completing the presentation layer for the Experience SDK.
|
|
10
|
+
|
|
11
|
+
## 🎉 New Features
|
|
12
|
+
|
|
13
|
+
### Modal Plugin
|
|
14
|
+
|
|
15
|
+
- **Rich Content Modals**: Display announcements, promotions, and interactive content
|
|
16
|
+
- **Built-in Forms**: Email capture, surveys, and feedback forms with validation
|
|
17
|
+
- **Size Variants**: Small, medium, large, and extra-large sizes
|
|
18
|
+
- **Hero Images**: Full-width images for visual impact
|
|
19
|
+
- **Responsive Design**: Mobile fullscreen mode for optimal UX
|
|
20
|
+
- **Keyboard Navigation**: Focus trap, Escape key, Tab navigation
|
|
21
|
+
- **Animations**: Smooth fade-in/fade-out transitions
|
|
22
|
+
- **Form States**: Success, error, and loading states
|
|
23
|
+
- **API Methods**: `show()`, `remove()`, `isShowing()`, `showFormState()`, `resetForm()`, `getFormData()`
|
|
24
|
+
|
|
25
|
+
### Inline Plugin
|
|
26
|
+
|
|
27
|
+
- **DOM Insertion**: Embed content anywhere in your page
|
|
28
|
+
- **5 Insertion Methods**: `replace`, `append`, `prepend`, `before`, `after`
|
|
29
|
+
- **CSS Selector Targeting**: Use any valid selector to target elements
|
|
30
|
+
- **Dismissal with Persistence**: Users can dismiss and it persists in localStorage
|
|
31
|
+
- **No Layout Disruption**: Seamlessly integrates with existing page structure
|
|
32
|
+
- **API Methods**: `show()`, `remove()`, `isShowing()`
|
|
33
|
+
|
|
34
|
+
### Forms (Built into Modal)
|
|
35
|
+
|
|
36
|
+
- **Field Types**: text, email, url, tel, number, textarea, select, checkbox, radio
|
|
37
|
+
- **Validation**: Required, email, URL, pattern, custom validation, min/max length
|
|
38
|
+
- **Real-time Feedback**: Validates on blur, shows errors inline
|
|
39
|
+
- **Submission Handling**: Emits `experiences:modal:form:submit` event
|
|
40
|
+
- **Success/Error States**: Built-in UI for post-submission states
|
|
41
|
+
- **Pure Functions**: Validation and rendering logic easily extractable
|
|
42
|
+
|
|
43
|
+
## 🎨 Theming & Customization
|
|
44
|
+
|
|
45
|
+
### CSS Variables
|
|
46
|
+
|
|
47
|
+
All plugins now support CSS variable theming:
|
|
48
|
+
|
|
49
|
+
- **Modal**: `--xp-modal-*` variables for backdrop, dialog, title, content, buttons
|
|
50
|
+
- **Forms**: `--xp-form-*` variables for inputs, labels, errors, submit button
|
|
51
|
+
- **Banner**: `--xp-banner-*` variables (refactored from inline styles)
|
|
52
|
+
- **Inline**: `--xp-inline-*` variables for custom styling
|
|
53
|
+
|
|
54
|
+
See the [Theming Guide](https://prosdevlab.github.io/experience-sdk/guides/theming) for full reference.
|
|
55
|
+
|
|
56
|
+
## 🔧 API Improvements
|
|
57
|
+
|
|
58
|
+
### Runtime
|
|
59
|
+
|
|
60
|
+
- **Auto-registration**: Modal and inline plugins are automatically registered
|
|
61
|
+
- **Plugin API Access**: Expose plugin APIs via singleton (`experiences.modal.show()`)
|
|
62
|
+
- **Trigger Event Handling**: Explicit listeners for each trigger type (exit intent, scroll depth, time delay)
|
|
63
|
+
|
|
64
|
+
### Display Conditions
|
|
65
|
+
|
|
66
|
+
Seamless integration with existing display condition plugins:
|
|
67
|
+
|
|
68
|
+
- **Exit Intent + Modal**: Capture emails before users leave
|
|
69
|
+
- **Scroll Depth + Inline**: Progressive feature discovery
|
|
70
|
+
- **Time Delay + Modal**: Time-sensitive promotions
|
|
71
|
+
- **Page Visits + Banner**: Returning user messages
|
|
72
|
+
|
|
73
|
+
## 📦 Bundle Size
|
|
74
|
+
|
|
75
|
+
- **Core SDK**: 13.4 KB gzipped (under 15 KB target ✅)
|
|
76
|
+
- **All Plugins**: ~26 KB gzipped total (smaller than competitors like Pathfora at ~47 KB)
|
|
77
|
+
- **Excellent Compression**: CSS-in-JS with CSS variables maintains small footprint
|
|
78
|
+
|
|
79
|
+
## 🧪 Testing
|
|
80
|
+
|
|
81
|
+
- **432 tests passing** (unit, integration, browser tests)
|
|
82
|
+
- **Modal Plugin**: 56 tests for core functionality, forms, keyboard nav, accessibility
|
|
83
|
+
- **Inline Plugin**: 24 tests for DOM insertion, dismissal, persistence
|
|
84
|
+
- **Form Validation**: 35 tests for all field types and edge cases
|
|
85
|
+
- **Integration Tests**: 10 tests for plugin interactions
|
|
86
|
+
- **Exit Intent**: 21 tests with timing and sensitivity validation
|
|
87
|
+
|
|
88
|
+
## 📚 Documentation
|
|
89
|
+
|
|
90
|
+
- **Modal Plugin Reference**: Complete API docs with examples
|
|
91
|
+
- **Inline Plugin Reference**: Full insertion method documentation
|
|
92
|
+
- **Theming Guide**: CSS variable reference with examples
|
|
93
|
+
- **Use Case Examples**: 4 complete implementation guides in playground
|
|
94
|
+
|
|
95
|
+
## 🚀 Playground Enhancements
|
|
96
|
+
|
|
97
|
+
- **Layout Gallery Hub**: Visual directory for banner, modal, and inline layouts
|
|
98
|
+
- **Navigation System**: Breadcrumbs and sub-navigation tabs
|
|
99
|
+
- **Use Case Examples**:
|
|
100
|
+
- Exit Intent Email Capture (exit intent + modal forms)
|
|
101
|
+
- Feature Discovery Journey (scroll depth + inline + modal)
|
|
102
|
+
- Time-Delayed Promotions (time delay + hero image modal)
|
|
103
|
+
- Promotions & Announcements (banner examples)
|
|
104
|
+
- **Interactive Demos**: Live examples with SDK integration
|
|
105
|
+
|
|
106
|
+
## ⚠️ Breaking Changes
|
|
107
|
+
|
|
108
|
+
None. This is a **minor** release with backward compatibility.
|
|
109
|
+
|
|
110
|
+
## 🔜 Next Steps (Phase 3+)
|
|
111
|
+
|
|
112
|
+
- Browser tests for form focus management
|
|
113
|
+
- Composable form plugin (separate from modal)
|
|
114
|
+
- Additional layout plugins (tooltip, slideout, sticky bar)
|
|
115
|
+
- Multi-instance support with `instanceId` tracking
|
|
116
|
+
|
|
117
|
+
***
|
|
118
|
+
|
|
119
|
+
**Migration Guide**: No migration needed. Simply upgrade and start using the new plugins!
|
|
120
|
+
|
|
121
|
+
**Full Changelog**: See [Phase 2 Spec](https://github.com/prosdevlab/experience-sdk/blob/main/specs/phase-2-presentation-layer/spec.md)
|
|
122
|
+
|
|
3
123
|
## 0.2.0
|
|
4
124
|
|
|
5
125
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -2,100 +2,90 @@
|
|
|
2
2
|
|
|
3
3
|
Official plugins for [Experience SDK](https://github.com/prosdevlab/experience-sdk).
|
|
4
4
|
|
|
5
|
-
**Size:**
|
|
5
|
+
**Size:** 12.7 KB gzipped (all plugins)
|
|
6
6
|
|
|
7
7
|
## Included Plugins
|
|
8
8
|
|
|
9
|
-
###
|
|
9
|
+
### Layout Plugins
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
**Banner Plugin** - Top/bottom notification bars with push-down support
|
|
12
12
|
|
|
13
13
|
**Features:**
|
|
14
14
|
- Multiple buttons with variants (primary, secondary, link)
|
|
15
15
|
- Responsive layout (desktop inline, mobile stack)
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
- **CSS customization** via `className` and `style` props
|
|
20
|
-
- Stable `.xp-*` CSS classes for styling
|
|
16
|
+
- Top/bottom positioning with optional push-down
|
|
17
|
+
- HTML sanitization for XSS protection
|
|
18
|
+
- CSS variables for full theming
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
import { createInstance, bannerPlugin } from '@prosdevlab/experience-sdk-plugins';
|
|
24
|
-
|
|
25
|
-
const sdk = createInstance();
|
|
26
|
-
sdk.use(bannerPlugin);
|
|
20
|
+
**Modal Plugin** - Overlay dialogs with forms and rich content
|
|
27
21
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
],
|
|
37
|
-
position: 'top',
|
|
38
|
-
dismissable: true
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
```
|
|
22
|
+
**Features:**
|
|
23
|
+
- Multiple sizes (sm, md, lg, fullscreen, auto)
|
|
24
|
+
- Mobile fullscreen for large modals
|
|
25
|
+
- Hero images with max height
|
|
26
|
+
- Animations (fade, slide-up, none)
|
|
27
|
+
- Built-in form support with validation
|
|
28
|
+
- Focus trap and keyboard support (Escape)
|
|
29
|
+
- CSS variables for full theming
|
|
42
30
|
|
|
43
|
-
**
|
|
31
|
+
**Inline Plugin** - In-content experiences using CSS selectors
|
|
44
32
|
|
|
45
|
-
|
|
33
|
+
**Features:**
|
|
34
|
+
- 5 insertion methods (replace, append, prepend, before, after)
|
|
35
|
+
- Dismissal with persistence
|
|
36
|
+
- Multi-instance support
|
|
37
|
+
- HTML sanitization
|
|
38
|
+
- Custom styling (className, style props)
|
|
39
|
+
- CSS variables for theming
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
// With Tailwind
|
|
49
|
-
content: {
|
|
50
|
-
message: 'Flash Sale!',
|
|
51
|
-
className: 'bg-gradient-to-r from-blue-600 to-purple-600 text-white',
|
|
52
|
-
buttons: [{
|
|
53
|
-
text: 'Shop Now',
|
|
54
|
-
className: 'bg-white text-blue-600 hover:bg-gray-100'
|
|
55
|
-
}]
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// With inline styles
|
|
59
|
-
content: {
|
|
60
|
-
message: 'Flash Sale!',
|
|
61
|
-
style: {
|
|
62
|
-
background: 'linear-gradient(90deg, #667eea 0%, #764ba2 100%)',
|
|
63
|
-
color: 'white'
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
41
|
+
### Display Condition Plugins
|
|
67
42
|
|
|
68
|
-
|
|
43
|
+
**Exit Intent Plugin** - Detect when users are leaving
|
|
69
44
|
|
|
70
|
-
|
|
45
|
+
**Features:**
|
|
46
|
+
- Mouse movement tracking
|
|
47
|
+
- Configurable sensitivity
|
|
48
|
+
- Min time on page
|
|
49
|
+
- Delay before triggering
|
|
50
|
+
- Session persistence
|
|
71
51
|
|
|
72
|
-
|
|
52
|
+
**Scroll Depth Plugin** - Track scroll engagement
|
|
73
53
|
|
|
74
54
|
**Features:**
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
55
|
+
- Multiple thresholds (25%, 50%, 75%, 100%)
|
|
56
|
+
- Max scroll tracking
|
|
57
|
+
- Velocity and direction tracking
|
|
58
|
+
- Time-to-threshold metrics
|
|
59
|
+
- Throttling and resize handling
|
|
79
60
|
|
|
80
|
-
|
|
81
|
-
import { createInstance, frequencyPlugin } from '@prosdevlab/experience-sdk-plugins';
|
|
61
|
+
**Page Visits Plugin** - Session and lifetime counters
|
|
82
62
|
|
|
83
|
-
|
|
84
|
-
|
|
63
|
+
**Features:**
|
|
64
|
+
- Session-scoped visits (sessionStorage)
|
|
65
|
+
- Lifetime visits (localStorage)
|
|
66
|
+
- First-visit detection
|
|
67
|
+
- DNT (Do Not Track) support
|
|
68
|
+
- Expiration and cross-tab safety
|
|
85
69
|
|
|
86
|
-
|
|
87
|
-
const count = sdk.frequency.getImpressionCount('welcome', 'session');
|
|
70
|
+
**Time Delay Plugin** - Show after time elapsed
|
|
88
71
|
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
**Features:**
|
|
73
|
+
- Configurable show delay
|
|
74
|
+
- Auto-hide after duration
|
|
75
|
+
- Pause when page hidden (Page Visibility API)
|
|
76
|
+
- Timer management
|
|
91
77
|
|
|
92
|
-
|
|
93
|
-
sdk.frequency.reset('welcome');
|
|
94
|
-
```
|
|
78
|
+
### Utility Plugins
|
|
95
79
|
|
|
96
|
-
|
|
80
|
+
**Frequency Plugin** - Impression tracking and capping
|
|
97
81
|
|
|
98
|
-
|
|
82
|
+
**Features:**
|
|
83
|
+
- Session/day/week impression tracking
|
|
84
|
+
- Automatic storage management
|
|
85
|
+
- Manual impression recording
|
|
86
|
+
- Reset capabilities
|
|
87
|
+
|
|
88
|
+
**Debug Plugin** - Logging and window events
|
|
99
89
|
|
|
100
90
|
**Features:**
|
|
101
91
|
- Console logging with prefix
|
|
@@ -103,18 +93,87 @@ Provides console logging and window event emission for debugging and Chrome exte
|
|
|
103
93
|
- Automatic decision logging
|
|
104
94
|
- Configurable logging levels
|
|
105
95
|
|
|
96
|
+
## Quick Examples
|
|
97
|
+
|
|
98
|
+
### Banner
|
|
99
|
+
|
|
106
100
|
```typescript
|
|
107
|
-
import { createInstance,
|
|
101
|
+
import { createInstance, bannerPlugin } from '@prosdevlab/experience-sdk-plugins';
|
|
108
102
|
|
|
109
|
-
const sdk = createInstance(
|
|
110
|
-
sdk.use(
|
|
103
|
+
const sdk = createInstance();
|
|
104
|
+
sdk.use(bannerPlugin);
|
|
111
105
|
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
sdk.banner.show({
|
|
107
|
+
id: 'welcome',
|
|
108
|
+
type: 'banner',
|
|
109
|
+
content: {
|
|
110
|
+
message: 'Welcome! Get 20% off today.',
|
|
111
|
+
buttons: [
|
|
112
|
+
{ text: 'Shop Now', url: '/shop', variant: 'primary' }
|
|
113
|
+
],
|
|
114
|
+
position: 'top'
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
```
|
|
114
118
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
### Modal with Form
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
sdk.modal.show({
|
|
123
|
+
id: 'newsletter',
|
|
124
|
+
type: 'modal',
|
|
125
|
+
content: {
|
|
126
|
+
title: 'Stay Updated',
|
|
127
|
+
message: 'Subscribe for exclusive offers.',
|
|
128
|
+
size: 'sm',
|
|
129
|
+
form: {
|
|
130
|
+
fields: [
|
|
131
|
+
{ name: 'email', type: 'email', required: true }
|
|
132
|
+
],
|
|
133
|
+
submitButton: { text: 'Subscribe', variant: 'primary' },
|
|
134
|
+
successState: {
|
|
135
|
+
title: '✓ Subscribed!',
|
|
136
|
+
message: 'Check your inbox.'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Inline Experience
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
sdk.inline.show({
|
|
147
|
+
id: 'promo',
|
|
148
|
+
type: 'inline',
|
|
149
|
+
content: {
|
|
150
|
+
selector: '#sidebar',
|
|
151
|
+
position: 'prepend',
|
|
152
|
+
message: '<p><strong>Special Offer!</strong> Get 20% off with SAVE20.</p>',
|
|
153
|
+
buttons: [
|
|
154
|
+
{ text: 'Shop Now', url: '/shop', variant: 'primary' }
|
|
155
|
+
],
|
|
156
|
+
dismissable: true,
|
|
157
|
+
persist: true
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Exit Intent
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// Trigger modal on exit intent
|
|
166
|
+
sdk.on('trigger:exitIntent', () => {
|
|
167
|
+
sdk.modal.show({
|
|
168
|
+
id: 'exit-offer',
|
|
169
|
+
content: {
|
|
170
|
+
title: 'Wait! Before You Go...',
|
|
171
|
+
message: 'Get 15% off your first order.',
|
|
172
|
+
buttons: [
|
|
173
|
+
{ text: 'Claim Discount', variant: 'primary', url: '/checkout?code=EXIT15' }
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
});
|
|
118
177
|
});
|
|
119
178
|
```
|
|
120
179
|
|
|
@@ -145,8 +204,11 @@ experiences.register('banner', { ... });
|
|
|
145
204
|
## Documentation
|
|
146
205
|
|
|
147
206
|
- [Full Documentation](https://prosdevlab.github.io/experience-sdk)
|
|
148
|
-
- [
|
|
149
|
-
- [
|
|
207
|
+
- [Banner Plugin](https://prosdevlab.github.io/experience-sdk/reference/plugins/banner)
|
|
208
|
+
- [Modal Plugin](https://prosdevlab.github.io/experience-sdk/reference/plugins/modal)
|
|
209
|
+
- [Inline Plugin](https://prosdevlab.github.io/experience-sdk/reference/plugins/inline)
|
|
210
|
+
- [Display Conditions](https://prosdevlab.github.io/experience-sdk/reference/plugins/exit-intent)
|
|
211
|
+
- [All Plugins](https://prosdevlab.github.io/experience-sdk/reference/plugins)
|
|
150
212
|
|
|
151
213
|
## License
|
|
152
214
|
|