@freshjuice/zest 0.1.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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +312 -0
  3. package/dist/zest.de.js +2621 -0
  4. package/dist/zest.de.js.map +1 -0
  5. package/dist/zest.de.min.js +1 -0
  6. package/dist/zest.en.js +2621 -0
  7. package/dist/zest.en.js.map +1 -0
  8. package/dist/zest.en.min.js +1 -0
  9. package/dist/zest.es.js +2621 -0
  10. package/dist/zest.es.js.map +1 -0
  11. package/dist/zest.es.min.js +1 -0
  12. package/dist/zest.esm.js +3104 -0
  13. package/dist/zest.esm.js.map +1 -0
  14. package/dist/zest.esm.min.js +1 -0
  15. package/dist/zest.fr.js +2621 -0
  16. package/dist/zest.fr.js.map +1 -0
  17. package/dist/zest.fr.min.js +1 -0
  18. package/dist/zest.it.js +2621 -0
  19. package/dist/zest.it.js.map +1 -0
  20. package/dist/zest.it.min.js +1 -0
  21. package/dist/zest.ja.js +2621 -0
  22. package/dist/zest.ja.js.map +1 -0
  23. package/dist/zest.ja.min.js +1 -0
  24. package/dist/zest.js +3109 -0
  25. package/dist/zest.js.map +1 -0
  26. package/dist/zest.min.js +1 -0
  27. package/dist/zest.nl.js +2621 -0
  28. package/dist/zest.nl.js.map +1 -0
  29. package/dist/zest.nl.min.js +1 -0
  30. package/dist/zest.pl.js +2621 -0
  31. package/dist/zest.pl.js.map +1 -0
  32. package/dist/zest.pl.min.js +1 -0
  33. package/dist/zest.pt.js +2621 -0
  34. package/dist/zest.pt.js.map +1 -0
  35. package/dist/zest.pt.min.js +1 -0
  36. package/dist/zest.ru.js +2621 -0
  37. package/dist/zest.ru.js.map +1 -0
  38. package/dist/zest.ru.min.js +1 -0
  39. package/dist/zest.uk.js +2621 -0
  40. package/dist/zest.uk.js.map +1 -0
  41. package/dist/zest.uk.min.js +1 -0
  42. package/dist/zest.zh.js +2621 -0
  43. package/dist/zest.zh.js.map +1 -0
  44. package/dist/zest.zh.min.js +1 -0
  45. package/locales/de.json +40 -0
  46. package/locales/en.json +40 -0
  47. package/locales/es.json +40 -0
  48. package/locales/fr.json +40 -0
  49. package/locales/it.json +40 -0
  50. package/locales/ja.json +40 -0
  51. package/locales/nl.json +40 -0
  52. package/locales/pl.json +40 -0
  53. package/locales/pt.json +40 -0
  54. package/locales/ru.json +40 -0
  55. package/locales/uk.json +40 -0
  56. package/locales/zh.json +40 -0
  57. package/package.json +63 -0
  58. package/zest.config.schema.json +256 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FreshJuice
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,312 @@
1
+ # Zest 🍋
2
+
3
+ A lightweight cookie consent toolkit for GDPR/CCPA compliance.
4
+
5
+ - **Lightweight** - ~9KB gzipped (single language) / ~14KB (all 12 languages)
6
+ - **Zero dependencies** - Vanilla JavaScript
7
+ - **Shadow DOM** - Styles isolated from your site
8
+ - **Modern browsers** - No IE11 polyfills needed
9
+ - **Privacy-first** - Respects Do Not Track / Global Privacy Control
10
+
11
+ ## Quick Start
12
+
13
+ ```html
14
+ <!-- unpkg -->
15
+ <script src="https://unpkg.com/@freshjuice/zest"></script>
16
+
17
+ <!-- jsdelivr -->
18
+ <script src="https://cdn.jsdelivr.net/npm/@freshjuice/zest"></script>
19
+ ```
20
+
21
+ Or with configuration:
22
+
23
+ ```html
24
+ <script>
25
+ window.ZestConfig = {
26
+ position: 'bottom-right',
27
+ theme: 'auto',
28
+ accentColor: '#0071e3',
29
+ policyUrl: '/privacy-policy'
30
+ };
31
+ </script>
32
+ <script src="https://unpkg.com/@freshjuice/zest"></script>
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ ### Via `window.ZestConfig`
38
+
39
+ ```javascript
40
+ window.ZestConfig = {
41
+ // Position: 'bottom' | 'bottom-left' | 'bottom-right' | 'top'
42
+ position: 'bottom',
43
+
44
+ // Theme: 'light' | 'dark' | 'auto' (default: 'auto' follows system)
45
+ theme: 'auto',
46
+
47
+ // Accent color for buttons
48
+ accentColor: '#0071e3',
49
+
50
+ // Link to privacy policy
51
+ policyUrl: '/privacy',
52
+
53
+ // Show floating widget after consent
54
+ showWidget: true,
55
+
56
+ // Consent expiration in days
57
+ expiration: 365,
58
+
59
+ // Callbacks
60
+ callbacks: {
61
+ onAccept: (consent) => {},
62
+ onReject: () => {},
63
+ onChange: (consent) => {},
64
+ onReady: (consent) => {}
65
+ }
66
+ };
67
+ ```
68
+
69
+ ### Via data attributes
70
+
71
+ ```html
72
+ <script
73
+ src="zest.min.js"
74
+ data-position="bottom-left"
75
+ data-theme="dark"
76
+ data-accent="#0071e3"
77
+ data-policy-url="/privacy"
78
+ ></script>
79
+ ```
80
+
81
+ ## API
82
+
83
+ ```javascript
84
+ // Show/hide UI
85
+ Zest.show() // Show banner
86
+ Zest.hide() // Hide banner
87
+ Zest.showSettings() // Show settings modal
88
+ Zest.reset() // Clear consent, show banner
89
+
90
+ // Consent management
91
+ Zest.getConsent() // Get current consent state
92
+ Zest.hasConsent('analytics') // Check specific category
93
+ Zest.acceptAll() // Accept all categories
94
+ Zest.rejectAll() // Reject all (except essential)
95
+ ```
96
+
97
+ ## Do Not Track (DNT) / Global Privacy Control (GPC)
98
+
99
+ Zest respects browser privacy signals by default:
100
+
101
+ ```javascript
102
+ window.ZestConfig = {
103
+ respectDNT: true, // Respect DNT/GPC signals (default: true)
104
+ dntBehavior: 'reject' // What to do when DNT is enabled
105
+ };
106
+ ```
107
+
108
+ | Behavior | Description |
109
+ |----------|-------------|
110
+ | `reject` | Auto-reject all non-essential cookies, don't show banner (default) |
111
+ | `preselect` | Show banner with non-essential options unchecked |
112
+ | `ignore` | Ignore DNT/GPC signals completely |
113
+
114
+ **API methods:**
115
+ ```javascript
116
+ Zest.isDoNotTrackEnabled() // Returns true if DNT or GPC is enabled
117
+ Zest.getDNTDetails() // Returns { enabled: boolean, source: 'dnt' | 'gpc' | null }
118
+ ```
119
+
120
+ ## Blocking Modes
121
+
122
+ Control how aggressively scripts are blocked:
123
+
124
+ ```javascript
125
+ window.ZestConfig = {
126
+ mode: 'safe' // 'manual' | 'safe' | 'strict' | 'doomsday'
127
+ };
128
+ ```
129
+
130
+ | Mode | Description |
131
+ |------|-------------|
132
+ | `manual` | Only blocks scripts with `data-consent-category` attribute |
133
+ | `safe` | Manual + known major trackers (Google Analytics, Facebook, etc.) |
134
+ | `strict` | Safe + extended tracker list (Hotjar, Mixpanel, Segment, etc.) |
135
+ | `doomsday` | Block ALL third-party scripts |
136
+
137
+ ### Custom Blocked Domains
138
+
139
+ Add your own domains to block:
140
+
141
+ ```javascript
142
+ window.ZestConfig = {
143
+ mode: 'safe',
144
+ blockedDomains: [
145
+ 'custom-tracker.com',
146
+ { domain: 'another-tracker.com', category: 'analytics' }
147
+ ]
148
+ };
149
+ ```
150
+
151
+ ### Manual Script Tagging
152
+
153
+ For any mode, you can explicitly tag scripts:
154
+
155
+ ```html
156
+ <script data-consent-category="analytics" src="https://..."></script>
157
+ <script data-consent-category="marketing">
158
+ // Inline scripts also supported
159
+ </script>
160
+ ```
161
+
162
+ ### Allow Specific Scripts
163
+
164
+ Prevent a script from being blocked (useful in strict/doomsday modes):
165
+
166
+ ```html
167
+ <script data-zest-allow src="https://cdn.example.com/library.js"></script>
168
+ ```
169
+
170
+ ## Events
171
+
172
+ ```javascript
173
+ document.addEventListener('zest:consent', (e) => {
174
+ console.log('User accepted:', e.detail.consent);
175
+ });
176
+
177
+ document.addEventListener('zest:reject', (e) => {
178
+ console.log('User rejected');
179
+ });
180
+
181
+ document.addEventListener('zest:change', (e) => {
182
+ console.log('Consent changed:', e.detail);
183
+ });
184
+
185
+ document.addEventListener('zest:ready', (e) => {
186
+ console.log('Zest initialized:', e.detail.consent);
187
+ });
188
+ ```
189
+
190
+ ## Localization
191
+
192
+ Zest has **built-in translations** with auto-detection.
193
+
194
+ **Supported languages:** `en`, `de`, `es`, `fr`, `it`, `pt`, `nl`, `pl`, `uk`, `ru`, `ja`, `zh`
195
+
196
+ ### Bundle Options
197
+
198
+ | Bundle | Size (gzip) | Description |
199
+ |--------|-------------|-------------|
200
+ | `zest.min.js` | ~14KB | All 12 languages, auto-detects |
201
+ | `zest.{lang}.min.js` | ~9KB | Single language (e.g., `zest.de.min.js`) |
202
+
203
+ ```html
204
+ <!-- Full bundle - auto-detects language -->
205
+ <script src="https://unpkg.com/@freshjuice/zest"></script>
206
+
207
+ <!-- Single language bundle - smaller size -->
208
+ <script src="https://unpkg.com/@freshjuice/zest/dist/zest.de.min.js"></script>
209
+ ```
210
+
211
+ ### Language Detection
212
+
213
+ ```javascript
214
+ window.ZestConfig = {
215
+ lang: 'auto' // Auto-detect (default)
216
+ };
217
+ ```
218
+
219
+ **Detection priority:**
220
+ 1. `lang` config option (if not 'auto')
221
+ 2. `<html lang="de">` attribute
222
+ 3. Browser language (`navigator.language`)
223
+ 4. Fallback to English
224
+
225
+ ### Force Specific Language
226
+
227
+ ```javascript
228
+ window.ZestConfig = {
229
+ lang: 'de' // Force German
230
+ };
231
+ ```
232
+
233
+ ### Override Labels
234
+
235
+ ```javascript
236
+ window.ZestConfig = {
237
+ lang: 'de', // Use German as base
238
+ labels: {
239
+ banner: {
240
+ title: 'Custom German Title' // Override just this
241
+ }
242
+ }
243
+ };
244
+ ```
245
+
246
+ Standalone JSON translation files also available in `/locales/` for external loading.
247
+
248
+ ## Custom Styling
249
+
250
+ Override default styles by passing custom CSS:
251
+
252
+ ```javascript
253
+ window.ZestConfig = {
254
+ customStyles: `
255
+ .zest-banner {
256
+ max-width: 600px;
257
+ }
258
+ .zest-btn--primary {
259
+ border-radius: 20px;
260
+ }
261
+ .zest-modal {
262
+ max-width: 600px;
263
+ }
264
+ `
265
+ };
266
+ ```
267
+
268
+ Available CSS custom properties (can also be set via parent CSS):
269
+
270
+ ```css
271
+ zest-banner, zest-modal, zest-widget {
272
+ --zest-accent: #0071e3;
273
+ --zest-bg: #ffffff;
274
+ --zest-bg-secondary: #f3f4f6;
275
+ --zest-text: #1f2937;
276
+ --zest-text-secondary: #6b7280;
277
+ --zest-border: #e5e7eb;
278
+ --zest-radius: 12px;
279
+ --zest-radius-sm: 8px;
280
+ }
281
+ ```
282
+
283
+ ## Categories
284
+
285
+ | Category | ID | Default | Description |
286
+ |----------|-----|---------|-------------|
287
+ | Essential | `essential` | ON | Required cookies (cannot be disabled) |
288
+ | Functional | `functional` | OFF | Personalization features |
289
+ | Analytics | `analytics` | OFF | Usage tracking |
290
+ | Marketing | `marketing` | OFF | Advertising cookies |
291
+
292
+ ## Config Schema
293
+
294
+ JSON Schema available for IDE autocompletion: `zest.config.schema.json`
295
+
296
+ ## Contributing
297
+
298
+ Contributions are welcome! Please feel free to submit a Pull Request.
299
+
300
+ 1. Fork the repository
301
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
302
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
303
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
304
+ 5. Open a Pull Request
305
+
306
+ ## Credits
307
+
308
+ Built by [Alex Zappa](https://alex.zappa.dev) at [FreshJuice](https://freshjuice.dev)
309
+
310
+ ## License
311
+
312
+ [MIT](LICENSE)