@dargmuesli/nuxt-cookie-control 5.4.0 → 5.5.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 +3 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/components/CookieControl.vue +27 -18
- package/dist/runtime/types.d.ts +1 -0
- package/dist/runtime/types.mjs +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -99,6 +99,9 @@ if (cookieControl.cookiesEnabledIds.value.includes('google-analytics')) {
|
|
|
99
99
|
// 'top-left', 'top-right', 'top-full', 'bottom-left', 'bottom-right', 'bottom-full'
|
|
100
100
|
barPosition: 'bottom-full',
|
|
101
101
|
|
|
102
|
+
// Switch to toggle if clicking the overlay outside the configuration modal closes the modal.
|
|
103
|
+
closeModalOnClickOutside: true,
|
|
104
|
+
|
|
102
105
|
// Component colors.
|
|
103
106
|
// If you want to disable colors set colors property to false.
|
|
104
107
|
colors: {
|
package/dist/module.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ interface LocaleStrings {
|
|
|
30
30
|
}
|
|
31
31
|
interface ModuleOptions {
|
|
32
32
|
barPosition: 'top-left' | 'top-right' | 'top-full' | 'bottom-left' | 'bottom-right' | 'bottom-full';
|
|
33
|
+
closeModalOnClickOutside: boolean;
|
|
33
34
|
colors: false | Record<string, any>;
|
|
34
35
|
cookieExpiryOffsetMs: number;
|
|
35
36
|
cookieNameCookiesEnabledIds: string;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
3
3
|
import { createResolver, defineNuxtModule, addPlugin, addImports, addTemplate, extendWebpackConfig, resolvePath } from '@nuxt/kit';
|
|
4
4
|
|
|
5
5
|
const name = "@dargmuesli/nuxt-cookie-control";
|
|
6
|
-
const version = "5.
|
|
6
|
+
const version = "5.5.0";
|
|
7
7
|
|
|
8
8
|
const en = {
|
|
9
9
|
accept: "Accept",
|
|
@@ -25,6 +25,7 @@ const en = {
|
|
|
25
25
|
|
|
26
26
|
const DEFAULTS = {
|
|
27
27
|
barPosition: "bottom-full",
|
|
28
|
+
closeModalOnClickOutside: false,
|
|
28
29
|
colors: {
|
|
29
30
|
barBackground: "#000",
|
|
30
31
|
barButtonBackground: "#fff",
|
|
@@ -43,7 +43,11 @@
|
|
|
43
43
|
</svg>
|
|
44
44
|
</button>
|
|
45
45
|
<transition name="cookieControl__Modal">
|
|
46
|
-
<div
|
|
46
|
+
<div
|
|
47
|
+
v-if="isModalActive"
|
|
48
|
+
class="cookieControl__Modal"
|
|
49
|
+
@click.self="onModalClick"
|
|
50
|
+
>
|
|
47
51
|
<p
|
|
48
52
|
v-if="isSaved"
|
|
49
53
|
class="cookieControl__ModalUnsaved"
|
|
@@ -238,12 +242,6 @@ const accept = () => {
|
|
|
238
242
|
cookiesOptionalEnabled: moduleOptions.cookies.optional,
|
|
239
243
|
})
|
|
240
244
|
}
|
|
241
|
-
const decline = () => {
|
|
242
|
-
setCookies({
|
|
243
|
-
isConsentGiven: true,
|
|
244
|
-
cookiesOptionalEnabled: moduleOptions.cookies.necessary,
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
245
|
const acceptPartial = () => {
|
|
248
246
|
const localCookiesEnabledIds = getCookieIds(localCookiesEnabled.value)
|
|
249
247
|
|
|
@@ -255,23 +253,18 @@ const acceptPartial = () => {
|
|
|
255
253
|
].filter((cookie) => localCookiesEnabledIds.includes(getCookieId(cookie))),
|
|
256
254
|
})
|
|
257
255
|
}
|
|
256
|
+
const decline = () => {
|
|
257
|
+
setCookies({
|
|
258
|
+
isConsentGiven: true,
|
|
259
|
+
cookiesOptionalEnabled: moduleOptions.cookies.necessary,
|
|
260
|
+
})
|
|
261
|
+
}
|
|
258
262
|
const declineAll = () => {
|
|
259
263
|
setCookies({
|
|
260
264
|
isConsentGiven: false,
|
|
261
265
|
cookiesOptionalEnabled: [],
|
|
262
266
|
})
|
|
263
267
|
}
|
|
264
|
-
const toogleCookie = (cookie: Cookie) => {
|
|
265
|
-
const cookieIndex = getCookieIds(localCookiesEnabled.value).indexOf(
|
|
266
|
-
getCookieId(cookie)
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
if (cookieIndex < 0) {
|
|
270
|
-
localCookiesEnabled.value.push(cookie)
|
|
271
|
-
} else {
|
|
272
|
-
localCookiesEnabled.value.splice(cookieIndex, 1)
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
268
|
const getDescription = (description: Translatable) =>
|
|
276
269
|
`${
|
|
277
270
|
moduleOptions.isDashInDescriptionEnabled === false ? '' : '-'
|
|
@@ -284,6 +277,11 @@ const getName = (name: Translatable) => {
|
|
|
284
277
|
const init = () => {
|
|
285
278
|
expires.setTime(expires.getTime() + moduleOptions.cookieExpiryOffsetMs)
|
|
286
279
|
}
|
|
280
|
+
const onModalClick = () => {
|
|
281
|
+
if (moduleOptions.closeModalOnClickOutside) {
|
|
282
|
+
isModalActive.value = false
|
|
283
|
+
}
|
|
284
|
+
}
|
|
287
285
|
const setCookies = ({
|
|
288
286
|
cookiesOptionalEnabled: cookiesOptionalEnabledNew,
|
|
289
287
|
isConsentGiven: isConsentGivenNew,
|
|
@@ -310,6 +308,17 @@ const toggleButton = ($event: MouseEvent) => {
|
|
|
310
308
|
?.nextSibling as HTMLLabelElement | null
|
|
311
309
|
)?.click()
|
|
312
310
|
}
|
|
311
|
+
const toogleCookie = (cookie: Cookie) => {
|
|
312
|
+
const cookieIndex = getCookieIds(localCookiesEnabled.value).indexOf(
|
|
313
|
+
getCookieId(cookie)
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
if (cookieIndex < 0) {
|
|
317
|
+
localCookiesEnabled.value.push(cookie)
|
|
318
|
+
} else {
|
|
319
|
+
localCookiesEnabled.value.splice(cookieIndex, 1)
|
|
320
|
+
}
|
|
321
|
+
}
|
|
313
322
|
const toggleLabel = ($event: KeyboardEvent) => {
|
|
314
323
|
if ($event.key === ' ') ($event.target as HTMLLabelElement | null)?.click()
|
|
315
324
|
}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export interface LocaleStrings {
|
|
|
33
33
|
}
|
|
34
34
|
export interface ModuleOptions {
|
|
35
35
|
barPosition: 'top-left' | 'top-right' | 'top-full' | 'bottom-left' | 'bottom-right' | 'bottom-full';
|
|
36
|
+
closeModalOnClickOutside: boolean;
|
|
36
37
|
colors: false | Record<string, any>;
|
|
37
38
|
cookieExpiryOffsetMs: number;
|
|
38
39
|
cookieNameCookiesEnabledIds: string;
|
package/dist/runtime/types.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dargmuesli/nuxt-cookie-control",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "Nuxt Cookies Control Module",
|
|
5
5
|
"author": "Dario Ferderber <dario.ferderber@broj42.com>",
|
|
6
6
|
"maintainers": [
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@dargmuesli/nuxt-cookie-control": "link:.",
|
|
47
|
-
"@nuxt/module-builder": "0.
|
|
47
|
+
"@nuxt/module-builder": "0.3.0",
|
|
48
48
|
"@nuxtjs/eslint-config-typescript": "12.0.0",
|
|
49
49
|
"@types/js-cookie": "3.0.3",
|
|
50
50
|
"eslint": "8.38.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typescript": "5.0.4",
|
|
58
58
|
"vue": "3.2.47",
|
|
59
59
|
"vue-tsc": "1.2.0",
|
|
60
|
-
"webpack": "5.
|
|
60
|
+
"webpack": "5.79.0"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|