@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.
- package/LICENSE +21 -0
- package/README.md +206 -285
- package/dist/module.cjs +5 -0
- package/dist/module.d.ts +66 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +186 -0
- package/dist/runtime/components/CookieControl.vue +274 -0
- package/dist/runtime/components/CookieIframe.vue +39 -0
- package/dist/runtime/composables.d.ts +1 -0
- package/dist/runtime/composables.mjs +1 -0
- package/dist/runtime/constants.d.ts +2 -0
- package/dist/runtime/constants.mjs +2 -0
- package/dist/runtime/locale/ar.d.ts +3 -0
- package/dist/runtime/locale/ar.mjs +16 -0
- package/dist/runtime/locale/de.d.ts +3 -0
- package/dist/runtime/locale/de.mjs +16 -0
- package/dist/runtime/locale/en.d.ts +3 -0
- package/dist/runtime/locale/en.mjs +16 -0
- package/dist/runtime/locale/es.d.ts +3 -0
- package/dist/runtime/locale/es.mjs +16 -0
- package/dist/runtime/locale/fr.d.ts +3 -0
- package/dist/runtime/locale/fr.mjs +16 -0
- package/dist/runtime/locale/hr.d.ts +3 -0
- package/dist/runtime/locale/hr.mjs +16 -0
- package/dist/runtime/locale/hu.d.ts +3 -0
- package/dist/runtime/locale/hu.mjs +16 -0
- package/dist/runtime/locale/index.d.ts +1 -0
- package/dist/runtime/locale/index.mjs +15 -0
- package/dist/runtime/locale/it.d.ts +3 -0
- package/dist/runtime/locale/it.mjs +16 -0
- package/dist/runtime/locale/ja.d.ts +3 -0
- package/dist/runtime/locale/ja.mjs +16 -0
- package/dist/runtime/locale/nl.d.ts +3 -0
- package/dist/runtime/locale/nl.mjs +16 -0
- package/dist/runtime/locale/no.d.ts +3 -0
- package/dist/runtime/locale/no.mjs +16 -0
- package/dist/runtime/locale/pt.d.ts +3 -0
- package/dist/runtime/locale/pt.mjs +16 -0
- package/dist/runtime/locale/ru.d.ts +3 -0
- package/dist/runtime/locale/ru.mjs +16 -0
- package/dist/runtime/locale/uk.d.ts +3 -0
- package/dist/runtime/locale/uk.mjs +16 -0
- package/dist/runtime/methods.d.ts +16 -0
- package/dist/runtime/methods.mjs +117 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +27 -0
- package/dist/runtime/styles.css +347 -0
- package/dist/runtime/types.d.ts +73 -0
- package/dist/runtime/types.mjs +66 -0
- package/dist/types.d.ts +6 -0
- package/package.json +60 -21
- package/components/CookieControl.vue +0 -182
- package/components/CookieIframe.vue +0 -32
- package/lib/module.js +0 -74
- package/lib/plugin.js +0 -206
- package/lib/postinstall.js +0 -1
- package/lib/styles.scss +0 -434
- package/locale/de.js +0 -15
- package/locale/en.js +0 -15
- package/locale/es.js +0 -15
- package/locale/fr.js +0 -15
- package/locale/hr.js +0 -15
- package/locale/hu.js +0 -15
- package/locale/it.js +0 -15
- package/locale/ja.js +0 -15
- package/locale/no.js +0 -16
- package/locale/pt.js +0 -15
- package/locale/ru.js +0 -15
- package/locale/uk.js +0 -15
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { createResolver, defineNuxtModule, addPlugin, addImports, addTemplate, isNuxt2, extendWebpackConfig } from '@nuxt/kit';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// -- Unbuild CommonJS Shims --
|
|
7
|
+
import __cjs_url__ from 'url';
|
|
8
|
+
import __cjs_path__ from 'path';
|
|
9
|
+
import __cjs_mod__ from 'module';
|
|
10
|
+
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = __cjs_path__.dirname(__filename);
|
|
12
|
+
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
13
|
+
const name = "@dargmuesli/nuxt-cookie-control";
|
|
14
|
+
const version = "2.0.0-beta.2";
|
|
15
|
+
|
|
16
|
+
const en = {
|
|
17
|
+
acceptAll: "Accept all",
|
|
18
|
+
acceptNecessary: "Accept necessary",
|
|
19
|
+
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.",
|
|
20
|
+
barTitle: "Cookies",
|
|
21
|
+
blockedIframe: "To see this, please enable functional cookies",
|
|
22
|
+
close: "Close",
|
|
23
|
+
declineAll: "Delete all",
|
|
24
|
+
functional: "Functional cookies",
|
|
25
|
+
here: "here",
|
|
26
|
+
manageCookies: "Manage cookies",
|
|
27
|
+
necessary: "Necessary cookies",
|
|
28
|
+
optional: "Optional cookies",
|
|
29
|
+
save: "Save",
|
|
30
|
+
unsaved: "You have unsaved settings"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const DEFAULTS = {
|
|
34
|
+
barPosition: "bottom-full",
|
|
35
|
+
colors: {
|
|
36
|
+
barBackground: "#000",
|
|
37
|
+
barButtonBackground: "#fff",
|
|
38
|
+
barButtonColor: "#000",
|
|
39
|
+
barButtonHoverBackground: "#333",
|
|
40
|
+
barButtonHoverColor: "#fff",
|
|
41
|
+
barTextColor: "#fff",
|
|
42
|
+
checkboxActiveBackground: "#000",
|
|
43
|
+
checkboxActiveCircleBackground: "#fff",
|
|
44
|
+
checkboxDisabledBackground: "#ddd",
|
|
45
|
+
checkboxDisabledCircleBackground: "#fff",
|
|
46
|
+
checkboxInactiveBackground: "#000",
|
|
47
|
+
checkboxInactiveCircleBackground: "#fff",
|
|
48
|
+
controlButtonBackground: "#fff",
|
|
49
|
+
controlButtonHoverBackground: "#000",
|
|
50
|
+
controlButtonIconColor: "#000",
|
|
51
|
+
controlButtonIconHoverColor: "#fff",
|
|
52
|
+
modalBackground: "#fff",
|
|
53
|
+
modalButtonBackground: "#000",
|
|
54
|
+
modalButtonColor: "#fff",
|
|
55
|
+
modalButtonHoverBackground: "#333",
|
|
56
|
+
modalButtonHoverColor: "#fff",
|
|
57
|
+
modalOverlay: "#000",
|
|
58
|
+
modalOverlayOpacity: 0.8,
|
|
59
|
+
modalTextColor: "#000",
|
|
60
|
+
modalUnsavedColor: "#fff"
|
|
61
|
+
},
|
|
62
|
+
cookies: {
|
|
63
|
+
necessary: [],
|
|
64
|
+
optional: []
|
|
65
|
+
},
|
|
66
|
+
isAcceptNecessaryButtonEnabled: true,
|
|
67
|
+
isControlButtonEnabled: true,
|
|
68
|
+
isCssEnabled: true,
|
|
69
|
+
isCssPolyfillEnabled: true,
|
|
70
|
+
isDashInDescriptionEnabled: true,
|
|
71
|
+
isIframeBlocked: false,
|
|
72
|
+
domain: "",
|
|
73
|
+
locales: ["en" /* EN */],
|
|
74
|
+
localeTexts: { en }
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const resolver = createResolver(import.meta.url);
|
|
78
|
+
const runtimeDir = resolver.resolve("./runtime");
|
|
79
|
+
const module = defineNuxtModule({
|
|
80
|
+
meta: {
|
|
81
|
+
name,
|
|
82
|
+
version,
|
|
83
|
+
configKey: "cookieControl",
|
|
84
|
+
compatibility: { nuxt: "^3.0.0" }
|
|
85
|
+
},
|
|
86
|
+
defaults: DEFAULTS,
|
|
87
|
+
hooks: {
|
|
88
|
+
"components:dirs"(dirs) {
|
|
89
|
+
dirs.push({
|
|
90
|
+
path: resolve(runtimeDir, "components"),
|
|
91
|
+
prefix: "cookie"
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async setup(moduleOptions, nuxt) {
|
|
96
|
+
nuxt.options.alias["#cookie-control"] = runtimeDir;
|
|
97
|
+
nuxt.options.build.transpile.push(runtimeDir);
|
|
98
|
+
pushCss(moduleOptions, nuxt);
|
|
99
|
+
blockIframes(moduleOptions);
|
|
100
|
+
await loadLocales(moduleOptions);
|
|
101
|
+
addPlugin(resolve(runtimeDir, "plugin"));
|
|
102
|
+
addImports({
|
|
103
|
+
name: "useCookieControl",
|
|
104
|
+
as: "useCookieControl",
|
|
105
|
+
from: resolve(runtimeDir, "composables")
|
|
106
|
+
});
|
|
107
|
+
addTemplate({
|
|
108
|
+
filename: "cookie-control-options.ts",
|
|
109
|
+
write: true,
|
|
110
|
+
getContents: () => `import { ModuleOptions } from '../../src/runtime/types'
|
|
111
|
+
|
|
112
|
+
export default ${JSON.stringify(
|
|
113
|
+
moduleOptions,
|
|
114
|
+
void 0,
|
|
115
|
+
2
|
|
116
|
+
)} as ModuleOptions`
|
|
117
|
+
});
|
|
118
|
+
if (isNuxt2()) {
|
|
119
|
+
try {
|
|
120
|
+
if (require.resolve("nuxt-purgecss").length > 0) {
|
|
121
|
+
if (nuxt.options.purgeCSS) {
|
|
122
|
+
if (nuxt.options.purgeCSS.whitelistPatternsChildren) {
|
|
123
|
+
nuxt.options.purgeCSS.whitelistPatternsChildren.push(
|
|
124
|
+
/cookieControl/
|
|
125
|
+
);
|
|
126
|
+
} else {
|
|
127
|
+
nuxt.options.purgeCSS.whitelistPatternsChildren = [
|
|
128
|
+
/cookieControl/
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
} else {
|
|
132
|
+
nuxt.options.purgeCSS = {
|
|
133
|
+
whitelistPatternsChildren: [/cookieControl/]
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (e) {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
const blockIframes = (moduleOptions) => {
|
|
143
|
+
if (moduleOptions.isIframeBlocked) {
|
|
144
|
+
const isIframeBlocked = {
|
|
145
|
+
name: "functional",
|
|
146
|
+
initialState: typeof moduleOptions.isIframeBlocked !== "boolean" && moduleOptions.isIframeBlocked.initialState !== void 0 ? moduleOptions.isIframeBlocked.initialState : true
|
|
147
|
+
};
|
|
148
|
+
if (moduleOptions.cookies) {
|
|
149
|
+
if (moduleOptions.cookies.optional) {
|
|
150
|
+
moduleOptions.cookies.optional.push(isIframeBlocked);
|
|
151
|
+
} else {
|
|
152
|
+
moduleOptions.cookies.optional = [isIframeBlocked];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
extendWebpackConfig((config) => {
|
|
156
|
+
config.module?.rules?.push({
|
|
157
|
+
test: /\.vue$/,
|
|
158
|
+
loader: "string-replace-loader",
|
|
159
|
+
exclude: /node_modules/,
|
|
160
|
+
options: {
|
|
161
|
+
multiple: [
|
|
162
|
+
{ search: "<iframe", replace: "<CookieIframe", flags: "g" },
|
|
163
|
+
{ search: "</iframe>", replace: "</CookieIframe>", flags: "g" }
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const loadLocales = async (moduleOptions) => {
|
|
171
|
+
const locales = moduleOptions.locales;
|
|
172
|
+
moduleOptions.locales = [];
|
|
173
|
+
for (const locale of locales) {
|
|
174
|
+
const text = await import(resolve(runtimeDir, "locale", `${locale}.ts`));
|
|
175
|
+
if (!text)
|
|
176
|
+
throw new Error(`Could not import text for locale ${locale}`);
|
|
177
|
+
moduleOptions.locales.push(locale);
|
|
178
|
+
moduleOptions.localeTexts[locale] = text;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const pushCss = (moduleOptions, nuxt) => {
|
|
182
|
+
if (moduleOptions.isCssEnabled)
|
|
183
|
+
nuxt.options.css.push(resolve(runtimeDir, "styles.css"));
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export { module as default };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<client-only>
|
|
3
|
+
<section class="cookieControl">
|
|
4
|
+
<transition :name="`cookieControl__Bar--${moduleOptions.barPosition}`">
|
|
5
|
+
<div
|
|
6
|
+
v-if="colorsSet && !isConsentGiven"
|
|
7
|
+
:class="`cookieControl__Bar cookieControl__Bar--${moduleOptions.barPosition}`"
|
|
8
|
+
>
|
|
9
|
+
<div class="cookieControl__BarContainer">
|
|
10
|
+
<div>
|
|
11
|
+
<slot name="bar">
|
|
12
|
+
<h3 v-text="localeStrings?.barTitle" />
|
|
13
|
+
<p v-text="localeStrings?.barDescription" />
|
|
14
|
+
</slot>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="cookieControl__BarButtons">
|
|
17
|
+
<button
|
|
18
|
+
v-if="moduleOptions.isAcceptNecessaryButtonEnabled"
|
|
19
|
+
@click="acceptNecessary"
|
|
20
|
+
v-text="localeStrings?.acceptNecessary"
|
|
21
|
+
/>
|
|
22
|
+
<button
|
|
23
|
+
@click="isModalActive = true"
|
|
24
|
+
v-text="localeStrings?.manageCookies"
|
|
25
|
+
/>
|
|
26
|
+
<button
|
|
27
|
+
@click="setConsent({ reload: false })"
|
|
28
|
+
v-text="localeStrings?.acceptAll"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</transition>
|
|
34
|
+
<button
|
|
35
|
+
v-if="
|
|
36
|
+
moduleOptions.isControlButtonEnabled && colorsSet && isConsentGiven
|
|
37
|
+
"
|
|
38
|
+
class="cookieControl__ControlButton"
|
|
39
|
+
aria-label="Cookie control"
|
|
40
|
+
@click="isModalActive = true"
|
|
41
|
+
>
|
|
42
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
|
|
43
|
+
<path
|
|
44
|
+
fill="currentColor"
|
|
45
|
+
d="M510.52 255.82c-69.97-.85-126.47-57.69-126.47-127.86-70.17 0-127-56.49-127.86-126.45-27.26-4.14-55.13.3-79.72 12.82l-69.13 35.22a132.221 132.221 0 00-57.79 57.81l-35.1 68.88a132.645 132.645 0 00-12.82 80.95l12.08 76.27a132.521 132.521 0 0037.16 72.96l54.77 54.76a132.036 132.036 0 0072.71 37.06l76.71 12.15c27.51 4.36 55.7-.11 80.53-12.76l69.13-35.21a132.273 132.273 0 0057.79-57.81l35.1-68.88c12.56-24.64 17.01-52.58 12.91-79.91zM176 368c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm32-160c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm160 128c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z"
|
|
46
|
+
/>
|
|
47
|
+
</svg>
|
|
48
|
+
</button>
|
|
49
|
+
<transition name="cookieControl__Modal">
|
|
50
|
+
<div v-if="isModalActive" class="cookieControl__Modal">
|
|
51
|
+
<p
|
|
52
|
+
v-if="!saved"
|
|
53
|
+
class="cookieControl__ModalUnsaved"
|
|
54
|
+
v-text="localeStrings?.unsaved"
|
|
55
|
+
/>
|
|
56
|
+
<div class="cookieControl__ModalContent">
|
|
57
|
+
<div>
|
|
58
|
+
<slot name="modal" />
|
|
59
|
+
<button
|
|
60
|
+
class="cookieControl__ModalClose"
|
|
61
|
+
@click="isModalActive = false"
|
|
62
|
+
v-text="localeStrings?.close"
|
|
63
|
+
/>
|
|
64
|
+
<div v-for="cookieType in CookieType" :key="cookieType">
|
|
65
|
+
<h3 v-text="localeStrings && localeStrings[cookieType]" />
|
|
66
|
+
<ul v-if="moduleOptions.cookies">
|
|
67
|
+
<li
|
|
68
|
+
v-for="cookie in moduleOptions.cookies[cookieType]"
|
|
69
|
+
:key="cookie.id"
|
|
70
|
+
>
|
|
71
|
+
<div class="cookieControl__ModalInputWrapper">
|
|
72
|
+
<input
|
|
73
|
+
v-if="
|
|
74
|
+
cookieType === CookieType.NECESSARY &&
|
|
75
|
+
cookie.name !== 'functional'
|
|
76
|
+
"
|
|
77
|
+
:id="resolveTranslatable(cookie.name)"
|
|
78
|
+
type="checkbox"
|
|
79
|
+
disabled
|
|
80
|
+
checked
|
|
81
|
+
/>
|
|
82
|
+
<input
|
|
83
|
+
v-else
|
|
84
|
+
:id="resolveTranslatable(cookie.name)"
|
|
85
|
+
type="checkbox"
|
|
86
|
+
:checked="
|
|
87
|
+
cookiesEnabledIds.includes(getCookieId(cookie)) ||
|
|
88
|
+
(Cookies.get('cookie_control_consent')?.length ===
|
|
89
|
+
0 &&
|
|
90
|
+
typeof moduleOptions.isIframeBlocked === 'object' &&
|
|
91
|
+
moduleOptions.isIframeBlocked.initialState)
|
|
92
|
+
"
|
|
93
|
+
@change="toogleCookie(cookie)"
|
|
94
|
+
/>
|
|
95
|
+
<label :for="resolveTranslatable(cookie.name)">
|
|
96
|
+
{{ getName(cookie.name) }}
|
|
97
|
+
</label>
|
|
98
|
+
<span class="cookieControl__ModalCookieName">
|
|
99
|
+
{{ getName(cookie.name) }}
|
|
100
|
+
<span v-if="cookie.description">
|
|
101
|
+
{{ getDescription(cookie.description) }}
|
|
102
|
+
</span>
|
|
103
|
+
</span>
|
|
104
|
+
</div>
|
|
105
|
+
<template v-if="cookie.targetCookieIds">
|
|
106
|
+
<slot name="cookie" v-bind="{ config: cookie }">
|
|
107
|
+
<ul>
|
|
108
|
+
<li
|
|
109
|
+
v-for="targetCookieId in cookie.targetCookieIds"
|
|
110
|
+
:key="targetCookieId"
|
|
111
|
+
>
|
|
112
|
+
{{ targetCookieId }}
|
|
113
|
+
</li>
|
|
114
|
+
</ul>
|
|
115
|
+
</slot>
|
|
116
|
+
</template>
|
|
117
|
+
</li>
|
|
118
|
+
</ul>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="cookieControl__ModalButtons">
|
|
121
|
+
<button
|
|
122
|
+
@click="setConsent({ type: 'partial' })"
|
|
123
|
+
v-text="localeStrings?.save"
|
|
124
|
+
/>
|
|
125
|
+
<button
|
|
126
|
+
@click="() => setConsent({})"
|
|
127
|
+
v-text="localeStrings?.acceptAll"
|
|
128
|
+
/>
|
|
129
|
+
<button
|
|
130
|
+
@click="setConsent({ declineAll: true, consent: false })"
|
|
131
|
+
v-text="localeStrings?.declineAll"
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</transition>
|
|
138
|
+
</section>
|
|
139
|
+
</client-only>
|
|
140
|
+
</template>
|
|
141
|
+
|
|
142
|
+
<script setup lang="ts">
|
|
143
|
+
import Cookies from 'js-cookie'
|
|
144
|
+
|
|
145
|
+
import { Cookie, CookieType, Locale, Translatable } from '../types'
|
|
146
|
+
import {
|
|
147
|
+
getCookieId,
|
|
148
|
+
useAcceptNecessary,
|
|
149
|
+
useSetConsent,
|
|
150
|
+
useResolveTranslatable,
|
|
151
|
+
} from '../methods'
|
|
152
|
+
|
|
153
|
+
export interface Props {
|
|
154
|
+
locale?: Locale
|
|
155
|
+
}
|
|
156
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
157
|
+
locale: Locale.EN,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
const { cookiesEnabledIds, isConsentGiven, isModalActive, moduleOptions } =
|
|
161
|
+
useCookieControl()
|
|
162
|
+
const setConsentFun = useSetConsent()
|
|
163
|
+
const acceptNecessary = useAcceptNecessary()
|
|
164
|
+
const resolveTranslatable = useResolveTranslatable(props.locale)
|
|
165
|
+
|
|
166
|
+
// data
|
|
167
|
+
const saved = ref(true)
|
|
168
|
+
const colorsSet = ref(false)
|
|
169
|
+
|
|
170
|
+
// computations
|
|
171
|
+
const localeStrings = computed(() => moduleOptions.localeTexts[props.locale])
|
|
172
|
+
|
|
173
|
+
// methods
|
|
174
|
+
const toogleCookie = (cookie: Cookie) => {
|
|
175
|
+
const cookieId = getCookieId(cookie)
|
|
176
|
+
|
|
177
|
+
if (saved.value) saved.value = false
|
|
178
|
+
|
|
179
|
+
if (!cookiesEnabledIds.value.includes(cookieId)) {
|
|
180
|
+
cookiesEnabledIds.value.push(cookieId)
|
|
181
|
+
} else {
|
|
182
|
+
cookiesEnabledIds.value.splice(cookiesEnabledIds.value.indexOf(cookieId), 1)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const setConsent = ({
|
|
186
|
+
type = undefined,
|
|
187
|
+
consent = true,
|
|
188
|
+
reload = true,
|
|
189
|
+
declineAll = false,
|
|
190
|
+
}: {
|
|
191
|
+
type?: 'partial'
|
|
192
|
+
consent?: boolean
|
|
193
|
+
reload?: boolean
|
|
194
|
+
declineAll?: boolean
|
|
195
|
+
}) => {
|
|
196
|
+
const enabledCookies = declineAll
|
|
197
|
+
? []
|
|
198
|
+
: type === 'partial' && consent
|
|
199
|
+
? cookiesEnabledIds.value
|
|
200
|
+
: moduleOptions.cookies.optional.map((cookie) => getCookieId(cookie))
|
|
201
|
+
|
|
202
|
+
const expirationDate = new Date()
|
|
203
|
+
expirationDate.setFullYear(expirationDate.getFullYear() + 1)
|
|
204
|
+
|
|
205
|
+
Cookies.set('cookie_control_consent', consent.toString(), {
|
|
206
|
+
expires: expirationDate,
|
|
207
|
+
})
|
|
208
|
+
Cookies.set(
|
|
209
|
+
'cookie_control_enabled_cookies',
|
|
210
|
+
consent ? enabledCookies.join(',') : '',
|
|
211
|
+
{
|
|
212
|
+
expires: expirationDate,
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
if (reload) {
|
|
217
|
+
window.location.reload()
|
|
218
|
+
} else {
|
|
219
|
+
setConsentFun()
|
|
220
|
+
isModalActive.value = false
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const getDescription = (description: Translatable) =>
|
|
224
|
+
`${
|
|
225
|
+
moduleOptions.isDashInDescriptionEnabled === false ? '' : '-'
|
|
226
|
+
} ${resolveTranslatable(description)}`
|
|
227
|
+
const getName = (name: Translatable) => {
|
|
228
|
+
return name === 'functional'
|
|
229
|
+
? localeStrings.value?.functional
|
|
230
|
+
: typeof name === 'string'
|
|
231
|
+
? name
|
|
232
|
+
: name[props.locale]
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// lifecycle
|
|
236
|
+
onBeforeMount(async () => {
|
|
237
|
+
if (moduleOptions.colors) {
|
|
238
|
+
const variables: Record<string, any> = {}
|
|
239
|
+
|
|
240
|
+
for (const key in moduleOptions.colors) {
|
|
241
|
+
variables[`cookie-control-${key}`] = `${moduleOptions.colors[key]}`
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (moduleOptions.isCssPolyfillEnabled) {
|
|
245
|
+
const module = await import('css-vars-ponyfill')
|
|
246
|
+
const cssVars = module.default
|
|
247
|
+
cssVars({ variables })
|
|
248
|
+
} else {
|
|
249
|
+
for (const cssVar in variables) {
|
|
250
|
+
document.documentElement.style.setProperty(
|
|
251
|
+
`--${cssVar}`,
|
|
252
|
+
variables[cssVar]
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const cookieControlConsent = Cookies.get('cookie_control_consent')
|
|
259
|
+
|
|
260
|
+
if (!cookieControlConsent || !cookieControlConsent.length) {
|
|
261
|
+
for (const cookieOptional of moduleOptions.cookies.optional) {
|
|
262
|
+
if (
|
|
263
|
+
typeof moduleOptions.isIframeBlocked === 'boolean'
|
|
264
|
+
? moduleOptions.isIframeBlocked === true
|
|
265
|
+
: moduleOptions.isIframeBlocked?.initialState === true
|
|
266
|
+
) {
|
|
267
|
+
cookiesEnabledIds.value.push(getCookieId(cookieOptional))
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
colorsSet.value = true
|
|
273
|
+
})
|
|
274
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<client-only>
|
|
3
|
+
<iframe v-if="isCookieFunctionalEnabled" />
|
|
4
|
+
<div v-else class="cookieControl__BlockedIframe">
|
|
5
|
+
<p>
|
|
6
|
+
{{ localeStrings?.blockedIframe }}
|
|
7
|
+
<a
|
|
8
|
+
href="#"
|
|
9
|
+
@click.prevent="cookieControl.isModalActive.value = true"
|
|
10
|
+
v-text="localeStrings?.here"
|
|
11
|
+
/>
|
|
12
|
+
</p>
|
|
13
|
+
</div>
|
|
14
|
+
</client-only>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { LOCALE_DEFAULT } from '../constants'
|
|
19
|
+
import { Locale } from '../types'
|
|
20
|
+
|
|
21
|
+
export interface Props {
|
|
22
|
+
locale?: Locale
|
|
23
|
+
}
|
|
24
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
25
|
+
locale: LOCALE_DEFAULT,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const cookieControl = useCookieControl()
|
|
29
|
+
|
|
30
|
+
// computations
|
|
31
|
+
const isCookieFunctionalEnabled = computed(
|
|
32
|
+
() =>
|
|
33
|
+
cookieControl.cookiesEnabled.value.filter((c) => c.name === 'functional')
|
|
34
|
+
.length > 0
|
|
35
|
+
)
|
|
36
|
+
const localeStrings = computed(
|
|
37
|
+
() => cookieControl.moduleOptions.localeTexts[props.locale]
|
|
38
|
+
)
|
|
39
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useCookieControl: () => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const useCookieControl = () => useNuxtApp().$cookies;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "\u0642\u0628\u0648\u0644 \u0627\u0644\u0643\u0644",
|
|
3
|
+
acceptNecessary: "\u062A\u0642\u0628\u0644 \u0627\u0644\u0636\u0631\u0648\u0631\u0629",
|
|
4
|
+
barDescription: "\u0646\u062D\u0646 \u0646\u0633\u062A\u062E\u062F\u0645 \u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0646\u0627 \u0648\u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637 \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0627\u0644\u062C\u0647\u0627\u062A \u0627\u0644\u062E\u0627\u0631\u062C\u064A\u0629 \u062D\u062A\u0649 \u0646\u062A\u0645\u0643\u0646 \u0645\u0646 \u0639\u0631\u0636 \u0647\u0630\u0627 \u0627\u0644\u0645\u0648\u0642\u0639 \u0648\u0641\u0647\u0645 \u0643\u064A\u0641\u064A\u0629 \u0627\u0633\u062A\u062E\u062F\u0627\u0645\u0647 \u0628\u0634\u0643\u0644 \u0623\u0641\u0636\u0644 \u060C \u0628\u0647\u062F\u0641 \u062A\u062D\u0633\u064A\u0646 \u0627\u0644\u062E\u062F\u0645\u0627\u062A \u0627\u0644\u062A\u064A \u0646\u0642\u062F\u0645\u0647\u0627. \u0625\u0630\u0627 \u0648\u0627\u0635\u0644\u062A \u0627\u0644\u062A\u0635\u0641\u062D \u060C \u0641\u0625\u0646\u0646\u0627 \u0646\u0639\u062A\u0628\u0631 \u0623\u0646\u0643 \u0642\u0628\u0644\u062A \u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637.",
|
|
5
|
+
barTitle: "\u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637",
|
|
6
|
+
blockedIframe: "\u0644\u0631\u0624\u064A\u0629 \u0647\u0630\u0627 \u060C \u064A\u0631\u062C\u0649 \u062A\u0645\u0643\u064A\u0646 \u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637 \u0627\u0644\u0648\u0638\u064A\u0641\u064A\u0629",
|
|
7
|
+
close: "\u0625\u063A\u0644\u0627\u0642",
|
|
8
|
+
declineAll: "\u062D\u0630\u0641 \u0627\u0644\u0643\u0644",
|
|
9
|
+
functional: "\u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637 \u0627\u0644\u0648\u0638\u064A\u0641\u064A\u0629",
|
|
10
|
+
here: "\u0647\u0646\u0627",
|
|
11
|
+
manageCookies: "\u0625\u062F\u0627\u0631\u0629 \u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637",
|
|
12
|
+
necessary: "\u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637 \u0627\u0644\u0636\u0631\u0648\u0631\u064A\u0629",
|
|
13
|
+
optional: "\u0645\u0644\u0641\u0627\u062A \u062A\u0639\u0631\u064A\u0641 \u0627\u0644\u0627\u0631\u062A\u0628\u0627\u0637 \u0627\u0644\u0627\u062E\u062A\u064A\u0627\u0631\u064A\u0629",
|
|
14
|
+
save: "\u062D\u0641\u0638",
|
|
15
|
+
unsaved: "\u0644\u062F\u064A\u0643 \u0625\u0639\u062F\u0627\u062F\u0627\u062A \u063A\u064A\u0631 \u0645\u062D\u0641\u0648\u0638\u0629"
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "Alle akzeptieren",
|
|
3
|
+
acceptNecessary: "Akzeptiere das Notwendige",
|
|
4
|
+
barDescription: "Wir verwenden unsere eigenen Cookies und Cookies von Drittanbietern, damit wir Ihnen diese Website zeigen k\xF6nnen und verstehen wie Sie diese verwenden, um die von uns angebotenen Dienstleistungen zu verbessern. Wenn Sie weiter surfen, gehen wir davon aus, dass Sie die Cookies akzeptiert haben.",
|
|
5
|
+
barTitle: "Cookies",
|
|
6
|
+
blockedIframe: "Um den Inhalt zu sehen, aktivieren Sie bitte funktionale Cookies",
|
|
7
|
+
close: "Schlie\xDFen",
|
|
8
|
+
declineAll: "Alle ablehnen",
|
|
9
|
+
functional: "Funktionale Cookies",
|
|
10
|
+
here: "hier",
|
|
11
|
+
manageCookies: "Cookies verwalten",
|
|
12
|
+
necessary: "Notwendige Cookies",
|
|
13
|
+
optional: "Optionale Cookies",
|
|
14
|
+
save: "Speichern",
|
|
15
|
+
unsaved: "Sie haben nicht gespeicherte Einstellungen"
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "Accept all",
|
|
3
|
+
acceptNecessary: "Accept necessary",
|
|
4
|
+
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.",
|
|
5
|
+
barTitle: "Cookies",
|
|
6
|
+
blockedIframe: "To see this, please enable functional cookies",
|
|
7
|
+
close: "Close",
|
|
8
|
+
declineAll: "Delete all",
|
|
9
|
+
functional: "Functional cookies",
|
|
10
|
+
here: "here",
|
|
11
|
+
manageCookies: "Manage cookies",
|
|
12
|
+
necessary: "Necessary cookies",
|
|
13
|
+
optional: "Optional cookies",
|
|
14
|
+
save: "Save",
|
|
15
|
+
unsaved: "You have unsaved settings"
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "Aceptar todo",
|
|
3
|
+
acceptNecessary: "Acepto lo necesario",
|
|
4
|
+
barDescription: "Utilizamos cookies propias y de terceros para poder mostrarle una p\xE1gina web y comprender c\xF3mo la utiliza, con el fin de mejorar los servicios que ofrecemos. Si contin\xFAa navegando, consideramos que acepta su uso.",
|
|
5
|
+
barTitle: "Cookies",
|
|
6
|
+
blockedIframe: "Para ver esto, por favor habilita las cookies funcionales.",
|
|
7
|
+
close: "Cerrar",
|
|
8
|
+
declineAll: "Borrar todo",
|
|
9
|
+
functional: "Cookies funcionales",
|
|
10
|
+
here: "aqu\xED",
|
|
11
|
+
manageCookies: "Administrar cookies",
|
|
12
|
+
necessary: "Cookies obligatorias",
|
|
13
|
+
optional: "Cookies opcionales",
|
|
14
|
+
save: "Guardar",
|
|
15
|
+
unsaved: "Tienes configuraciones no guardadas"
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "Tout accepter",
|
|
3
|
+
acceptNecessary: "J'accepte le n\xE9cessaire",
|
|
4
|
+
barDescription: "Nous utilisons des cookies d\u2019origine et des cookies tiers. Ces cookies sont destin\xE9s \xE0 vous offrir une navigation optimis\xE9e sur ce site web et de nous donner un aper\xE7u de son utilisation, en vue de l\u2019am\xE9lioration des services que nous offrons. En poursuivant votre navigation, nous consid\xE9rons que vous acceptez l\u2019usage des cookies.",
|
|
5
|
+
barTitle: "Cookies",
|
|
6
|
+
blockedIframe: "Pour voir cela, veuillez activer les cookies fonctionnels",
|
|
7
|
+
close: "Fermer",
|
|
8
|
+
declineAll: "Tout refuser",
|
|
9
|
+
functional: "Cookies fonctionnels",
|
|
10
|
+
here: "ici",
|
|
11
|
+
manageCookies: "G\xE9rer les cookies",
|
|
12
|
+
necessary: "Les cookies obligatoires",
|
|
13
|
+
optional: "Les cookies optionnels",
|
|
14
|
+
save: "Sauvegarder",
|
|
15
|
+
unsaved: "Vous avez des param\xE8tres non sauvegard\xE9s"
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "Dozvoli sve",
|
|
3
|
+
acceptNecessary: "Prihva\u0107am obavezne",
|
|
4
|
+
barDescription: "Koristimo vlastite kola\u010Di\u0107e i kola\u010Di\u0107e tre\u0107e strane kako bismo Vam mogli prikazati web stranicu i razumijeti kako je koristite, s pogledom na pobolj\u0161anje usluga koje nudimo. Ako nastavite s pregledavanjem, smatramo da prihva\u0107ate upotrebu kola\u010Di\u0107a.",
|
|
5
|
+
barTitle: "Kola\u010Di\u0107i",
|
|
6
|
+
blockedIframe: "Da bi vidjeli ovo, molimo Vas omogu\u0107ite funkcionalne kola\u010Di\u0107e",
|
|
7
|
+
close: "Zatvori",
|
|
8
|
+
declineAll: "Obri\u0161i sve",
|
|
9
|
+
functional: "Funkcionalni kola\u010Di\u0107i",
|
|
10
|
+
here: "ovdje",
|
|
11
|
+
manageCookies: "Upravljaj kola\u010Di\u0107ima",
|
|
12
|
+
necessary: "Obavezni kola\u010Di\u0107i",
|
|
13
|
+
optional: "Neobavezni kola\u010Di\u0107i",
|
|
14
|
+
save: "Spremi",
|
|
15
|
+
unsaved: "Imate nespremljenih postavki"
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
acceptAll: "\xD6sszes elfogad\xE1sa",
|
|
3
|
+
acceptNecessary: "Elfogadom a sz\xFCks\xE9geset",
|
|
4
|
+
barDescription: "Saj\xE1t, illetve harmadik f\xE9lt\u0151l sz\xE1rmaz\xF3 s\xFCtiket haszn\xE1lunk annak \xE9rdek\xE9ben, hogy megmutassuk ezt a weboldalt, \xE9s jobban meg\xE9rts\xFCk, hogyan haszn\xE1lja azt, azzal a c\xE9llal, hogy jav\xEDtsuk az \xE1ltalunk k\xEDn\xE1lt szolg\xE1ltat\xE1sokat. Ha folytatod a b\xF6ng\xE9sz\xE9st, \xFAgy gondoljuk, hogy elfogadtad a s\xFCtiket.",
|
|
5
|
+
barTitle: "S\xFCtik",
|
|
6
|
+
blockedIframe: "Ennek megtekint\xE9s\xE9hez, enged\xE9lyezd a funkcion\xE1lis s\xFCtik haszn\xE1lat\xE1t",
|
|
7
|
+
close: "Bez\xE1r",
|
|
8
|
+
declineAll: "\xD6sszes elutas\xEDt\xE1sa",
|
|
9
|
+
functional: "Funkcion\xE1lis s\xFCtik",
|
|
10
|
+
here: "itt",
|
|
11
|
+
manageCookies: "S\xFCtikk kezel\xE9se",
|
|
12
|
+
necessary: "Sz\xFCks\xE9ges s\xFCtikk",
|
|
13
|
+
optional: "Opcion\xE1lis s\xFCtik",
|
|
14
|
+
save: "Ment\xE9s",
|
|
15
|
+
unsaved: "Ment\xE9s n\xE9lk\xFCli be\xE1ll\xEDt\xE1sok vannak"
|
|
16
|
+
};
|