@dargmuesli/nuxt-cookie-control 1.9.9 → 2.0.0-beta.2

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 (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +206 -285
  3. package/dist/module.cjs +5 -0
  4. package/dist/module.d.ts +66 -0
  5. package/dist/module.json +8 -0
  6. package/dist/module.mjs +186 -0
  7. package/dist/runtime/components/CookieControl.vue +274 -0
  8. package/dist/runtime/components/CookieIframe.vue +39 -0
  9. package/dist/runtime/composables.d.ts +1 -0
  10. package/dist/runtime/composables.mjs +1 -0
  11. package/dist/runtime/constants.d.ts +2 -0
  12. package/dist/runtime/constants.mjs +2 -0
  13. package/dist/runtime/locale/ar.d.ts +3 -0
  14. package/dist/runtime/locale/ar.mjs +16 -0
  15. package/dist/runtime/locale/de.d.ts +3 -0
  16. package/dist/runtime/locale/de.mjs +16 -0
  17. package/dist/runtime/locale/en.d.ts +3 -0
  18. package/dist/runtime/locale/en.mjs +16 -0
  19. package/dist/runtime/locale/es.d.ts +3 -0
  20. package/dist/runtime/locale/es.mjs +16 -0
  21. package/dist/runtime/locale/fr.d.ts +3 -0
  22. package/dist/runtime/locale/fr.mjs +16 -0
  23. package/dist/runtime/locale/hr.d.ts +3 -0
  24. package/dist/runtime/locale/hr.mjs +16 -0
  25. package/dist/runtime/locale/hu.d.ts +3 -0
  26. package/dist/runtime/locale/hu.mjs +16 -0
  27. package/dist/runtime/locale/index.d.ts +1 -0
  28. package/dist/runtime/locale/index.mjs +15 -0
  29. package/dist/runtime/locale/it.d.ts +3 -0
  30. package/dist/runtime/locale/it.mjs +16 -0
  31. package/dist/runtime/locale/ja.d.ts +3 -0
  32. package/dist/runtime/locale/ja.mjs +16 -0
  33. package/dist/runtime/locale/nl.d.ts +3 -0
  34. package/dist/runtime/locale/nl.mjs +16 -0
  35. package/dist/runtime/locale/no.d.ts +3 -0
  36. package/dist/runtime/locale/no.mjs +16 -0
  37. package/dist/runtime/locale/pt.d.ts +3 -0
  38. package/dist/runtime/locale/pt.mjs +16 -0
  39. package/dist/runtime/locale/ru.d.ts +3 -0
  40. package/dist/runtime/locale/ru.mjs +16 -0
  41. package/dist/runtime/locale/uk.d.ts +3 -0
  42. package/dist/runtime/locale/uk.mjs +16 -0
  43. package/dist/runtime/methods.d.ts +16 -0
  44. package/dist/runtime/methods.mjs +117 -0
  45. package/dist/runtime/plugin.d.ts +2 -0
  46. package/dist/runtime/plugin.mjs +27 -0
  47. package/dist/runtime/styles.css +347 -0
  48. package/dist/runtime/types.d.ts +73 -0
  49. package/dist/runtime/types.mjs +66 -0
  50. package/dist/types.d.ts +6 -0
  51. package/package.json +60 -21
  52. package/components/CookieControl.vue +0 -182
  53. package/components/CookieIframe.vue +0 -32
  54. package/lib/module.js +0 -74
  55. package/lib/plugin.js +0 -206
  56. package/lib/postinstall.js +0 -1
  57. package/lib/styles.scss +0 -434
  58. package/locale/de.js +0 -15
  59. package/locale/en.js +0 -15
  60. package/locale/es.js +0 -15
  61. package/locale/fr.js +0 -15
  62. package/locale/hr.js +0 -15
  63. package/locale/hu.js +0 -15
  64. package/locale/it.js +0 -15
  65. package/locale/ja.js +0 -15
  66. package/locale/no.js +0 -16
  67. package/locale/pt.js +0 -15
  68. package/locale/ru.js +0 -15
  69. package/locale/uk.js +0 -15
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c)
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 CHANGED
@@ -1,285 +1,206 @@
1
- # Nuxt Cookie Control
2
- ![Nuxt Cookie Control](https://drive.google.com/a/broj42.com/uc?id=1FGQVyj2s0OT-gpTYxH_FuQhe6oU9iejW)
3
- ####
4
- Try it out here:
5
- [Nuxt.js Cookie Control](https://codesandbox.io/s/vkwqmm577)
6
-
7
- ## 🚀 Usage
8
- ```bash
9
- npm i nuxt-cookie-control
10
- ```
11
- [![npm version][npm-version-src]][npm-version-href]
12
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
13
- [![npm downloads][kofi-src]][kofi-href]
14
-
15
- ```javascript
16
- //nuxt.config.js
17
- modules: [
18
- 'nuxt-cookie-control'
19
- ]
20
- //or
21
- modules: [
22
- ['nuxt-cookie-control', {
23
- //your options
24
- }]
25
- ]
26
-
27
- //to open cookie modal anywhere:
28
- $cookies.modal = true
29
- //or
30
- this.$cookies.modal = true
31
- ```
32
- ```html
33
- <!--template-->
34
- <!--
35
- CookieControl component is registered globally,
36
- you don't need to register it anywhere.
37
- -->
38
- <CookieControl/>
39
- <!--or-->
40
- <CookieControl></CookieControl>
41
- ```
42
- ## Slot
43
- ### Bar
44
- ```html
45
- <CookieControl>
46
- <template v-slot:bar>
47
- <h3>Bar title</h3>
48
- <p>Bar description (you can use $cookies.text.barDescription)</p>
49
- <n-link>Go somewhere</n-link>
50
- </template>
51
- </CookieControl>
52
- ```
53
- ### Modal
54
- ```html
55
- <template v-slot:modal>
56
- <h3>Modal title</h3>
57
- <p>Modal description</p>
58
- </template>
59
- ```
60
- ### Cookie
61
- ```html
62
- <template v-slot:cookie="{config}">
63
- <span v-for="c in config" :key="c.id" v-text="c.cookies"/>
64
- </template>
65
- ```
66
-
67
- ## Props
68
- ### Locale
69
- ```html
70
- <CookieControl locale="de"/>
71
- ```
72
- #### Default: en,
73
- #### Currently available:
74
- - en
75
- - de
76
- - it
77
- - es
78
- - fr
79
- - pt
80
- - hr
81
- - no
82
- - hu
83
- - ja
84
- - ru
85
- - uk
86
-
87
- ## 🔧 Options
88
- Options in nuxt.config.js
89
- ```javascript
90
- modules: [
91
- ['nuxt-cookie-control', {
92
- //default css (true)
93
- //if css is set to false, you will still be able to access
94
- //your color variables (example. background-color: var(--cookie-control-barBackground))
95
- css: true,
96
-
97
- //enable or disable css variables polyfill
98
- cssPolyfill: true,
99
-
100
- //in case you have subdomains (shop.yourdomain.com)
101
- domain: 'yourdomain.com',
102
-
103
- //if you want to tree-shake locales set locales you want to use
104
- locales: ['en', 'de'],
105
-
106
- //modal opener (cookie control)
107
- controlButton: true,
108
-
109
- //block iframes to prevent them from adding additional cookies
110
- blockIframe: true,
111
-
112
- //or if you want to set initialState to false (default value for initialState is true)
113
- blockIframe: {
114
- initialState: false
115
- },
116
-
117
- //position of cookie bar:
118
- //'top-left', 'top-right', 'top-full',
119
- //'bottom-left', 'bottom-right', 'bottom-full'
120
- barPosition: 'bottom-full',
121
-
122
- //default colors
123
- //if you want to disable colors set colors property to false
124
- colors: {
125
- barTextColor: '#fff',
126
- modalOverlay: '#000',
127
- barBackground: '#000',
128
- barButtonColor: '#000',
129
- modalTextColor: '#000',
130
- modalBackground: '#fff',
131
- modalOverlayOpacity: 0.8,
132
- modalButtonColor: '#fff',
133
- modalUnsavedColor: '#fff',
134
- barButtonHoverColor: '#fff',
135
- barButtonBackground: '#fff',
136
- modalButtonHoverColor: '#fff',
137
- modalButtonBackground: '#000',
138
- controlButtonIconColor: '#000',
139
- controlButtonBackground: '#fff',
140
- barButtonHoverBackground: '#333',
141
- checkboxActiveBackground: '#000',
142
- checkboxInactiveBackground: '#000',
143
- modalButtonHoverBackground: '#333',
144
- checkboxDisabledBackground: '#ddd',
145
- controlButtonIconHoverColor: '#fff',
146
- controlButtonHoverBackground: '#000',
147
- checkboxActiveCircleBackground: '#fff',
148
- checkboxInactiveCircleBackground: '#fff',
149
- checkboxDisabledCircleBackground: '#fff',
150
- },
151
-
152
- //default texts
153
- text: {
154
- barTitle: 'Cookies',
155
- barDescription: 'We use our own cookies and third-party cookies so that we can show you this website and better understand how you use it, with a view to improving the services we offer. If you continue browsing, we consider that you have accepted the cookies.',
156
- acceptAll: 'Accept all',
157
- declineAll: 'Delete all',
158
- manageCookies: 'Manage cookies',
159
- unsaved: 'You have unsaved settings',
160
- close: 'Close',
161
- save: 'Save',
162
- necessary: 'Necessary cookies',
163
- optional: 'Optional cookies',
164
- functional: 'Functional cookies',
165
- blockedIframe: 'To see this, please enable functional cookies',
166
- here: 'here'
167
- }
168
- ]
169
- ]
170
-
171
- //for multilanguage see - Multilanguage
172
- ```
173
- without options (Simple)
174
- ```javascript
175
- modules: [
176
- 'nuxt-cookie-control'
177
- ]
178
- ```
179
- ### Cookies
180
- ```javascript
181
- modules: [
182
- 'nuxt-cookie-control'
183
- ]
184
- ...
185
- ...
186
- ...
187
- cookies: {
188
- necessary: [
189
- {
190
- //if multilanguage
191
- name: {
192
- en: 'Default Cookies'
193
- },
194
- //else
195
- name: 'Default Cookies',
196
- //if multilanguage
197
- description: {
198
- en: 'Used for cookie control.'
199
- },
200
- //else
201
- description: 'Used for cookie control.',
202
- cookies: ['cookie_control_consent', 'cookie_control_enabled_cookies']
203
- }
204
- ],
205
- optional: [
206
- {
207
- name: 'Google Analitycs',
208
- //if you don't set identifier, slugified name will be used
209
- identifier: 'ga',
210
- //if multilanguage
211
- description: {
212
- en: 'Google GTM is ...'
213
- },
214
- //else
215
- description: 'Google GTM is...',
216
-
217
- initialState: true,
218
- src: 'https://www.googletagmanager.com/gtag/js?id=<API-KEY>',
219
- async: true,
220
- cookies: ['_ga', '_gat', '_gid'],
221
- accepted: () =>{
222
- window.dataLayer = window.dataLayer || [];
223
- window.dataLayer.push({
224
- 'gtm.start': new Date().getTime(),
225
- event: 'gtm.js'
226
- });
227
- },
228
- declined: () =>{
229
- }
230
- }
231
- ]
232
- }
233
- ```
234
- ### Multilanguage
235
- Set **locale** prop
236
- ```html
237
- <CookieControl locale="de"/>
238
- ```
239
- #### Default: en,
240
- #### Currently available:
241
- - en
242
- - de
243
- - it
244
- - es
245
- - fr
246
- - pt
247
- - hr
248
- - no
249
- - hu
250
- - ja
251
- - ru
252
- - uk
253
-
254
- If you don't like the default texts you can change them in options (**nuxt.config.js**)
255
- ```javascript
256
- text: {
257
- locale: {
258
- en: {
259
- barTitle: 'Cookies Different',
260
- barDescription: 'We use our own cookies and third-party...',
261
- },
262
-
263
- de: {
264
- ...
265
- }
266
- },
267
-
268
- //this will override locale text
269
- barTitle: 'Override Title'
270
- }
271
- ```
272
-
273
- ### Buy me a coffee
274
- [![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/F1F31MWWL)
275
-
276
-
277
- <!-- Badges -->
278
- [npm-version-src]: https://badgen.net/npm/v/nuxt-cookie-control/latest
279
- [npm-version-href]: https://npmjs.com/package/nuxt-cookie-control
280
-
281
- [kofi-src]: https://badgen.net/badge/icon/kofi?icon=kofi&label=support
282
- [kofi-href]: https://ko-fi.com/darioferderber
283
-
284
- [npm-downloads-src]: https://badgen.net/npm/dm/nuxt-cookie-control
285
- [npm-downloads-href]: https://npmjs.com/package/nuxt-cookie-control
1
+ # Nuxt Cookie Control
2
+
3
+ Continuing Dario Ferderber's work on [gitlab.com/broj42/nuxt-cookie-control](https://gitlab.com/broj42/nuxt-cookie-control).
4
+
5
+ ![Nuxt Cookie Control](https://drive.google.com/a/broj42.com/uc?id=1FGQVyj2s0OT-gpTYxH_FuQhe6oU9iejW)
6
+ ####
7
+ Try it out here:
8
+ [Nuxt.js Cookie Control](https://codesandbox.io/s/vkwqmm577)
9
+
10
+ ## 🚀 Usage
11
+ ```bash
12
+ npm i -D @dargmuesli/nuxt-cookie-control
13
+ yarn add -D @dargmuesli/nuxt-cookie-control
14
+ pnpm i -D @dargmuesli/nuxt-cookie-control
15
+ ```
16
+ [![npm version][npm-version-src]][npm-version-href]
17
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
18
+
19
+ ```javascript
20
+ // nuxt.config.js
21
+
22
+ modules: [
23
+ '@dargmuesli/nuxt-cookie-control'
24
+ ]
25
+ // or
26
+ modules: [
27
+ ['@dargmuesli/nuxt-cookie-control', {
28
+ // module options
29
+ }]
30
+ ]
31
+ ```
32
+
33
+ Components and composables are [auto-imported](https://nuxt.com/docs/guide/concepts/auto-imports)!
34
+
35
+ ```html
36
+ <!-- component.vue -->
37
+
38
+ <template>
39
+ <CookieControl locale="en" />
40
+ </template>
41
+
42
+ <script setup lang="ts">
43
+ const {
44
+ cookiesEnabled,
45
+ cookiesEnabledIds,
46
+ isConsentGiven,
47
+ isModalActive,
48
+ moduleOptions
49
+ } = useCookieControl()
50
+ </script>
51
+ ```
52
+ ## Slot
53
+ ### Bar
54
+ ```html
55
+ <CookieControl>
56
+ <template #bar>
57
+ <h3>Bar title</h3>
58
+ <p>Bar description (you can use $cookies.text.barDescription)</p>
59
+ <n-link>Go somewhere</n-link>
60
+ </template>
61
+ </CookieControl>
62
+ ```
63
+ ### Modal
64
+ ```html
65
+ <template #modal>
66
+ <h3>Modal title</h3>
67
+ <p>Modal description</p>
68
+ </template>
69
+ ```
70
+ ### Cookie
71
+ ```html
72
+ <template #cookie="{config}">
73
+ <span v-for="c in config" :key="c.id" v-text="c.cookies"/>
74
+ </template>
75
+ ```
76
+
77
+ ## Props
78
+ - locale: `['en']`
79
+ ```html
80
+ <CookieControl locale="de"/>
81
+ ```
82
+
83
+ Currently available:
84
+ - ar
85
+ - de
86
+ - en
87
+ - es
88
+ - fr
89
+ - hr
90
+ - hu
91
+ - it
92
+ - ja
93
+ - nl
94
+ - no
95
+ - pt
96
+ - ru
97
+ - uk
98
+
99
+ ## Module Options
100
+
101
+ ```javascript
102
+ // Position of cookie bar.
103
+ // 'top-left', 'top-right', 'top-full', 'bottom-left', 'bottom-right', 'bottom-full'
104
+ barPosition: 'bottom-full',
105
+
106
+ // Component colors.
107
+ // If you want to disable colors set colors property to false.
108
+ colors: {
109
+ barBackground: '#000',
110
+ barButtonBackground: '#fff',
111
+ barButtonColor: '#000',
112
+ barButtonHoverBackground: '#333',
113
+ barButtonHoverColor: '#fff',
114
+ barTextColor: '#fff',
115
+ checkboxActiveBackground: '#000',
116
+ checkboxActiveCircleBackground: '#fff',
117
+ checkboxDisabledBackground: '#ddd',
118
+ checkboxDisabledCircleBackground: '#fff',
119
+ checkboxInactiveBackground: '#000',
120
+ checkboxInactiveCircleBackground: '#fff',
121
+ controlButtonBackground: '#fff',
122
+ controlButtonHoverBackground: '#000',
123
+ controlButtonIconColor: '#000',
124
+ controlButtonIconHoverColor: '#fff',
125
+ modalBackground: '#fff',
126
+ modalButtonBackground: '#000',
127
+ modalButtonColor: '#fff',
128
+ modalButtonHoverBackground: '#333',
129
+ modalButtonHoverColor: '#fff',
130
+ modalOverlay: '#000',
131
+ modalOverlayOpacity: 0.8,
132
+ modalTextColor: '#000',
133
+ modalUnsavedColor: '#fff',
134
+ },
135
+
136
+ // The cookies that are to be controlled.
137
+ // See detailed explanation further down below!
138
+ cookies: {
139
+ necessary: [],
140
+ optional: [],
141
+ }
142
+
143
+ // Switch to toggle the "accept necessary" button.
144
+ isAcceptNecessaryButtonEnabled: true
145
+
146
+ // Switch to toggle the button that opens the configuration modal.
147
+ isControlButtonEnabled: true,
148
+
149
+ // Switch to toggle the inclusion of this module's css.
150
+ // If css is set to false, you will still be able to access your color variables.
151
+ isCssEnabled: true,
152
+
153
+ // Switch to toggle the css variables polyfill.
154
+ isCssPolyfillEnabled: true,
155
+
156
+ // Switch to toggle the separation of cookie name and description in the configuration modal by a dash.
157
+ isDashInDescriptionEnabled: true,
158
+
159
+ // Switch to toggle the blocking of iframes.
160
+ // This can be used to prevent iframes from adding additional cookies.
161
+ isIframeBlocked: false,
162
+ // or:
163
+ // isIframeBlocked: {
164
+ // initialState: false
165
+ // },
166
+
167
+ // The domain to set cookies on.
168
+ // This is useful in case you have subdomains (shop.yourdomain.com)
169
+ domain: 'yourdomain.com',
170
+
171
+ // The locales to include.
172
+ locales: ['en'],
173
+
174
+ // Translations to override.
175
+ localeTexts: {
176
+ en: {
177
+ save: 'Remember',
178
+ }
179
+ }
180
+ ```
181
+
182
+ ### Cookies
183
+
184
+ Every property the includes a `{ en: ... }` value is a translatable property that could instead only specify a string (`'...'`) or other locales as well (`{ de: ..., uk: ... }`).
185
+
186
+ ```javascript
187
+ {
188
+ description: {
189
+ en: 'Used for cookie control.'
190
+ },
191
+ id: 'ga', // if unset, the slugified name will be used
192
+ name: {
193
+ en: 'Google Analytics'
194
+ },
195
+ src: 'https://www.googletagmanager.com/gtag/js?id=<API-KEY>',
196
+ targetCookieIds: ['cookie_control_consent', 'cookie_control_enabled_cookies']
197
+ }
198
+ ```
199
+
200
+
201
+ <!-- Badges -->
202
+ [npm-version-src]: https://badgen.net/npm/v/@dargmuesli/nuxt-cookie-control/latest
203
+ [npm-version-href]: https://npmjs.com/package/@dargmuesli/nuxt-cookie-control
204
+
205
+ [npm-downloads-src]: https://badgen.net/npm/dm/@dargmuesli/nuxt-cookie-control
206
+ [npm-downloads-href]: https://npmjs.com/package/@dargmuesli/nuxt-cookie-control
@@ -0,0 +1,5 @@
1
+ module.exports = function(...args) {
2
+ return import('./module.mjs').then(m => m.default.call(this, ...args))
3
+ }
4
+ const _meta = module.exports.meta = require('./module.json')
5
+ module.exports.getMeta = () => Promise.resolve(_meta)
@@ -0,0 +1,66 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ declare enum Locale {
4
+ AR = "ar",
5
+ DE = "de",
6
+ EN = "en",
7
+ ES = "es",
8
+ FR = "fr",
9
+ HR = "hr",
10
+ HU = "hu",
11
+ IT = "it",
12
+ JA = "ja",
13
+ NL = "nl",
14
+ NO = "no",
15
+ PT = "pt",
16
+ RU = "ru",
17
+ UK = "uk"
18
+ }
19
+ type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
20
+ type Translatable = string | PartialRecord<Locale, string>;
21
+ interface Cookie {
22
+ description?: Translatable;
23
+ id?: string;
24
+ name: Translatable;
25
+ src?: string;
26
+ targetCookieIds?: string[];
27
+ }
28
+ interface LocaleStrings {
29
+ acceptAll: string;
30
+ acceptNecessary: string;
31
+ barDescription: string;
32
+ barTitle: string;
33
+ blockedIframe: string;
34
+ close: string;
35
+ declineAll: string;
36
+ functional: string;
37
+ here: string;
38
+ manageCookies: string;
39
+ necessary: string;
40
+ optional: string;
41
+ save: string;
42
+ unsaved: string;
43
+ }
44
+ interface ModuleOptions {
45
+ barPosition?: 'top-left' | 'top-right' | 'top-full' | 'bottom-left' | 'bottom-right' | 'bottom-full';
46
+ colors?: false | Record<string, any>;
47
+ cookies: {
48
+ necessary: Cookie[];
49
+ optional: Cookie[];
50
+ };
51
+ isAcceptNecessaryButtonEnabled?: boolean;
52
+ isControlButtonEnabled?: boolean;
53
+ isCssEnabled?: boolean;
54
+ isCssPolyfillEnabled?: boolean;
55
+ isDashInDescriptionEnabled?: boolean;
56
+ isIframeBlocked?: boolean | {
57
+ initialState: boolean;
58
+ };
59
+ domain?: string;
60
+ locales: Locale[];
61
+ localeTexts: PartialRecord<Locale, LocaleStrings>;
62
+ }
63
+
64
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
65
+
66
+ export { _default as default };
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@dargmuesli/nuxt-cookie-control",
3
+ "version": "2.0.0-beta.2",
4
+ "configKey": "cookieControl",
5
+ "compatibility": {
6
+ "nuxt": "^3.0.0"
7
+ }
8
+ }