@dargmuesli/nuxt-cookie-control 5.3.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 +6 -0
- package/dist/module.d.ts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +3 -1
- package/dist/runtime/components/CookieControl.vue +34 -19
- package/dist/runtime/types.d.ts +2 -0
- package/dist/runtime/types.mjs +2 -0
- package/package.json +8 -8
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: {
|
|
@@ -171,6 +174,9 @@ isIframeBlocked: false,
|
|
|
171
174
|
// initialState: false
|
|
172
175
|
// },
|
|
173
176
|
|
|
177
|
+
// Switch to toggle the modal being shown right away, requiring a user's decision.
|
|
178
|
+
isModalForced: false,
|
|
179
|
+
|
|
174
180
|
// The domain to set cookies on.
|
|
175
181
|
// This is useful in case you have subdomains (shop.yourdomain.com)
|
|
176
182
|
domain: 'yourdomain.com',
|
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;
|
|
@@ -48,6 +49,7 @@ interface ModuleOptions {
|
|
|
48
49
|
isIframeBlocked: boolean | {
|
|
49
50
|
initialState: boolean;
|
|
50
51
|
};
|
|
52
|
+
isModalForced: boolean;
|
|
51
53
|
locales: Locale[];
|
|
52
54
|
localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>;
|
|
53
55
|
}
|
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",
|
|
@@ -68,6 +69,7 @@ const DEFAULTS = {
|
|
|
68
69
|
isCssPonyfillEnabled: false,
|
|
69
70
|
isDashInDescriptionEnabled: true,
|
|
70
71
|
isIframeBlocked: false,
|
|
72
|
+
isModalForced: false,
|
|
71
73
|
domain: "",
|
|
72
74
|
locales: ["en"],
|
|
73
75
|
localeTexts: { en }
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<section class="cookieControl">
|
|
4
4
|
<transition :name="`cookieControl__Bar--${moduleOptions.barPosition}`">
|
|
5
5
|
<div
|
|
6
|
-
v-if="!isConsentGiven"
|
|
6
|
+
v-if="!isConsentGiven && !moduleOptions.isModalForced"
|
|
7
7
|
:class="`cookieControl__Bar cookieControl__Bar--${moduleOptions.barPosition}`"
|
|
8
8
|
>
|
|
9
9
|
<div class="cookieControl__BarContainer">
|
|
@@ -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"
|
|
@@ -53,6 +57,7 @@
|
|
|
53
57
|
<div class="cookieControl__ModalContentInner">
|
|
54
58
|
<slot name="modal" />
|
|
55
59
|
<button
|
|
60
|
+
v-if="!moduleOptions.isModalForced"
|
|
56
61
|
class="cookieControl__ModalClose"
|
|
57
62
|
@click="isModalActive = false"
|
|
58
63
|
v-text="localeStrings?.close"
|
|
@@ -166,6 +171,7 @@
|
|
|
166
171
|
v-text="localeStrings?.acceptAll"
|
|
167
172
|
/>
|
|
168
173
|
<button
|
|
174
|
+
v-if="!moduleOptions.isModalForced"
|
|
169
175
|
@click="
|
|
170
176
|
() => {
|
|
171
177
|
declineAll()
|
|
@@ -236,12 +242,6 @@ const accept = () => {
|
|
|
236
242
|
cookiesOptionalEnabled: moduleOptions.cookies.optional,
|
|
237
243
|
})
|
|
238
244
|
}
|
|
239
|
-
const decline = () => {
|
|
240
|
-
setCookies({
|
|
241
|
-
isConsentGiven: true,
|
|
242
|
-
cookiesOptionalEnabled: moduleOptions.cookies.necessary,
|
|
243
|
-
})
|
|
244
|
-
}
|
|
245
245
|
const acceptPartial = () => {
|
|
246
246
|
const localCookiesEnabledIds = getCookieIds(localCookiesEnabled.value)
|
|
247
247
|
|
|
@@ -253,23 +253,18 @@ const acceptPartial = () => {
|
|
|
253
253
|
].filter((cookie) => localCookiesEnabledIds.includes(getCookieId(cookie))),
|
|
254
254
|
})
|
|
255
255
|
}
|
|
256
|
+
const decline = () => {
|
|
257
|
+
setCookies({
|
|
258
|
+
isConsentGiven: true,
|
|
259
|
+
cookiesOptionalEnabled: moduleOptions.cookies.necessary,
|
|
260
|
+
})
|
|
261
|
+
}
|
|
256
262
|
const declineAll = () => {
|
|
257
263
|
setCookies({
|
|
258
264
|
isConsentGiven: false,
|
|
259
265
|
cookiesOptionalEnabled: [],
|
|
260
266
|
})
|
|
261
267
|
}
|
|
262
|
-
const toogleCookie = (cookie: Cookie) => {
|
|
263
|
-
const cookieIndex = getCookieIds(localCookiesEnabled.value).indexOf(
|
|
264
|
-
getCookieId(cookie)
|
|
265
|
-
)
|
|
266
|
-
|
|
267
|
-
if (cookieIndex < 0) {
|
|
268
|
-
localCookiesEnabled.value.push(cookie)
|
|
269
|
-
} else {
|
|
270
|
-
localCookiesEnabled.value.splice(cookieIndex, 1)
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
268
|
const getDescription = (description: Translatable) =>
|
|
274
269
|
`${
|
|
275
270
|
moduleOptions.isDashInDescriptionEnabled === false ? '' : '-'
|
|
@@ -282,6 +277,11 @@ const getName = (name: Translatable) => {
|
|
|
282
277
|
const init = () => {
|
|
283
278
|
expires.setTime(expires.getTime() + moduleOptions.cookieExpiryOffsetMs)
|
|
284
279
|
}
|
|
280
|
+
const onModalClick = () => {
|
|
281
|
+
if (moduleOptions.closeModalOnClickOutside) {
|
|
282
|
+
isModalActive.value = false
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
285
|
const setCookies = ({
|
|
286
286
|
cookiesOptionalEnabled: cookiesOptionalEnabledNew,
|
|
287
287
|
isConsentGiven: isConsentGivenNew,
|
|
@@ -308,6 +308,17 @@ const toggleButton = ($event: MouseEvent) => {
|
|
|
308
308
|
?.nextSibling as HTMLLabelElement | null
|
|
309
309
|
)?.click()
|
|
310
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
|
+
}
|
|
311
322
|
const toggleLabel = ($event: KeyboardEvent) => {
|
|
312
323
|
if ($event.key === ' ') ($event.target as HTMLLabelElement | null)?.click()
|
|
313
324
|
}
|
|
@@ -337,6 +348,10 @@ onBeforeMount(() => {
|
|
|
337
348
|
}
|
|
338
349
|
}
|
|
339
350
|
}
|
|
351
|
+
|
|
352
|
+
if (moduleOptions.isModalForced && !isConsentGiven.value) {
|
|
353
|
+
isModalActive.value = true
|
|
354
|
+
}
|
|
340
355
|
})
|
|
341
356
|
watch(
|
|
342
357
|
() => cookiesEnabled.value,
|
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;
|
|
@@ -51,6 +52,7 @@ export interface ModuleOptions {
|
|
|
51
52
|
isIframeBlocked: boolean | {
|
|
52
53
|
initialState: boolean;
|
|
53
54
|
};
|
|
55
|
+
isModalForced: boolean;
|
|
54
56
|
locales: Locale[];
|
|
55
57
|
localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>;
|
|
56
58
|
}
|
package/dist/runtime/types.mjs
CHANGED
|
@@ -6,6 +6,7 @@ export var CookieType = /* @__PURE__ */ ((CookieType2) => {
|
|
|
6
6
|
})(CookieType || {});
|
|
7
7
|
export const DEFAULTS = {
|
|
8
8
|
barPosition: "bottom-full",
|
|
9
|
+
closeModalOnClickOutside: false,
|
|
9
10
|
colors: {
|
|
10
11
|
barBackground: "#000",
|
|
11
12
|
barButtonBackground: "#fff",
|
|
@@ -49,6 +50,7 @@ export const DEFAULTS = {
|
|
|
49
50
|
isCssPonyfillEnabled: false,
|
|
50
51
|
isDashInDescriptionEnabled: true,
|
|
51
52
|
isIframeBlocked: false,
|
|
53
|
+
isModalForced: false,
|
|
52
54
|
domain: "",
|
|
53
55
|
locales: ["en"],
|
|
54
56
|
localeTexts: { en }
|
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": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lint": "pnpm prepack && eslint --ext .js,.ts,.vue . && nuxi typecheck playground"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nuxt/kit": "3.
|
|
39
|
+
"@nuxt/kit": "3.4.0",
|
|
40
40
|
"@sindresorhus/slugify": "2.2.0",
|
|
41
41
|
"css-vars-ponyfill": "2.4.8",
|
|
42
42
|
"js-cookie": "3.0.1",
|
|
@@ -44,20 +44,20 @@
|
|
|
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
|
-
"eslint": "8.
|
|
50
|
+
"eslint": "8.38.0",
|
|
51
51
|
"eslint-config-prettier": "8.8.0",
|
|
52
52
|
"eslint-plugin-prettier": "4.2.1",
|
|
53
53
|
"husky": "8.0.3",
|
|
54
|
-
"lint-staged": "13.2.
|
|
55
|
-
"nuxt": "3.
|
|
54
|
+
"lint-staged": "13.2.1",
|
|
55
|
+
"nuxt": "3.4.0",
|
|
56
56
|
"prettier": "2.8.7",
|
|
57
|
-
"typescript": "5.0.
|
|
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"
|